4 ms·
> Exclusive ownership invariably mandates copying for certain use cases. Hm, why would you not use multiple ownership then, instead?
by steveklabnik 10y ago
> Exclusive ownership invariably mandates copying for certain use cases.
Hm, why would you not use multiple ownership then, instead?
- sqeaky 10y agoI think that is his point, he thinks Rust and C++ cannot do this. But is the default in C++ and well done in Rust.
- rbehrends 10y agoNo, my point is not that it cannot be done (both Rust and C++ are Turing-complete, so "cannot be done" does not make sense for anything that's a computable property), but that it comes with a cost. See my other response for the details.
- rbehrends 10y ago> Hm, why would you not use multiple ownership then, instead? That's exactly what I want. The problem is that (1) it comes with significant runtime overhead and/or syntactic noise in Rust/C++ (or alternatively, lack of memory safety); and (2), it becomes difficult to write code that works equally well for multiple and exclusive ownership (module APIs often become burdened with implicit or explicit ownership assumptions).
- steveklabnik 10y agoGotcha. I'm not sure I agree, but I understand :)
- rbehrends 10y agoWell, let me also add that I completely understand that there are use cases for Rust, where a GCed language would be a poor fit. An obvious example is a web browser ( :) ), where the x% memory overhead that comes with a garbage collector is just a price that you may not be able to afford to pay. In other words, don't read this as "Rust sucks" (I actually rather admire Rust's design), read it as: for my purposes, the practical use cases of Rust are generally too niche to justify the software engineering tradeoffs.
- steveklabnik 10y agoYeah, I hear you. I think this is fair. And at least some of it comes down to preference, that is, I don't think that the syntactic noise is very much, but others can certainly disagree. The others would mostly be a "nuh uh" since I don't have numbers anyway :) At the end of the day, Rust can never be great for every single last programmer, and this is entirely okay.