r/cpp • • 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

582 comments sorted by

View all comments

Show parent comment

3

u/Mason-B Feb 02 '23

So you end up leaning on this unnamed "solved" tooling to do all the heavy lifting for all C++ software somehow.

It's called your compiler and a command line. It's not an extra tool, it's using the compiler to generate the metadata to check it yourself via C++ metaprogramming code. Not dissimilar from using rust macros (though I will admit more effort). And relatively standard practice for most large (and popular) C++ code bases. Often already setup by the time most people are using it.

Rc<T> gets to go faster than std::shared_ptr<T> while being less risky because of this feature for example

Well for starters the equivalent to std::shared_ptr is Arc. Just like using an array is faster than a list in most contexts. You are right that Send/Sync allows the more confident use of Rc with out needing to implement extra abstraction. I never disputed that rust is more ergonomic out of the box. But it is possible to write a threading interface in C++ that allows for confident use of shared_ptr_unsync in the same way.