News for hackers. Stuff that matters.
Re:Node v6.6.0 by michaelsbradley on Thursday September 15, 2016 @05:28PM (#12509959)
It seems generators and trampolines involve considerably more CPU overhead in the 6.x series vs. 5.x, while tail calls are now fully optimized and/or the default stack limit has grown considerably.

Try running the following script with v5.12.0 and again with v6.6.0:

https://gist.github.com/michaelsbradleyjr/d1b104137e8e00468d...

   node --version && node --use_strict ./mutrec_vs_tramp_vs_gen.js
Re:Node v6.6.0 by _greim_ on Friday September 16, 2016 @12:40AM (#12511873)
> tail calls are now fully optimized

Can't remember where I heard this, but I'm given to understand they aren't optimized, just allowed. As in, recursive calls from tail position won't be super-fast or anything, they just won't blow out the call stack. Optimization may or may not be added to the engine at some future date.

Re:Node v6.6.0 by jnbiche on Thursday September 15, 2016 @09:11PM (#12511230)
> while tail calls are now fully optimized and/or the default stack limit has grown considerably

That is great to hear. Now we can finally start really doing functional programming in JS. Too bad about the generators, though.

Re:Node v6.6.0 by michaelsbradley on Thursday September 15, 2016 @09:34PM (#12511324)
Well, I'm not sure which one is the case, sorry to say (TCO or bigger stack limits, or both). I was only taking a guess as to why the mutual recursion example works for very large values in node v6.x but not in v5.x. But yes, if tail call optimization is guaranteed, then functional programming patterns can certainly shine the brighter for it.