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
- hammer
- 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++?
Processor Advances
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 Coders
We now have more devices, powered by processors than ever before. The result is a need for more coders with various backgrounds. An artist might benefit from making use of the processing power of a computer, but they shouldn’t (and now don’t) need to use the same tool as a full-time coder. Their goal is not, “how do I make this code the most robust, reusable, and efficient”, but instead, how do I use the computer to make my work as an artist easier. We’ve already saw this in the 90s with the rise of JavaScript. It was a simple language that allowed a designer to do a little programming inside a web browser … perfect tool for the job.
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.
As a side note, it is interestingly that with the move to support mobile processors (RISC) and Windows 8, it seems that Microsoft is moving away from C# and toward HTML5 and JavaScript as the entry-level coder language. But these changes take decades. Not only are most PC developers currently focused on C#, we still have a whole host of Visual Basic programmers in corporate industries, and they are not clambering to rewrite all their tools.
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.
Summary
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.
Sometimes the fact that you are an expert in one language over another is good enough justification to use it, and rewriting 20 years of legacy code simply because there is a new language available isn’t cost effective. Other times you will have a specific need that is better met by a language shift, I wouldn’t write a corporate database in JavaScript, I wouldn’t build a Operating System in Ruby, and I wouldn’t start trying to manipulate 3D models with C++ in Maya.
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
P.S.
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.
2 comments on “The Future of C++”
People said rock and roll was dead too…
Nice article. The analogy of the toolbox sums it up perfectly.
Very nice article. Glad people can reason about these things.