krzkaczor / babel-plugin-tailcall-optimization

Tail call optimization for JavaScript!
MIT License
193 stars 9 forks source link

Didn't ES2015 introduce tail call optimization? #10

Closed MichalZalecki closed 7 years ago

MichalZalecki commented 7 years ago

Krzysztof, can you shed some light why plugins' optimization is a thing? I'm refering to introduced optimizations.

xtuc commented 7 years ago

Some JavaScript engines and Babel have disabled the tail call optimization because of its complexity.

krzkaczor commented 7 years ago

@MichalZalecki as you can see on compatibility table, still in 2017 almost no major js engine supports TCO. I am not sure why is that... probably full compliance with spec is waaaay harder than what this plugin tries to achieve.

@xtuc is right. Babel used to have TCO (i guess in version 5.x) but it was quite buggy. I found some old issues and tried to create workarounds for them (mostly for function scope). My workaround was simply not to attempt to optimize it at all :D

MichalZalecki commented 7 years ago

@xtuc @krzkaczor Thanks guys for a quick response 👏