If C is so evil why is it so successful?

John Wilson wilson at dbit.com
Tue Apr 11 20:03:02 CDT 2017


On Tue, Apr 11, 2017 at 08:38:22PM -0400, Charles Dickman via cctalk wrote:
>Subject: If C is so evil why is it so successful?

Seriously, I think the #1 reason is that K&R was fantasically well-written.
If you barely skim that book, you know C.

It's *almost* a good low(-ish)-level language, but unfortunately it's the
wrong kind of low-level:  it's designed mainly to be easy to compile, but
access to bits and bytes is much more fiddly than it needs to be.  It would
have been nice if it had stolen FORTRAN-77's idea of declaring a variable
in the size that you want (I'm talking about INTEGER*2 vs. INTEGER*4 etc.),
instead of just "knowing" what the difference is between int and long and
maybe long long on some architectures and using limits.h plus enough #ifs
to probably, usually, get the size you meant.

That plus the ability to specify endianness of variables, at least as
an option (and also bit order for bit fields -- justifiably rarely used
because we just can't trust them) would have made it a much better fit
for the kinds of stuff it's so often used for (like touching on-disk
structures or or device registers or stuff sent over the network w/o ending
up in a ridiculous talk vs. ntalk situation).  But instead it's just so
lazy ... the compiler barely does anything, and even when you're *trying*
to write portable code, you often fail w/o realizing it, and if it's not
portable then it might as well be assembly and get the benefits that come
with that.

It's still better than lots of other languages.  It's just not nearly as
good at what it's *for* as it would have been with a bit more effort.

John Wilson
D Bit


More information about the cctalk mailing list