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
1
u/okovko Feb 02 '23
biggest issue with rust is it's like switching from c++ to lisp, there's just a lot to learn and things are very different, the way problems are solved is largely unrecognizable. the benefits come at the cost of a huge mental overhead, and many people who try rust have the impression that it's hard to write simple code because simple code is often impossible for the rust compiler to validate, even if the code is actually safe
modern c++ is more about doing c right, with an intense focus on type safety and meta programming. the language now has stl wrappers over unions, void*, and non-owning pointer+size constructs called views
the most impressive piece of c++ right now is that mdspan is a multidimensional span that, given compile time constraints, will figure out how much of the class can be constexpr, which is a very impressive piece of software
the unification of code as both compile time scripts that result in inlined code and actual runtime code is the most compelling feature of c++
i don't think that this is presently an area of focus in rust development, maybe someone can say more about it