4 ms·
> The worst thing about exceptions is that you can't tell from the type signature of a function whether it might throw one. In Java exceptions can be part of a
by michaelt 3mo ago
> The worst thing about exceptions is that you can't tell from the type signature of a function whether it might throw one.
In Java exceptions can be part of a method's declared type information, so handling is checked at compile time and IDEs can display the info.
Unfortunately certain Java missteps made this design unpopular these days. For example, for many years new String(bytes, "UTF-8"); made it mandatory to catch a UnsupportedEncodingException despite the language spec guaranteeing UTF-8 would be available. A later version of Java addressed it, but still...
- vips7L 2mo agoJava's problem with checked exceptions is that they didn't add them fully to the type system (the lambda problem), and they never added any syntax sugar to make them easier to deal with. I really love checked exceptions and wish we could get some improvements.