4 ms·
They tried that in Java and no one uses it...
by None4U 2y ago
They tried that in Java and no one uses it...
- erik_seaberg 2y agoLambdas broke checked exceptions. You can't declare that you throw whatever a generic lambda might throw, so they quickly devolved to "I throw nothing (only unchecked)." The "I throw everything" alternative is rarely used because it spreads virally through every caller.
- baq 2y agoChecked exceptions were strongly discouraged because they have nonlocal behavior when changing library code. If you want to rethrow exceptions you can’t handle you have to update all callers when the callee changes the throw signature. Lambdas are orthogonal.
- erik_seaberg 2y agoI'm thinking of cases like Stream#flatMap where I might be prepared for what a lambda (probably a method ref) could throw, yet still can't use it because exception lists for the Stream interface methods had to be declared statically years ago.
- jcranmer 2y agoChecked exceptions were vilified long before Java gained lambdas.
- pjmlp 2y agoWhile Java usually gets the blame, it was following a precedent set by CLU, Modula-3 and C++. Also I dearly miss them in .NET, every single time something breaks in production, because some developer didn't bother to catch exceptions, when they should have.