3 ms·
> There's a similar tradeoff for tracing GC vs. precise monitoring of ownership and lifetime (Rust uses reference-counting GC, which is generally less effective
by deaddodo 7y ago
> There's a similar tradeoff for tracing GC vs. precise monitoring of ownership and lifetime (Rust uses reference-counting GC, which is generally less effective than tracing, in cases where ownership and lifetime are not statically determined), but this comment is already too long.
Rust doesn't use a GC. It uses a borrowing mechanism that ensures (theoretically) a single reference to any variable at a time. In the case of shared variables, you do have std::sync::Arc<T> (atomic references) and std::rc::Rc<T> (reference counted immutables), but I would hesitate to conflate those to the language as a whole as it's not the default.
- vardump 7y agoReference counting is a type of garbage collection. Of course Rust isn't a garbage collected language, but you can kind of use it as one.
- deaddodo 7y ago> Reference counting is a type of garbage collection. I'm well aware, or I wouldn't have brought Those types up, obviously. But there's a vast difference between a language's memory management/type system being intrinsically Garbage Collected and a couple special use types hoisting that functionality.
- snovv_crash 7y agoIf you want to go that way, C++ has shared_ptr and can also be a garbage collected language. It is kind of missing the point though.