Page 6 of 10
Posted: Sat Jan 12, 2008 6:25 am
by JamesM
I understand your points about distributed/parallel compiling and that jazz. But, in my opinion, I would rather trust my compiler, than my linker, to check if functions exist in another file.
Please reiterate that point when you get a project like I work on at work - we have between 500,000 - 600,000 lines of code in our codebase, and even with conditionally #ifdef'd file includes and a clever make system we STILL need to use distcc (distributed compiler) to compile 12 files at a time to get the time from "make clean" to "make complete" to be under 5 minutes.
If all those compilation units were interlinked (i.e. compiler checks and parses each file), it would take, literally, an ice age.
Posted: Sat Jan 12, 2008 8:53 am
by Craze Frog
It seems like a lot of people on this forum doesn't know how Pascal's separate compilation works.
It does NOT parse each used file. It does NOT include each used file. Once a file is compiled, it's compiled. No need to recompile it. In fact, the source file doesn't even need to present as long as the .o and .ppu (or similar for different compilers) file is. There is nothing that hinders parallel compilation (someone just need to implement it). The .ppu is an auto-generated file with a functionality similar to c header files, the .o file is the object file.
In fact, the .ppu files are stored in a binary format, which makes parsing them much faster than parsing C header files.
I know a Delphi project with over 40000 lines. It is not a problem as far as I understand.
Posted: Sat Jan 12, 2008 3:28 pm
by JamesM
You're right - I don't know how the pascal compiler works. I was going on the description given in this thread. (I've never written anything in pascal).
However, I do note that 40,000 lines is over 10 times less than the figure I stated...
Posted: Sat Jan 12, 2008 3:42 pm
by Alboin
JamesM wrote:However, I do note that 40,000 lines is over 10 times less than the figure I stated...
Now try several million for things like Windows or Linux.
Posted: Sat Jan 12, 2008 3:50 pm
by piranha
I use C because I find it easy to read.
I used to use only BASIC, but I wanted top learn C and couldn't. My brain wouldn't deal with it (because of the symbols). But now, I read the symbols easier. I don't know why.
However, I read that symbols are processed faster then words in your brain, so that may help, who knows?
-JL
Well .. Welll
Posted: Sun Jan 13, 2008 4:13 am
by DeletedAccount
I use C because I find it easy to read
See some entries in the Obscufarated C Coding contest .....
It is the programmers art to write readable and reusable code ... You can use the features to your advantage or abuse them .....
eg There was a complain about case - sensitiveness of C -- Here is a way to abuse it
Code: Select all
void MyFunc()
{
// do something here
}
void Myfunc()
{
// do Something totally different like incrementing a NULL pointer
// so that you can crash your program
}
Also operatior overloading can be made to do something that is not very natual eg using operatior '+' to compute product of 2 complex numbers ...
there is another complain that
char *var1,var2;
var1 -> pointer variable
var2 -> simple char
is not natural .... For such fellows .. there exists a work - around
typedef char* char_ptr;
char_ptr v1,v2;
now both v1 and v2 are pointers
An advantage of Pascal is when writing a Pascal compiler ... You can very easily make - up an LL -1 grammar for Pascal .... (So that you can handcraft your compiler - using a Recrsive Descent Parser) .. But the same is not true for C-- I found it somewhat difficult to make - up an LL-1 grammar for C . :- Also C and Pascal belong to class of Imperative Programming Languages ... There is not too much difference in the style of programming .... It's just a matter of personal preference in my opinion
Posted: Sun Jan 13, 2008 4:37 am
by Solar
I intended not to go into a sentence-by-sentence one-uppance, but, well...
Craze Frog wrote:- C is unreadable
Compare { vs. begin
Matter of taste at best. I'd be interested to hear someone who specializes in this stuff on the matter.
- C is untypable
{ requires AltGr+7, which means stretching or moving the hands a lot
A two-keys combination is hardly "untypable".
- C is illogical
An empty parameter list does not mean no parameters, but any number of parameters.
It's trivial to have your compiler spit out a warning on this.
In "int unsigned* ptr, notptr;" notptr does not become a pointer, but it becomes unsigned.
Yes. So?
- The de facto free C compiler, gcc, is very slow (I'm talking about the compilation time)
As compared to a Pascal compiler? I'd like to see a
fair comparison on this, i.e. code that is functionally equivalent, compiled on compilers of comparable scope.
- C is inconsistent
* in declarations means you want a pointer.
* in normal lvalues means you don't want the pointer, but the value it points to.
As I said, it might have helped to read the rationale. (Declaration and most common use case should be identical. Excuse me if I don't look up the exact wording ATM.)
- C requires makefiles or similar
Lots of typing and thinking for what can easily be done automatically by the compiler
If you take a well-written Makefile, it can next-to-trivially be adapted to any other project you might work on, because dependency handling
can be done automatically by a (C) compiler, too.
- C requires header files
Lots of typing for what can easily be done automatically by the compiler.
I consider header files to be one of the biggest
assets of C/C++. Header-less languages like C# or Java basically depend on special tools (e.g. Javadoc) to provide proper overviews over what a piece of code can do or not.
- C doesn't know basic math
If a has the value 6385921 and you do "a += 1;" then a may well have the value 6385925 if a was declared as int *.
If a is a pointer to an integer value, I would expect a + 1 to be a pointer to the
next integer value, so I don't see the problem here.
Posted: Sun Jan 13, 2008 5:49 am
by Craze Frog
I know why you like the things I mentioned. That doesn't mean I do. Which was the original question.
I can't see why some people do not understand that other people wants 4 + 1 to be 5.
Posted: Sun Jan 13, 2008 6:10 am
by JamesM
I can't see why some people do not understand that other people wants 4 + 1 to be 5.
So don't declare your variable as a pointer then, you dumb ****!
Posted: Sun Jan 13, 2008 6:11 am
by AndrewAPrice
Craze Frog wrote:I know why you like the things I mentioned. That doesn't mean I do. Which was the original question.
I can't see why some people do not understand that other people wants 4 + 1 to be 5.
Then use *a += 1 and if you're too dumb to figure that out then you shouldn't be using pointers anyway, yet alone be on an OSDev website.
Posted: Sun Jan 13, 2008 6:43 am
by JamesM
I think my answer was more eloquent
Posted: Sun Jan 13, 2008 11:16 am
by Colonel Kernel
Solar wrote:I consider header files to be one of the biggest assets of C/C++. Header-less languages like C# or Java basically depend on special tools (e.g. Javadoc) to provide proper overviews over what a piece of code can do or not.
The problem with header files is that they force me to write every declaration twice. The project I'm working on now is over 50000 LOC, but the ratio of declarations to straight-line statements is unusually high because everything is heavily factored. However, that means there are probably at least 15000 LOC of declarations that are just redundant.
Unfortunately, the less... diligent developers decide not to factor things out because they're too lazy to write the declarations twice.
I would much prefer a "headerless" language... I think the need for something like JavaDoc encourages the golden rule for documentation -- "Document your classes to be like the class documentation that you would find useful."
Unfortunately, C++, Java, C#, et. al. are not sufficiently self-documenting in the first place. As I said before, Smalltalk FTW!
Posted: Sun Jan 13, 2008 12:33 pm
by ucosty
Edit: I retract my post. I need sleep. JamesM points out the fault in my post. It will only equal 5 if the type is char or a very small struct equal to one byte in size.
Pointers increment in units size of the pointed thing. The funny thing is that I knew this and posted crap anyway.
Craze Frog wrote:I know why you like the things I mentioned. That doesn't mean I do. Which was the original question.
I can't see why some people do not understand that other people wants 4 + 1 to be 5.
4 + 1 always equals 5 in C. Always.
Now example will equal 5.
Posted: Sun Jan 13, 2008 12:39 pm
by JamesM
Alas, no. The increment operator operates as "ptr += sizeof(ptr)" on a pointer variable (to access the next pointer!)
the test program:
Code: Select all
[18:35:51] ~ $ cd test
[18:35:56] ~/test $ emacs -nw test.c
[18:38:01] ~/test $ gcc -o test test.c
test.c: In function ‘main’:
test.c:5: warning: initialization makes pointer from integer without a cast
[18:38:08] ~/test $ ./test
example = 8
[18:39:23] ~/test $ cat test.c
#include <stdio.h>
int main(char argc, char**argv)
{
int *example =4;
example++;
printf("example = %d\n", example);
}
[18:39:29] ~/test $
Posted: Sun Jan 13, 2008 12:45 pm
by ucosty
Quite right. My fault for posting at 5:30am after no sleep and a lot of partying and stuff with no sleep the past couple of days.
/slaps head