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

Peter Michaux petermichaux at gmail.com
Sat May 7 09:08:32 PDT 2011


On Sat, May 7, 2011 at 6:04 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> On Sat, May 7, 2011 at 2:22 AM, Peter Michaux <petermichaux at gmail.com> wrote:
>>
>> I think that this is what compilers and projects like coffeescript are
>> for. In my opinion, JavaScript itself doesn't need this new syntax.
>>
>> I think improving JavaScript as a compilation target is a good goal.
>
> This argument comes up time and again: "We don't need to make
> JavaScript a good programming language,

JavaScript is already a good programming language. It can use
improvements but it has "good" covered.

> just a good compilation
> target".

I did not write that it needs to be "just a good compilation target."

I don't use a compiler to enable me to write source in another
language and then serve JavaScript to the browser. I write in
JavaScript. So I do want JavaScript to remain a good language.

That said, improving JavaScript as a compilation target does expose
areas where the language could use features it does not have at all
(in any syntax.) Adding those features makes JavaScript objectively a
more capable language.

> I think it's really wrong-headed.

Me too.

> First, JavaScript is a
> language used by millions of people as a programming language, and we
> should give them a great language to program in.

JavaScript already has "great" covered too. :-) I'd be willing to go
for "even better" but the arrow syntax isn't even a significant
contribution to this cause. Real features would be. A weak map, for
example, is a great idea because we just cannot do anything like that
now without implementing our own garbage collection.

> Second, JavaScript
> as source rather than target has been a huge enabler of the Web as an
> open platform, which I certainly don't want to move away from.  So,
> even though we've worked hard in the module system to better support
> compilation to JavaScript, I think the our fundamental goal should be
> to make JavaScript a great language to write all kinds of programs in.

That wasn't one of Brendan's stated goals; however, it is a good goal.
I think the arrow syntax is not helpful in this goal.

>> For example, a real "lambda" with guaranteed proper tail calls, no
>> "arguments", no need for "return", etc would make is possible to
>> compile Scheme to JavaScript without using something inefficient like
>> trampolines. It would also open up recursive programming options in
>> plain JavaScript so it would be win-win.
>
> And hey, it turns out we've done this too -- at least with the -> syntax.  :)

It has been confirmed that the arrow syntax is *only* syntactic sugar
for existing function syntax. That means introducing the arrow syntax
does *not* improve the compilation Scheme to JavaScript *at all*.

Peter


More information about the es-discuss mailing list