3 ms·
Prepack is rather nice. It allows you to execute part of your code at compile time, like a macro.
by k__ 9y ago
Prepack is rather nice. It allows you to execute part of your code at compile time, like a macro.
- leeoniya 9y 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 9y 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 9y 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)