Top

Why is the C programming language still irreplaceable? Are there no similar alternatives?

There’s no acceptable replacement.Professional programming is about tradeoffs.

Python is really popular because developers can work really rapidly in it – and with fast CPUs, the cost of developer time way outstrips the on-going cost of CPUs. I can afford to have a hideously inefficient application because I can buy a crap ton of CPU time for what I’d pay another developer for a year.

Java is really popular because it provides not only a robust data abstraction model via it’s object oriented basis, but because it has a reputation of being stable, solid, reliable and “enterprise grade”. You can build big hairy complicated code bases in Java and have them perform robustly (and slowly) for a very long time.

C++ was sort of a half-step between C and Smalltalk. You have to recall that originally, it was a pre-processor that let you build object-oriented programs, but transpiled to C, then built to running code. If you have ever looked at C++ and wondered why it’s clunky… that’s it. Modern C++ is more or less isomorphic to Java.

C, though… C was built to be a high-level portable replacement for assembler. It had ALGOL-like control structures, plus the ability to directly manipulate register use, directly address physical locations in hard memory and I/O controls, and freed the programmer to directly meddle in the data structures by exposing all the pointer arithmetic that actually lives under dimensioned arrays in, well, literally every other programming language.

So in particular if you’re building code all the way down on the hardware, where you have to worry about needing to touch this particular address in that particular way, where you can’t afford to have the language “garbage collect” for performance reasons, where you don’t need a layer of abstraction because you know a priori that the abstraction models built into other languages will actually fuck you up… you write in C.

You can argue that there’s nothing that you can do in C that you can’t do in C++ and to some extent that’s true — but when you do, you have to turn off all the type safety, and ignore everything in C++ that’s not in C. Which sort of defeats the purpose.

Apple argues that you can build systems level code in Swift. I tried that. Gave up. Sure enough, Apple came out with some additional libraries that made it possible to use some incredibly complex methods to say “this physical address right here now contains an object of this type, with this variable name” (which is like a single line in C). So I’ll concede that it now might be possible, but it’s a big enough pain in the ass that I haven’t gone back to verify.

Google argues that Go is devised to provide a similar “the language gets out of your way” leitmotif, but it’s also missing some of the critical “no really, this thing, that location, thanks much” features. I gotta say, I do like Go. But it’s not a replacement for C as a systems language.

It’s not that C isn’t portable, it’s that most of the things that you find yourself doing in C aren’t portable. They’re very hardware specific, because you’re writing right down there on top of the hardware, typically without much (if any) operating system support.

Which is the antithesis of literally every other programming language you’re likely to encounter.

(sidebar: yes, I’m purposely leaving out BCPL which while a personal favorite, is literally C’s great-grandfather, and other than as a teaching tool is effectively dead)

Santosian Noor is a Kenyan Environmental Engineer, Wildlife film producer, and director of film and television. He is best known as wildlife conservationist and the Author of "THE CRY FOR ELEPHANTS", "THE LAST TUSKS", "THE CRY OF A SON", and "THE MISSING ELEPHANTS"

Post a Comment

DONATE TO OUR NEW ONLINE WILDLIFE ACADEMY