Hacker News new | ask | show | jobs
by atomicity 1756 days ago
Except that people are too lazy to use exceptions that are checked at compile time.

The main benefit of Go is that the people that defined the library ecosystem actually decided to handle errors. It's the bare minimum, but it's better than just forgetting that the error exists and not documenting it either.

The language is ... not the best, but the libraries tend to be more robust.

2 comments

Libraries can almost never handle errors - they can only signal them. And Go libraries are particularly bad at this, because they almost always return error strings, instead of meaningful error types, which means you can't easily handle a subset of errors. Even if you did, Go's errors suffer from the same problems as exceptions in many languages: there is no way to document what errors your function can actually return, just that it returns some error.

What language are you thinking of when saying Go libraries do better at error handling?

It’s not always laziness, in Java

  stream.map(f)
doesn’t allow f to declare any checked exceptions. We could catch and wrap everything but that obscures the useful code without any improvement in safety.