Rust's memory management vs pointerless C++

187 points Voidbert

In C++, you can use data structures like vectors, strings, smart pointers, etc. You could technically code an entire program without using (raw) pointers (the underlying structures are likely implemented using raw pointers, but we can assume they don't leak memory, for example). You can manage all objects by copying and/or passing references of them.

I know you might need to interact with code that uses pointers directly (especially C libraries), and that is a problem, but it can be mitigated by either using smart pointers, or writing a small safe wrapper around those functions (small so it's easy to verify it's memory safe).

Note: I have never wrote a single line of rust, but I've been reading on ownership and borrowing.

In Rust, the compiler uses these two features to manage memory. On the top of my head, I understand why it might be good for parallelism, as, for example, you can only make a single mutable reference of an object (correct me if I'm wrong), so you can't write to the same memory from two different threads. But on a single threaded environment, accesses would be sequential, and editing the same object wouldn't be a problem in that case.

Could you, rustaceans, give me other examples on differences in these two paradigms?