| ▲ | byko3y 3 hours ago | |||||||
There are programming languages/models/runtimes that crash and recover, there are models that gracefully degrade. Rust cannot recover. Neither can C++ in many cases e.g. when you have an exception in a destructor then it's a guaranteed `std::terminate`. Do note that C did not have such a flaw built into language — C++ authors invented it and Rust inherited this flaw (the authors simply did not feel like it's a flaw). I mean specially designed embedded C code can survive total RAM erasure and still perform some meaningful work (with CPU registers and ROM intact). Or compare it to BEAM that can have processes crash all day long and still continue to work. "Memory safety at all cost" is not a practical requirement — it's theological. | ||||||||
| ▲ | aw1621107 2 hours ago | parent | next [-] | |||||||
> Rust cannot recover. catch_unwind exists for a reason. > e.g. when you have an exception in a destructor then it's a guaranteed `std::terminate`. You can throw in a destructor [1]. You just need to mark that destructor noexcept(false). You do get a guaranteed std::terminate if an exception escapes a destructor while unwinding is already underway, though. > Do note that C did not have such a flaw built into language assert() says hi? > I mean specially designed embedded C code can survive total RAM erasure and still perform some meaningful work (with CPU registers and ROM intact). Why doesn't a similar argument apply to "specially designed" Rust? > Or compare it to BEAM that can have processes crash all day long and still continue to work. Again, nothing stops you from writing Rust that does the same. [0]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html | ||||||||
| ||||||||
| ▲ | EnPissant 2 hours ago | parent | prev [-] | |||||||
Nothing forces you to panic in Rust any more than anything forces you to call abort() in C.
is conceptually no different to:
don't write either if you don't want to halt. | ||||||||