With the introduction of C++ 11 and C++ CX there has been a lot of renewed interest in the language. And a lot of developers, especially Windows developers, are wondering if they should set aside C# and Java in favor of it. John Sonmez argues no.

In his article titled Why C++ Is Not ‘Back’, John Sonmez argues that there are only three reasons to use C++:

You absolutely need to ink out every bit of performance possible out of your software and you would like to do that with a language that will support OO abstractions.

You are writing code which will directly interface with raw hardware. (Example: you are writing a low level driver.)

Memory control and timing is of absolute importance, so you must have completely deterministic behavior in your system and the ability to manually manage memory. (Think real time embedded operating system controlling a moving piece of machinery.)

Herb Sutter, who has heavily praised this article for offering a “a thoughtful hype-free opinion” adds to the list:

Servicing, which is harder when you depend on a runtime.

Testing, since you lose the ability to test your entire application (compare doing all-static or mostly-static linking with having your application often be compiled/jitted for the first time on an end user’s machine).

One of the reasons that John Sonmez offers against learning C++ is the sheer complexity of the language. Even though C++ 11 has made development easier, it doesn’t excuse the programmer from learning all of the old ways of writing C++ code. “You will encounter C++ code from 20 years ago and it will look like a different language entirely.” To reinforce his point he posted the 36 questions he asked candidates for a C++ developer position. Here are a couple of examples,

1. How many ways are there to initialize a primitive data type in C++ and what are they?

12. What is a copy constructor and when is it used, especially in comparison to the equal operator.

16. When is it and when is it not a good idea to return a value by reference in C++?

33. Why should you never throw an exception in a destructor?

Another argument against C++ is that “programming languages really need to get simpler and increase the level of abstraction not reduce it.” He continues,

There will always be a need for low level code, but a majority of the code that we write today is at a much higher level. I first jumped off the C++ ship many years ago when I finally could no longer make the argument that I could develop apps faster in C++ than C#. I held out for a long time trying to believe that all the investment I had made in C++ was not lost, but it turned out that C# simplified things to such a great degree that the extra power C++ gave me was not worth the extra responsibility.

John Sonmez concludes by saying that learning C++ is still useful for understanding how computers work in general, “but I don’t think it is going to make a comeback any time soon, and that is a good thing.”

To this Alo adds,

I started out on C++ and spent the first four years of my career exclusively on C++. That experience has been extremely valuable for me down the line because – as you pointed out – once you learn C++ to an adequate level, you can pick up any other language really fast and you’ve developed a deeper understanding of how software works on a lower level – a knowledge that’s much harder to acquire when starting out at higher-level languages; I’ve always frowned upon the idea of starting programmers out on Java for that very reason.

Richard Dunks counters with,

I think C++ is unhelpful for use in first semester introduction to programming classes and in teaching data structures, you have to spend so much time on the implementation, the students often lose sight of the structure they’re trying to replicate. I’m glad I’ve gained the proficiency in C++, but I don’t think it’s worth the cost and definitely not a one-size fits all instructional language.

Stephen Cleary offers a comment on reusability,

I’m a former C++ master who became a C# developer a few years ago due to marketplace pressures. I am CERTAINLY more productive in C#, but it’s simply not possible to reach the same level of code reuse as you can with C++ templates. The classic example is the triumvirate of containers, iterators, and algorithms. In C++, you can create one algorithm that will work with any container and adjust itself at compile time to take advantage of random access if necessary. Try doing that in C#. And I’m not talking about the “new C++” here, either; C++ permitted greater code reuse in 1998 than C# does today.

And in regards to performance, Herb Sutter offers this bit of advice,

In any language, if you are serious about performance you will be using arrays a lot (not “always,” just “a lot”). Some languages make that easier and give you much better control over layout in general and arrays in particular, while other languages/environments make it harder (possible! but harder) and you have to “opt out” or “work against” the language’s/runtime’s strong preference for pointer-chasing node-based data structures.

In additional to numerous high quality comments on Herb Sutter and John Sonmez’s respective blogs, there is much to be learned from Programming and Coding subgroups of Reddit.