DEV Community

Cover image for What is WebAssembly and why it is a game changer?
Aryan Kaushik
Aryan Kaushik

Posted on • Originally published at wasm.builders

What is WebAssembly and why it is a game changer?

Wasm

WebAssembly (Wasm)

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications.

It is a new type of code that can be run in modern web browsers — it is a low-level assembly-like language with a compact binary format that runs with near-native performance and provides languages such as C/C++, C# and Rust with a compilation target so that they can run on the web.

WebAssembly is the third generation of Cloud Computing

Why it is a game changer?

Wasm brings the performance of native applications to the web in a way that's completely secure, yet enabling a full functionality expected from games, major applications and the entire spectrum of software you can run on a computer.

A tweet by Solomon Hykes, who is the Founder, Chief Technology Officer and Chief Architect of Docker.

Tweet

Some Benefits Of Wasm:

  1. It is very fast compared to JavaScript. Because, unlike JavaScript, when the browser runs it, there is no need to compile it since it is compiled at build time.
    Js/Wasm

    Developers right now be like:

  2. The security model of WebAssembly has two important goals:
    a. It protect users from buggy or malicious modules.
    b. It provide developers with useful primitives and mitigations for developing safe applications, within the constraints of (a).

  3. Wasm is super Light-weight.

  4. Wasm is Open-Source.

  5. Wasm works with all modern architectures, devices, and embedded systems, and doesn't favor one language, programming model, or object model over another. Additionally, it can be implemented on browsers, stand-alone systems, and in other environments.
    Adaptive

    Wasm has a co-operative nature.

Top Use Cases of Wasm:

  1. Greenfield/multiplatform development.
  2. Migrating from desktop-only to desktop and browser-based applications.
  3. Modernizing older apps written in Silverlight.
  4. Backward compatibility with older platforms.
  5. Progressive web apps.
  6. Mobile apps.
  7. Blockchain
  8. Gaming applications and many more!

Conclusion:

Currently Wasm is in its early days. Notwithstanding, many popular programming languages such as C, C++, Rust, Go and C# can already compile their source code into production ready Wasm code.
change

There are a number of impressive in-browser Wasm applications available today. But there are also Wasm compilers and runtimes that allow Wasm to run outside of the web browser; closer to the hardware.

It is inevitable that Wasm flavored compilers will become more and more integrated with the hardware. The aim is to develop highly efficient, portable, and reusable discrete units of functionality.

Wasm has all of the features of the next generation's service-oriented architecture (SOA). It can target specific outcomes, be self-contained, provide abstraction and be easily shared and consumed with other underlying units of functionality.

It is an exciting area for collaboration. The projects are under very heavy development, and we are destined to see great results.

References:

  1. https://medium.com/wasm/the-future-of-web-assembly-wasm-the-hardware-execution-revolution-4116eafa39a0
  2. https://thenewstack.io/what-is-webassembly-and-why-do-you-need-it/
  3. https://webassembly.org/

Do comment your thoughts and suggestions related to the blog and please share if you found it useful.

Discussion (22)

Collapse
joelbonetr profile image
JoelBonetR

Theoretically it's correct, but when you test WASM vs JS at runtime you'll see that in most cases JS performs better, maybe not the first run but as soon as JIT enters in the equation.

It has pros and cons, just like every tech you can play with. It's just that the pros are not enough to be a real game changer or to substitute JS.

Collapse
aryank21 profile image
Aryan Kaushik Author

Wasm is not there to compete with JS but infact to support each other. Executing things directly to the browser and much faster is the main usp. But if we talk about the comparison I would definitely agree with your point @joelbonetr .

Collapse
joelbonetr profile image
JoelBonetR • Edited on

Oh sorry, I was thinking about those compile/transpile to JS trend that show up a while ago.

You can see it in
Kotlin
C#
Emscripten, Emception to workaround it with C++...
The same way we can found multiple tools for many other languages.
There's even a project to convert PHP into JS, take a look

Some of them are well supported others don't (the same happens on WASM world).
There are two main ways to code with any language and run it into web, Compile/transpile it into JS or doing the same to WASM. (I say main because there are others out there).

Never had the need nor I wanted to take a try on coding in a different language and running it as JS or WASM after a conversion, it's something that I've as very very very low priority in my list but I'm curious about the marketshare or the real needs that it can cover IRL.

I also would like to know whether one approach is better than the other and what are the key points to decide. If you have this knowledge please share and tell me something through a message (or mention me), I'll be much appreciated 😄

Thread Thread
aryank21 profile image
Aryan Kaushik Author

