Before its initial standardization in 1998, C++ had been developed by Bjarne Stroustrup at Bell Labs since 1979, as an extension of the C language, because he wanted an efficient and flexible language similar to C.
In 1983, “C with Classes” was renamed “C++”, adding new features that included virtual functions, function name and operator overloading, references, constants, type-safe free-store memory allocation (new/delete), and improved type checking.
The 1990s were the golden age of C++: it was very popular, and many projects were developed with it, especially after the OOP revolution. But after 1998, C++ stagnated for many years. And between 2000 and 2010, no big companies supported the evolution of the language. Microsoft focused more on its new .NET technology.
Surprisingly, after 2010, people started talking about a “C++ Renaissance”. We have to admit that Microsoft was a major player in this movement; I remember this video where Craig Symonds and Mohsen Agsen discussed it.
In 2011, Microsoft announced the comeback of C++ in many articles, and Microsoft C++ experts like Herb Sutter gave many talks explaining why C++ is back, mostly recommending the use of modern C++. At the same time, the C++11 standard was approved, and we began to talk about C++ as a new language.
However, in 2011, C++ already had more than 30 years of history. And it’s not easy to convince developers that the new C++ has simplified many frustrating aspects of C++ and that there’s a new, modern way to improve C++ code.
Let’s take memory management as an example — maybe the most criticized mechanism in C++. For many years, object allocation was done with the new keyword, and developers had to remember to invoke delete somewhere in the code. “Modern C++” addressed this issue and promotes the use of shared pointers.
But unfortunately, all the efforts of the active C++ community and well-known experts were not sufficient. Moral of the story: if you give someone the possibility to do something with a language or a tool, don’t be surprised if they do it.
That’s what happened with C++: we still have the possibility to use new and delete, and of course we can’t remove this possibility for many reasons. Even though modern C++ has promoted the use of smart pointers for many years, object allocation with new will continue to be used for many years.
The C++ past heavily influences how it is used, even for newly created projects, and many developers still think that this language is very complex.
How does C++’s past affect the language?
To find out, let’s do a test: just search the web for “C++ object allocation” and look at the results — almost all the links on the first page talk about new/delete or even malloc.
Another interesting test is to go to any university library, ask for a C++ book, and read the chapter on object allocation: it mostly talks about the new keyword.
To sum up, if a new C++ developer wants to learn it, they will find more resources about “C with classes” than about modern C++.
How to limit the impact of the C++ past?
There’s no magic solution. We can hope that C++ compilers could help us by emitting warnings about deprecated practices, like the old string manipulation functions (strcpy, strcat,…). But this solution alone won’t have much impact. Modern C++ is more about new idioms to learn and practice.
Another solution would be to consider that C++ has changed its name and become “Modern C++”. Even though this solution is very simple, the result is very interesting. And to be convinced, let’s do the same web search as before, but this time for “Modern C++” object allocation: the first link talks about smart pointers.
A piece of advice to new C++ developers: consider that C++ has changed its name, and for all your searches on the web always use “Modern C++” instead of C++ — the results will be very different, as searching with just C++ will mostly return information about older practices.
