DEV Community

Cover image for WebAssembly: the future of web development

WebAssembly: the future of web development

anilkaundal profile image Anil Kaundal ・3 min read

Imagine a world where you could build software with C, C++, Rust, Python or even GO and then deliver that software to the end-user in a web browser without any installation and near-native performance. More than 75 per cent of the users are running browsers capable of running languages other than JS in their browser.

We're looking at a future where the web will be built not just on JS, but on C, Rust, even GoLang. WebAssembly 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. It is also designed to run alongside JavaScript, allowing both to work together. WebAssembly has huge implications for the web platform.

It became an official W3C standard in December 2019. WebAssembly enables developers to build powerful, interactive experiences that are available on any device. It includes a low-level language similar to an assembly that can be represented with the text which is then converted to a binary format that runs on all modern browsers. However, you won't actually write this code directly but rather use it as a compilation target for programs written in other languages. For example, you might build a video game with Unity and C# and then compile it to WebAssembly so it can be easily delivered in the browser.

Now it's important to note that it's not intended to replace javascript in fact the two work well together side by side. This may be a force that will shape not only how we think about JS, but the entire web experience. Figma for example uses React.js for its outer UI than on the inside you have a high-performance C++ design tool that feels just as fast as native software. I didn't know this before reading this article by Evan Wallace, CTO at Figma.

WebAssembly is so much more. You can use WebAssembly as a puzzle piece to give the web platform the few missing capabilities that you are missing or to surgically replace a JavaScript bottleneck. Unlike javascript, a dynamic interpreted language WebAssembly is a static compiled language with strict type guarantees. There are many different ways you can build a WebAssembly app, one of the most popular tools is emscripten which can convert a C or C++ program to WebAssembly. If you want low-level control over your code then you can use something called AssemblyScript. It is a TypeScript to WebAssembly compiler. Now, that might mislead you, because you can't just throw your existing TypeScript at this compiler and get WebAssembly out of it, because in WebAssembly, you don't have DOM API's, so you can't just use the same code. But what AssemblyScript uses is the TypeScript syntax.

JavaScript and WebAssembly are not opponents. There is a synergy between them. Use them together. One doesn't replace the other.
Like debugging is going to be harder, and code splitting is much harder with WebAssembly currently than it is with JavaScript and you have to call back and forth.

I have tried to keep the article short and crisp. I will be writing more about WebAssembly and its use cases in future writings. Please let me know your thoughts in the comments.

Happy coding!!! 🎉


Editor guide