r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

308 Upvotes

436 comments sorted by

View all comments

Show parent comments

27

u/dv_ Jul 13 '22

Then you most likely used a seriously restricted subset of C++. This indeed is useful, though the newest C standard iterations do contain additions that help as well I think. Also, IIRC, there is a small set of runtime functions that must be implemented when using C++, while there are none required in C. See here for example. But "C++" can also mean heavy use of template metaprogramming, which can easily create super bloated binaries.

27

u/delta_p_delta_x Jul 13 '22

heavy use of template metaprogramming, which can easily create super bloated binaries.

I was under the impression that heavy template metaprogramming only causes skyrocketing compile times, not bloated binaries...

3

u/HabemusAdDomino Jul 13 '22

Think it through. Template metaprogramming is templates. C++ templates generate code at compile-time. Code that goes into your binaries.

14

u/delta_p_delta_x Jul 13 '22

I agree with that, but I was thinking more along the lines of... some complex recursive template specialisation that takes ages to compile, but when it eventually does, it coughs up barely a handful of lines of assembly that map to the metaprogramming recursion, anyway.

I was also certain that templates are only instantiated for the types you specify to them, unlike Java generics, so one could have a templated header but no instantiations whatsoever...

→ More replies (4)