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

Null value is used to determine several things: missing value, incorrect value or unknown value (there are other semantics).

A program that transforms one value into another value, may return a NULL value to denote that program processed value is missing or incorrect due to error. That was what it was in C, which had no exceptions.

Your example is nice, but if you are thinking exceptions aren't a problem, keep in mind they add several branching paths in a code that seems non-branching. This hides the errors and causes all other forms of confusion. In fact I do remember an anecdotal story of a team working on a Java system of critical importance, forbidding use of exceptions in order to guarantee that code would be run smoothly.

Maybe Java 8 will fix some pain points[1] of exceptions.

[1]http://java8blog.com/post/37385501926/fixing-checked-excepti...



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

Search: