Live data from Hacker News

Prepack helps make JavaScript code more efficient

prepack.io

31–40 of 233 posts

Re: Prepack helps make JavaScript code more efficient

#31
This looks very good indeed but the lack of initial data model very severely limits the production usability of this tool. You can't use "document" and "window" ...

It's the same problem TypeScript have/had that for external libs you need definition files for it to work. Now if we had TypeScript-to-assumeDataProperty generator that would be VERY interesting!

Re: Prepack helps make JavaScript code more efficient

#33
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 readable output.

Prepack looks like the same kind of optimizer – it could be a fun task to write an interpreter and see if this can turn it into a compiler/transpiler.

Re: Prepack helps make JavaScript code more efficient

#34

Earlier quoted context omitted.

Can you prove that any of the optimizations in your docs aren't already done by V8? I agree with the other commenters in this thread-- V8 likely does these already. You have an extraordinary claim, which requires extraordinary proof.

The whole point is to not let V8 do any job at all. V8 == user impacted. Compile time V8 == compiler impacted, users happy. It's like interpreting what you can during compile time, with caching capabilities. To speed up boot time and init time, not runtime per say.

This. By transforming and evaluating things that really could be constants beforehand, V8 has less to do when it goes to run the javascript.

Re: Prepack helps make JavaScript code more efficient

#36

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

Can you prove that any of the optimizations in your docs aren't already done by V8? I agree with the other commenters in this thread-- V8 likely does these already. You have an extraordinary claim, which requires extraordinary proof.

[deleted]

Re: Prepack helps make JavaScript code more efficient

#37
I just ran this on a huge JS project that has a quite intensive "initialization" stage (modules being registered, importing each other, etc.), and prepack basically pre-computed 90% of that, saving some 3k LOC. I had to replace all references to "window" with a fake global object that only existed within the outer (function() {..})() though (and move some other early stuff with side effects to the end of the initialization), to get it to make any optimizations at all.

Very impressive overall.

Re: Prepack helps make JavaScript code more efficient

#38
post #27

Earlier quoted context omitted.

The benefit of this would be at runtime when implementing interpreters: > experiment with JavaScript features by tweaking a JavaScript engine written in JavaScript, all hosted just in a browser; think of it as a "Babel VM", realizing new JavaScript features that cannot just be compiled away I've been playing with making toy languages inside of Javascript, and I believe there's lots of untapped power there. The paradi…

> Webpack is for dead fish. I haven't used webpack but I have used many similar tools, and I've heard a lot of praise for webpack. Can you elaborate on why you dislike webpack so much?

I'm using "dead fish" in the Bret Victor sense.[0] It's a static tool by nature. By the time you're in a live environment, webpack is gone.

[0] https://vimeo.com/64895205

Re: Prepack helps make JavaScript code more efficient

#39
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?

Reducing this initial work would really help startup time - especially on mobile. Consider that v8 etc are really fast only after the JIT kicks in after seeing repeated work: for time-to-first-significant-paint that's too late.

Re: Prepack helps make JavaScript code more efficient

#40
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?

A good resource to have info about this initiative: https://www.youtube.com/watch?v=xbZzahWakGs
Post reply on HN