e-Why, What & How · 2017-03-29

All you wanted to know about ‘WebAssembly’ – the new buzzword in browser development

1215133

Image from Iconfinder

This next generation language for the Web greatly increases the performance of the ubiquitous HTML & JavaScript when developing for a browser environment. Open source & backed by all major browser makers, it allows programmers to provide a native app-like experience across major platforms & browsers. 

There’s much buzz Online around WebAssembly or wasm, as it is called. You can use standard C & C++ compilers on Linux, Windows or Mac to generate load-time-efficient binary format that gets executed on browsers at native speeds. The wasm “stack machine” uses common hardware capabilities that are available on most platforms.

WebAssembly is backwards compatible & can also run alongside JavaScript, & can be called out of & into JavaScript contexts, being able to use the same Web APIs to access browser functionality. It’s safe to use since it can use sandboxed JavaScript virtual machines.

As its name implies, wasm can be thought of as an assembly language for browsers. It allows for the use of the much lower level C/C++ languages, so developers can forgo the complex & resource hungry JavaScript environment. It has already been proven to be able to execute resource-hogging video games quickly in browsers, & to greatly reduce download times.

The project was started back in June 2015 & has since been adopted by Microsoft, Apple, Google & Mozilla for their lineup of browsers. It’s now being worked on by a W3C working group to make it a standard Web technology. Eric Elliott, the founder of the project & senior developers at some of these major companies claim that, even though the tech still isn’t mature, browser-based wasm apps can “recreate as much as 80% of the performance of a native application, on a mobile device or on a desktop/laptop.”

To get started with wasm, you’ll have to compile the Emscripten LLVM-to-JavaScript Compiler from source. To do this you need the Git distributed version control system, the Cmake software manager, a native host system compiler (GCC on Linux, Xcode on OS X or Visual Studio on Windows) & Python.

Then you compile Emscripten from source using the Emscripten SDK & enter the compiler environment using a provided shell script. A binary executable will be generated that can be run from your browser within a JavaScript wrapper, which can also be generated.

…& if you wanna know what all this means for JavaScript, click here.

 

 

•Share This•

Click here to opt-out of Google Analytics