Live data from Hacker News

Prepack helps make JavaScript code more efficient

prepack.io

121–130 of 233 posts

Re: Prepack helps make JavaScript code more efficient

#121
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

Thanks!

Re: Prepack helps make JavaScript code more efficient

#122
post #79

I hate to bring this up whenever I see a Facebook project, but it still warrants saying: the patents clause in this project, like in others including React, is too broad. I really wish they made a "version 3" that limited the scope of the revocation to patents pertaining to the software in question, e.g. Prepack, React, rather than a blanket statement that covers any patent assertion against Facebook. While I suppose…

Previously, when absurd patents first (see edit) as far as our sight alerted us, the history is of course very long -- we placed all our public facing work in a arms length company. Down to the company website.

I never imagined, then (being late 90s) that a brochureware dot com might require liability boxing legally, but I never imagined whole libraries like React being adopted so wholesale, so seemingly blindly (if not blindly, why has nobody posted the outcome of due diligence? A blog topic I'd like the attention from.) and so trivially as, yes, our brochureware site just could get used against us. Our early clients expressed concern, first: we had to pass their IP hygiene checks. We adopted those, right away. Such stringencies are why many entities I've worked with, have no or empty websites, but old old registration dates on their dot coms...

* edit, missing dependant clause I guess was strongly implied, but it's about when we first saw frivolous, vexatious patent suits aiming at the front doors of random web presences condition there might be money and weak legal... I mistakenly imagined that to be spurious, not it would develop into a psedo- legitimate"industry".

A moral thought: Maybe if we sold fewer reinvented wheels, there might be less temptation for parasitic behaviour to organize itself, like patent trolling has done? I can certainly plead the fifth to wheel reinvention, most days I write code ... (edit last) my meaning behind this is that I frequently have found highly objectionable behaviour being justified by the calling out of perceived comparable poor behaviour. Now I don't go sp far to condemn e.g. the js library crowd or any of anything for that matter, it's too young to blame yet. But with the first generation who grew up exposed to computing comparable to modernity, now maturing, its natural the industry will mature also. I see the brake on maturation more as lots of great new tools, than moral or human lacking. But self appointed grown ups trying to bully tax us, might be the natural parasitic compliment to this rich novel ecosystem. We don't need no random adults to appoint to combat this, we just need to question and talk about what is sane to accept. There's too much over reaching paternalism propping up big business assumptions, right now.

Re: Prepack helps make JavaScript code more efficient

#123
post #114

This has promise but still needs more work. I added one line to their 9 line demo ( https://prepack.io/repl.html ) and it ballooned to 1400+ lines of junk: (function() { function fib(x) { y = Date.now(); // the useless line I added return x 42) x = fib(10); global.result = x; })(); I understand Date might not be acceptable for inner loops but a lot of my code that deals with scheduling would benefit significantly if…

It's not a useless line, because prepack has no idea what Date.now() does (there are no guarantees in javascript that it hasn't been replaced with another function). It might mutate some global state somewhere, so the resulting code needs to call Date.now() as often as it would've if fib(10) was called. Basically the output is the unrolled version of the recursion, which cuts down on function invocation (comparatively expensive in dynamic languages).

If you replaced the line with say: `var y = 4;` you'll notice that it has been optimized out.

Re: Prepack helps make JavaScript code more efficient

#124
post #112

This is cool–it's worth mentioning that you might be trading runtime performance for bundle size though, here's a contrived example to demonstrate: http://i.imgur.com/38CR3Ws.jpg

Keep in mind that everything is gzipped nowadays, so it may not make a big difference in network usage. Although it is still likely to cause some memory overhead

No, I have done and pubpished an article about how gzip works with JS and the result will compress pretty well. Not better than the code, but I would guess within the same order of magnitude.

Re: Prepack helps make JavaScript code more efficient

#125

Awesome project, the performance gains seem real, but why wouldn't these optimizations be happening at the javascript JIT level in the vm? (serious question) React / javascript programming, is the most complex environment I've ever dug into, and it's only getting more complex. create-react-app is great for hiding that complexity until you need to do something it doesn't support and then it's like gasping for air in a…

download js -> run through JIT compiler -> execute

vs.

run through JIT compiler -> download js -> execute

Whatever overhead the JIT compiler adds will be latency for the user.

Re: Prepack helps make JavaScript code more efficient

#126

Awesome project, the performance gains seem real, but why wouldn't these optimizations be happening at the javascript JIT level in the vm? (serious question) React / javascript programming, is the most complex environment I've ever dug into, and it's only getting more complex. create-react-app is great for hiding that complexity until you need to do something it doesn't support and then it's like gasping for air in a…

Because they'd have to happen every time for every user, so there'd be no real gain there. It has to happen as the code is published in .min.

Re: Prepack helps make JavaScript code more efficient

#127
Coming from a non-CS background, I've always wondered why you can't "convert" code from one framework or paradigm to another. For instance, converting a project from jQuery to React. If you can define the outputs, why can't you redefine the inputs? That's what it seems like this project does... I suppose converting frameworks would be a few orders of magnitudes harder though.

Re: Prepack helps make JavaScript code more efficient

#128

Earlier quoted context omitted.

And the weakness, legally speaking, of implicit patent grants was one major reason why GPL moved from v2 to v3. Explicit is much much safer for users of software, legally speaking, because implicit grants have to be settled in court . If you really want to go to court over it, and can afford it, then you may be right. Want to test that against Facebook? They reasoned (quite rightly) that it would be silly to suggest…

I can read and understand the MIT or BSD licenses. That is an extremely valuable property of a contract to me. Both clearly state that I may modify and distribute the software. Adding a huge pile of details about what exactly that means makes me rather nervous. I am not a lawyer, and I worry that somewhere in that huge pile of explicitness that there are consequences that I don't anticipate, and that don't match up w…

That "pile of explicitness" replaces a pile of implicitness wrapped up in case law and statutes that are relevant to any case that arises but you don't know about. Because what you read in a license is not what matters--how do you know you understand them as they will be interpreted by a court of law? What do you not know that you do not know?

(This is why companies have legal teams.)

Re: Prepack helps make JavaScript code more efficient

#129

Coming from a non-CS background, I've always wondered why you can't "convert" code from one framework or paradigm to another. For instance, converting a project from jQuery to React. If you can define the outputs, why can't you redefine the inputs? That's what it seems like this project does... I suppose converting frameworks would be a few orders of magnitudes harder though.

Can you turn lead in gold? Maybe using nuclear transmutation. But the potential cost of the process seems higher than the benefits.

Can you convert a code base to React from Angular? Maybe, but the effort to write this converter is higher than rewriting the code base.

Re: Prepack helps make JavaScript code more efficient

#130

This is cool–it's worth mentioning that you might be trading runtime performance for bundle size though, here's a contrived example to demonstrate: http://i.imgur.com/38CR3Ws.jpg

It's in beta stage, so that's not unexpected. They can easily add a cost function later that considers multiple parameters.
Post reply on HN