DEV Community

loading...

WebAssembly May Be The Universal Executable Format We've Been Looking For

sr229 profile image Ayane Satomi ใƒป4 min read

We all have dreams of having to write once for a specific API and it'll just work on all platforms. But some companies and vendors have their own priorities, though we may already have a format vendors finally agreeing to implement: and that's WebAssembly.

The History of WORE (Write Once, Run Everywhere)

WORE, otherwise known as "Write Once, Run Everywhere" was a slogan by the late Sun Microsystem to pitch the advantage of their Java programming language. The idea was basically this: We just write one common language, one common API, and it'll just work for every platform in existence. There was one problem though...

Java, to allow this relies on what we call a process virtual machine - in this case, JVM. However, JVM wasn't one implementation: it has multiple implementations (every Java developer knows this by heart that there's multiple JVMs to target, especially during Java's early days) - and so the WORE paradigm became a lie because the idea was to be able to write and debug on one API - but since behavior differences on each JVM basically threw this paradigm out of the window. We were back on the laden C/C++ days of writing platform-specific code, in this case, JVM runtime-specific code.

This didn't stop everyone trying to ride on the WORE paradigm however. Microsoft also tried with C# and their .NET Framework, which were mockingly called a "Java copycat" (because it kinda was on its early days, nowadays it's basically it's own thing), again like Java, it wasn't exactly living to it's purpose as well, .NET before was locked to Microsoft's own platform: Windows. This means if you want to write C# you need to use a interpreter like Mono. It will take them a whole decade to finally realize that to be able for .NET to have more market share (which during around the past 5 years where Linux is now the money printer for the world's leading industries), it needs to be open and cross-platform, and so .NET Core existed: and ironically, .NET Core was so good it's going to replace it's older brother, .NET Framework, to become .NET 5.0.

However, it seems the idea has kinda WORE out, and these runtimes became more of a general purpose instead of being this magical "Universal runtime" that you can just code once and it works: however from their design it kinda is. Moreover, these runtimes and languages were not exactly open languages from the start: C# itself only had one ECMA Specification, and that was it. Java had it's own thing (JLS) but I don't think I saw any active participation on it regarding the standardization.

Enter WebAssembly

If you followed my previous posts about WebAssembly, it was obvious the WebAssembly standard was basically intended for the web. However, as more developers became interested with this "universal" format - it became clear it was going to become the next big thing: A true "Write Once, Run Everywhere" format. And the best part about WebAssembly is that it's not tied to any company. It's a open standard designed by the W3C - the governing body for Web standards, so that means WASM is always assured a vendor-neutral experience regarding the platform.

You know what this means? People started implementing WebAssembly as a userspace runtime instead of being constrained on the confines of a web browser - so it was clear it's becoming something else.

The advantages of WebAssembly

WebAssembly may be a web-first format but it's advantages are certainly what we can call "desktop-grade". Here's a few:

  • Safe by default - WebAssembly is a stack-based VM that enforces strict sandboxing and memory safety. You're in the safe confines of WebAssembly always and you won't even need to do unsafe operations at all.

  • More control on the memory - WebAssembly builds upon the open source LLVM project: so any low level language that allows direct memory control can target WASM. This allows even more efficient WASM code.

  • Every LLVM language just works - Rust? Go? C? WebAssembly got you covered. Just like JVM and CLR, they implement a common API that you can refer just like a normal module. So remember this mantra for WebAssembly development: if it works on LLVM it works on WebAssembly.

The current state of userspace WebAssembly

Right now, we have what we call Wasmer which is essentialy the quintessential all-in-one kit to do anything WebAssembly: it includes a runtime, a package manager: basically everything for development. They even have a Kernel-based runtime which allows WebAssembly within the Linux kernel.

As for Microsoft: I haven't heard much but they're willing to support WebAssembly within Edge but I have a hunch they may also see the potential of WebAssembly as a runtime choice for Windows development so we might have a chance of getting WebAssembly on Windows.

Conclusion

WebAssembly is still in it's early days, but it does show a lot of promise. It has gained a large following and a fanbase that is willing to implement it on any platform imaginable. The best part about the standard is that everyone agreed to it - so that means you really have a true WORE runtime for once.

Due to the increased interest with WebAssembly being ran outside of its original specification, the question now stands: "Is it going to still be named WebAssembly in the near future?" Time will tell, but it's certainly the most exciting times in the web development that we're no longer just developing for the web anymore.

So whatever happens in the future, WebAssembly has definitely earned its mark and may truly evolve into something else more than just a web-based runtime.

Discussion (0)

pic
Editor guide