What if you could write software once and have it run on every phone and computer?
While that dream may still be a long way from realization, moves are afoot to turn the web browser into a universal computing platform, capable of running even the most-demanding apps.
The performance gains WebAssembly makes possible could one day see the heaviest of desktop software running in the web browser. WebAssembly is already being used to get the traditionally very taxing AutoCad software up and running as a proof-of-concept demo.
“My dream is that every platform will become the web platform,” Ashley Williams, systems engineer at Cloudflare and member of the Rust core team, told the Qcon London 2019 conference.
“I genuinely believe the languages that will succeed in the future are the ones that are going to be able to target WebAssembly successfully.”
How to get started with Web Assembly
WebAssembly (WASM) isn’t designed to be a programming language that humans write, even if it can be viewed in a human-readable format. Rather it’s a language that is generated by a compiler, based on code written by developers in a higher-level programming language.
Williams say that while in theory it’s possible to compile code written in any language into WASM, in reality you wouldn’t want to, with the best options currently being compiling from the C, C++ and Rust programming languages, rather than from an interpreted language.
“A thing to note about WebAssembly is because it doesn’t have a GC [garbage collector] and doesn’t have a runtime, you must compile your runtime in addition to your program when using an interpreted language,” she said.
Here are various tools developers can use to start generating and inspecting WebAssembly:
This is a backend for the LLVM compiler that generates WebAssembly from C, C++ and Rust and that is used by the Unity and Unreal game engines to generate web-versions of games.
If you want to experiment with WebAssembly but don’t fancy learning Rust, C or C++, there are compilers for higher-level languages.
“In general, the WebAssembly this produces is not necessarily the fastest or the smallest but it works very well and they are doing a ton of great work on it right now,” says Williams.
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: Hiring kit: Python developer (Tech Pro Research)
However, WebAssembly isn’t a finished product, with plenty of room for improvement in both its support, features, and performance.
“WebAssembly is young, what has landed in the browser right now is certainly not a fully mature product,” says Williams, giving the example of garbage collection not being implemented in WASM as yet.
“If you’ve started working with WebAssembly now, you’ll immediately going to go ‘Why is my WASM so big and why is it not as fast as I want it to be?’.
Williams is bullish on the prospects for WebAssembly, and with many people looking to the future of the web as it celebrates its 30th birthday, she has high hopes for how WebAssembly might transform the platform.
“I believe WebAssembly is going to lead to a future where the applications we’re going to be making are very different from what we’re seeing people make now.”