Live data from Hacker News

Tail-call optimization added to 6to5 compiler

github.com

31–33 of 33 posts

Re: Tail-call optimization added to 6to5 compiler

#31

http://jsperf.com/tco/8

Thanks for sharing the benchmarks. I'm not sure how 6to5, or any other transpiler, could do much better. The job these tools exist to do necessarily means they can't do better than what today's browsers' JS engines will support. Presumably in due course browsers will provide ES6 natively and so be better able to optimise code that uses tail calls in this way. Still, it's important to realise that the 6to5 implementat…

Ingvar Stepanyan, author of the original 6to5 pull request has finished submitting a series of further optimizations via https://github.com/6to5/6to5/pull/736.

I'm clocking a 110-215X performance boost: 1,255,700 - 2,384,556 ops/sec! (on Chrome and Firefox alpha builds respectively) Check out the new JSPerf: http://jsperf.com/tco/17

Re: Tail-call optimization added to 6to5 compiler

#32
post #17

Earlier quoted context omitted.

In practice recursion probably covers most of the cases where it matters. Corecursion could (if awkwardly) be converted into ordinary recursion.

Corecursion doesn't mean what you think it means. You mean mutual recursion.

It occurs to me that the existence (and nature) of "coroutines" probably primes this mistake.

Re: Tail-call optimization added to 6to5 compiler

#33

Earlier quoted context omitted.

Thanks for sharing the benchmarks. I'm not sure how 6to5, or any other transpiler, could do much better. The job these tools exist to do necessarily means they can't do better than what today's browsers' JS engines will support. Presumably in due course browsers will provide ES6 natively and so be better able to optimise code that uses tail calls in this way. Still, it's important to realise that the 6to5 implementat…

Ingvar Stepanyan, author of the original 6to5 pull request has finished submitting a series of further optimizations via https://github.com/6to5/6to5/pull/736 . I'm clocking a 110-215X performance boost: 1,255,700 - 2,384,556 ops/sec! (on Chrome and Firefox alpha builds respectively) Check out the new JSPerf: http://jsperf.com/tco/17

That's quite a speed-up, isn't it? It looks like the newly optimised version of 6to5 effectively inlines the tail call, similar to the way a real compiler would, and so avoids function call overheads altogether. Smart move. I hadn't realised the processing done by transpilers like 6to5 was so sophisticated, and I have even more respect for their developers now than I already did.
Post reply on HN