What is Crockford's law?
Asked Answered
D

2

15

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

Daughterinlaw answered 23/10, 2013 at 14:39 Comment(5)
youtube.com/watch?v=dkZFtimgAcMFragmentation
@Fragmentation If you have the answer it would be quicker for us to read it instead of having to watch the video ...Lucier
It's possibly a reference to "Monads are cursed; the moment that it clicks and you understand what it means you are suddenly incapable of explaining it anyone else" (paraphrased).Furbelow
@J.Abrahamson Saw the first half, yeah I believe that is.Flog
"Crockford'w law of Monad" is about how JS people see monad, as simple as thatEdacity
C
34

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!

Cyndie answered 23/10, 2013 at 19:59 Comment(4)
I think the trouble is that explaining monads to imperative programmers is like trying to explain water to fish. It's so ingrained in everything they've done before that they just take their laws for granted. The best way to learn what monads are is actually to try to build serious programs without them.Present
Example: ...flattens the promise of a promise to a single promise... it returns a promise, and the detailsPromise that we now have is redeemed when that promise is redeemed... And that is a monad. groups.google.com/d/msg/Golang-Nuts/iIAhrtK8XRo/tcXeIvVMOl0JLaundrywoman
mine would be "monads are all about nested loops, and about unrolling". Great answer!Secretion
#4 is my experience as an outsider to monads — they feel like some Haskell hazing ritual that initiate you into a club of the gnostic.Vickey
M
2

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.

Mcphail answered 11/8, 2020 at 0:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.