Allen Wirfs-Brock wrote:
you might consider ticketing performance bugs against the various 
implementations.

Right, and at most summarize with links to those issues for es-discuss. This is not a language issue, rather a quality of implementation one.

/be

Allen


On Jul 10, 2013, at 9:16 AM, Claus Reinke wrote:

The TypeScript project tries to emulate arrow functions through the
"_this = this" pattern and keeps running into corner cases where a
semi-naïve renaming is not sufficient.

I have been trying to suggest using .bind to emulate arrow functions
instead, but the counter-arguments are (a) .bind might not be available
(supporting pre-ES5 targets) and (b) .bind is slow.

The polyfill isn't the problem, but I'm a bit shocked every time
someone reminds me of the performance hit for using .bind. Given
that a bound function has strictly more info than an unbound one,
I wouldn't expect that (I expected a bound function to be roughly
the same as an unbound function that does not use "this"). Unless
there is no special casing for the just-add-this case, and .bind is
always treated as a non-standard (meta-level) call.

While playing with test-code, I also found that v8 does a lot better
than other engines when using an .apply-based .bind emulation.

Can anyone explain what is going on with .bind, .apply and the
performance hits?

The TypeScript issue is https://typescript.codeplex.com/workitem/1322 .
My test code (*) is attached there as "bind-for-arrows.html".

Claus
http://clausreinke.github.com/

(*) I also tried to make a jsperf test case, but the way jsperf
   runs the loop seems to prevent the optimization that makes
   v8 look good for the .apply-based bind.

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to