Re:Experimental support for WebAssembly in V8
by gliptic on Tuesday March 15, 2016 @12:14PM
(#11290726)
Compiling JavaScript into WASM is most likely not going to result in better performance unless you make an extremely good static optimizing compiler, and probably not even then. It's very hard to do the kind of optimizations that JIT compilers do ahead of time, in one single static binary.
Re:Experimental support for WebAssembly in V8
by AgentME on Tuesday March 15, 2016 @01:42PM
(#11291475)
Agreed. The entire point of asm.js (which WASM is currently just a compact encoding of) is that it's a simpler subset of javascript that's easier to optimize. If you could transform arbitrary Javascript into asm.js efficiently, then similarly you could also apply asm.js's optimizations to arbitrary Javascript, and the whole asm.js part would be pointless.
Re:Experimental support for WebAssembly in V8
by xigency on Tuesday March 15, 2016 @12:58PM
(#11291077)
Pull the developers (or poll them) from V8 and ask them what they think.
All of the "just-in-time" optimizations can be done ahead of time. Which saves [that much run time x that many users] in computer time.
Re:Experimental support for WebAssembly in V8
by jfbastien on Tuesday March 15, 2016 @01:03PM
(#11291121)
Everyone on V8 would disagree with you :-)
Type tracing in particular is the big win, and with a dynamic languages you simply can't prove enough to do it ahead of time. There's also startup time that you're paying with AOT and avoiding with JIT.
Re:Experimental support for WebAssembly in V8
by mason55 on Tuesday March 15, 2016 @01:13PM
(#11291197)
> Type tracing in particular is the big win, and with a dynamic languages you simply can't prove enough to do it ahead of time.
The post I originally replied to brought this up in the context of TypeScript with the aside that TypeScript is basically JavaScript. Do you think that using TypeScript's static typing and compiling to wasm could/would be faster than JIT-compiled JavaScript?
Similar to asking why would you want to run JavaScript on the server?
There's something to be said for having your code in a single language. People can move to different parts of the project more easily and if you need to run the code in multiple places then you can do so with (mostly) a single codebase.
The real question is why WOULDN'T you compile all your JavaScript to wasm assuming the build process is easy enough. For complex site that already have a build pipeline I don't see any reason to publish minified JavaScript instead of just building it all into wasm for performance reasons (assuming mature debugging tools of course). The only question I'd have is whether you get that much gain by going from JavaScript to wasm or if the browser's JIT compiler can do a good enough job.