r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

308 Upvotes

436 comments sorted by

View all comments

Show parent comments

30

u/AdultingGoneMild Jul 13 '22 edited Jul 14 '22

it was fine. C++ hides too much of the machine for his liking. C++11 would have made that even worse. Knowing where bytes are, how they are laid out and what they are doing is necessary for high performance code. His belief is that C++ developers were made lazy by the language and therefore in mass would not know what the language is doing and therefore cant be trusted to write highly optimized code. Sure, he wouldnt have a problem with a well trained, very talented C++ dev. But as a whole he doesnt trust C++ devs.

To give some credence to his claim: do you know what a v-table is OR how the order of declared members in your class/struct affects their padding and thus the memory layout?

22

u/TheFlamingDiceAgain Jul 14 '22

> cant be trusted to write highly optimized code.

The entire high performance computing community would like to disagree with this

0

u/another_day_passes Jul 14 '22

HPC is mostly Fortran and C no?

7

u/TheFlamingDiceAgain Jul 14 '22

C++, C, and Fortran. C++ can always be written like C and for HPC applications is often faster that C or Fortran because of the extra info you can give the compiler (templates etc); plus there’s just more time spent on C++ compilers since it’s more popular in general. The US Department of Energy is also really pushing C++ for their supercomputers and is heavily involved in developing C++ with better accelerator support. If you’re writing a new HPC code now you should probably write it in C++

→ More replies (4)