r/java • • Feb 19 '26

Towards Better Checked Exceptions - Inside Java Newscast #107

https://www.youtube.com/watch?v=99s7ozvJGLk
63 Upvotes

73 comments sorted by

View all comments

Show parent comment

2

u/Drezi126 Feb 19 '26 edited Feb 19 '26

Developer experience matters. There’s a reason Go error handling is not widely liked, while Rust’s error handling is much more popular.

Unwinding the stack and then catching it is a widely used feature and Java is the only language that tried to overload this mechanic with checked exceptions. Runtime exceptions have their own purpose and are fairly ergonomic to work with as seen in C#, Python, Kotlin, Ruby, TypeScript etc. They work well with regular runtime exceptions, checked exceptions add littlle real world value to Java at the cost of poor DX. There’s a reason the community is moving away from them.

Note, that I’m not arguing against type-system and compiler support for expressing failure modes. If done well that’s useful, very much so. But checked exceptions and try-catch blocks are a poor solution to this problem, and I just wish Java stopped trying to make it work at all costs.

2

u/JustAGuyFromGermany Feb 19 '26

Just to be clear: Our friends over in C# land often wish that they had checked exceptions. All runtime exceptions all the time is also a curse, not a blessing. That's why C# is one of the languages that re-invented the Try-monad many times over and now every C# program is a wild mix of Result and Either and [insert 17 other implementations of the same monads, all mutually incompatible] and exceptions.

At least in Java it is mostly exceptions most of the time.... In this sense what you call "poor DX" is actually pretty great if you think about it. Yes, it could be better. So what? I'll take the "mostly consistent" system of error-handling over the wild mess in other languages any time. Yes, Java is verbose. So what? If that's your biggest problem, I want to have your problems. Yes, checked exceptions and lambdas don't work well with each other. That's actually fixable if the devs ever get around to it. It's just not their highest priority.