Wasm Builders 🧱

Deepanshu Arora
Deepanshu Arora

Posted on • Updated on

What makes WebAssembly Important? Use Cases of WebAssembly

Hey Folks,

Today we are going to have a discussion about some of the points that makes WebAssembly stand out and we will also discuss some of the Use cases of WebAssembly

1). The Difference between JavaScript and WebAssembly that makes WASM stand out:

Well, JavaScript is a dynamically typed language, so when you want to execute a piece of JavaScript code on a browser, essentially what will happen is that the Browser will fetch that JavaScript code from the Server and then it will start the process of Parsing by converting it into a Syntax Tree, then it will perform the Compilation Process by converting it into ByteCode, and then finally it will turn that into Machine Code.

So, there are a lot of steps involved while working with JavaScript on the Browser.

On the other hand, WebAssembly is not a Dynamic Language, it is a Static Language, so therefore the code that we will write, will automatically get compiled in advance.
So, therefore what you are really doing is pulling down the WebAssembly code and all that needs to happen is Code Optimisation at the Backend Part, that's it.
None of that Parsing Process, converting into Abstract Syntax Tree, all of that jazz, nothing takes place.

Now, the Second Point is Performance.
As we have seen in the Second Point that, with JavaScript
with all of that Transpilation Process taking place in between, it really takes a toll on the Performance of our Application.

With WebAssembly, we get rid of those intermediary stages of Transpilation, since we know that WASM is a static language,
so it saves us from that Compilation process, and thus helps in making our Applications Perform efficiently.

3). WebAssembly as a containerisation tool:
We already know that Docker has become a de-facto tool in the Development Space.
I can write my code, I can package it up and I know that whenever I hand over my Docker Image to you, we know it's going to work across any platform that you want.

The Problem with Docker in that Sense is that, it can get quite bloaty and by bloaty I mean that,

Let's suppose you are developing an Application, and you have to hand it over to the Testing team for testing it out. Now, it's not that you can directly hand over them the code, and then they can directly test it out.
You will also have to hand over the Dependencies that your application is using, any external libraries that your application is making use of in the form of a Docker Image

Now, in that sense, the Docker Image kind of becomes very big in size and not only that, you will have to make sure that the Infrastructure/Host Operating System, that the Docker Image will operate upon, is also appropriate.

Here, WebAssembly comes to our rescue and particularly the Sandbox Nature of WebAssembly can help us a lot here.

Let me explain it to you with the help of an Example:

Let's say I run an Infrastructure Company, suppose AWS, and if somebody comes up to me and hands over to me a piece of code, and says that
Can you please run it on your Infrastructure?

I will be highly skeptical at this moment. Why? Due to Security Concerns
What if, the piece of code contains some malware that can infect my Infrastructure Service and bring it down to a halt.

In this scenario, we can make use of WebAssembly.
Let's flip over this Scenario now

Now, if someone comes up to me and hands over me a
WebAssembly Module, and says me to run it on my Infrastructure. I'll do so without any doubt
Why? Due to the Sandbox Nature of WebAssembly

When someone hands over to me a WebAssembly Module, it's sandboxed.
You can think of it as Your piece of code is protected by a big square box and that Square Box acts as a protector of your Code and protector in the sense that, you get to control who has access to which piece of code and you can also constraint what specific modules you want to expose to the Outside World.

Thus, it improves the overall security of our Infrastructure.

4). Security Provided by the Sandboxed Nature of WebAssembly:

As we have discussed in the third point, the Sandbox nature of WebAssembly helps in improving the overall security of our Application and it can then be executed on any Infrastructure without any worries.

5). Docker vs WebAssembly - The Tug Of War:

As of now, Docker is the De-facto standard of providing containerisation to our Applications.
But I believe that anytime soon, WebAssembly can disrupt Docker. Why?

Because WebAssembly is sandboxed/containerised in itself, and thus we do not need to make any extra efforts to containerise our Application.
It is containerised/sandboxed by default.

The only thing that is still a work in progress with WebAssembly is the ability to interact with interfaces like the File System or Networking, and that's why a new Web Standard is being created which is known as WASI.

So, in a few years, we can definitely see WebAssembly challenging Docker as well.

Top comments (0)