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

If/else provides a clear and easy to follow control flow. try/catch is like a roaming goto that works it's way back up your stack in ways you can't predict.

http://www.lighterra.com/papers/exceptionsharmful/



The context here is Java's checked exceptions, which have to be handled explicitly at the site where they may occur, leading to control flow that - in my view - isn't substantially different from handling errors with if/else.


Fair enough.


I don't understand the argument that stack unwinding is unpredictable -- the most naive implementation of exceptions would just be multiple-function returns with automatic propagation (effectively the same as automatically putting the try! macro on every call in Rust).

Nothing about try/catch is like a "roaming goto".




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

Search: