Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Checked exceptions are bad because people just catch them and rethrow RuntimeException. Proper errors as data would be much preferable.




Checked exceptions are proper errors as data. There is no difference between Result[T, E] and T throws E. The same people that just rethrow as RuntimeException would call unwrap() on Result and panic. The main problem with _Java_'s implementation of checked exceptions is that they're not fully in the type system because of Java's weak type system. That is solvable with a strong type system though, like in Scala or Swift.

You can misuse the errors as data paradigm just like you can misuse checked exceptions. That doesn't make either paradigm bad, it makes the programmers who misuse them bad.

> people just catch them and rethrow

People don't have to. There is a lot of misinformation out there about checked exceptions, and people are responding to the misinformation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: