Runtime errors aren't the same as crashing. When writing an application, "it should never crash" is a good goal to strive for. All it means is that you should account for all possible errors and handle them properly, even if it's just showing it as a clean error message. Unless of course they're unrecoverable, but this should be rare and only for things out of your control. And even in this case, if the app is user-facing, you should still avoid crashing outright and display the error cleanly before bailing out.
And I never talked about exceptions. I don't think they're a good construct for most languages. I'd much rather have a type-based error handling system, like rust for example. Which inherently works the same way as Go, except hidden within an expressive type system, which means it's much more ergonomic to use (and fool-proof).
I've only dabbled with Rust but it sounds good from what you've said.
Interpreted languages should never really crash, unless you run out of memory or something, so the worst that can happen is you try to open a file that doesn't exist or something and then the interpreter just generates a runtime error, so therefore you could always catch that at the main() level.
I'm sure it's possible to artificially force Python to crash by doing something funky with ctypes but it's not like C which is basically made out of crashes, even div zero will crash on many machines iirc.
Exceptions in general are pretty good except that you can put them around multiple lines, which leads to terrible abuse. The exceptions themselves would be typed so they can have stack traces, messages etc attached, they can be defined as part of a hierarchy etc.
View all comments
Show parent comment
1
u/ConspicuousPineapple Mar 21 '24
Runtime errors aren't the same as crashing. When writing an application, "it should never crash" is a good goal to strive for. All it means is that you should account for all possible errors and handle them properly, even if it's just showing it as a clean error message. Unless of course they're unrecoverable, but this should be rare and only for things out of your control. And even in this case, if the app is user-facing, you should still avoid crashing outright and display the error cleanly before bailing out.
And I never talked about exceptions. I don't think they're a good construct for most languages. I'd much rather have a type-based error handling system, like rust for example. Which inherently works the same way as Go, except hidden within an expressive type system, which means it's much more ergonomic to use (and fool-proof).