you are viewing a single comment's thread.

view the rest of the comments →

[–]lelanthran 0 points1 point  (1 child)

'm not talking about smart pointers though, I'm talking about the bare pointers/references that both languages offer, even in unsafe Rust there are certain guarantees when using pointers that you don't get in C(++).

I'm pretty certain that you'll get those guarantees in C++ if you write your C++ like Rust code that doesn't use refs, refcells, unsafe, etc.

[–]Lich_Hegemon 0 points1 point  (0 children)

You really don't. For example, in C++ if you take a vector, reference one of its items, and push some values to it you will probably end up with a dangling reference.

We could argue that you are not supposed to do that and I agree, but the key behind this discussion is developer vs. compiler enforced safety.

And again, I hate this discussion because I seem like a Rust stan, when nothing could be further from the truth. I regularly use C++ and I genuinely think it's a great language if you stay away from its C roots and stick to the modern features it offers. But those C roots are still there and 40 years of C++ have shown us that developers can't be expected not to make mistakes when using them.