News for hackers. Stuff that matters.
Re:32 years on, K&R's "The C Programming Language" still sta... by Dellort on Tuesday April 06, 2010 @03:04PM (#1245336)
Very nice semantics, but hideous syntax. Pascal had it done right with a more linear declaration syntax. C looks like lisp in a bad way if you make slightly nontrivial declarations. Of course to make matters worse somebody went on and made C++, which must be the most hideous language ever to evolve, possibly because its creator borrowed heavily ideas from how his native natural language Danish was formed; It is mostly comprised of guttural sounds and every new groan you make is added to the language. It has been said that C++ is to C what lung cancer is to lung.

Basically we will never get rid of C, for there is just too much piled up on it. C++ though we should replace because it is an atrocity to programming.

Re:32 years on, K&R's "The C Programming Language" still sta... by MikeTaylor on Tuesday April 06, 2010 @03:09PM (#1245352)
C's syntax is much more terse than Pascal's; whether that makes it better or worse is open to discussion. begin...end or {...}? I would argue that Pascal's syntax is easier to learn, but that C's is easier to use once learned. And since I spend more time using languages than learning them, the latter is more important to me.
Re:32 years on, K&R's "The C Programming Language" still sta... by barrkel on Tuesday April 06, 2010 @05:38PM (#1245735)
C's type syntax for functions, pointers and arrays is terrible; it was an experiment that failed. C++ made it worse when introducing references and cv-qualifiers.
Re:32 years on, K&R's "The C Programming Language" still sta... by magoghm on Tuesday April 06, 2010 @09:40PM (#1246186)
In the 80's we used to say: "You can't compare Pascal to C. It's like comparing a bicycle with training wheels to a ten-speed racing cycle."
Re:32 years on, K&R's "The C Programming Language" still sta... by eru on Wednesday April 07, 2010 @12:10PM (#1247646)
> to a ten-speed racing cycle.

Lacking brakes.

Re:32 years on, K&R's "The C Programming Language" still sta... by Dellort on Tuesday April 06, 2010 @03:12PM (#1245357)
The nontrivial differences are more interesting. To make declarations look similar to use was a gigantic mistake.

http://cdecl.org/

Re:32 years on, K&R's "The C Programming Language" still sta... by tzs on Tuesday April 06, 2010 @03:34PM (#1245410)
How is it a mistake? In C, if you know how to use it, you know how to declare it, and if you know how to declare it, you know how to use it. I don't see how one can make even a remotely plausible case that doing it otherwise would be an improvement.
Re:32 years on, K&R's "The C Programming Language" still sta... by Dellort on Tuesday April 06, 2010 @03:47PM (#1245448)

  char * (*(** foo[][8])())[]

  declare foo as array of array 8 of pointer to pointer to function returning pointer to array of pointer to char
Which do you prefer reading?
Re:32 years on, K&R's "The C Programming Language" still sta... by mcantor on Tuesday April 06, 2010 @04:34PM (#1245560)
They're both equally illegible to my eyes!
Re:32 years on, K&R's "The C Programming Language" still sta... by tzs on Tuesday April 06, 2010 @07:52PM (#1245994)
The first, for a couple reasons, but that's not relevant. My point was that I see no advantage or even plausible case for having declaration syntax be different from use syntax.

If C made us declare foo using the second format you gave, we'd still have to write, e.g., ((foo[12][3])())[7] in the code where we are actually trying to use foo.

Can you look at a declaration in the second format, and compare to where the variable is used, and see quickly if the usage is correct? With the current declaration format, it's easy--because declaration and usage use the same format.

Re:32 years on, K&R's "The C Programming Language" still sta... by senki on Tuesday April 06, 2010 @03:57PM (#1245466)
Why would you write code like this?
Re:32 years on, K&R's "The C Programming Language" still sta... by Dellort on Tuesday April 06, 2010 @04:04PM (#1245483)
The point is not that, but that as soon as you make slightly nontrivial declarations it is not readable in one pass.
Re:32 years on, K&R's "The C Programming Language" still sta... by senki on Tuesday April 06, 2010 @04:25PM (#1245541)
Well, the K&R book talk about the complicated declarations, and recommend the use of the typedef command. Also, it contains a simple program called "dcl", analogous to what you linked.
Re:32 years on, K&R's "The C Programming Language" still sta... by sketerpot on Tuesday April 06, 2010 @07:17PM (#1245936)
If that's what you consider "slightly nontrivial", I never want to see what you would consider a difficult type declaration.
Re:32 years on, K&R's "The C Programming Language" still sta... by eru on Wednesday April 07, 2010 @12:08PM (#1247640)
I'd volunteer some Haskell, but I am afraid that while complex, it doesn't have enough line noise in the type declarations.