| ▲ | msluyter an hour ago | |||||||||||||
I haven't really been in the java space for a while now, but I recall there being a fair bit of criticism[1][2] of checked exceptions over the years. [1] https://www.javacodegeeks.com/2026/01/javas-checked-exceptio... [2] https://reflectoring.io/do-not-use-checked-exceptions/ WRT magic, I've generally thought that was a result of frameworks - Spring, for example. In the past, my feeling was that these impose a sort of meta/configuration language that itself is not checkable at compile time, so you'd get weird runtime errors that are somewhat inexplicable. This was like... 2018 though, so perhaps things have improved. | ||||||||||||||
| ▲ | BoppreH 31 minutes ago | parent | next [-] | |||||||||||||
I'd argue that checked exceptions are still worth it, even though all the problems pointed out do exist. And that's because it works to inform consumers of what a producer is doing. Haskell has the IO and Maybe monads; Java communicates the same information through IOException and other domain exceptions. Many times I've decided to switch from one function to another, or even an entirely new library, because the checked exceptions told me that it was doing far more than I expected, and I was not comfortable introducing those new failure modes. It's far from perfect, one still has to handle nulls and wrapped/merged exceptions, but overall I like this language feature. | ||||||||||||||
| ▲ | voidfunc 41 minutes ago | parent | prev [-] | |||||||||||||
Checked exceptions are controversial mostly because a lot of the core APIs use them in places where it's pointless to check, like IOException. Using them correctly can be great tho. | ||||||||||||||
| ||||||||||||||