Why (not) Use C++ ?

Now in its 25th year, C++ sits a little awkwardly in the modern world. It grew enormously in the late 80s and early 90s, even overcoming the Department of Defense’s 1987 “Only Ada code to be used” mandate in 1997. But with the arrival of Java in the last years of the century, things became less certain and C++ looked to be becoming a legacy language like Delphi or Visual Basic.

Since .NET appeared in 2000, Microsoft has pushed two enhanced versions of C++ onto it but neither version fared well. First was Managed C++, which was replaced by C++/CLI.

Since C++ 11 was standardized and Windows 8 has C++ as one of its four
development languages, things are maybe looking a bit brighter, but who actually uses it?

Bjarne Stroustrup, the creator of C++, keeps a large list of applications written in it. Big names there include Adobe and Microsoft with most of their products, large chunks of Mac OS/X, the Gnu Compiler Collection GCC, MySQL and MongoDB databases, and many many games.

What about Linux?

Linus Torvalds is a C programmer and not overly fond of C++, to put it mildly. “C++ is a horrible language,” starts a reply of his to someone who asked why Git is written in C not C++. Many well-known Linux programs are written in C — not C++ — such as Apache and Nginx webservers.

Some projects are developed in both C++ and C and often other programming languages as well. An interesting paper was published looking at how the choice of programming language impacts software quality and developer productivity. It used four projects (Firefox, Blender, VLC and MySQL) that were made up of both C and C++. The conclusions are unequivocal: “Our analyses demonstrate that applications that start with C as the primary language are shifting their code base to C++, and that C++ code is less complex, less prone to errors and requires less effort to maintain.”

The decision to use C or C++ depends on many factors, of which age is probably the most important. For very low level or embedded programs, C comes with less overhead. But for any program that does major text processing or has a more complex data model, the benefits of C++ should not be ignored.

What About games?

In the game engines listed on GpWiki, it’s fair to say that the bulk — about 90 percent, use C++. Though C was favored in the past for game development — until the mid-1990s, C++ offers greater advantages for the complexities of 3D games, resource management and sophisticated multiplayer for networking.

High energy physics uses C++. ROOT, a framework for data processing that was created at CERN, is employed in applications that are used by thousands of physicists each day. ROOT simplifies the tasks of storing large amounts of data, retrieving, processing and then visualizing it. It includes 1,200 classes organized in 60 frameworks.

At times I really do wonder about Microsoft’s long term development strategy with regard to C++. It was just 20 years ago, in February 1993, when Visual C++ 1.0 (16-bit) was released. The Visual Studio IDE is highly regarded by developers and yet Microsoft sometimes seems a bit embarrassed by C++ still being on the scene.

Microsoft isn’t the only C++ compiler provider for Windows. The free GNU Compiler Collection (GCC) and the more modern open source Clang and LLVM are also available on Windows, as well as Mac and Linux.

Tablets and Smartphones

One area that lacks C++ is mobile computing. iPhone is coded in Objective-C, Android in Java and Windows Phone in C#. You could use C++ for iOS development, or even Objective-C++, but you still have to use Objective-C for interacting with iOS. There have been attempts to develop for iOS in C++ — DragonFire SDK springs to mind — but they’re the exceptions.

Conclusion

C++ is still around and many of the applications that run on Windows and Linux are written in it. The entire AAA games industry, with a few multimillion dollar titles, depends on C++. I doubt any other language will ever be a good fit in that domain.

The world of open source uses C++ extensively and thanks to the free Microsoft C++ Compiler, Windows is considered a viable platform. But while languages such as Python don’t match it for performance, but they are good enough and far easier to learn.

One Response to Why (not) Use C++ ?

Java is owned by Oracle, who bought it from the barely-for-profit Sun, who owned it for almost as long as there has been Windows, or even longer.

Android can be programmed, it’s true in Java, but also in C++, despite this glaring omission from the writer.

“dot Net” (.NET) is Micro$oft’s ploy to capture Java market from Sun now Oracle, yet each leaves corporate users hostage to version mismatches and support nightmares. Especially when corporate customers like TeraData have multiple enterprise applications whose customers depends on their different versions of Java to be compatible…

The jury is divided on whether the monolithic owner of Java or the semi-retired owner of .NET is willing or capable to provide as robust support as the entire C++ community .