3 ms·
My issue with checked exceptions in Java is that it becomes another branch of control flow. It increases cognitive load to keep in mind that exceptional cases a
by piva00 4y ago
My issue with checked exceptions in Java is that it becomes another branch of control flow. It increases cognitive load to keep in mind that exceptional cases are basically running a `GOTO` that you have to keep track of.
I think they can have its place but operating well with lambdas would be a must... If Java supported a multi-value return, like Go and Python do, and control flow was based on `var a, err = obj.exec()` or some other syntax that could work nicely with Streams and the functional features of Java I wouldn't have an issue with checked exceptions. A multi-return for errors with checked exceptions would even allow the compiler to narrow down all the possible `err` types you could get, automatically generate a Java 17 `switch()` to parse through all the possible cases of checked exceptions. It could help a lot with error handling.