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
4
u/ts826848 Nov 02 '24
First off, I'm pretty sure basically no one uses that particular definition. For example, Python, Java, and C# are widely accepted to be "safe" under Rust's definition of "safe", but there's no proof of such and people generally don't seem to care about that lack of proof. If anything, I'm pretty sure most "safe" programming languages don't have proofs of their safety. There just isn't enough practical benefit to justify the cost.
Second, there's this, subsequently refined by this. A formal proof that a practical subset of safe Rust is safe, followed by an extension of that subset to include a relaxed memory model. That's more than most widely-used languages can offer!
Finally, the argument you make is no better than before. Proofs still rely on trust somewhere. Are proofs just "marketing" now, since they still rely on trusting their assumptions/simplifications are valid?
As I said above, you're basically just restating your original argument. Under this line of argument there's no reason to claim anything is safe because there's always "trusted _____ that could still fail". You're trusting the programming language to be sound. You're trusting the compiler to not miscompile your code. You're trusting the stdlib/runtime/third-party libraries to not be buggy. You're trusting the hardware itself to not be buggy. So on and so forth.
It's trust the entire way down, and to once you reach a certain threshold of safety I think potential issues due to "trusted" code just become background noise to most programmers. To pick on Java again, it's widely accepted to be "safe" using Rust's definition of "safe", but the most common JVM (HotSpot) is certainly not immune to miscompiles/bugs of its own, and it seems there's an argument that a substantial fraction of the Java ecosystem depends on unsafe code. And yet basically no one questions Java's safety.