3 ms·
I didn't say "you can make any data structure you want without unsafe blocks or garbage collection." I said that you can write safe Rust without mandatory garb
by Jweb_Guru 11y ago
I didn't say "you can make any data structure you want without unsafe blocks or garbage collection." I said that you can write safe Rust without mandatory garbage collection and with deallocation. You're responding to a point I didn't make.
In any case, part of the point of Rust is the ability to write safe abstractions over unsafe code. Arguing that the data structures like vectors are not memory safe is identical to the argument that other languages' runtimes are not safe.
- SamReidHughes 11y ago> I didn't say "you can make any data structure you want without unsafe blocks or garbage collection." I didn't say you said that, I gave an example of a useful thing you can't do in Rust. It is very meaningful to say that Rust isn't practically memory safe if you have to resort to unsafe code a lot of the time, or pay performance costs. I'm not talking about data structures like vectors, by the way. And it's not just data structures themselves, it's what you can do with them on the outside. Obviously you can make pretty much whatever abstractions you want in Rust if you use some GC'd heap or allocate stuff in vectors and use indices instead of pointers. But if you're doing that, you're probably going to not be doing it for long, there's a reason you aren't using Java.
- Jweb_Guru 11y agoI don't disagree with you. I think Rust has a long way to go before it can practically match well-optimized C in many cases without unreasonable amounts of unsafe code (obviously, this is subjective). But it at least offers the possibility of doing so, which is much more than I can say for essentially any other language. And even in performance-critical, optimized-assembly-output code in Rust, a lot of it is safe already.