News for hackers. Stuff that matters.
Re:Beautiful JavaScript – Functional JavaScript by LeanderK on Sunday December 25, 2016 @05:53PM (#13255837)
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.

Re:Beautiful JavaScript – Functional JavaScript by groovy2shoes on Sunday December 25, 2016 @08:38PM (#13256425)
> 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, ....

Re:Beautiful JavaScript – Functional JavaScript by crooked-v on Sunday December 25, 2016 @08:46PM (#13256445)
Take 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.

Re:Beautiful JavaScript – Functional JavaScript by ced_vdb on Sunday December 25, 2016 @08:50PM (#13256456)
What about typing added on top of javascript for that purpose. Like typescript.
Re:Beautiful JavaScript – Functional JavaScript by crooked-v on Sunday December 25, 2016 @09:17PM (#13256551)
Typescript doesn't go far enough yet for asm.js code. It would need much more fine-grained types, like specific kinds of numbers instead of a single 'number' type.