Most code running in a web browser runs much slower than native code (C/C++/ assembly), and it’s fine for many applications, but some others requiring higher performance like software video decoding would have to relies on native code, initially provided via browser plugins, but then Google introduced PNaCL (Portable Native Client) allowing to run native code on multiple targets (ARM, Intel, etc..) but in Chrome browser only, and now one of Chrome developers has explained that the community has moved to WebAssembly.
WebAssembly works just as well as PNaCl, and is already natively supported by Chrome and Firefox, with support added to preview versions of Microsoft Edge and Apple Safari browsers.Since it works just as well as PNaCL, and adoption of the later is low enough, Google decided to drop support for PNaCl in the Chrome browser in Q1 2018, except inside Chrome Apps and Extensions.
To get a feel for the performance and capabilities, you can find a few demos on WebAssembly website:
- A 3D Tank game based on Unity and WebGL
- An in-browser video editor applying various filter to a video or your webcam input in real-time.
The latter demo also compares the performance for the same task between WebAssembly and JavaScript, and in the screenshot below we can see WASM (short name for WebAssembly) is 80% faster than JS (JavaScript) while applying “Sunset” filter to the video in Firefox.
You’ll find the source code of the demo in Github. It’s still far from the performance of desktop app, but a big improvement over JavaScript.
If you’ve ever made a native web app relying on PNaCl, Google has provided a set of recommendation to help migration to WASM.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
It’s closer to what Java had hoped for. It’s roughly on a par with PNaCL, which is part of the reason Google’s dropping the one for the other. You get it with all the mainline browsers and it seems to run well enough between Linux, OSX, and Windows.