C's syntax

Alex Martelli aleaxit at yahoo.com
Wed Oct 25 06:25:29 EDT 2000


"Erik Max Francis" <max at alcyone.com> wrote in message
news:39F65D4C.8270EE5A at alcyone.com...
> Alex Martelli wrote:
>
> > It *IS* most definitely the language's fault if its syntax is so
> > horrid that it needs specific implementations to "subset" that
> > syntax, while having standards that assert the whole syntax
> > must be such-and-such.
>
> Then don't use it.  People who like C will disagree with you, however.

I like C, and I don't disagree with myself.  So, I use it (when
needed -- i.e., as little as possible, since higher-abstraction-
level languages such as Python are more productive when their
use is feasible), *despite* its syntax.  And, of course, despite
your imperative "don't use it": I don't take orders from you
(what ever made you think I would?).

See below for another person who considers C "quirky and flawed",
about whom I'm expecting to hear you saying "he doesn't like C"...


> > Either the idiom
> >     while(this_char = get_next_char())
> > is a good thing to have in the language, in which case it's
> > silly to state that a good compiler should strive to make its
> > users avoid it; or, the idiom is a BAD thing to have in the
> > language, in which case it's just as silly to keep stating that
> > the language's syntax is good!
>
> It's a good thing to have in the language, because it adds more
> flexibility.  The typical way of using it is something like
>
>     while ((c = getchar()) != EOF)

This is not "using the idiom" where the assignment is directly
used as the while's condition; it's a different idiom.  If,
instead of accepting any expression in while(expr)/if(expr),
C's syntax specified something slighty different (a "logical
expression" -- comparison, negation, &&, ||...), then this
"typical idiom" would not be affected; "if(a&b)" and "if(a=b)"
would become syntactically invalid -- one could still insert a
specific comparison-with-0 to get the same effect:
    if( (a&b) != 0)
etc.  There are also other, non-syntactic possibilities (e.g,
Java's introduction of a specifically 'boolean' type) to make
most such typos into compile-time errors.


By the way, the need for extra parentheses here points to
another one of C's syntax horrors, one which even Dennis
Ritchie cannot fail to admit is "an infelicity of C's
precedence rules".  Do read his very interesting paper:

http://cm.bell-labs.com/cm/cs/who/dmr/chist.html

including such assertions as "historical accidents or
mistakes have exacerbated their difficulty", "many of
the nested declarations and expressions would become
simpler if the indirection operator had been taken
as a postfix operator instead of prefix, but by then
it was too late to change", "an accident of syntax
contributed to the perceived complexity of the
language", etc.

Don't worry, Ritchie isn't disowning his brainchild!

He sums it up: "C is quirky, flawed, and an enormous
success", explaining that success exactly the way I
do -- "satisfied a need for a system implementation
language efficient enough to displace assembly language,
yet sufficiently abstract".  Note well, syntactic
aspects are prominently ABSENT from this explanation,
and quite rightly, too.

As Ritchie's quoted paper amply shows, the "quirks
and flaws", which make C "quirky" and "flawed" in his
estimation, are predominantly concentrated in the
syntax of the language, and explained by historical
accidents, and by mistakes that he has no compunction
against owning up to.

Now will you claim that _Ritchie_ "doesn't like C",
and admonish HIM to give it up, too...?  Or will it
finally get through your skull that one can at the
same time admire, respect, and like the key aspects
of a programming language, while being acutely aware
of the many defects (quirks, flaws, whatever) of its
syntax, and therefore not ready to acquiesce in any
assertion to the effect that said syntax is "good"?!


> > you seem unable to follow through logically and admit
> > that, as *the syntax of C has horrid aspects that should
> > NOT be used* (with, even, compiler-warnings pushing users
> > away from them), therefore, *the syntax of C is _NOT_
> > good*.
>
> _You_ don't like C's syntax.  That does not mean that it is not good;
> that just means that, in your opinion, it is not good.  Don't use C; get
> over it.

In my opinion, in Koenig's, in Ritchie's, C's syntax is
such as to make the language quirky and flawed.  & and |
have the wrong priority, comments should have stayed //
as in BCPL right from the start (as they finally have
become again, in C++ and C99), assignment might well have
remained := as in BCPL rather than = (avoiding many issues;
Ritchie has admitted to "legacy of PL/I" in those changes
he made back when BCPL became B, and couldn't undo later),
break is a silly way to terminate a switch's case (making
it impossible to conditionally exit a loop based on a
switch rather an an if!), the indirection-operator should
have been postfix rather than prefix, etc, etc.

All of this is just as likely to convince me (or Ritchie,
or Koenig) to "not use C" or "get over it", as the buses'
horrid color is likely to convince me to stop commuting
by bus (and start spewing exhaust fumes at the environment
twice a day every day...).

But, being acutely aware of all of these flaws and quirks
in the language's syntax, I don't have to keep quiet while
clueless assertions about the syntax's goodness get
bandied about.  Neither does Ritchie have to keep quiet,
and maybe his words are likelier to command respect from
true _fanatics_ of C (as is typical, those who can best
claim to understand the language are _not_ fanatical in
its favour -- they just opine that its semantical-level
strengths have been, and may still be, more important
than its undeniable syntactic quirks and flaws).


Alex






More information about the Python-list mailing list