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

Just out of curiosity, how is Kotlin's approach less practical than Option? (I'm new to this style of programming) Is it because you can use Option types in maps and filters and the like?


Yes, but it goes deeper and I can't give it enough justice by typing this on my iPad.

The thing to understand about Nulls is that most often they denote non-fatal errors that have to be either explicitly handled or otherwise they get ignored. That's why nulls are evil, because NPEs take developers by surprise, at the worst possible time.

Monads are useful for dealing with errors. It's a tool, or a design pattern if you will, that makes the developer either deal with exceptional state or make it somebody else's problem. Developers that are not familiar with monads are doomed to implement it badly [1]

If you're interested for more and are a little familiar with Scala, I've attached an URL for an awesome explanation of this topic [2]

[1] https://gist.github.com/3889970

[2] http://james-iry.blogspot.ro/2007/09/monads-are-elephants-pa...


> It's a tool, or a design pattern if you will, that makes the developer either deal with exceptional state or make it somebody else's problem.

So, exactly like exceptions.




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

Search: