3 ms·
> Just because you bump a version number it doesn't mean you are forced to use all the bells and whistles. But I want to use those features. I want memory saf
by imron 7y ago
> Just because you bump a version number it doesn't mean you are forced to use all the bells and whistles.
But I want to use those features. I want memory safety and a way to say this variable owns the memory, vs that variable which is only borrowing it. I want move semantics in some cases and copy semantics in others. I want lambdas so I don't need to define new functions (or classes) to handle simple visitor patterns (or other cases where passing a 'function' makes sense).
These are good, useful features that I'd like to use to make my code more safe, more performant and more readable, and while C++ can do these things to some degree, there's boiler plate and new rules (rule of 5 vs rule of 3) and gotchas, compared to a language like Rust that has these things built in, with more safety and without compromising performance, and for me it made sense to start using it instead.
I still have projects in C++ that I'll maintain with modernish C++ rather than re-writing them, but for new things where I have a say in the matter, I'll choose Rust.
- ncmncm 7y agoI see that you have not kept up. Since C++17 it's "rule of zero": you don't need to write any of them, because the compiler does it. As the language gets more capable, the code you write gets simpler. I don't think that is happening in Rust.
- imron 7y ago> I see that you have not kept up. I have not (C++14 onwards was roughly where I started paying less attention), and that was partly my point. C++ has gone through dramatic change, and if I'm going to go through that dramatic change, I might as well do it with a language that has modern features and safety built in, and doesn't require extra boilerplate to do it. Looking up the rule of zero, it seems there's still some debate about whether it's a good thing or not [0] (don't know if it's been resolved yet), and it still doesn't preclude you from knowing about the rule of 5 and the side-effects of declaring or not declaring certain operators/constructors/destructors. > As the language gets more capable, the code you write gets simpler. > I don't think that is happening in Rust. This happens quite often in Rust, see for example error handling and the evolution of the ? operator, and the recent addition of async/await, and unlike c++, as the language gets more capable the changes required in terms of coding style and updating your mental model of how things work is usually not so dramatic. 0: http://scottmeyers.blogspot.com/2014/03/a-concern-about-rule-of-zero.html http://scottmeyers.blogspot.com/2014/03/a-concern-about-rule...
- ncmncm 7y ago2014 was a long time ago. Scott has retired. The better alternative to his suggestion was noted right there in the comments. Rules of 3 or 5 concern only designers of a library, and if you are designing a library, you may ignore them now.