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.
Some Benefits Of Wasm:
-
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.
Developers right now be like:
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).Wasm is super Light-weight.
Wasm is Open-Source.
-
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.
Wasm has a co-operative nature.
Top Use Cases of Wasm:
- Greenfield/multiplatform development.
- Migrating from desktop-only to desktop and browser-based applications.
- Modernizing older apps written in Silverlight.
- Backward compatibility with older platforms.
- Progressive web apps.
- Mobile apps.
- Blockchain
- 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.
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:
- https://medium.com/wasm/the-future-of-web-assembly-wasm-the-hardware-execution-revolution-4116eafa39a0
- https://thenewstack.io/what-is-webassembly-and-why-do-you-need-it/
- https://webassembly.org/
Do comment your thoughts and suggestions related to the blog and please share if you found it useful.
Top comments (19)
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.
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 .
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 toWASM
. (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 😄
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.
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 :)
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!
JavaScript has been around since soo long, wasm will get there too
Or not, time will tell 😆
yeah, absolutely agree with you pal @dhravya !
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.
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
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.
Thanks for the suggestion pal @curiousdev . I'll be posting new stuff very soon.
New?? It was first released 5 years ago
Found it super useful and shared it in my communities. Do you might have GitHub references with cool usecases for WASMs?
Thanks for the appreciation @mmuller88.
You can visit madewithwebassembly.com/ for cool stuff
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.
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.
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