Nannying (was: Array comprehension syntax)

Jason Orendorff jason.orendorff at gmail.com
Mon Sep 24 10:37:12 PDT 2012


I want to defend my kind of nannying.  :-)

I favor rejecting `if x = y` in comprehensions because it's almost
always going to be a bug, and a tough bug to diagnose.  Mistaken
assumptions tend to stay invisible for a long time.  The more
fundamental the mistake, the harder it is to see.

Here's another program I think we should reject, for the same reason:

    var titles = books.map(b => {title: b.title});

The behavior here is really astonishing.  It's hard to see how the
developer is supposed to figure out what's wrong.  I'm willing to take
on some implementation complexity to head off this kind of
frustration.

Beyond likely mistakes, my sympathy for nannying drops off quickly.
In particular, there's little to gain from trying to enforce
readability in JS at the language level.  It's just not that kind of
language.

-j


More information about the es-discuss mailing list