Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Crockford's law?

Someone referenced "Crockford's law" recently with respect to monads. Google shows very little in the way of results. Anyone know what it is?

like image 405
brooks94 Avatar asked Oct 23 '13 14:10

brooks94


2 Answers

Assuming "Crockford's Law" is The Curse that he mentions early in the video, he's referring to this common occurrence (described much more eloquently here):

  1. person X doesn't understand monads
  2. person X works long and hard, and groks monads
  3. person X experiences amazing feeling of enlightenment, wonders why others are not similarly enlightened
  4. person X gives horrible, incomplete, inaccurate, oversimplified, and confusing explanation of monads to others which probably makes them think that monads are stupid, dumb, worthless, overcomplicated, unnecessary, something incorrect, or a mental wank-ercise

Here's are some of the reasons why I think The Curse exists:

  • forgetting how different functional programming is from so-called "mainstream" programming. If you don't already have a good understanding of what FP is, and why people do it, things built using FP won't make sense. Such things take time and effort
  • forgetting how different capturing effects as first-class citizens is from effects provided by the system (exceptions or mutable state, for example): same as above
  • lack of good motivating examples. You know, stuff like "this is the problem, here's the typical solution, but oh wait, the typical solution has these problems so let's see how we can cleanly fix those using monads!" That's a lot more work than the tired old example about null pointer exceptions
  • forgetting what a monad provides -- lots of "monad" examples I see actually work just fine as Functor or Applicative Functor examples
  • forgetting that monads are built within Haskell. Question: if monads suddenly disappeared, would you still be able to do I/O in Haskell?
  • thinking that monads require syntactic support, or a certain type system
  • thinking that monads are only about mutable state or I/O

I have fallen victim to The Curse. :(

It sounds like Crockford has as well, based on one of the questions at the end: "so monads are basically just the Builder pattern?" IMHO, it's a great video for learning kick-ass Javascript techniques, but not so great if you actually want to learn about monads.

If you are trying to learn about monads, just put in the time and effort and do lots of examples. Reimplement all the monad instances and combinators from scratch. Eventually you will be in a position to fall victim to The Curse as well!

like image 128
Matt Fenwick Avatar answered Nov 18 '22 14:11

Matt Fenwick


Artist's impression of Crockford conundrum
(alternate link)

Crockford conundrum - the inability of Haskell beginners to help other Haskell beginners to understand monads, before or after they understand it themselves; the phenomenon typically seen in Haskell beginners who have been trying to figure out how to print "Hello, world!". Occasionally offered up as proof of the futility of presenting Haskell beginners with a model of I/O relying on an abstract data type (A.D.T.) whose interface is based on "one of the most abstract branches of mathematics". Sometimes given as one reason for teaching JavaScript in introductory courses instead of Haskell. Rumoured to be under consideration for inclusion to the Millennium problems by The Clay Institute of Mathematics.

Alternate names: Crockford complex, Crockford's law.

like image 23
atravers Avatar answered Nov 18 '22 15:11

atravers