C's syntax (was Re: Python Formatted C Converter (PfCC))

Glyph Lefkowitz glyph at no.spam
Tue Oct 24 15:45:39 EDT 2000


"Alex Martelli" <aleaxit at yahoo.com> writes:

> "Glyph Lefkowitz" <glyph at no.spam> wrote in message
> > (Also, there's the fact that C's syntax is actually pretty good for
> > doing what C does)
> 
> I strongly disagree.  C's syntax has glaring flaws, such as being
> unparsable "locally" -- i.e., without knowing what typedef's have
> been previously met.  For example:
> 
>     foo * bar;

I do not disagree that C is awful :) but "what C does" in this
context, is mostly being compatible with C.  Keep in mind that C is
not just a language, but a suite of associated tools and techniques
and assumptions that it carries.  In order to make a worthwhile
competitor, you have to have a significant advantage.

I think that on some level syntax is important, but it's not important
enough to outweigh other benefits.  Compare the following hypothetical
statements in my language:

  foo pointer: bar, baz
  allocate bar
  allocate baz

to the C equivalent:

  foo *bar, *baz;
  bar = calloc(sizeof(foo));
  baz = calloc(sizeof(foo));

We can easily tell that they do the same thing, although one might be
a little shorter than the other.  Is it worth giving up a robust,
strenuously-tested compiler and debugger for the nicer-looking one?

I don't think that this alone (how it looks) is a compelling
advantage... but when you stop to consider that 'allocate' is an
operation that is really an operation which can be overloaded at
compile-time to dispatch to an appropriate function for the type 'foo
pointer', you get something quite like the object-oriented
"constructor" mechanism, but implemented in a more straightforward
manner.  (This can also be extended to give you more or fewer features
from that set.)  It's essential that things building on top of C add
significant value, or their advantages will be dismissed as "nice, but
not as important as X" which is some feature (symbolic debugger,
native interface) that merely not being C loses you.

-- 
Glyph Lefkowitz
Professional -- Software Engineer,  Origin Systems
Amateur      -- Computer Scientist, Twisted Matrix Enterprises
(My opinions are my own and do not reflect in any way on the policies
or practices of my employer, etcetera etcetera.)



More information about the Python-list mailing list