4 ms·
Disclaimer: CS-Student who is interested in FP-languages but is yet not really experienced in this topic. I am also a bit drunk. i think the problem is that js
by LeanderK 10y ago
Disclaimer: CS-Student who is interested in FP-languages but is yet not really experienced in this topic. I am also a bit drunk.
i think the problem is that js is not really designed for this kind of usage. If you look at this from the point pf view of an compiler FP is way easier to modify and optimize to improve performance. There are many factors but i believe the most important factor of future FP-base optimising compiler is rich type-info that makes many optimisation techniques possible or easier (this is important) to implement. While it's kinda boring, just look at haskell what possible there with rewrite rules. In a way it's possible to write your own compiler optimisation for your library.
In JS it's way harder because JS is untyped and the type system is way, way more complicated. Many of the hatches you use to optimise your program make it harder for the compiler to optimize your program. And i know about JIT-compiler, they are really complex beasts and the only way to tackle a language like JS. Just look (again) at Haskell, i always wondered what a really, really god JIT-compiler would look like. I would think that all the optimisation that you get by just using some pragmas would be only "engineering" work and don't require some fundamental breakthroughs. Especially if you consider the huge amount of time that went into something like the JVM.
- groovy2shoes 10y ago> i always wondered what a really, really god JIT-compiler would look like. Take a look at LuaJIT, then. Also, I feel like it's worth mentioning that Haskell, OCaml, and Standard ML all have high-quality compilers available that can generate some pretty performant code. You won't get C speed out of them (at least not with idiomatic code), but you can wind up with executables that beat Java or C# perhaps, and easily beat the likes of Python, Ruby, Perl, JavaScript, ....
- crooked-v 10y agoTake a look at asm.js. It's a subset of JS that uses de facto type annotations to let the JIT compiler get tremendous performance gains compared to normal JS - benchmarks put it at something like 1/2 the speed of raw C. The problem, of course, is that (among other complications) you need to generate it from something that's completely strictly typed in order to do that in the first place, so most asm.js-compatble code is actually just generated anyway based on C or a similar language.