Criticism of C++

[3] Among the critics have been: Robert Pike,[2] Joshua Bloch, Linus Torvalds,[3] Donald Knuth, Richard Stallman, and Ken Thompson.

One of the most often criticized points of C++ is its perceived complexity as a language, with the criticism that a large number of non-orthogonal features in practice necessitates restricting code to a subset of C++, thus eschewing the readability benefits of common style and idioms.

As expressed by Joshua Bloch:[4] I think C++ was pushed well beyond its complexity threshold, and yet there are a lot of people programming it.

Donald Knuth (1993, commenting on pre-standardized C++), who said of Edsger Dijkstra that "to think of programming in C++" "would make him physically ill":[5][6] The problem that I have with them today is that... C++ is too complicated.

At the moment, it's impossible for me to write portable code that I believe would work on lots of different systems, unless I avoid all exotic features.

Ken Thompson, who was a colleague of Stroustrup at Bell Labs, gives his assessment:[7][4] It certainly has its good points.

[8] C only has limited amounts of information in header files, the most important being struct declarations and function prototypes.

This problem is magnified where the classes are written as templates, forcing all of their code into the slow header files, which is the case with much of the C++ standard library.

This fits very poorly together with exceptions, when a function must interrupt the control flow, after an error but before resetting the global format state.

The error number in the catch statement will be written out in hexadecimal which probably is not what one wants: It is even acknowledged by some members of the C++ standards body[13] that is an aging interface that eventually needs to be replaced.

C++20 added std::format that eliminated the global formatting state and addressed other issues in iostreams.

The design of std::format permits more performant implementations, comparable or even faster (because of locale independence) to that of printf.

Functions that change the size of the container often invalidate all iterators pointing to it, creating dangerous cases of undefined behavior.

This safety issue has led to the invention of the RAII idiom,[23] which has proven useful beyond making C++ exceptions safe.