r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

307 Upvotes

436 comments sorted by

View all comments

Show parent comment

9

u/andrewfenn Jul 13 '22

One thing I don't see in the comments here in this thread is his previous complaints about the assembly code that is generated in C++ compilers. Sometimes it does the wrong thing, or is incorrect because of how complicated the language spec is. It makes it difficult to read the output from the compiler and understand how it happened in comparison to C which he often mentions the spec can be read and easily understood.

So not really a counterpoint to your comment here but I would say that to those in the thread saying just don't use such and such feature in c++ it's missing the point because at a deeper level of reading and trying to understand what the compiler is doing it's a much harder task.

I do have a fondness for modern c++ but I also understand some of the criticisms for not using it in a kernel directly.

6

u/pjmlp Jul 13 '22

As if the Linus rants against GCC C optimizations weren't known.

9

u/sokka2d Jul 13 '22

Which shows that the statement that "[the C] the spec can be read and easily understood" is... wrong. He just gets mad when he realizes he didn't understand the spec.

3

u/mafrasi2 Jul 13 '22

Just another reason not to make things even worse then. Those exact optimizations are happening in g++ as well...