Hacker News new | past | comments | ask | show | jobs | submit login

Java is probably the worst language for error handling. It has checked exceptions AND unchecked.

I can't say I've ever seen a Java codebase that handles InterruptedException properly. It's so bad that most Java devs I've talked to don't even know what the right thing to do is.

And don't get me started about catching Throwable. Why make it so easy for application code to catch VirtualMachineError. I've not once seen Throwable or Error caught in a way that makes any sense.

Java seems to encourage a culture of not handling errors properly because it looks "messy". Then, these same acculturated devs try to bring that misguided sensibility about how code should look to Go and start complaining that they actually have to handle errors.

Yeah, Java botched generics by not adding exception sum types. stream.map(f).collect(…) should throw whatever f can throw, but instead f has to wrap any checked exception, which makes them nearly unusable in practice.

But the drudgery of explicitly passing every error up the stack over and over is not a good use of human beings' time. We can generate that if we must, but not actually read it.

> not adding exception sum types What's this mean?

Ideally we want something like

  class Stream<T> {
    <R, X> Stream<R> map(
      Function<? super T, ? extends R, throws X> mapper
    ) throws X
and if you pass a function that throws, say, IOException and SQLException, then X=IOException|SQLException and that's what that call to #map throws.

You can sort of do it by http://natpryce.com/articles/000738.html but you have to choose one base type and you can't make stdlib support it.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact