4 ms·
Bash script (without -e) continue merrily even if the last command's exit status is non-null. PHP also ignored errors out of the box (even has @ to suppress er
by pas 2y ago
Bash script (without -e) continue merrily even if the last command's exit status is non-null.
PHP also ignored errors out of the box (even has @ to suppress error output), but error_reporting(-1); is basically how every sane framework starts, and PHP 8 set the default level to E_ALL [1](in 5.3 accessing undefined variable was also ignored (notices - as far as I remember)[2])
Python and NodeJS by default aborts on error. (Python had exceptions before user-defined classes in the last millennia. [3])
...
Rob Pike said in 2015 "don't just check errors, handle them gracefully." [4]
I think Scala/ZIO has the most powerful and comprehensive and compact [5] error handling machinery that I have experience with, that's where it's the easiest to live up to Mr Pike's admonition.
...
All are fine. I hope/predict Go will pull a Bash or PHP and will introduce flags to turn some/most unchecked errors into aborts. (Or perhaps people will build tooling and alternative stdlib eventually.)
Result types are nice because it allows library developers to encode a shitton of really useful semantic information into them, and it's really easy to handle them however the downstream user wishes. (Rust offers .unwrap(), TypeScript ! (assume non-null), and JS itself has the ? optional chaining operator.)
[1] https://php.watch/versions/8.0/error-display-E_ALL https://php.watch/versions/8.0/error-display-E_ALL
[2] https://stackoverflow.com/a/69291454/44166 https://stackoverflow.com/a/69291454/44166
[3] https://python-history.blogspot.com/2009/03/how-exceptions-came-to-be-classes.html https://python-history.blogspot.com/2009/03/how-exceptions-c...
[4] https://softwareengineering.stackexchange.com/a/406347 https://softwareengineering.stackexchange.com/a/406347
[5] https://zio.dev/overview/handling-errors/ https://zio.dev/overview/handling-errors/