4 ms·
I actually quite like checked exceptions, and miss them in other languages. My biggest gripe with exceptions is that a few calls deep, you can no longer tell wh
by asddubs 3y ago
I actually quite like checked exceptions, and miss them in other languages. My biggest gripe with exceptions is that a few calls deep, you can no longer tell whether calling something might throw or not, and what type of exception it might potentially throw.
- _old_dude_ 3y agoChecked exceptions are a leaky concept in Java. The Java type system has no union types so you can not have a generics method that abstract more than one exception. That's why Stream::map can not capture the checked exceptions properly.
- pharmakom 3y agoYes! The problem with the Java implementation of checked exceptions is the inheritance hierarchy, which encourages catching the broadest possible error.
- rozap 3y agoDefinitely they have shortcomings in Java but throwing the concept out entirely is a bummer. It creates a whole shadow type system where all bets are off.
- josephcsible 3y agoI like checked exceptions in principle too, but Java's implementation of them is so bad that I hate them there. The first major mistake is that it doesn't support exception polymorphism (e.g., I wish you could pass a comparator to Arrays.sort that throws checked exceptions, and have that call to Arrays.sort itself then throw the same checked exceptions), and the second is that the standard library makes a bunch of exceptions checked that should be unchecked (e.g., IOException from close()).
- sam_lowry_ 3y agoWhich is now commonly wrapped into UncheckedIOException.