Verity Stob Teaches Functional Programming

Published by marco on

Updated by marco on

The article Learn you Func Prog on five minute quick! by Verity Stob (The Register) provides a typically twisted and unhelpful overview of the state of functional programming in this 21st-century renaissance—heralded decades ago by Lisp programmers. It includes an honest overview of the major players, including Scala, for which the “pro” and “con” are the same (a “[c]lose relationship with Java […]”) and ending with JavaScript, for which the “pro” is “It’s what you’ll end up using.”

The discussion continues with rules: variable immutability, function purity, curryability and monadicity, which is where things really go off the rails. Property 7 dribbles to a shuddering halt with,

“All monads define a unit() function called of(), a bind() function called map() and a type constructor function called…

“Wait a minute. Wait a minute. Perhaps bind() is a functor not a function. I’m pretty sure about that. Hold on to the horses a moment there while I look it up.

“…And I should perhaps clarify that this bind() and map() is nothing to do with any other bind() or map() methods or functions that you might be familiar with, although their actions are in some sense quite similar.

Summary: It has been an honour and a pleasure to clear all that up for you.

Final Reader’s comment: My gratitude is inexpressible.[1]


[1] I’ve been reading Verity Stob since the days when she was published in Dr. Dobbs. Nice to see her still going with the same sense of humour (sic) and insight into the at-times puffed-up and self-important programming world.[2]
[2]

Which is not to say that I don’t enjoy immensely the functional aspects of C#. I do. I also have read a lot about monads and am completely familiar with the tragically bad and unenlightening explanations. Stob captures this elegantly with the following corollary to Rule 4:

“If you should by some accident come to understand what a Monad is, you will simultaneously lose the ability to explain it to anybody else.”