4 ms·
Reference counting doesn't solve all memory management problems. With closures you often end up with circular references. And yes, in probably 99% of cases you
by amelius 6y ago
Reference counting doesn't solve all memory management problems. With closures you often end up with circular references.
And yes, in probably 99% of cases you can actually find a way out of a memory management problem in Rust if you think hard enough.
But my point is that quite often you don't want to think about memory management. Rust doesn't help here. Rust advertises that it solves memory management problems, but in reality that only holds up to a point. So use Rust for your OS or your low-level server, but don't think it is a panacea.
- zozbot234 6y ago> With closures you often end up with circular references. In that case, you can manually lift the data object involved into a function argument, as opposed to a variable capture - with its ownership being thus managed explicitly. This is generally an improvement in design. Of course, Rust does only solve memory management problems "to a point"; there are cases where fully general GC is pretty much a necessity. But even most uses of closures - a fairly high-level language feature, all things considered - don't require this in many cases.