re: You Either Have It Or You Don't VIEW POST

FULL DISCUSSION
 

While I generally find myself mostly agreeing with Rich Hickey, this is one of the rare cases where I think I don't (I read his statement before). I'm just not sure how Maybe is fundamentally different from "you either have it or you don’t". Even the type constructors (Just/Nothing) encode this very concept. Either way you gonna have to deal with the potential absence, be it with a pattern match, a null check or a NullPointerException.

 

Right, I'm with you. Call it whatever you like, encode it at whatever level of your stack you like, reality will come knocking one way or another.

 

Mostly agree, but in Java especially it can be very confusing. Something typed as Optional could still hold a null value. And there is also some diversity in @NonNull annotations, some working compile time, and some runtime. In that case it's much easier if anytime might actually be nil, and that's the only thing you have to take into account. Especially with functions like 'if-let' and how 'and' works in clojure, it's much easier and cleaner to write null safe code in Clojure is my experience.

That's interesting. I definitely have not spent nearly enough time with Clojure, but always had a better time around null using optional types. My Clojure I never felt as confident about - but I think this is a familiarity issue.

Good point, the way Java handles Optionals is something I didn’t consider (and something I dislike very much).

code of conduct - report abuse