News for hackers. Stuff that matters.
Re:WebAssembly: Mozilla Won by TekMol on Thursday June 01, 2017 @08:09AM (#14459574)
What are the main benefits of WebAssembly over asm.js?

I understand that asm.js was a subset of JavaScript that allowed the compiler to create faster code. For example because it could be sure that variable types do not change during runtime.

But what do we gain with WebAssembly? Faster download+compilation times? How much faster?

Re:WebAssembly: Mozilla Won by flohofwoe on Thursday June 01, 2017 @08:36AM (#14459709)
Here's a good overview from the emscripten author: https://hacks.mozilla.org/2017/03/why-webassembly-is-faster-...

TL;DR: much faster parsing over asm.js (10x to 20x faster), parsing should also use much less memory, 10%..20% smaller downloads (when comparing the compressed sizes, uncompressed WASM is several times smaller then asm.js), 64-bit integers (these have to be emulated on asm.js),

Re:WebAssembly: Mozilla Won by TekMol on Thursday June 01, 2017 @09:24AM (#14460014)

    much faster parsing
Isn't parsing super fast already? From my experiments, jquery seems to compile in a staggering 0.1ms.
Re:WebAssembly: Mozilla Won by flohofwoe on Thursday June 01, 2017 @10:55AM (#14460745)
I get 165ms for my 8-bit homecomputer emulator which is 534KB compressed asm.js (http://floooh.github.io/virtualkc/), and it seems the first call into the code takes another 500ms on Chrome (probably for JIT warmup). Bigger apps like UE4 or Unity demos are several times bigger and can take seconds to compile.
Re:WebAssembly: Mozilla Won by sqeaky on Thursday June 01, 2017 @04:26PM (#14464233)
If you are using ms as a unit you several orders of magnitudes too slow for many domains.

3d gaming comes to mind, most games have a tight budget of 16ms per frame, and at those speeds 0.1 ms is a real chunk of that. If I am going to download a new module in then try to load it the game shouldn't have to hiccup for that.

Re:WebAssembly: Mozilla Won by kibwen on Thursday June 01, 2017 @12:00PM (#14461422)
The partial intent of WASM is to write things orders of magnitude larger than jQuery. Whether or not it will ever be practical to ship e.g. a complete Photoshop clone in a browser remains to be seen, but if that's your goal then you do have to start worrying about things like parse time.
Re:WebAssembly: Mozilla Won by TekMol on Thursday June 01, 2017 @02:27PM (#14463007)
Why would the whole Photoshop be downloaded and compiled? I would expect a web app to only download the parts the I use. If I want to blur an image, I don't need the other gazillion filters for example.

And hey, even if photoshop is 1000 times bigger then jquery - that would still compile in one tenth of a second.

Re:WebAssembly: Mozilla Won by vanderZwan on Friday June 02, 2017 @03:46AM (#14468209)
Developers like you are why apps are slow when they don't need to be.

EDIT: Also, if you think 10%-20% smaller downloads aren't worth it, you're clearly not working at a CDN.

Re:WebAssembly: Mozilla Won by bzbarsky on Thursday June 01, 2017 @01:02PM (#14462119)
jQuery is tiny. https://code.jquery.com/jquery-3.2.1.js is 268KB; the minified version at https://code.jquery.com/jquery-3.2.1.min.js is 86KB, 30KB after gzip compression.

For asm.js/webassembly we're talking about source code sizes in the multiple megabytes range after gzip compression.

Re:WebAssembly: Mozilla Won by vanderZwan on Thursday June 01, 2017 @08:18AM (#14459623)
A lot.

There's a talk by Alex Danilo from Google IO 17 explaining it in detail.

Here, I'll link you directly to the part where he starts explaining the differences on a technical level:

https://www.youtube.com/watch?v=6v4E6oksar0&t=11m24s

Another part is that I suspect it makes maintaining a good JS compiler easier, because all of that asm.js code can be removed. I'm sure the browser vendors are happy about that.

Re:WebAssembly: Mozilla Won by TekMol on Thursday June 01, 2017 @08:28AM (#14459666)
I don't mean the technical differences. I mean the benefit. What will be the gain for the user of a web app?
Re:WebAssembly: Mozilla Won by Arcaten on Thursday June 01, 2017 @10:19AM (#14460420)
I'm not 100% sure about any of this (I've only listened to most of the video above), but I think the gist is that WebAssembly provides a compile target for applications, meaning you can pre-compile an application so that your source is downloaded essentially as machine code. Furthermore, that means your compilation can perform as many optimizations that you care for, because it's happening ahead of time (not on the user's machine).

Without WebAssembly, browser vendors have to strike a balance between optimizing the JS as much as possible (for increased performance), and running the script as soon as possible (so the user isn't waiting too long for execution to begin).

edit: Demo of this in-browser video editor charts a FPS difference between the JS and WebAssembly implementations. https://github.com/shamadee/web-dsp

Re:WebAssembly: Mozilla Won by flohofwoe on Thursday June 01, 2017 @08:37AM (#14459713)
Compressed download size is indeed only slightly smaller (mostly around 10%), but the parsing is much faster, even noticeable for fairly small demos.

(edit: replied to the wrong comment, apologies)

Re:WebAssembly: Mozilla Won by TekMol on Thursday June 01, 2017 @09:23AM (#14460008)
Is the "parsing" what is displayed as "compile script" in Chromes profiler? That seems to take almost zero time. For example jquery.min.js compiles in 0.1ms here.
Re:WebAssembly: Mozilla Won by livingparadox on Thursday June 01, 2017 @12:44PM (#14461908)
Libraries like jquery are not the target use case for WASM. Its intent is to make large applications viable on the web, like something you'd normally install on your computer.
Re:WebAssembly: Mozilla Won by paulddraper on Thursday June 01, 2017 @08:18AM (#14459622)
Yes, faster load times. Also, a more sensible target language.
Re:WebAssembly: Mozilla Won by TekMol on Thursday June 01, 2017 @08:28AM (#14459670)
How much faster? I would think gzip should even out most of the difference between a text based and a byte based code.
Re:WebAssembly: Mozilla Won by sanxiyn on Thursday June 01, 2017 @08:40AM (#14459726)
> I would think gzip should even out most of the difference between a text based and a byte based code.

You would be wrong then. Quoting Unity https://blogs.unity3d.com/2015/06/18/webgl-webassembly-and-f...

"Experimenting with a prototype WebAssembly format on a build of our AngryBots demo, we saw the size of the generated JavaScript code go from 19.0 MB of asm.js code (gzip-compressed to 4.1 MB) down to 6.3 MB of WebAssembly code (gzip-compressed to 3.0 MB). This means that the amount of data the browser needs to process gets reduced by 3.0x, and the compressed download size gets reduced by 1.4x."

So WebAssembly is 1.4x smaller, after gzip.