Web Assembly – Low level programming for browsers

Learn from our software experts from the HAT everything you should know about Web Assembly, a programming language that solves some Java’s problems.

Web Assembly

Anyone that develops or designs for the Web is familiar with JavaScript. JavaScript is the gateway to any kind of interactivity that can be activated within the user terminal from a simple drop-down menu to complex applications such as vector graphics editors, music production studios and multiplayer games.

The power and popularity of JavaScript is its versatility to run on any device that a web browser can interpret, that is, virtually anywhere. But this strength, which is its great capacity for abstraction, is also a major constraint when talking about the performance because of the need to interpret all the code. For this reason Web Assembly was born.

Also called “WASM”, Web Assembly is a programming language that comes to solve this problem. Its goal is to compile code from C and C ++, achieving an interpretation and execution much faster than JavaScript without losing the independence from the platform in which it runs. This is because Apple, Google, Microsoft and Mozilla are designing it altogether (companies with 97% of the browsers market covered).

This involves a number of features that are not minor:

  • It will open an access to low-level programming for those programmers who want to use it. No objects or dynamic association or garbage collectors programming.
  • The resulting code is binary, which is much smaller than the source code and much faster to run. You can also convert text format so that you can read.
  • Binary modules can be integrated with traditional JavaScript natively without supplements.
  • Some features close to the hardware (such as threads and microcontrollers) will be available for use.
  • Graphic engines like Unreal Engine and other applications made ​​in C or C ++ may be gather in WebAssembly and be available on any platform. And they will have a speed of compilation and execution from 4 to 20 times faster comparing to their counterparts in JavaScript.

The appearance of WebAssembly also hopes to provide a standard solution to this problem that had already attempted to solve from several approaches:

  • If additional language features are needed (being strongly typed), a new one is created to operate at a higher level. For example typescript, Dart or CoffeeScript. The problem is that the result always ends up becoming JavaScript code.
  • If you are looking for performance, some features of JavaScript are limited (as in the case of Asm.js in Firefox) or a specific client browser is created, capable of running native processor instructions (ActiveX in IE, Google Chrome NaCl is created). The last one is problematic because it harms the visibility of the source code that is common on the Web.

Asm.js case is interesting, because it is a subset of JavaScript instructions that only uses arrangements, assignments, operations and numeric data types. In this way, no extra memory is allocated, no garbage and no permanent types. It is useful to visualize the next Asm.js code because it may be very similar to how it will WebAssembly:

For those who know the game “Angry bots” (the template Unity game) and want to try it in your browser, you can do it in https://webassembly.github.io/demo/. You must have the beta version of browsers: Firefox Nightly or Chrome Canary and follow the instructions to activate WebAssembly. Activating WebAssembly doesn’t compromise safety; the runtime environment will always be encapsulated and it will adapt to the same license policies from the browser that contains it.

<strong>Web Assembly has no release date, and it will not replace JavaScript</strong>, but it will enrich the Web experience with other applications that don’t have yet their niche because they are very difficult to compile to the current language: video editors, P2P applications, image recognition, augmented reality, low-latency, CAD applications, visualization and scientific simulation, emulation platforms, POSIX, remote desktops, VPN and applications with heavy clients.

All these and more will see the light within a browser when Web Assembly completes its development and is available for use, defining once again Internet’s course.


Share this articleShare on LinkedInTweet about this on TwitterShare on FacebookShare on Google+Email this to someone
Go Back