4 ms·
> "oh shit, that throws" whackamole You don't have that problem in languages that support checked exceptions.
by flowerlad 6y ago
> "oh shit, that throws" whackamole
You don't have that problem in languages that support checked exceptions.
- dilap 6y agoAgreed, mostly true. (It's still not as explicit about where your function might exit, but you won't get surprise exceptions, which is way nicer.)
- kibwen 6y agoYou may still have that problem if the language also supports unchecked exceptions.
- ufmace 6y agoI've never seen a language that supported checked exceptions and actually used them consistently for everything. But then that would be kind of awful, because IMO the checked exceptions cases for "I know this will never actually throw, leave me alone" and "This is just a quick script, go ahead and blow up the whole program if this fails" are poor, forcing you to write try catch blocks all over the place. IMO, Rust has a nice approach for being stricter - unwrap. If it's a quick script, throw unwrap everywhere with reckless abandon. For real programs, grep for unwrap and make sure for every one, you really know for sure that it will never fail or that blowing up the whole program if it does is the right move. To convert from one to the other, grep unwrap and actually think about what you want to happen if that line is Err.
- dehrmann 6y agoYou do and you don't. If you're using a Java library written by someone who doesn't believe in checked exceptions in Java, you might be lulled into thinking everything will be fine.