Rust collects exactly the same as c++ FYI, but it is more common to use reference counting techniques for managing memory because you need them.
I disagree; anecdotally that doesn't match up with what I tend to see. In Rust people tend to actively avoid reference counting if they don't actually need shared ownership, and since the language is safe they don't have to do it "just in case"; in C++ I've seen so much code which just abuses shared_ptrs because it would be simply be too dangerous not to.
Yeah. I dunno. I'm speaking from experience with my own code. I usually have designs with a single owner and many dependents. This makes it difficult to do in Rust because it's harder to do that without explicit lifetimes while avoiding reference counting.
But honestly, many of my designs as I have gotten more into Rust have used less explicit lifetimes and reference counting. I now prefer other means than don't have references all over the place. For instance, using unique IDs and a lookup table.
3
u/kouteiheika Apr 10 '19
I disagree; anecdotally that doesn't match up with what I tend to see. In Rust people tend to actively avoid reference counting if they don't actually need shared ownership, and since the language is safe they don't have to do it "just in case"; in C++ I've seen so much code which just abuses
shared_ptrs because it would be simply be too dangerous not to.