Better Programming

Advice for programmers.

Member-only story

The Importance of Writing WASM-Compatible Code

5 min readAug 30, 2022

--

Photo by Artem Labunsky on Unsplash

I’ve already written a couple of articles about WebAssembly and Rust, but this post should be useful for everyone that is writing code in a language that can compile to WASM, especially if you are using first-class WebAssembly citizens like Rust, C, C++, or Zig.

If you’ve not read WASM-introductory resources like this post, WebAssembly is a binary language converted into machine code by its VM. You heard right, it’s VM, meaning that you only need a VM that supports WASM to run any executable ending with .wasm . Additionally, compiling your code to WASM requires minimal effort in most cases.

The Workflow of a WASM Application

Before getting into why you should have a wasm-compatible version of your code, let’s take a look at what your process of developing and deploying a WASM app could look like:

  1. write code/port existing code into a wasm-compatible fork
  2. compile it to WebAssembly
  3. publish the .wasm binary
  4. have people running it, for example: wasmer run your_code.wasm

--

--

Tommaso De Ponti
Tommaso De Ponti

Written by Tommaso De Ponti

Building stuff, #Stellar. https://tdep.xycloo.com. Check my personal blog at https://heytdep.github.io for more specific and/or advanced articles.