Getting started into Rust and WebAssembly

Rust is a systems programming language. It runs blazingly fast. It guarantees thread safety and promises no dangling pointer.

Why should I learn one more language, what is so exciting about Rust ?

Coming back to our next hero in this story, WebAssembly

WebAssembly in simple language, is running your native code (C / C++ / Rust and others) in the browser. It is fast, secure and maintainable.

They are a set of binary instruction format that runs on any stack based machine.

There were several attempts made by browser vendors to run the native code in browser. The one thing that was widely popular wasasm.js. But even it had many limitations.

WebAssembly is binary encoded instructions that are size- and load-time-efficient. They are secure and run on sandboxed environment.

Wait, isn’t Javascript fast. Yes it is, you can achieve ~native speed in Javascript. But, the work around and amount of effort that you have to spend is high. But with WebAssembly you can get this right out of the box.

Maintainable Performance is the key.

Let us get started with Rust and WebAssembly.

To start, you will need to install Rust-lang (and use nightly version rustup default nightly).

Then add wasm32-unknown-unknown in the tool chain. This will make the Rust compiler to compile Rust code into WebAssembly ( rustup target add wasm32-unknown-unknown --toolchain nightly ).

Check out here for more detailed steps.

A sample hello-world setup is explained in detail here.

There are certain tools that will help you to achieve even more with Rust and WebAssembly.

Have a look at our newsletter here.

Like what you read? Give sendilkumarn a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.