4 ms·
I share the conclusion of the other statically typed JVM languages (Scala, Kotlin): checked exceptions are bad.
by paulddraper 8y ago
I share the conclusion of the other statically typed JVM languages (Scala, Kotlin): checked exceptions are bad.
- vbezhenar 8y agoIf they are officially bad, remove them from the language. It's a backwards-compatible change. Currently we are in a weird situation, when standard library does not work well with each other. It's like making iPhone without USB-C cable and Macbook without USB-A port.
- dragonwriter 8y ago> It's like making iPhone without USB-C cable and Macbook without USB-B port. Was there ever a MacBook with USB-B?
- paulddraper 8y ago> If they are officially bad, remove them from the language java.util.Date is bad, but it's not getting removed. java.net.URLEncoder is bad, but it's not getting removed.
- l1ambda 8y agoYes. One can workaround it with the throw-as-unchecked pattern: https://stackoverflow.com/questions/14038649/java-sneakythrow-of-exceptions-type-erasure https://stackoverflow.com/questions/14038649/java-sneakythro...
- joostdevries 8y agoI find checked exceptions interesting. They happen to be the only example of an effect system in a mainstream language. Anders Hejlsberg formulated the main argument against them here [1] Basically the problem is that checked exceptions are infectious and intermediary code needs to annotate all the exceptions of code that it calls. Which is a chore. Lucas Rytz states in his PhD thesis [2] that the problem is not wich checked exceptions themselves, but that in the java implementation 'not mentioning an exception means if won't happen'. He proposes a system where the default is 'any exception' and being able to turn it off with a compiler flag. And states that the developer experience of that would be much better. This may become possible in Dotty Scala using the effect system based on implicit functions. But that's in 'proposed' status. [1]https://www.artima.com/intv/handcuffs.html https://www.artima.com/intv/handcuffs.html [2]https://lrytz.github.io/pubsTalks/ https://lrytz.github.io/pubsTalks/ the link to his thesis doesn't work anymore. I cherry pick some of it in my talk for a Scala meetup in Utrecht https://www.slideshare.net/yoozd/effect-systems-in-scala-beyond-flatmap https://www.slideshare.net/yoozd/effect-systems-in-scala-bey...