WebAssembly, will it replace JavaScript in the near future?

WebAssembly, will it replace JavaScript in the near future

Not so long ago, JavaScript quickly conquered the world, leaving its competitors behind. Now JavaScript itself is at risks losing to a very young opponent – WebAssembly.

10 years ago, no one had imagined that JavaScript would become so popular on it’s way to world domination were Java, Flash and other powerful rivals where. They were far ahead of JS due to features like adding video (this was much earlier than CSS animations appeared). But this advantage over time turned into the reason for their fall. After the emergence of HTML fifth version – the platform quickly became obsolete.

Perhaps in the near future JavaScript’s strengths will also have the same fate. From this point of view, special attention should be paid to technology Asm.js. But first, let’s talk about the current situation, and only then try to look ahead.

Today’s approach: transpiling

JavaScript developers have always been on the lookout for alternative solutions. So, there were attempts to pull code from browsers using plugins (they failed). Then they tried to make a code converter – a tool that allows you to convert code written in another language into JS.

The procedure for “ rewriting ” a program from one language to another is called transpiling. And it has several obvious flaws.

The syntax and functions of high-level programming languages ​​are different. Therefore, it is often simply impossible to construct equivalent constructions. But even if you manage to find them, there will definitely be problems that are hard to avoid.

For example, what happens if you stop developing a transpiler? Will it cause bugs? Or will you need to connect the JS framework? And how can a team work when everyone uses different languages?

Today, transpilers are quite popular, but they are used for only one purpose: to ensure backward compatibility. After writing the newest JavaScript, the developers then use transpilers like Babel to transform the code into a not-so-beautiful old version of JS that will work everywhere. Or they write in TypeScript (an advanced version of JavaScript), after which they turn the lines into JS code. As you can see, in any situation, we still do not go beyond JavaScript.

Tomorrow’s technology: asm.js

For the first time, new opportunities loomed on the horizon in 2013 thanks to Asm.JS, an experimental project from the creators of Mozilla. They tried to find a way to run high-performance code inside the browser. And if the plugins tried to follow the browser, asm paved the way straight through the JVM.

Asm.js is an optimized, concise JavaScript syntax. It is more nimble because it skips slow dynamic elements. Plus, web browsers, recognizing this, apply additional optimizations, which greatly increase productivity.

Simply put, asm.js complies with the basic law of not breaking the Web, indicating a direction for further development.

Firefox developers, combining asm.js resources with the Emscripten transporter, began to place it in a browser that runs only on JavaScript, real-time 3D games written in C ++.


WebAssembly was created in 2015. Now it is supported by 4 large browsers (Chrome, Mozilla Firefox, Edge and Safari) both on desktop and mobile devices. As for Internet Explorer, there is no support, but you can provide backward compatibility by converting the wasm code to asm.js (performance suffers in this case).

Read also: 5 programming languages condemned to die in less than a decade

WebAssembly Potential

The WebAssembly tool gives developers a way to write optimized procedures, mostly in C ++. This ability is very powerful, but narrowly targeted. It is used only to increase the efficiency of complex calculations. For example, fastq biousing wasm accelerate the process of reading DNA. It is also used when porting high-performance games, as well as for creating intra-browser emulators.

But that’s not all, otherwise Wasm would not have a single chance to compete with JavaScript. In addition to the uses described above, WebAssembly provides programmers with the ability to put platforms in the JavaScript development environment. This is where all the fun begins.

WebAssembly is enclosed in the JS runtime. It just cannot get around it. Wasm does not have direct access to web pages, so at least a minimal amount of JavaScript code should be in parallel with it. WebAssembly is not able to manipulate the document object model and receive events without passing through the JS layer. You probably thought that was a significant limitation. But the developers have already figured out how to redirect the runtime through WebAssembly.

Virtual machine inside a second virtual machine

For example, the Microsoft Blazor framework uses the .NET environment, which loads as a compiled Wasm file. It works with JS and provides garbage collection along with other basic services, as well as higher-order functions. In simple words, Blazor uses a virtual machine inside a second virtual machine. And this is just one example. Besides Blazor, there are other experiments based on WebAssembly. Take Pyodide, hosting the Python language in the browser, complemented by an expanded list of mathematical tools for working with data.

What is this if not a confident step in the advanced technologies of the future? WebAssembly was originally designed for C++ with Rust, and now it is used in more ambitious projects.

Wasm is growing rapidly. Its current state is just the minimum threshold that is enough for use in only a few important scenarios. But after the approval of WebAssembly, the situation will change for the better.

If Blazor and similar platforms become popular, WebAssembly is likely to gain direct access to the DOM. And browsers will take over the implementation of such details as multithreading and the garbage collector (at least, their creators are now nurturing such plans).

Do you think that such an evolutionary path is too long? Then remember how JavaScript ripened. Having gained popularity, WebAssembly will definitely make a big contribution to a number of improvements and will be able to easily outshine the native benefits of JS.

You can often hear the opinion that WebAssembly did not set the goal of becoming a replacement for JavaScript. But you must admit: this is what they said about all revolutionary platforms.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Scroll to Top