top | item 35813498

(no title)

xnoreq | 2 years ago

The issue is that in many programming languages that offer exceptions, exceptions are misused to handle common and unexceptional non-success cases. I think that is because it is hard to draw a sharp line between the two.

Java already went in the right direction with distinguishing errors from exceptions and having "checked" (that you cannot ignore) exceptions, but the implementation of those concepts sucks. Also, generics, which allow the implementation of "sum types", came later and so sum types were never established as the way to do error handling.

discuss

order

tialaramex|2 years ago

> exceptions are misused to handle common and unexceptional non-success cases.

This is my insurmountable objection to Exceptions.

What people will tell you is that you should only use Exceptions for "real" error conditions which should be rare, but the problem is that the people deciding whether to use Exceptions are writing some library, whereas the people who know whether this is a rare condition are the application writers, using that library only second or third hand, or maybe via some third party component. You might as well provide a language where the primitive integer types don't have a specified size so programmers don't know if numbers will fit in them...

... oh right yeah. That checks out.

masklinn|2 years ago

It's also an interesting objection because it means that when you have exceptions... you still need an error handling method for non-exceptional errors.