Who here doesn't use C and why?

Programming, for all ages and all languages.
Post Reply
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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...
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post 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. ;)
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Well .. Welll

Post by DeletedAccount »

I use C because I find it easy to read
See some entries in the Obscufarated C Coding contest ..... :P 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 :lol: :lol:
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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.
Every good solution is obvious once you've found it.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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 ****!
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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.
My OS is Perception.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

I think my answer was more eloquent :P
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Post 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. :P 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! ;)
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post 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.
:x :x :x :x :x
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.

Code: Select all

int * example = 4;
example ++;
Now example will equal 5.
Last edited by ucosty on Sun Jan 13, 2008 12:49 pm, edited 1 time in total.
The cake is a lie | rackbits.com
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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 $
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post 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
The cake is a lie | rackbits.com
Post Reply