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

Exceptional doesn't mean once in a blue moon; it just means "not the normal flow", for example, it could mean missing data, which could be handled by returning and testing for a null in Java. Python has more efficient exception handling, so missing data is often handled by an exception. Programmers are encouraged to use this idiom. It has the advantage that the return value space is not cluttered by a distinguished error value. If a function returns an integer, is the error value 0, -1, or 9999?


From casually looking at both CPython and JVM code I conclude that implementation of exception handling in Java and Python is almost same. So this is more a cultural difference than effectiveness issue.


In Java you can do stuff like, the JVM is going to bounds check you anyway, so why bother checking yourself if you're about to go off the end of an array? Just i++ and catch IndexException (or whatever it's called).


You can do that, but nobody writes Java code like this since it's more awkward and aesthetically offensive than explicit bounds checking.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: