Re:Thoughts on the “Guard” Proposal for Go's Error Handling
by kaba0 on Sunday November 06, 2022 @05:37AM
(#33491166)
Well, arguably Java’s implementation is not the best regarding checked exceptions. Nonetheless I feel we threw the baby out with the bath water here, as a non-inheritance based checked exception system was not really tried and I feel it would be the best of both words. Since in the end, checked exceptions are just Result types which happens to be natively “understood” by the language - it gets stack trace support, auto-unwraps and bubbles up.
Re:Thoughts on the “Guard” Proposal for Go's Error Handling
by layer8 on Sunday November 06, 2022 @08:22AM
(#33492304)
What's missing in Java is the ability for methods to abstract over the set of exceptions thrown by the methods it calls, via generics, for morethan a single exceptikn type. This would in principle be possible, similar to variadic template parameters in C++, and would solve the problem for lambdas and Streams etc. It's a bummer that Java doesn't provide this at present.
Java developers are really divided on the topic of checked exceptions, there is no consensus.
Those are just objective facts. I, personally, don’t like this feature either. May be with very different language design it could be better, but as it is, it’s ergonomics is awful IMO. And I have problems to imagine how to rework it to make it work.