4 ms·
Maybe I’m old and set in my ways but I don’t see where the monadic example provided is easier to read or interpret than the traditional example.
by efitz 3y ago
Maybe I’m old and set in my ways but I don’t see where the monadic example provided is easier to read or interpret than the traditional example.
- gnull 3y agohttps://news.ycombinator.com/item?id=37714144 https://news.ycombinator.com/item?id=37714144 This comment here, I think, has the answer. The inial returns from using the more functional and mathematical view of programs are smaller than that of traditional approach. But the former scales better if you invest more time in it, and eventually can give you much more.
- vjerancrnjak 3y agoAfter reading this kind of code for a week it becomes as easy as anything else. As long as there’s no pyramids of doom (possible with plain if else, promise .then and async/await and this optional and_then) code will be easy to read.
- NBJack 3y agoThat's true for many things we as humans can become accustomed to. But what exactly is the (hopefully quantifiable) improvement here? Otherwise, it's just a style option of preference.
- vjerancrnjak 3y agoIf you use the optional type, then nothing. It’s just style. If you don’t use it and your compiler can tell you’re dereferencing a possible null value, then again you gain nothing.