I have been reading about asm.js and WebAssembly recently:
http://ejohn.org/blog/asmjs-javascript-compile-target/
https://brendaneich.com/2015/06/from-asm-js-to-webassembly/
I am still confused about a few things:
js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications.
Be readable and debuggable — WebAssembly is a low-level assembly language, but it does have a human-readable text format (the specification for which is still being finalized) that allows code to be written, viewed, and debugged by hand.
In one recent study, a developer discovered Wasm is faster than JavaScript across three desktop browsers on desktop computers and smartphones. Wasm is 1.15-1.67 times faster than JavaScript on Google Chrome on a desktop. Wasm is 1.95-11.71 times faster than JavaScript on Firefox on a desktop.
Still, WebAssembly will allow developers to move intensive UI-blocking work outside of the browser. It will result in better performing web applications that run on newer and older hardware more smoothly. So, to answer the question (if the answer wasn't obvious enough), WebAssembly will not replace Javascript.
asm.js is a subset of JS with "highly optimizable" instructions. Basically you can declare the type (int, float) and the js engine (in the browsers but also the node.js one) will execute the instructions faster. It has benefits if your app does a lot of calculation or graphic if used together with WebGL.
web assembly is a binary format for JS, all JS, not only asm.js. It's not a bytecode, it's a binary encoding of the AST that the parser calculates. It has 2 big benefits:
We already can write code for browsers that isn't JS: EMSCripten can compile c++ code in JS code. Other transcompiler are already available to compile your code into JS. Using asm.js that code can run faster when it does math. Using web assembly that code will be more compact and the browser will be able to process it faster (because it will be able to skip the parsing). You won't have a new plugin to load like DirectX, JavaApplets, Flash or Silverlight because everything will run in the JS sandbox.
Is asm.js code compiled in time and run? Compiled into what?
asm.js is regular javascript code, and is compiled into bytecode by the JS interpreter as always. However, an interpreter with asm support is supposed to do ahead-of-time compilation, and possibly to generate more efficient code representation because of the static typing. See http://asmjs.org/ for details.
what are the differences between asm and wasm (other than text vs binary)?
None, for now. wasm is supposed to be backwards-compatible, compilable to asm (which again is executable as normal JS). It might however be extended with more features in the future as support for it grows.
What does this mean for other scripting languages, running in the browser?
The latter, rather, as Python still needs to be interpreted. Scripting languages that don't need an interpreter can of course be directly compiled to (w)asm, given that there is a compiler (chain) that supports it as a target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With