What if you could write software once and make it work on all phones and computers?
Although this dream is still a long way off, steps are underway to transform the web browser into a universal computing platform capable of running even the most demanding applications.
The performance gains made possible by WebAssembly could one day see the heaviest of desktop software running in the web browser. WebAssembly is already being used to run the traditionally very demanding AutoCad software as a proof-of-concept demonstration.
“My dream is for every platform to become the web platform,” said Ashley Williams, systems engineer at Cloudflare and core Rust team member, at the Qcon London 2019 conference.
“I sincerely believe that the languages that will succeed in the future are those that can successfully target WebAssembly.”
How to get started with web assembly
WebAssembly (WASM) is not designed to be a programming language that humans write, although it can be viewed in a human-readable format. Rather, it is a compiler-generated language, based on code written by developers in a higher-level programming language.
Williams says that while in theory it’s possible to compile code written in any language in WASM, in reality you wouldn’t, with the best options currently compiled from the C, C++ and Rust programming languages, rather than from an interpreted language.
“One thing to note about WebAssembly is that it has no GC [garbage collector] and doesn’t have a runtime, you have to compile your runtime on top of your program when using an interpreted language,” she said.
Here are various tools developers can use to get started building and inspecting WebAssembly:
It is a backend for the LLVM compiler that generates WebAssembly from C, C++ and Rust and is used by Unity and Unreal game engines to generate web versions of games.
If you want to experiment with WebAssembly but don’t feel like learning Rust, C, or C++, there are compilers for higher-level languages.
“Generally, the WebAssembly that this produces isn’t necessarily the fastest or the smallest, but it works great and they’re doing a ton of great work there right now,” Williams says.
WebAssembly.Studio is a fork of Visual Studio Code and runs in the browser, allowing developers to inspect WASM as compiled from C, C++ and Rust.
The state of WebAssembly
SEE: Recruitment Kit: Python Developer (Tech Pro Research)
However, WebAssembly is not a finished product, with plenty of room for improvement in both its support, features, and performance.
“WebAssembly is young, what landed in the browser right now is definitely not a fully mature product,” says Williams, giving the example of garbage collection not yet implemented in WASM.
“If you started working with WebAssembly now, you’ll immediately ask ‘Why is my WASM so big and why isn’t it as fast as I want it to be?’.
Williams is optimistic about WebAssembly’s prospects, and with many looking to the future of the web as it celebrates its 30th anniversary, she has high hopes for how WebAssembly could transform the platform.
“I believe WebAssembly is going to lead to a future where the apps we build are very different from what we see people doing now.”