It happens every so often that someone will report that C++ (or some other programming language) is dying. The latest occurrence is Why C++ is Dying, and is an analysis of the results from TIOBE Programming Language Award in which Objective-C is listed as the 2013 winner.
In the analysis, various programming languages are listed in the typical spectrum from machine code (low level) to human language (high level). The results are then discussed as if the only goal of choosing a programming language is to find the highest-level while still being able to accomplish the task.
While this sort of comparison of programming languages across a spectrum may be of use when first introducing students to the variety of languages, it is meaningless as a determination of usefulness of any particular programming language.
It’s like asking the question, “Why is the hammer dying?”, then making a list of various possible bonding tools:
- wood glue
- staple gun
- hydraulic nail gun
- electric nail gun
- screw driver
- power screw driver
The reality is that there will always be times when each of these is the best solution for the particular task. The invention of a new tool doesn’t “kill off” the old one, it just means that the variety of tools makes each individual one more specialized. Yes, C++ is no longer considered an all-in-one solution. However, a better question to ask is “Why are other languages rising in popularity when compared to C++?” especially as we continue to analyze which languages we should be teaching students in the classroom?
So, why are other languages rising in popularity when compared to C++?
While part of the answer is that fast processors allow for less efficient languages to be used successfully, a more important change is the ubiquitous nature of parallel processors. For a long time, computer processing power was advanced through the use of faster CPUs. But now, doubling processor speed is not as cost effective as simply doubling the number of processors. The result is that a single program running on multiple CPUs must be written differently to best deal with the issues surrounding parallel processing. Object Oriented Programming (of which C++ is one of the most efficient), is not the best tool for parallel programming. You can do it, but it just isn’t what it was designed for. Thus the reemergence of functional programming and the recent increased use of C over C++. But in the long run, C is not a great parallel programming language either, it just happens to be an easy transition for C++ coders. I suspect we may see more use of languages like Erlang as this trend continues.
More Corporate Players
Apple made a corporate decision to use Objective-C instead of C++. Both are OOP versions of C, but the difference is that with the popularity of iOS and access to the AppStore, the easiest way for developer to create apps was to use Apple’s XCode. Thus, we saw an almost overnight dramatic increase in the popularity of Objective-C. It’s not because Objective-C is better or worse than C++, its just what all the libraries and sample code are written in… so it’s what developers were forced to use. Similarly, Google chose Java as the language of choice for the Android… which pumped some blood back into the Java community. Microsoft has understandably always wanted to push their own standard for languages as well. They were unsuccessful with many attempts, but finally figured it out with C#. As for C#, its not so much the language itself that made it so successful, but the well designed and documented set of .NET libraries that addressed most of the common tasks required for network-capable Windows development. These various corporate players all have their own agendas, and they do their best to stroke the egos of their fan boys.
New Ways of Thinking
Finally, not all programming tasks have the same goal in mind. For example, when it comes to turning math into code, the programmer writing a 3D physics engine for a game has a different goal when compared to a tax accountant or scientist. In the case of the game physics programmer, they will want the mathematical function to run as efficiently as possible. Specifically, they may rearrange the values so that they can be processed quickly. On the other hand, a tax accountant is more concerned that the equation is correct. Languages like F# allow mathematical functions that have been converted to code to retain the nature of the mathematical language, allowing it to be easily checked for accuracy.
We know that C++ is a powerful language, but what makes it so powerful is that it is both object-oriented and it doesn’t hide or prevent access from the things that would be dangerous to a novice programmer. It is a tool, sometimes the best tool for the job, sometimes the worst.
To continue the original analogy, it is important for professional programmers to have multiple tools in their toolbox. Get practice using a variety and specialize in a few.
The Case for C++ in Computer Science Education
The following comment comes from a colleague, and I couldn’t have said it better myself.
Of course, from our perspective as educators, it would be tough if C++ fell off the radar completely but it would still be very valid educationally to teach in C++. Right now, it’s the only language where we can simultaneously teach Object Oriented programming and low level memory management in a platform independent way. Until such a language comes around which is also widely used in the Game Industry, we’ll keep teaching in C++.”
-Professor Dean Lawson, Champlain College
For development on multiple platforms (especially various mobile devices), I still recommend the use of a single language. For more information on how to achieve this despite the iOS and Android “languages of choice”, see my earlier post on multi-platform development. And if you want even more, I’ll see you at the Xamarin Evolve Conference in Austin.