Write Once for Web Assembly, Run On Everything

If you ever heard the phrase 'write once and run everywhere' then you know there's definitely difficulties in writing for multi architectures. Web Assembly may be the actual reality of running everywhere with one target.

Anyone who has written software for multiple architectures know it is never plainly, “compile for your target and it will just work.” The reality is, there are always some exception you must take account for. It makes sense why. Any difference in architecture means entirely different ISA or even revision. Which translates to different rules for memory, instruction sets available, operational cost analyst, and much more. So taking your C code and just compiling it for AArch64 wouldn't cut it.

The same can be said for a process virtual machine used in Java. In theory, using the virtual machine meant you would target only the virtual machine and not have have to worry about the architecture the virtual machine would run under. However, in practice it has not been the case. Almost always, you still have to be aware of the architecture you are targeting due to bound operational differences like the list given prior.

This is where Web Assembly (wasm) is starting to shine. Wasm initially started as a way to run bytecode faster on the browser. Allowing for running heavier logic not possible with ECMAScript. To accomplish this, wasm was set up to use a process virtual machine like the JVM, but that targets a very specific ISA. So the VM can execute the ISA differently, but still requires to be able to run without modification. This results in the bytecode having exactly the same assembly definition regardless of physical architecture. Which means the VM can execute the bytecode on how it would be better optimized for the architecture. Giving way to focusing on only writing for a single target and only optimizing for that target. Leaving the VM that will run the wasm binary to take care of the heavy lifting as it should.

Right now, the prospect of wasm use in running on everything is not there just yet. It was only December 2019 the wasm specification was even agreed upon by W3C. Yet, you can see the ability starting to creep up. Projects like WASI from Mozilla for portability and security, Krustlet for kubelet running wasm instead of containers on kubernetes, and Cloudflare's Workers for running on the edge with GEO distribution using wasm.

I'm excited to see web assembly's potential. Its progress may result in a saner stack. Maybe even only requiring one runtime and nothing else, web assembly.

#Day14 #100DaysToOffload #Wasm #WebAssembly