4 ms·
It's the opposite of my experience. The mental load of Rust is lower than C++ because I can trust the compiler to take care of and track ownership and lifetime
by imron 4y ago
It's the opposite of my experience. The mental load of Rust is lower than C++ because I can trust the compiler to take care of and track ownership and lifetimes, whereas with C++ that has to be done manually.
And yes, I aware of all the bells and whistles modern c++ can bring to alleviate some of that burden - but people can and do subvert those mechanisms intentionally and unintentionally, especially over refactors.
- 72deluxe 4y agoBy bells and whistles, do you mean smart pointers that have been around for decades and destructors? I have a codebase that I ported from C# to C++ and found a few bugs where the items were copied instead of moved. In C# this was completely invisible since I "trusted" the compiler to do it properly - it did it wrong according to my wishes but right compared to the language. By contrast in C++ it was very visible when the ownership was shared and wrong. I would rather use C++ because of this rather than trusting the compiler to get it right. The same was true on generics/templates for a function/parameter system I'd written. The C# compiler resolved to the wrong function every single time but in C++ it resolved correctly. I suspect there are plenty of subtleties in "safe" languages that actually muddy concepts of owernship and/or needless copying and lifetimes.
- Yoric 4y ago> I suspect there are plenty of subtleties in "safe" languages that actually muddy concepts of owernship and/or needless copying and lifetimes. True in my experience. However, not the case in Rust, which is actually much more explicit about ownership, copying and lifetimes than C++.
- 72deluxe 4y agoVery interesting. I will read more. Thanks!
- hardware2win 4y ago>where the items were copied instead of moved. Uh? What was being done there?