
Optimization algorithms and functional JavaScript - jcovington
Collecting readings on efficient production ready algorithms around functional JavaScript. Tail-call optimization, etc. Any suggestions?<p>This topic came up while reading JavaScript Allongé, the &quot;Six&quot; Edition.<p>Reading suggestions do not need to be written in JavaScript (although that is the preference), so long as they are applicable to functional programming in the context of optimized production apps.
======
jarcane
Babel.js is a transpiler from ES6/7 to earlier versions.
[https://babeljs.io/](https://babeljs.io/)

I mention it because this is currently the only implementation that I know of
with tail-call optimization (using a trampolining method, I believe), as well
as all the other new functional tools in ES6.

This here is a book on ES6, which you'll want Babel for:
[https://leanpub.com/exploring-es6/read](https://leanpub.com/exploring-
es6/read)

~~~
braythwayt
Babel performs tail- _recursion_ optimization.

It is, as far as I know, impossible to use trampolining to perform tail-call
optimization outside of very limited special cases. You need to do either
whole-program rewriting--which means rewriting both the original source and
every library or module included--or you need control of the engine itself.

Whole-program rewriting is very impractical and additionally imposes the
trampolining performance penalty on every function and method being invoked.
It’s very much like implementing continuations by rewriting in continuation-
passing style.

~~~
jarcane
Fair enough. My apologies for the imprecision.

------
braythwayt
Mori is "A library for using ClojureScript's persistent data structures and
supporting API from the comfort of vanilla JavaScript."

[http://swannodette.github.io/mori/](http://swannodette.github.io/mori/)

------
jcovington
[http://www.2ality.com/2015/06/tail-call-
optimization.html](http://www.2ality.com/2015/06/tail-call-optimization.html)

