3 ms·
I'm beginning to wonder if it's actually more difficult for C++ developers to learn Rust, at least speaking from personal experience. There are so many things I
by _huayra_ 4y ago
I'm beginning to wonder if it's actually more difficult for C++ developers to learn Rust, at least speaking from personal experience. There are so many things I want to do in Rust when mapping from my C++ knowledge that are genuinely unsafe, e.g. copying around reference objects (including iterators) but convincing myself through rigorous testing that none of them ever dangle despite the somewhat unrelated lifetimes.
Perhaps when one isn't trying to map some similar-ish knowledge onto Rust it becomes easier, as one doesn't have to drop preconceived notions.
This very much feels like the time I tried to snowboard after having skied for a couple of decades; why can't I move my feet like before?!
- zozbot234 4y ago> copying around reference objects (including iterators) but convincing myself through rigorous testing that none of them ever dangle despite the somewhat unrelated lifetimes The underlying issue with this kind of informal assurance is that it may become incorrect in a large-scale project as it evolves. This is why "unsafe" in Rust is best used locally, as part of something that provides a safe interface to the rest of the code.
- nicoburns 4y ago> I'm beginning to wonder if it's actually more difficult for C++ developers to learn Rust, at least speaking from personal experience. It seems to go one of two ways with C++ developers: - Some C++ developers were alsready hyper aware of object lifetimes and were effectively enforcing Rust's constraints on their own code manually anyway. They find Rust the easiest of anyone - Some C++ developers were blissfully unaware of object lifetimes and played fast and loose with them so long as it worked. Those C++ struggle with Rust more even those with no previous low-level experience. > There are so many things I want to do in Rust when mapping from my C++ knowledge As someone who came to Rust from JavaScript, I can attest that with a few exceptions the opposite is true for JS knowledge: basically everything I was used to being to do from JavaScript I can do in Rust.
- marcosdumay 4y agoOh, there are plenty of idioms you can use in C++ that are easy to make safe (as long as you don't make a mistake on some very small amount of code) that Rust will make a nightmare to implement. Just like there are plenty of idioms you can use in Haskell that are easy to make simple that Rust will make a nightmare to implement. At the end of the day, Rust is neither of those. It is a safe low level language, and that comes with plenty of restrictions. The language is amazing for how little restrictions it actually has when compared to a naive estimate, but there are still plenty of them.
- zozbot234 4y agoThe problem is that very few idioms are both safe and compositional (which you need if you want your development approach to scale to the largest projects). Rust focuses on these as a sensible default, for everything else there's unsafe.
- Ygg2 4y ago> Oh, there are plenty of idioms you can use in C++ that are easy to make safe (as long as you don't make a mistake on some very small amount of code) that Rust will make a nightmare to implement Like? I know double linked lists and graphs are harder to get right, but aren't impossible. But on the flip side getting Optional and Send/Sync to work in C/C++ and not to rely on people using best practices is downright impossible.