DEV Community

Discussion on: Pass-By-Value in C++ and Rust

Collapse
 
deciduously profile image
Ben Lovy

Sure, it's not a bug with C++, its a bug with the C++ programmer. It's still something that only comes with experience, whereas Rust by default will catch this programmer-introduced mistake for you.

I'm not trying to state this in the general case, only from a beginner's perspective. Both languages have their uses, it's not a cut-and-dry superiority situation.

Collapse
 
rtxa profile image
rtxa

The only difference is that Rust compiler will warn/error you about that and C++ will not for most of the cases (unless you use a static analyzer which will reduce the odds).
In every language you need to learn the rules, otherwise you will fight with the compiler everytime.