Function syntax

Brendan Eich brendan at
Sat May 21 11:18:05 PDT 2011

On May 21, 2011, at 11:01 AM, Peter Michaux wrote:

> On Sat, May 21, 2011 at 10:46 AM, Brendan Eich <brendan at> wrote:
>> Saying JS has function expressions that are wildly popular is jumping to a conclusion.
> How is that jumping to conclusions? All the JavaScript code that I
> read uses function expressions.

I answered this in my post. Did you read it? Let's try logic:

"English is wildly popular" does not imply "English irregular verbs are wildly popular".

"JS is wildly popular" does not imply "JS function expressions are wildly popular".

It's simply not the case. JS may be popular in spite of the verbosity of 'function', indeed I hear this directly from developers. They like the functional/prototypal multi-paradigm semantics. They *do not like* the overlong 'function' keyword.

>> JS is "popular" in that it's the only built-in browser language, but let's say it is popular on its own these days (NodeJS, e.g.).
> Not sure how this relates to the success of functions in JavaScript code.

Because there's no other way to build abstractions than by using functions. I explicitly cited C# classes as an alternative that left delegates in C# 1 and 2 with fewer problems to solve. Java did without anything but classes for too long, then added anonymous inner classes as a poor substitute for first class functions.

>> It still does not follow that function expressions are popular enough that shorter syntax would not make the language more usable for enough developers that shorter syntax is worth adding.
> JavaScript function expressions are not suffering neglect due to their
> length.

You are not responding to my point. JS has a lock on the browser, and even ignoring that, its popularity is not demonstrably due to 'function' being the right length. Indeed NodeJS is winning in part because of V8's performance, in part because JS's closures (not the 'function' keywords length!) make async programming easier than OOP-only languages.

In other words, there's no choice but to use JS in the browser, and its emergence elsewhere has been for explicitly cited benefits other than the length of 'function'. This proves nothing about whether that keyword length is too long, too short, or just right.

Now, independent of this lack of proof about 'function', we hear developers complain about that keyword's length. That's direct user feedback. I do not think you should ignore it.

> I doubt shorter syntax will increase their popularity because
> function expressions seem to be used where the concept is appropriate
> even.

This is pointless speculation. JS popularity does not prove 'function' or 'function' + 'return' maximum usability. Programming language usability is an art, not a science.

Meanwhile, direct user feedback says to consider shorter function syntax. So we in TC39 are considering it.

> Separately from that I don't think JavaScript needs shorter
> function syntax but that is up for debate.

Obviously -- can you get past this?


More information about the es-discuss mailing list