4 ms·
Prepack, https://prepack.io https://prepack.io, is also in the same realm of an optimizing Javascript compiler.
by RubenSandwich 8y ago
Prepack, https://prepack.io https://prepack.io, is also in the same realm of an optimizing Javascript compiler.
- k__ 8y agoPrepack is rather nice. It allows you to execute part of your code at compile time, like a macro.
- leeoniya 8y agoClosure compiler in ADVANCED_OPTIMIZATIONS mode does this too. function add5(x) { return x + 5; } console.log(add5(3)); compiles down to console.log(8);
- danabramov 8y agoPrepack is doing much more than GCC can because it effectively evaluates the whole code and then serialises its heap. This is both its biggest strength and weakness. Unlike GCC, it can unroll any kind of metaprogramming, but it needs to have a model of the environment (e.g. it won’t execute code relying on DOM) and it can produce larger code (in terms of absolute size).
- sumnulu 8y agoIncidentally, http://www.scala-js.org http://www.scala-js.org compiler has constant folding too. Also if you need faster numeric calculations https://github.com/non/spire https://github.com/non/spire (has scala.js support)
- abritinthebay 8y agoPrepack is somewhat different though in that it precalculates what can be. That's much less problematic than what the linked library does. Of course prepack also isn't even close to production ready yet either.