Reading HN sometimes make me wonder how I'm still getting paid for writing code / managing others that do so. Was software reinvented in the past few years while I was sleeping? Is functional programming taking over the world? Is understanding things like Monads and Promises now a must have for anyone calling themselves a programmer / developer / software engineer / hacker?
Giving names to these ideas just makes it easier to communicate common concepts to yourself and others. (imagine how hard it would be if you didn't know the terms "binary tree" or "MAC address").
The existence of these concepts is not an affront to your existing knowledge. Learn them only if you think it helps you.
That's one of the reasons I hate the reality of design patterns in modern software: they start off as useful vocabulary, then some specific variants of the pattern hijack the name, and soon it's impossible to communicate clearly as nobody knows which variants have which names and meanings, and vocabulary starts to diverge wildly (see also: MV* patterns).
Yes and yes, and it's awesome! :) Previously functional programming was mostly an academic pursuit but in the last decade it has definitely entered the mainstream. Once you understand FP, you become a much more skilled programmer and can make more efficient solutions even in languages not designed for FP like C.
> Is understanding things like Monads and Promises now a must have > for anyone calling themselves a programmer / developer / software engineer / hacker?
I don't understanding it per se is the water branching point. Instead the difference between an "office drone engineer" and a hacker is a natural curiosity and interest in learning new things. An office drone will say "damn! now i have to learn this NEW thing, argh." A hacker will instead enjoy it and have a very fun time learning about monads.
And when I learn something new, it's rarely a new language construct, I rather create something new, or learn a new technology, not a design pattern. (e.g. can't wait to find some spare time for Meteor 0.5 experimentation. I wonder if I can write a TypeScript interface for it)
So call me an office drone, but if Promises are syntactic sugar, I rather have my coffee unsweetened.
Similar experiences can probably be derived by learning about JavaFX, like understanding its pretty smart canvas api. Silverlight has, I don't know, state of the art drm technology for video streaming?
The point is that learning is almost always a good investment that pays off. If you love what you are learning about, then the investment becomes much smaller and the payoff almost immediate.
I don't think there's as much a need for it in Java because I'm less likely to want to write defensive code in that way outside of the browser.
It looks like Play supplies F.Promise, which provides the same functionality with a different API. I do like the simplicity of the API in the JS promises. The something.transform(good, bad, progress) is very easy to understand from the start.
Could you elaborate on how it's defensive?
(Edit: corrected "one or more" to "zero or more".)
If fulfilledHandler is a regular function, then then() is just Functor's fmap.
If fulfilledHandler is allowed to be either variant, then you can imagine then() as applying an implicit return when needed, which makes the types a bit less clear
The .then() method is this monad's bind operator. It allows you to chain a Promise through functions that do not have to know or care about how to accept promises as arguments.
Hopefully this might help Javascript programmers who are curious about the relevance of these esoteric functional programming ideas. They are in your language too! (just with less frightening names)