The C++ programming language was designed by Bjarne Stroustrup as an improvement over the C programming language, incorporating a number of enhancements. Probably the most important is built-in facilities for object oriented program design, as hinted by a term used as a working title for the project early in its development: “C with Classes.”

It is heavily used for software development where performance matters, particularly in the realm of very complex application development where a little bit of OOP goes a long way toward making that kind of complexity manageable. Unfortunately, C++ itself is an incredibly complex beast of a language.

Originally, it promised to be a superset of the C language with facilities for object oriented programming. Another language, developed around the same time (arriving a mere three years later) with the same goals, was Objective-C. To a significant degree, the differences between the languages can be attributed to two things:

  1. Influences on their design
  2. How well they achieved those early goals

C++ is listed on Wikipedia as having been influenced by a slew of languages, including C (of course), Ada 83, ALGOL 68, CLU, ML, and Simula. Most of its casual users would likely have a difficult time coming up with that list off the tops of their heads, and for the parts of the list that might occur to them, it is likely that any random pair of casual C++ programmers would not come up with the same short list. To some extent, the influences on C++ are obscured by how they were bent to fit the new language, and some might suggest absinthe is another important influence.

Objective-C, by contrast, has two influences that would come immediately to mind for even the most casual Objective-C programmer (possibly excluding people who are not aware the language is older than MacOS X): C and Smalltalk. The Wikipedia article about Objective-C offers those two, and only those two, influences on the language’s design, reinforcing the obviousness of those influences.

As for achieving the early goals of providing an object oriented superset of C, Objective-C appears to have succeeded in all essential details, while C++ looks in some respects more like the result of giving up on those goals in mid-effort to pursue something shiny instead.

Much as the influences on Objective-C are much simpler than those on C++, so is the design of the language much simpler. The reason Apple (and NeXT before it) chose Objective-C as its primary object oriented application and system development language seems obvious, in that it offers simplicity and elegance of design — at least as compared with the design of C++. Outside of its eventual rise to prominence as the language of choice on Apple platforms like MacOS X and Apple’s iOS, however, C++ is the clear winner in terms of popularity and mindshare. Even now, so many years after its creation and without any major resurgence like Objective-C has enjoyed, C++ is in heavy use. For instance, it is the core implementation language of all the most popular major Web browsers for non-Apple platforms; Chromium, Firefox, Internet Explorer, and Opera are all substantially built using C++. Even Apple’s Safari browser is written primarily in C++, though other browsers for MacOS X have used Objective-C instead.

Perhaps it was the fact that C++ was “first to market” by about three years that accounts for the massive success of the language, and the relative popularity failure of Objective-C. We can finally find books about programming in Objective-C on the shelves of every major book store, but they focus on development for MacOS X and Apple’s iOS. General-purpose, platform-agnostic use of the language is apparently not a popular enough area of interest for anyone to peddle books about the subject.

Criticisms of C++ appear to substantially outnumber its praises. Meanwhile, the only people talking about Objective-C (for the most part) are developers for Apple platforms. Those who develop only for Apple platforms are generally regarded as untrusthworthy in their pro-Apple biases by many other programmers, so the fact they primarily sing its praises carries little weight amongst developers who avoid Apple platforms.

What are probably the best criticisms of C++ have both been attributed to Stroustrup himself. The first is his statement that C makes it easy to shoot yourself in the foot, and C++ makes it harder — but when you shoot yourself in the foot with C++, you typically blow off your whole leg. The second is an interview for IEEE Computer Magazine that was supposedly shelved because it was decided it could not be published, in which he “admits” that C++ was all a joke from the very beginning, and he goes on to humorously extoll its vices. Stroustrup has disclaimed the article, saying it was a hoax, and said that he thinks it would have been funnier if he had written it himself.

By the time one is done reading that fictional interview, one might be forgiven for questioning for a moment whether C++ really was all a joke from the beginning. If so, the joke seems to have been made at the expense of Objective-C, which lingered in obscurity for almost a generation — an eon in the terms of computer technologies — before finally finding its niche in the Apple ghetto. The fact of the matter is that, without Objective-C and Cocoa, Apple would almost certainly be in real trouble in its search for developers to support its platforms; the joy many find in developing with those tools helps developers who are the target of systematic mistreatment by Apple’s legal and marketing teams overcome some of their misgivings.

One might think C++’s days are numbered, now. Alternatives that seem significantly better suited to the same jobs litter the landscape, and the obvious direct competitor — Objective-C — is in some ways the least of them. Objective Caml is regularly held up as an example of a high performance language, frequently outperforming C++ by a significant margin in benchmark tests, offering more succinct and well-organized source code, and providing developers with far cleaner and more interesting development models, and it is not even derived from the same family of programming languages. D aims to compete in the same space, though its proprietary roots may hinder its widespread adoption. Google’s Go language presents controversial trade-offs, but there is no doubt that its design offers huge advantages for certain types of software development, including concurrency.

Judging by the lessons of history, however, I am inclined to believe that C++ will have a long, stable tenure in its niche for some time to come. It has even been sneaking into operating system kernel development for years, as horrifying a thought as that might be for people who care about things like OS reliability. There is no doubt that it offers some advantages over C for certain types of performance-critical programming, and that its library support is extensive — even legendary. Despite this, at least some of the strength of its hold on developers seems to be based on ignorance of the alternatives, and that is not a characteristic that will easily be pushed aside by a would-be competitor.