Hi @joelbonetr . Though I'm also new to Wasm and don't have much development experience like you sir, but I'm very much facinated by wasm. Answering you question, Wasm is the 3rd generation of cloud computing, initially it was made to compile code on browser through its binary conversion property but Its more appealing property is towards server side for fast and securing processing work using Rust lang.

The purpose of my post was to aware the folks about wasm as many don't know its existence yet. It is currently in its pre famous phase as docker was in 2013.

Thread Thread
joelbonetr profile image
JoelBonetR

Ouch! Anyway remember about me when you decide to research more on that :D

I would love if you can expand the Use Cases and what benefits it can bring over alternatives more stablished on the market.

i.e. I code PWAs sometimes and never thought on using WASM on them.

It's always good to see younger people pushing knowledge on a tech or another and we oldies can also learn from you guys! I've not much knowledge on web3 (yet) nor in wasm so here's my follow to read your future posts :)

Thread Thread
aryank21 profile image
Aryan Kaushik Author • Edited on

yeah sure. Alot of stuff is coming up soon.

By the time please Check enarx.dev/ for a wonderful application used for security using TEEs.

Thanks for the suggestion sir!

Collapse
dhravya profile image
Dhravya

JavaScript has been around since soo long, wasm will get there too

Collapse
joelbonetr profile image
JoelBonetR

Or not, time will tell 😆

Collapse
aryank21 profile image
Aryan Kaushik Author • Edited on

yeah, absolutely agree with you pal @dhravya !

Collapse
aminmansuri profile image
hidden_dude

I like the idea of programming in one language. For example, using your favorite language on the backend and it generating a frontend as a compiled module. But using the same programming language for both.

Of course, people who program with NodeJS already have that. And it seems to have a lot of traction.

But debugging seems like it could be harder since Javascript is just there already for us.

But mostly it's an opportunity to take all our existing tech and tooling and start all over again. Hurray!

The software industry is obsessed with starting from scratch every few years.

Collapse
natescode profile image
Nathan Hedglin

Backend languages have better tooling, semantic versioning and huge ecosystems. It isn't about starting from scratch but getting that on frontend without dealing with the messy, insecure, unstable JavaScript ecosystem.

Collapse
aminmansuri profile image
hidden_dude

nevertheless.. every few years, the industry abandons some well established ecosystem and starts all over because some company convinces developers to switch to their tech

Thread Thread
natescode profile image
Nathan Hedglin

Example? I've done .NET for a decade and this hasn't happened. Maybe frontend.

Thread Thread
aminmansuri profile image
hidden_dude • Edited on

MS does it's own churning. ASP.Net -> Webforms -> .Net core

But plenty of examples. Just when Java was getting mature and usable, many switched to Rails or Node.JS or whatever that is much less proven and had some of the same early mistakes that early Java platforms had. Then everything became more "client / server" with React, Angular, Vue, etc..

I've seen the web wheel invented over and over again. And I'm not necessarily seeing much benefit in these tech changes. Some of the new stuff can be quite complex if not more complex that some of the earlier technologies.

Thread Thread
natescode profile image
Nathan Hedglin • Edited on

True. Agreed. That's the process of tech. Now RoR is ancient history and everything is JavaScript for better or worse.

Thread Thread
aminmansuri profile image
hidden_dude

But it is often churn for churn's sake. I believe that as the field matures we won't have such radical changes all the time, because abandoning so many platforms and frameworks and technologies only raises the cost over time and with very little benefit.

Unfortunately often the software industry seems to be more similar to the fashion industry than an engineering discipline. We don't technically need a new fad every couple of years. We only fall prey to large company interests when we do so.

Collapse
pinotattari profile image
Riccardo Bernardini • Edited on

A really interesting advantage of WASM is that there is on github a project to compile from Ada to WASM. In this way you can take advantage of the robustness and easiness of maintenance of Ada for your web development (no more "type promiscuity")

Oh, and do not forget the possibility of formal checking your code

Collapse
curiousdev profile image
CuriousDev

I think you should still add things which can be bad next to the ones which are good. For example if you are using Blazor (for C#) the initial load takes some time.

Collapse
aryank21 profile image
Aryan Kaushik Author

Thanks for the suggestion pal @curiousdev . I'll be posting new stuff very soon.

Collapse
jonrandy profile image
Jon Randy

New?? It was first released 5 years ago

Collapse
mmuller88 profile image
Martin Muller

Found it super useful and shared it in my communities. Do you might have GitHub references with cool usecases for WASMs?

Collapse
aryank21 profile image
Aryan Kaushik Author

Thanks for the appreciation @mmuller88.
You can visit madewithwebassembly.com/ for cool stuff