Live data from Hacker News

Prepack helps make JavaScript code more efficient

prepack.io

21–30 of 233 posts

Re: Prepack helps make JavaScript code more efficient

#21

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.

Re: Prepack helps make JavaScript code more efficient

#22

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…

I was right there a year or two ago developing portable native client things for my project, Linux on the Web (I was able to get vim and python running). Projects like that can pioneer a whole lot of new techniques and infrastructure that can be very easily applied to whatever technology is eventually going to win out.

@dennykane It's a shame seeing your comments are getting downvoted on here too. It really leaves me with a bad impression about how FB operates.

@rattray Even without access, downvotes don't just happen out of nowhere; you have to admit that this just looks too obvious to any reasonable person.

I'm curious what you thought was downvote-worthy of my original post pre-edit?

I get it, rules are rules, and this is a matter of principle.

Re: Prepack helps make JavaScript code more efficient

#23

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…

From the guidelines:

> Please resist commenting about being downvoted. It never does any good, and it makes boring reading.

https://news.ycombinator.com/newsguidelines.html

Disclaimer: I do not work at Facebook.

Re: Prepack helps make JavaScript code more efficient

#24
post #23

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…

From the guidelines: > Please resist commenting about being downvoted. It never does any good, and it makes boring reading. https://news.ycombinator.com/newsguidelines.html Disclaimer: I do not work at Facebook.

While I appreciate your vigilantism (given you aren't actually a moderator nor do you work at FB), the real elephant in the room is that HN really needs to a better solution for vote collusion. I am already familiar with the guidelines, and I usually follow this rule to a tee, but the optics here are damning.

What I'd really like to see is this discussion steered back on topic. It was originally interesting and productive. I like talking about web technologies; it is my passion.

Re: Prepack helps make JavaScript code more efficient

#25

Earlier quoted context omitted.

I was right there a year or two ago developing portable native client things for my project, Linux on the Web (I was able to get vim and python running). Projects like that can pioneer a whole lot of new techniques and infrastructure that can be very easily applied to whatever technology is eventually going to win out.

@dennykane It's a shame seeing your comments are getting downvoted on here too. It really leaves me with a bad impression about how FB operates. @rattray Even without access, downvotes don't just happen out of nowhere; you have to admit that this just looks too obvious to any reasonable person. I'm curious what you thought was downvote-worthy of my original post pre-edit? I get it, rules are rules, and this is a matt…

Unless you have access to the HN database, there isn't a way to know the source of downvotes.

This kind of commentary is not welcome on HN.

Re: Prepack helps make JavaScript code more efficient

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

One of the examples contains a function to calculate the nth fibonacci number, and then a variable uses the result of that function.

Prepack doesn't seem to optimize for V8 in particular; rather, it just does some calculations ahead of time. V8 cannot possibly do these optimizations. How would it know that e.g. my code tries to calculate PI to 1000 decimals? That's where prepack steps in and calculates PI to 1000 decimals for you during your build-step, so that the JS you ship doesn't have to do that calculation.

Re: Prepack helps make JavaScript code more efficient

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

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 paradigm battles don't have to be: we can run all sorts of paradigms in the same VM, with data executing as code. This means that you can decompose expressions to see where they came from (e.g. the steps in a state machine that yielded an evaluation result). If you believe (as I do) that invisibility-by-default is one of the greatest pain points in the history of computing, then these sorts of approaches are essential.

The problem with doing that is that some things will be slower than they would in "native" JS. I've been proceeding anyway and thinking that could be dealt with later. So I'm bookmarking this, because it attacks that exact problem: runtime-compilation of generated AST's.

The name is a little unfortunate, in that respect, though, especially since it will make people think it's a build tool like Webpack. Webpack is for dead fish. This is incomparably more powerful.

edit so to answer your original question, this would piggyback on the optimizations of the VM (V8 or SpiderMonkey, or whatever), taking for granted that JS which is not needlessly verbose (as generated code must sometimes be), can be run nearly optimally.

Re: Prepack helps make JavaScript code more efficient

#29

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.

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.

Re: Prepack helps make JavaScript code more efficient

#30
post #27
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?

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?

Post reply on HN