The AtomicObject team described well on their website the danger of the richness of C++:
C++ is an immensely rich language. This richness is both a blessing and a curse. A blessing, because of the expressive power and support for several programming paradigms; a curse because this richness means complexity, and there is much to master. C++ is a language to grow with, one for which each experience can teach new features, or better understanding.
Since each of C++’s features may interact with the others, learning C++ feels like gradually filling in a not-so-sparse matrix of knowledge formed by the cross product of the C++ feature vector with itself. No serious use of the language should be undertaken without good references at hand.
Since 2011 Microsoft announced in many articles the come back of C++, and Microsoft C++ experts like Herb Sutter did many conferences to explain why C++ is back and mostly recommend the use of Modern C++. In the same time, the standard C++11 was approved and we begin to talk about C++ as a new language.
However, in 2011, C++ had a past of more than 30 years. And it’s not easy to convince developers that the new C++ simplified many frustrating C++ usages, and there’s a new modern way to improve the C++ Code.
But unfortunately, all the effort from the active C++ community and the known experts was not sufficient. Moral of the story: If you give to someone the possibility to do something with a language or a tool, don’t be surprised if he did it.
Currently, we need some safeguards to assist the developers coding a clean C++ code.
1- Protected compiler mode to use a subset of the language
To benefit from all the amazing effort from the standards committee and the C++ community we need compilers where we can exclude the use of some old C++ features.
It’s true that there’s a big constraint when using the existing C++ libraries, but if we are convinced that C++ will have a very long life we need to prepare from now the switch to the new modern C++ language.
The existing compilers are not designed to accept only a subset of the standards. However, after working with Clang as a parser for CppDepend we can confirm that its modularity, its implementation, and its powerful diagnostics feature will help its contributors to develop in the near future a version where we can customize it easily from command line and exclude some old features of the C++ standards when compiling our sources.
2- Diagnostics and warnings of the compiler
We need more diagnostics and warnings to report us the deprecated usage. Clang reports many interesting diagnostics related to the deprecated usages and maybe in the future, it can give the possibility to stop the build if some specific diagnostics are reported.
3- Tools
Some tools can help us to detect the deprecated usage and it can be integrated into the build process to fail the build if some rules are violated.
Clang tidy is a powerful tool to detect many flaws and deprecated usage. CppDepend integrates it with the 2017 version and provides also a code query language to query the code like a database to customize easily your coding rules and detect where some deprecated usage exists.
To resume we need a solution to help better the C++ developers to switch to the new modern C++.