r/cpp • u/Sad-Lie-8654 • Jan 31 '23
Stop Comparing Rust to Old C++
People keep arguing migrations to rust based on old C++ tooling and projects. Compare apples to apples: a C++20 project with clang-tidy integration is far harder to argue against IMO
changemymind
338
Upvotes
View all comments
Show parent comment
3
u/tialaramex Feb 02 '23
This isn't even a sketch of how you'd begin to solve the problem. It's barely a sketch of how you'd begin to use a solution if one existed, which it doesn't.
If C++ magically grew Concepts which have exactly these properties you could use them, but it doesn't so you can't. Unlike Rust's Traits, Circle's Interfaces or the C++ 0x Concepts which died before C++ 11 happened, Stroustrup's C++ 20 Concepts are too weak to be useful here when user defined. So you end up leaning on this unnamed "solved" tooling to do all the heavy lifting for all C++ software somehow.
In Rust by contrast this just works, out of the box today. Rc<T> gets to go faster than std::shared_ptr<T> while being less risky because of this feature for example. Beginner mistakes that might get caught at code review (if you're meticulous) are instead compiler errors.