Crockford: Monads and Gonads

As seen in this YouTube video:

The wonders of monads are finally revealed without resorting to Category Theory or Haskell. It turns out that monads are trivially expressed in JavaScript, and are one of the key enablers of Ajax. Monads are amazing. They are simple things, almost trivially implemented, with enormous power to manage complexity. But understanding them is surprisingly difficult, and most people, once they have that ah-ha moment, seem to lose the ability to explain them to others.

Still, I will continue to enjoy and consume burritos.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Monads for JavaScript

Watched the video. It is a tutorial on monads for JavaScript.

1) It uses the analogy of Ajax methods which were already a monad.
2) It spends some time on how to implement Null pointer exceptions as the Maybe Monad.

____

He also made an interesting comment that Intel is adding direct support for ECMA's parallelism so essentially if I understand him correctly a web browser app will be able to hit all available cores on a function by function basis. I'm not sure I buy that but his belief was that JavaScript was on its way to being #1 in speed.

I saw him giving this

I saw him giving this talk... could not stand it though.
Douglas Crockford just does not understand what a monad is, what a functor is, what a category is. There's not much to understand, but he does not. Happens frequently with people, actually. Just beware.

I think this is useful to

I think this is useful to get monadic programming more attention; for example I'm glad one of the examples was automating NULL checks using Maybe, since that's incredibly relevant for a lot of mainstream programming, and the comparison to NaN is useful. If all this achieves is to get API designers to stop and think about the burden of result-checking they're forcing on to their consumers, and programmers to stop and think before just wrapping everything in "try" then it can only be a good thing. However, I found the presentation overall to be very confusing.

I think it would have been better to start with a caveat "I'm going to present this in an OO way" and stick with that notation throughout. In the video he provides an implementation with standalone functions, then throws it away and gives another with methods, then throws it away and gives yet another with a 'macroid' (similar to a factory), which made it hard for me to follow what's going on.

I get the impression that this will get many Javascript programmers interested in Monads, since Douglas Crockford is an influential figure, but they'll still have no idea what a Monad is. Still, that's what Google's for :)

I can't say he has totally broken the curse but...

The presenter seems to grok Monads and is able to describe them and to describe them as useful thing for javascript programmers.

I really appreciate his not using the name unit rather than return, because if you do a lot with the C derived curly brace languages from return is a horribly confusing name for that function.

Is-there a PDF?

Videos are a waste of time (most of the time).