Isn't it ironic? On one hand, you've kept hearing/reading have all this talk about WebAssembly and what a game changer for the web it is. Yet, on the other hand, few developers are actually leveraging it in their projects? There's all this hype around the new way of assembling code in any language and running it right in the web browser, yet everyone's still a bit hesitant about using it. Are there any truly compelling use cases for WebAssembly?

Why would you use it? What are its primary use cases?

For now, what you do know are its “selling points”, that everyone's blowing the trumpet about:
 

  • it enables you to build reliable, dynamic, faster websites
  • it's now shipping in all major browsers
  • it enables you to write your piece of software once and then have it run on... every platform with a browser
  • it's a “revival” of the smart client software development


On the other hand: it's still a “steamy fresh” technology and people are half-hearted about using it. 

And where do you add that it requires a huge shift in mentality, as well: using the browser for tasks that developers are used to performing in the back-end. 

Now, let's shed some light here and bring forward the most compelling use cases for WebAssembly:
 

1. Writing Faster Code              

And writing “almost fast as native code for web browsers” has been one of developers' ever-present goal. 

Well, yes: WebAssembly does enable you to write faster code.

And yes, it is faster than JavaScript, “showing off” its performance-oriented side particularly when it comes to performing highly computational tasks. Those kinds of operations where lots of numbers and memory strain are involved.

Notes:
 

  • Do keep in mind that being able to write faster code to be run with ES6 doesn't mean that WebAssembly will replace JavaScript. It's designed to cohabit with it, not to be the “cause of its death”.
  • benchmarks have shown WebAssembly to be 10% slower than C code. Still, many consider it as a too little compromise for all the flexibility and portability they get in return.
     

2. Client-Side Compression: One of the Primary Use Cases for WebAssembly

Just think of the tones of convenience that such a use case comes bundled with.

Let's take this hypothetical user who takes a photo on his/her phone and then uploads it on a website. In that case, it's the server that normally handles the compression part: the user uploads the image at a default maximum resolution, then the server compresses it.

When using WebAssembly all this compression happens in the... browser. The result: fewer server resources and data/bandwidth used...

You get to run your web apps using the client's CPU instead. Compared to the “old way”, where you would access the server first, then send the result to the client.
 

3. Writing Code for the Web in Other Languages than JavaScript

By far one of WebAssembly's biggest “selling points” is the flexibility that it provides. You get to write your code for the web in a... non-JavaScript language.

And that's huge! Just think that till recently you were constrained to write your code for the web browsers in JavaScript. There was no alternative...

Again, that doesn't mean that we'll witness a migration of developers from JavaScript to other specialized languages. Instead, scenarios where you'd use JS for the app's logic and UI alongside WebAssembly, used for the core functionality, are more likely to happen. As well as those scenarios where performance bottlenecks in your existing JS apps will get rewritten in a more... specialized language. One that's more fitted to tackle those specific issues...
 

4. Compiling Existing Applications for the Browser

Another one of the compelling use cases for WebAssembly is this: compiling your current apps so that they run on the browser.

A possible way to do this is by writing your existing apps in a managed language that has a large runtime. Take for instance a scenario where you'd compile Photoshop for the web browser.

That, of course, if you don't have anything against sending an oversized file over each user's network.
 

5. Compiling & Accessing C/C++ Libraries

… and compiling Rust, I must add.

“What is WebAssembly good for?” To access C/C++ libraries for a wide range of operations:
 

  • digital media processing
  • graphics
  • compression
  • physics simulation
     

And, of course, to compile C/C++ and Rust (or other statically typed languages) to a new format, to be easily run in the web browser. All that with a low runtime, so that you can reap the benefits of predictable performance.
 

6. Moving from Desktop-Only to Browser-Based Applications

WebAssembly marks the “extinction” of the last desktop-only apps. 

From VR/AR apps to apps with heavy data usage, to photo and video editors, to games with complex system requirements, they can all be run in the web browser now.
 

Final Word 

Just imagine all the possibilities that WebAsembly unlocks: it enables you to take code from any language and run it in the web browser. Moreover, since it's a compile target, it “plays nicely” with other languages on the web: C++, Rust, C...

And this leads us to the required shift in mentality mentioned at the beginning of this post: using technology for operations that would normally be performed in the back-end, but which, in this case, involve the web browser...

Image by Rani Suarni from Pixabay

Development

We do Web development

Go to our Web development page!

Visit page!

Browse cities

Recommended Stories

OPTASY is Officially a Diamond Certified Partner of Drupal
Today, we’re excited to unveil a significant milestone for OPTASY: we are now officially recognized as a Diamond… (Read more)
5 min /
Drupal Commerce: Building Powerful E-commerce Solutions
E-commerce sales are projected to reach $6.3 trillion globally by the end of 2024. With online shopping… (Read more)
10 Minutes /
Choosing the Right Drupal Distribution: A Guide for Businesses
Choosing the perfect Drupal distribution can feel like navigating a maze—especially for businesses and government… (Read more)
10 minutes /