r/cpp_questions • • Sep 13 '24

OPEN Why Linux community hates C++ so much?

It seems like they have an extreme disliking towards C++. Especially the kernel developers. Linus has even said he doesn't allow C++ in kernel just to keep C++ programmers away. Which sounds very weird because C++ seem to be used in all kinds of complicated systems, and they are fine.

175 Upvotes

192 comments sorted by

View all comments

Show parent comments

18

u/clusty1 Sep 13 '24

Recently I wrote again some C ( ported c++ ) and damn, the mem management is a pain: allocation of temp scratch buffers forces a ton of boilerplate.

In no way is such code faster, just uglier and more error prone.

2

u/SlothWithHumanHands Sep 16 '24

and the moment some memory needs to stick around, or has non-trivial ownership, slow drag into heap abyss

1

u/jediwizard7 Sep 17 '24

I remember once doing something simple like I wanted to split a path with dirname and basename, and with the posix c APIs you need to strdup the string before calling the functions because they modify the string in place (so two strdups to call both), and then you need to strdup the results as well or keep around the input copies since the result is either a substring of the input or a static pointer.