Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

It's about leaky abstractions.

If programming is about managing complexity and status is ideally specified explicitly, then null is simply the option in a mathematical set defining that status which corresponds to the option commonly seen on surveys: Other (please specify): ...

While it can be handy to have this 'extra value' in a set, and it is most commonly used to denote special meanings within a carefully controlled context (eg. SQL column in a result set is empty, a variable is of no type - ie. not defined at all, etc.), issues arise when people accidentally carry context or presumptions about the meaning of null across contexts, creating a leaky abstraction.

Most of the author's article appears to deal with differences in these context-specific assumptions.

Perhaps the Java approach: throw an exception.

Unix approach? Nonzero return values and arbitrary stream or file data to clarify. In edge-case leakiness, very similar to the Java approach.

The functional and dedicated non-OO procedural programming approach: define exit parameters to your function, specifying complete precision and ending any ambiguity.

Since a type is a formal context (set), then using a typed language is another solution, although that adds overhead it brings benefits in rigor.

Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function. - John Carmack



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

Search: