Live data from Hacker News

Prepack helps make JavaScript code more efficient

prepack.io

51–60 of 233 posts

Re: Prepack helps make JavaScript code more efficient

#52
How does it compare to Google's closure compiler? It is considered by many best in class. It understands the code (uses Java based Rhino Javascript engine), while most alternatives (UglifyJS & co) just monkey patch things. You can trust the Google's closure compiler output.

Edit: @jagthebeetle: have you tried "advanced mode"? (One should read the documentation before using it, it's really a game changer but requires one to read the docu first)

Re: Prepack helps make JavaScript code more efficient

#53

Not a comment about the tool, which looks cool and well done. It's sad that there are developers and projects who write the type of code that causes these sorts of performance trade offs. I stopped writing this kind of fancy code a long time ago when I realized it wasn't worth it. You're just shooting yourself in the foot in the long run. I think static analysis performance optimization tools are great but a certain…

There is some confusion in this thread about the purpose of this tool, which is targeted at generated code—specifically, code generated by other compilers. In order to get language features that don't exist in javascript, code has to be generated in a more or less context-agnostic way. This (as I understand it) brings more context to bear, to reduce the cost of the new abstractions for your specific usage.

Re: Prepack helps make JavaScript code more efficient

#54
post #13

I was under the impression that V8 and the like are so optimized that this would give marginal gains. Would love to be wrong though. Do you have any performance benchmarks?

Without reading further. I'd say yes and no.

No for client javascript. Compilation is a slow and intensive process. You don't have the time to optimize the mountains of code loading on every new page. It makes the page much slower to load. The returns are negative if all the code executed turned out to be a single function to flash a menu, before the user left.

Yes for server javascript. It's long running processes, web servers should take time on startup to perform JIT compilation. It's beneficial in the long run.

Re: Prepack helps make JavaScript code more efficient

#55

The examples are very far from the JS I see and read, but this is definitely a very useful tool. It seems like gcc -Olevel. It would be interesting to incorporate some sort of tailoring for JS engines into this, like how a compiler might try to make x86-specific optimizations. For example, if you know your target audience mostly runs Chrome (or if the code is to be run by node), you might apply optimizations to chang…

The examples seem more typical of Coffeescript output.

Re: Prepack helps make JavaScript code more efficient

#56
post #53

Not a comment about the tool, which looks cool and well done. It's sad that there are developers and projects who write the type of code that causes these sorts of performance trade offs. I stopped writing this kind of fancy code a long time ago when I realized it wasn't worth it. You're just shooting yourself in the foot in the long run. I think static analysis performance optimization tools are great but a certain…

There is some confusion in this thread about the purpose of this tool, which is targeted at generated code—specifically, code generated by other compilers. In order to get language features that don't exist in javascript, code has to be generated in a more or less context-agnostic way. This (as I understand it) brings more context to bear, to reduce the cost of the new abstractions for your specific usage .

Ah that makes sense. I was wondering why the examples all looked like Coffeescript output.

Re: Prepack helps make JavaScript code more efficient

#57

A long time ago there was a theory about using Guile (the GNU Scheme) as a general interpreter for languages using partial evaluation: you write an interpreter for a language in Scheme, use a given program as input, and run an optimizer over the program. This turns your interpreter into a compiler. I played around with the concept (making a Tcl interpreter), and it even kind of worked, often creating reasonably reada…

Pypy does it a lot like that.

Re: Prepack helps make JavaScript code more efficient

#58

Looks like it's applying the same sort of optimizations a normal optimizing compiler would. With all of these JS "compilers" and transpilers, at some point, it just makes sense to build a client-side language in the browser that compiles down to native and runs sandboxed. I'm excited for WebAssembly, but I realize that, like with all shiny new web things (for example, WebRTC on Safari/iOS), mainstream browsers that m…

How much marketshare do you think that Javascript will lose once WebAssembly gets mainstream?

Has it evolved so much that it's now a language you would pick out of free will? With ES6, I'm hearing that it's actually usable and kinda nice, but every time I use JS for something instead of Python, I get hit with things like the weird typing that you just can't change.

Re: Prepack helps make JavaScript code more efficient

#59

Not a comment about the tool, which looks cool and well done. It's sad that there are developers and projects who write the type of code that causes these sorts of performance trade offs. I stopped writing this kind of fancy code a long time ago when I realized it wasn't worth it. You're just shooting yourself in the foot in the long run. I think static analysis performance optimization tools are great but a certain…

Evaluating constant expressions at compile time is something any good compiler will do. It's not bad practice to write something like "60 * 60" in code instead of 3600, if the underlying computation is important. At the same time, performing a multiply at runtime is unnecessary and wasteful. This just gives you in JavaScript what any decent C compiler has been doing for ages.

Re: Prepack helps make JavaScript code more efficient

#60

Hi, I am Nikolai Tillmann, a developer on the Prepack project. I am happy to answer any questions!

What will happen if you have bug in your function? Take the fibonacci function for example, what if you have a bug and created an infinite loop? Will Prepack terminate?
Post reply on HN