As you may or may not know, ANSI is trying to push a new C++ standard out the door called C++0x (which those of you who know C may find amusing, since you can read it “C++ Hex”). C++0x’s primary goal is to take C++'s already horribly convoluted syntax and make it even worse. Looking at a summary of C++0x’s additions, for example, we come across the concept of rvalue references, expressed as int &&x. With this move, C++ now has a bizarre hybrid of pointers and handles that solves a legitimate problem in C++, but one that really shouldn’t exist to begin with. C++0x also introduces the odd concept of nullptr, a strongly typed null pointer. There’s a reason similar constructs exist in higher-level languages like Java or Python that try to move away from the hardware, but given that one of C++'s huge initial advantages was retaining the close-to-the-metal feel of C, I really fail to see why we want nullptr when we already have 0. Most of the other changes seem frivolous (the new concept keyword), closing the barn doors after the horses have already come home (Boost’s shared_ptr and weak_ptr will enter the language), and trying to cram high-level constructs into a language never designed for them (such as garbage collection).

Thankfully, even if you need to stay close the hardware (which most programmers rarely do), there are several superior alternatives available. On Windows and Linux systems, you can take a look at D, which is basically everything that C++ should have been: easy low-level access when need be, a vastly cleaner and less ambiguous syntax, per-allocation optional garbage collection, optional contracts, generic containers, typesafe varargs…the list goes on. Calling existing C code from D is downright trivial, involving little more than a few extern declarations. It’s a project that anyone stuck doing low-level programming should be keeping an eye on.

On Windows, Linux, and Macs, Objective-C can also make a superb choice—especially when coupled with GNUstep, whose FoundationKit framework provides a rich, cross-platform set of low-level libraries for things such as memory management, common data structures, and file operations. With Objective-C, you can program in an almost Smalltalk-like environment for non-speed-critical components, but then drop down seamlessly into C for the tight parts. Because Objective-C, unlike C++, is a true superset of C, this can actually be easier in Objective-C than C++ anyway.

If you’re in the mood for something a bit different, but still want to stay close to the hardware, take a look at Free Pascal, a superb cross-platform Pascal implementation that includes a massive, powerful class library, a great language runtime, and the scarily easy ability to drop down into assembler that made Turbo Pascal so great. If you’re scared by what you once read in Why Pascal is Not My Favorite Programming Language aeons ago, fear not; the Pascal language implemented by Free Pascal resolves basically every single one of those problems. And, of course, calling C libraries involves nothing more than running the C header file through a converter or linking against the shared object directly. Easy.

Keep in mind, I’m a high-level language fan. I’d greatly prefer to be working in Smalltalk or Common Lisp over any of these options if I have the choice, but I recognize that there are time you really do need to be close the hardware, whether for size, speed, or both. But even in that domain, there is no reason why any sane person should feel compelled to chose C++ over the alternatives.

I have a hunch, given this blog’s audience, that I’m probably preaching to the choir, but on the off chance I’m not: if you haven’t already, take a look at something other than C++ the next time you have to do system programming. You might really like what you see.