3 ms·
Golang arguably has exceptions via panic/recover: https://mitranim.com/posts/goex https://mitranim.com/posts/goex I think the issue is that many languages lack
by cardanome 2y ago
Golang arguably has exceptions via panic/recover: https://mitranim.com/posts/goex https://mitranim.com/posts/goex
I think the issue is that many languages lacked support for option types for a long time so exceptions got overused and abused. Now the pendulum has swung towards "exceptions are bad".
I think both ways of handling errors serve different use cases and it is good to have proper language support for both. I like to use exceptions for errors that are... literally exceptions. Stuff that is out of my control, being out of memory, stuff that I don't expect to happen on the happy path. When the default should be to just log the thing and crash. And if your language supports proper exceptions you get nice stack traces in your logs to see what went wrong.
On the other hand error types are superior for things that you should explicitly handle in your code. That are reasonable invariants to take care of. Here the language forcing you to handle them or to explicitly opt out of handling them is extremely valuable.
Having more tools is not always bad.