Hacker News new | ask | show | jobs
by gizmo686 4807 days ago
I disagree. If null was like Maybe, than you should be able to do:

E foo; ... foo=foo.bar().bat()

without having to do a null check after each function.

I think that Java's approach has the worst of both worlds, because there is no way to make foo.bar().bat() safe when a function could return null.

In C, for example, calling a method on a null object does not cause an error. Rather it passes in null as the 'this' value, allowing you to do you null checks within the method.

2 comments

Null is like Nothing, nullability is like Maybe, and (.) has an implicit fromJust.
I agree that C handles this much better than java. But your description is inaccurate. In C there are no methods, objects or 'this', which is far better.