Conversation

Checked exceptions aren't as nice as reporting errors directly via return types but it's a whole lot better than unchecked exceptions I can't understand why people hate checked exceptions so much and I find Kotlin removing them to be a huge downgrade when using Java libraries.
3
10
Replying to
There can be issues around checked exceptions and maintaining/breaking backwards compatibility for libraries 🤷‍♀️
1
Replying to
Changing the exceptions that are thrown is always breaking backwards compatibility. If it's not well defined the API is poorly specified. It's better if it's reflected in the API and prompts people to handle the new error. It can easily be dealt with in an automated way.
1
1
Replying to and
Being against checked exceptions for that reason is simply being against static typing. Java has such a terrible type system that I can understand why it turns people against typing but for the most part I don't actually see much issue with how it handles checked exceptions.
1
1
Replying to and
My stance would be that unchecked exceptions should only ever be used for logic errors or serious issues with the execution environment being broken. That means you either report errors with return values or checked exceptions, and Java's type system is terrible at the former.
1
2
Show replies
Replying to
If they're willing to silently break code by adding or changing unchecked exceptions used for error reporting, they're just pretending to have backwards compatibility when they don't actually provide it. It's just dynamic typing instead of static typing. It's still incompatible.
2