August 23rd, 2008

Captain Obvious

Quit damning C with your faint praise.

Here’s the thing: C is everywhere. Recently Tim Bray made basically the same point; all the major operating systems, all the high-level language runtimes, all the databases, and all major productivity applications are written in C. And there are many other categories of software that I haven’t even mentioned, all written in C.

So can you as a developer choose to ignore it? Live in high-level language land for your entire career? I would say almost certainly not. High-level languages often provide abstractions that relieve you from the burden of dealing with the platform on which you’re building. Which is great, but sooner or later a crack is going to open up and the abstraction is going to leak.

Some day you’ll need to go spelunking into the depths of your runtime environment. Maybe you’ll need to call some other C-based API for which you don’t have a convenient wrapper in your high-level language of choice. Like, say, mmap-ing a part of a file instead of the whole thing. Or maybe you’ll just want a bit of a performance boost. And on that day, boy will you wish you knew C.

It’s for this pragmatic and entirely non-bigoted reason that I promoted C to the top of my language pantheon. If you’ve never learned C, it means you’ll never be able to delve too deeply into the foundations your programming environment and find out exactly what is happening under the surface, or to extend it in any way.

Do these arguments ("it underlies everything", "you need it for maximum performance", "it's the only way to do certain things") sound familiar at all?

How about if you s/C/assembler/g and read again?

C will go the way of assembly sooner or later. All the same arguments are being made in its defense. The only question is, how long will it take? Don't get me wrong - I like C, and I hope it will be a long, long time before it goes away. But don't kid yourself. Nobody learns assembly any more (except for embedded engineers and a few EEs), and there will come a day when C suffers the same fate.

And frankly, I find all this over-blown defense of C to be stupid. Quit damning C with faint praise. It is a perfectly good programming language on its own merits. So good, in fact, that it's spawned a horde of imitators and knock-offs. C++, Java, C#, etc, etc - they're all based on C syntax. Partly a historical accident? Sure. But ask yourself this: if it's only about history, why didn't FORTRAN or COBOL come to dominate? You pretty much have to concede that C is awfully good for a language invented 35 years ago.

If you really want to defend C, how about less of this "well, you have to know it, because everyone else knows it!" argument-from-popularity bullshit1, and a little more of the "C is a good language because..." A) it's relatively simple and clean, B) anything you want to do, someone HAS done it before in C, and you can probably download the code, and C) yeah, okay, when performance does matter2, C is a reasonable choice.

N.B. Pre-emptive stike against the C++ weenies: NONE of the above arguments are meant, in any way, to defend or endorse C++. I am talking about, at most, C99 here.

1 Save that for your vi vs emacs holy wars. Lamer.
2 Which it very often does not - see Programming As If Performance Matters.
  • Current Music
    KMFDM - Power
  • Tags

Oh NOES. Teh nerdz has teh bat'leth!!

This horrifying five-foot weapon has been recovered by police during a knife amnesty.

The three-handled sword with a blade at either end, designed to be swung like a paddle, shocked officers who took custody of it.

The blade is believed to be a stainless-steel copy of a Klingon weapon used in the science fiction series Star Trek. "It's an extremely dangerous weapon," said a martial arts expert last night.

It's less dangerous than the katana I have sitting upstairs on my bookshelf. Which I assure you will part a neck much faster than any bat'leth ever will. A bat'leth is a composite tonfa and blade - easier to block with, harder to swing. Less specialized for slicing.

But don't tell it to the banners. Once the paranoid nanny-staters get going, there's no stopping the damn fuckheads...

Anyone wanna take bets on how much longer before you're not allowed to posess tire irons and hammers in England?