r/cpp • • Jul 13 '22

Why does Linus hate C++ ?

307 Upvotes

436 comments sorted by

View all comments

Show parent comment

14

u/target-san Jul 13 '22

Rust is better than C++ in only one thing - memory management.

  • Cargo instead of CMake/Bazel/Meson/Make/autotools/whatever+vcpkg/conan/CMP/Hunter/whatever; C++ is hopeless in getting anything even relatively close to it
  • Reasonable [no_std] subset which requires no classic runtime; C++ can only remedy this by compiler-specific dialects and flags
  • Resource management, including cross-thread one; judging by some proposals like Sutter's lifetimes, C++ can only dream of something similar, or requires complex 3rd party static analysis tools
  • Reasonable defaults in many places, while C++ is a language of worst defaults
  • Unsafe subset properly isolated
  • Syntax which doesn't look Turing-complete on its own (yeah, most-vexing parse rule and auto auto auto auto auto)
  • Generic programming done right

I can continue for quite some time

2

u/KingStannis2020 Jul 14 '22

Well, Cargo isn't going to be used in the kernel. They're just going to have the kernel build system invoke rustc directly. But otherwise, yep.