|
|
|
|
|
by simonask
21 days ago
|
|
This is such a deep topic with literally decades of discourse behind it. I tend to agree with the general principle that panicking or throwing an exception should terminate the process in most cases. But those last microseconds of a process' lifetime matter quite a lot: Are you able to save the user's work? Are you able to log the error so the crash can be diagnosed? With Undefined Behavior in the picture, you cannot do anything. The whole process is toast, and its entire memory state is invalid. |
|
You can’t rely on it for correctness because for your software to be reliable it needs to deal with an abrupt power outage and recover.
Best effort diagnostics make sense. And the “Rust 2.0” or successor language will with certainty close this gap.
But I also understand why we are here. A decade ago when 1.0 came out Rust had already used up most of its complexity budget for traits, enums, borrow checker, generics, functional style programming and so on.
Diverging even further from what was expected by the majority of programmers would very likely have left Rust as an esoteric language with a tiny following. Instead of what it became.
And back then unsafe was thought to work more like “just do like in C”.
There has been years of research formalizing how it actually works that’s brought us to the current understanding where it’s not trivial to write it correctly.