3 ms·
This, and most of the time if you’re simply bubbling up an error it’s busy work. Languages like python get out of your way here. If python was able to reliably
by fbdidjauavzbdjx 3y ago
This, and most of the time if you’re simply bubbling up an error it’s busy work. Languages like python get out of your way here. If python was able to reliably tell you possible exceptions (within reason - at a certain level generic errors like out of memory can be ignored since they’re globally present) and provide a convenient way to handle them that’d be great.
This is domain dependent, but most of the time errors are handled by “catch it, log it, display an oops and move on”, and optimizing for that case is very pragmatic.
- hamandcheese 3y ago> If python was able to reliably tell you possible exceptions I know typed errors in Java are regarded by many as a failure... but it is still conceptually very appealing to me. I love result types and pattern matching in more typed/functional languages, except that they often have similar issues to go re: not having a stack trace.
- erik_seaberg 3y agoI liked checked exceptions, but higher-order functions break them. The method signature of stream.map(f) allows a generic type for f but it can't vary with f's exceptions. The choices usually boil down to "only throw unchecked exceptions" (like Runnable) or "throw any exception" (like Callable).
- plorkyeran 3y agoIt’s worth noting that this is specifically a shortcoming of Java’s type system and not an unsolvable problem. I’m a fan of Swift’s solution where you can directly mark a function as only rethrowing errors from a given parameter; it’s a lot simpler than making the error type a full fledged type parameter and covers most scenarios.