2 ms·
* Ownership is very clear. In most GC languages ownership of objects is shared between everyone that can access it. That encourages bugs. * You can trivially m
by IshKebab 3y ago
* Ownership is very clear. In most GC languages ownership of objects is shared between everyone that can access it. That encourages bugs.
* You can trivially make objects immutable. That feature is tacked on to most GC languages (e.g. Object.freeze) and rarely used, if it's even available. Again mutability of everything encourages bugs.
* You can easily copy values.
* You can use RAII to deterministically and automatically clean up resources, and guard things (e.g. using mutexes).
These features are all in C++ too but Rust lets you have all that and memory safety (and it's better designed than C++).
A classic bug that you wouldn't see in Rust might be passing a list into a function and the function mutating it when you weren't expecting it to. Basically impossible in Rust.