|WebAssembly Has Mozilla, Microsoft,Apple and Google Backing It|
|Written by Ian Elliot|
|Thursday, 18 June 2015|
The point is that we could at any point have simply opted to build a virtual machine into the standard web browser. It might even have been the JVM making all Java related languages instantly run-able in the browser. But despite Google's best efforts to get PNaCL a byte code interpreter accepted it has been mostly ignored.
Web assembler (or wasm) is a binary byte code that has all of the primitive data types, integers of various sizes and floats and a range of simple operators and flow of control structures. It is binary but the byte code has such a close affinity to a text representation that you can swap between them without a loss of information. This will be good news to anyone wanting to view the code as part of the browsers source view but not so good news for any programmer sick of having to use obfuscation where a good binary code would be enough protection.
The basic structure of the byte code is to make use of ASTs - Abstract Syntax Trees - to code up expressions. An AST is simply a tree consisting of operators and operands and once you have an AST it is very quick for a VM to evaluate it simply by walking the tree. It also means you can use a standard compiler front end like LLVM to spit out an AST from your favurite language - mostly C/C++ at the moment. The binary representation is up to 20 times faster to parse than asm.js and it creates smaller files. This should speed up load times as well as run times.
Wasm is good news and as when it arrives we will be even closer to running at native code speeds in the browser, but it is worth noting that viewed as an assembler wasm is still a fairly high level construct.
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: email@example.com
|Last Updated ( Friday, 19 June 2015 )|