arrow syntax unnecessary and the idea that "function" is too long

Brendan Eich brendan at mozilla.com
Fri May 6 18:39:32 PDT 2011


On May 6, 2011, at 5:04 PM, Peter Michaux wrote:

> The only possible category is "be a better language" but the arrow
> syntax won't make JavaScript a better language for complex
> applications or libraries in comparison to any other kind of
> JavaScript code.

Usability is always on the top three lists of programming language success factors. 'function' and 'return' are too long.


> I would argue that the arrow syntax will make
> JavaScript a worse language anyway as there are already perfectly good
> forms using the "function" keyword now.

Eight characters is at least six too many.


> We don't need new syntax and
> we don't need multiple ways to do the same thing just for the sake 6

Wrong, 14. You are not counting 'return'.


> characters. Please keep JavaScript simple.

Sorry, this is a bogus argument. "Simple" does not mean "fewest productions in all possible grammars" or "fewest ways of saying any given sentence." That is simpler by some measures, more complex by others. In particular, writing and (lesser but still material) reading 'function' over and over is not a win.

Consider the destructuring object shorthand: let {x, y} = pt; instead of let {x:x, y:y} = pt;


> Look at all the complex/subtle edge cases mentioned in the wiki page
> about arrow function syntax. Do we really want to have that much
> trickiness added to the language?

The wiki page is a work in progress. I have updates coming, which should address the parenthesization burden. But again, you can use 14 characters if you want. This is shorthand, and only shorthand. And usability counts, so shorthands are in Harmony (e.g., destructuring)

Gzip is not the issue (although stats I've seen from Steve Souders show too may scripts not being compressed at the Transfer-encoding layer). Human usability is.

/be



More information about the es-discuss mailing list