I am a Java developer and I am learning Kotlin, which is very exciting to me. But when I found the exception is unchecked in Kotlin, I have some concerns.
I agree in some cases the checked exception is not good and annoying, such as the samples in Kotlin’s tutorial.
But when you build large system with several tiers and multiple modules, checked exception is part of the interface definition. It’s not just “a compile-time vs. run-time checking issue”. Lower-end module has the responsibility to hide the internal detail, such as IOException, FileNotFoundException, and translate it to other type of Exception. That’s the standard in Java. And everything is built on checked-exception to specify which kind of Exception to be thrown. Otherwise, upper level code may get weird exception, which may be handled by other modules. And when project grows bigger, more different types of exception may be thrown. I can foresee the final solution is to catch any “Throwable” to make client code stable, no matter if any exception will be thrown or not.
So could Kotlin have checked exception in future? At least, give compiler an option to check unhandled exception and treat them as warnings.
Or someone has better ideas on my problem.