5 ms·
> Rust does require structuring programs in a "Rust way" to avoid fighting with things it can't prove to be safe. That was my concern that I had when I started
by Mesopropithecus 4y ago
> Rust does require structuring programs in a "Rust way" to avoid fighting with things it can't prove to be safe.
That was my concern that I had when I started learning the language. I think it is true, but I was surprised how quickly I managed to get used to the Rust way.
- LAC-Tech 4y agoI'm surprised at how slowly I'm getting used to it! I mean I've improved but I still have a lot of "wtf" moments. End up doing a lot of deep copying and heap allocations just to shut the compiler up, which makes me question just how "zero cost" the safety is.
- maccam94 4y agoAre you able to store that data in reference-counted RC/ARC types? Those can help you avoid dealing with lifetime issues, though you'll still have to think about mutability and concurrency.
- chc 4y agoIt's also worth noting that the "Rust way" often ends up being clearer and better structured, in hindsight. Rust forces you to think through questions of ownership and identity more than most languages, and a lot of "structuring programs the Rust way" is just expressing these things. Of course, that's just "often," not nearly "always." There are many valid programs that the borrow checker struggles with, and in those cases, the "Rust way" is just needlessly convoluted. There are many problems for which the most common answer is "just store all this data in a list and use list indices like pointers." (Thankfully there has been a lot of progress on a new borrow checker that's less easily startled.)
- marcosdumay 4y agoThe "Rust way" is very close to the safe variety of the "experienced C++ way", so many people adapt promptly.