4 ms·
Rust is definitely not a drop-in for C++, be it for interop with massive C++ codebases or developer adoption. You may be able to get your devs to switch, but yo
by meibo 4y ago
Rust is definitely not a drop-in for C++, be it for interop with massive C++ codebases or developer adoption. You may be able to get your devs to switch, but your productivity will suffer so much that your stakeholders will be on your ass to figure out how to fix something there is no fix for: the mental load of Rust is a lot higher than C++'s and it takes a long time for regular people to become as proficient in it as they are having written C++ for 15 years.
- zozbot234 4y ago> the mental load of Rust is a lot higher than C++'s I don't believe this. That's a reasonable claim for many other languages, but C/C++ are in a category of their own.
- FpUser 4y ago>"C/C++ are in a category of their own." If one wants to know it all then yes. C++ is huge language. In practice except few people nobody really needs to. Subset of modern C++ enough to solve many real world tasks is very easy to learn in my opinion. With Rust one must first train brain to wrap around those ownership rules and this might not be easy. Fortunately or not I do not know even remotely enough of Rust to do the real comparison of "mental load" but at some point I will.
- imron 4y ago> With Rust one must first train brain to wrap around those ownership rules and this might not be easy. You need to do that in c++ also, otherwise you'll still have the same problem - only randomly at runtime instead of at compile time.
- charcircuit 4y ago>With Rust one must first train brain to wrap around those ownership rules and this might not be easy. C++ users already understand ownership because C++ has ownership too. With C++ you have to me extra careful because the compiler won't save you from making mistakes like Rust will.
- FpUser 4y agoI meant ownership as implemented in Rust. I am perfectly fine with ownership models of C++ and some other languages.
- charcircuit 4y ago>I meant ownership as implemented in Rust. It's the same thing in Rust and C++. There is no difference conceptually.
- hn_go_brrrrr 4y agoDisagree, unless we're including Rust's unsafe. Excluding that, you need to understand what the Rust compiler is able to prove is safe. In C++, you "just" need to prove to yourself that it's safe. It's a very different experience writing code.
- Yoric 4y agoSo perhaps "ownership rules" is the wrong vocable for this. Maybe "ownership proofs"?
- charcircuit 4y agoIn Rust you need to understand borrowing to write programs that compile. In C++ you need to understand borrowing to avoid writing programs that use undefined behaviour. Yes, it's a different experience, but both have the same concept of borrowing that you must understand.
- imron 4y agoIt'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?
- Yoric 4y ago> the mental load of Rust is a lot higher than C++'s and it takes a long time for regular people to become as proficient in it as they are having written C++ for 15 years There are very good reasons to use C++ rather than Rust for some projects, typically interoperability, or developer already having experience in C++, as you mention. However, having coded in both C++ and Rust professionally, my experience is that switching Rust has liberated much of my brainpower to concentrate on actually implementing useful stuff, so I have to strongly disagree on "mental load". What is true is that, for a while after switching, getting code to compile in C++ is easier than in Rust. Took me maybe 6 months to 1 year before it became natural? However, as we all know, there is a huge difference between writing code that builds and writing code that works. In my experience, that difference is order of magnitudes larger in C++ than in Rust.
- baby 4y agoPersonally I found Rust much easier to learn than C++
- Yoric 4y agoAs someone who developed professionally in both C++ and Rust, I found it that it was much faster for me to believe that I had learnt C++ :)