Now a days everyone is talking about WebAssembly. In this blog, I will explain how you can get started with Rust and WebAssembly fast with a simple template. But before we start, lets discuss what is webassembly, why Rust should be preferred for it.

What is WebAssembly:

We can think of webassembly as a type of bytecode that can be generated from any language. That bytecode can be compiled and run by modern web browsers. It’s a low-level, portable, binary format for the web that aims to speed up web apps.

It works in two stages. First, a webassembly module is generated from the source code. Once the module is built, it can be run anywhere.

Why Rust should be preferred for WebAssembly:

WebAssembly, also known as Wasm, is supported by 40 high-level programming languages including C and C++, Python, Go, Rust, Java, and PHP.

eople are looking to leverage WASM for web because of its advantages over javascript like Efficiency, Standardization, Security, and Language Independence. People want WASM bundle to actually perform better than JavaScript.

This is why languages like Rust and C/C++ are usually prime candidates for WASM use, because they both are languages with performance and efficiency as a focus.

Over most other languages, Rust has the advantage of having a very slim runtime (many call it no runtime), no garbage collection and well-defined memory allocation behaviour. Since the wasm32 environment is very memory-constrained, that’s a big reason for using Rust. Over C/C++, Rust has the advantage of having a modern development environment and directly supporting the target in its core tools.

#rust #rust programming language

Rust with WebAssembly: Simple explanation with a nice example
1.20 GEEK