2 ms·
I don't think it's correct to say that Rust "encourages" reference counting. Rust's standard library provides `Rc` and `Arc`, but the default paradigm encourage
by woodruffw 4y ago
I don't think it's correct to say that Rust "encourages" reference counting. Rust's standard library provides `Rc` and `Arc`, but the default paradigm encouraged by Rust is to do no garbage collection at all (since all lifetimes are validated statically.)
Separately, there's a good argument to be made that Rust does reference counting better than C++: `shared_ptr` has to pessimistically assume use across multiple threads, while Rust allows users to safely select `Rc` instead of `Arc` when the compiler can prove that the inner type is `Sync`/`Send`. Consequently, Rust programs that do use reference counting get "free" performance compared to the equivalent C++ APIs.