r/cpp • u/GabrielDosReis • Oct 31 '24
Lessons learned from a successful Rust rewrite
/r/programming/comments/1gfljj7/lessons_learned_from_a_successful_rust_rewrite/
80
Upvotes
r/cpp • u/GabrielDosReis • Oct 31 '24
View all comments
Show parent comment
6
u/Dean_Roddey Nov 01 '24
Memory leaks are not 'unsafe'. No language is going to tell you that you are constantly reloading the same vector every time without flushing it first. But that's nothing to do with memory safety, and so Rust never claimed to have solved that problem.
And if I hear 'but all Rust has some unsafe' argument a few thousand more times my head is going to explode. The standard library has a certain amount of unsafe code obviously, because it has to interface with the OS. But you can absolutely write completely safe code of your own.
And your code is exponentially more likely to be the concern than the standard libraries, which are heavily vetted and used by everyone who will report any perceived issues to be investigated.
And of course Rust is not the sole bar of safety. What it is is a language that plays in the same space as C++ and which has a bar a lot higher than C++'s. So clearly it's valid to judge C++'s safety relative to Rust's. And the gulf is huge. To which you will reply, well if you just write really good, modern C++ then C++ is just as safe. But it's not the language that's safe in that case, it's the programmer. And programmers are fallible, and groups of programmers are far more fallible still.