Member-only story

Using Web Assembly with Rust

Ryan Deschamps
4 min readDec 11, 2024

--

Creative Commons Photo by Alden Jewell

What is Web Assembly?

More formal definitions likely exist, but to me, Web Assembly (abbreviated to wasm) is basically creating a foreign function interface (ffi) to a low-level C++, Rust or other language (aka Native code) library into a web site. Basically, you create an api in your favorite language, run a command line product to compile some of your code into JavaScript and other parts into an assembled api called a .wasm file. This means that instead of running interpreted JavaScript code, your product can run much faster server-based code as well.

While there is much more to it, I recommend exploring the documentation for more details. A Web Assembly stan would probably speak to its flexibility, power and easy integration into Node as other solid advantages. It also doesn’t hurt that you can hide your web-based code in a binary instead of having your naked JavaScript out there for everyone to steal. Personally, I like that I can decide how much native and how much web I want to put into a project.

What do you need to build wasm in Rust?

I will get right to it. You need:

  • Rust
  • wasm-pack (just use cargo install wasm-pack) in your terminal.
  • to add wasm-bindgen to your Cargo.toml as a dependency.

--

--

Ryan Deschamps
Ryan Deschamps

Written by Ryan Deschamps

College professor covering just about everything tech and policy.

No responses yet