Sorry Jeff, but this is actually not the case. The performance consequences from using .bind() can be quite severe because it pollutes type information and disables fast paths. Not 'your entire application runs in the interpreter' slow, but surprisingly slow. It can even slow down code paths where .bind()/bound functions are not being used because of how inline caches and such tend to work in modern engines.
The problem here isn't that 'calling a bound function is slow'; it's a more general problem that the introduction of bound functions into an existing application can make the application get slower in places where the bound functions aren't being used. I do agree with the general principle that it is not likely to be the biggest performance problem, but it's surprisingly harmful. On a related note, it would certainly be unwelcome if arrow functions had the same downsides. -kg On Sat, Jul 13, 2013 at 12:15 PM, Jeff Walden <[email protected]> wrote: > On 07/12/2013 02:54 PM, Allen Wirfs-Brock wrote: > > Looking at it another way, if implementation haven't found it > straightforward to optimize ES5 bound functions why would you expect that > would have an easier time with Proxys? > > I'm pretty sure no implementation has seriously tried to optimize bound > functions, and that that's the major reason for any slowness. I don't > think there's anything fundamentally difficult about optimizing bound > functions. It's just never been a priority for engines, because it doesn't > show up in benchmarks and because the perf bugs for it are less pressing > than other perf work is, as bound functions remain underused on the web. > Chicken and egg? Sure. > > In the meantime, while I wouldn't currently question (as a purely > pragmatic choice) avoiding bind in highly intensive code where every bit of > perf matters, I do think bound functions are fast enough for the vast > majority of cases. The overhead of calling a bound function will rarely be > the difference between adequate and inadequate performance. > > Jeff >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

