WebAssembly

In today’s age, most of the code that runs on the browsers are developed using Javascript. However, when JS was introduced to the world, it wasn’t meant or envisaged to take over the web world, so to say. Javascript, inherently, doesn’t perform well as compared to a native application developed using other high-level languages such as C/C++. WebAssembly is a way to run native applications in web browsers to get similar performance.

What is WebAssembly?

WebAssembly is a binary instruction format to enable near-native performance for web applications. Applications written in native languages could be compiled to this new format, also known as “wasm“. Web browsers – all major four browsers – Mozilla firefox, chrome, safari, and edge – support this format. These browsers can validate, optimize and run this low-level machine ready code in wasm format, thereby producing near-native performance even for web applications.

WebAssembly flow [Source: https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts]
WebAssembly flow [Source: https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts]
Until now, applications needed some kind of a plug-in to achieve higher performance in web browsers. With this new format, there will be no dependency on the plug-ins. Browser support is expected to grow further since the results are encouraging and big four are already on-boarded. This is also being developed as part of a W3C working group.

Important point is that Javascript and WASM can work together and are not really competitors. WebAssembly provides APIs so that WASM code can be loaded via Javascript and executed.

Why WebAssembly?

In a nutshell, if you are looking for higher performance on the web applications, WebAssembly would be the way forward. Javascript is not a statically typed language and hence even simple operations such as additions tend to be CPU consuming [watch this video]. This problem gets solved when you use statically typed languages for your web applications via WebAssembly. This also opens up the possibility of porting several games and applications to the web and still achieve the same or similar performance.

Related Links

Related Keywords

JavaScript, TypeScript, Transpiler, ECMAScript, Programming, Framework, Google, Firefox, Chrome, Safari, Microsoft Edge

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.