Getting started into Rust and WebAssembly
Why should I learn one more language, what is so exciting about Rust ?
- It has better ergonomics.
- Easier and explicit syntax with some sweet implicit syntaxes.
- It includes best of both worlds (the high and low level languages).
- Easier to learn and much more easier to debug. (look at the below error message from Rust).
- It evolves fast for giving a better experience to the developers.
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 was
asm.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.
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).
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.