(no title)
nauticacom | 4 years ago
In languages with manual memory management you can do it, but it's incredibly easy to mess up. You either have to maintain the entire mental model of who owns what data and what data has been initialized in your head or write it down and risk that becoming out of date.
In languages with a GC, the implementors have assumed this complexity for you. Depending on what style of GC your language uses the exact strategy will be different, but on a GC is a comparatively complex piece of code, especially one which handles reference cycles well like we're talking about here.
Either way, the complexity is there somewhere. If you manage memory yourself, you deal with the complexity yourself in a hard-to-debug way. If you can accept the tradeoffs of a GC, then the complexity is abstracted behind the GC. Because Rust is designed for use-cases where you can't accept the tradeoffs of a GC, it has to surface that inherent complexity somewhere. It decides to surface it with ownership semantics, which at least make the rules you're following in manual languages explicit and (largely) unbreakable.
Yeah it's complex, but the underlying problem is complex. I can use GC languages, so I do, but you'd be no better off in C.
lumost|4 years ago
The rust docs try to pretend this is never a problem and that people writing such structures are doing it wrong which is imho a problem.
dystroy|4 years ago
What you need (a feature, a performance improvement, etc.) is usually better served with other structures, especially in languages which don't heavily favor heap allocations (in a GC based language you've already paid the allocation cost when creating the object anyway).
I think there's now some evidence that Rust prevents developers neither from making efficient applications nor from efficiently making them.
ridiculous_fish|4 years ago
There's no inherent underlying complexity to transforming a recursive function to an iterative one, yet it is legitimately hard in Rust.