C tips (again)

bearophile bearophileHUGS at lycos.com
Fri May 1 08:36:08 PDT 2009


superdan:
> d00d. u first messed with k&r which are Gods. any1 mess'n' with Gods better bring around some fuckin' supergod instead.<

I have not appreciated that book, I don't care of what you say. I am generally able to see good books when I see then.
I guess that author has more programming experience than all my teachers combined.


>the trailin' empty array trick is so ol' it smells like ol' people.<

Of course few or none of those things are new. C is around for a lot of time. The author never says he's inventing things.
But the way he is combining those things, the rigor he shows, creates something I have not seen elsewhere. Note that he also shows the two-empty array trick (not found elsewhere by me) and then adds sentinels, reflection, type genericity, several tricks to memory safety, etc.
In most of the good C code I see around there's no even 1/5 of those qualities (that become qualities almost only in bigger programs). This is an example of very good C code:
http://svn.python.org/view/*checkout*/python/trunk/Modules/_collectionsmodule.c?revision=70298&content-type=text%2Fplain
It's better than most C code you see around, yet it's far from the code shown in the ctips.


>been thru first 19 pieces of advice. nuttin' new or remotely interestin'.<

I don't agree. I have some experience of C programming, and yet, I have found several interesting things.


>wut i saw was some lame shit that puts a grown man 2 sleep.<

I guess Ruby coding is more sexy. This is sometimes more boring that Ada coding, but you can't use Ruby for some of those things.


>use assert, macros, & checks. wtf. then got interrupted. the 70s called. they wanted they lame c idioms back<

Among those idioms there are some things, like certain reflection, that D isn't doing now. If you write to write/fix big programs in C today you need those things. And more modern languages like C# are a collection of some of those idioms, as I have explained.
Note that I am planning in creating a new module for Python 2.7, it has to be written in C, so I need C today too, it seems.

So I agree with nearly nothing you have (badly) expressed.

Bye,
bearophile



More information about the Digitalmars-d mailing list