Optimization algorithms and functional JavaScript

6 points by jcovington ↗ HN
Collecting readings on efficient production ready algorithms around functional JavaScript. Tail-call optimization, etc. Any suggestions?

This topic came up while reading JavaScript Allongé, the "Six" Edition.

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.

5 comments

[ 0.22 ms ] story [ 19.4 ms ] thread
Babel.js is a transpiler from ES6/7 to earlier versions. 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

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.

Fair enough. My apologies for the imprecision.