Rust + Wasmer tests to check out the viability of using WASM as a scripting language
Find a file
2026-02-22 19:23:30 +01:00
assemblyscript test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
src refactor Rust code a bit to simplify working with WASM scripts 2026-02-22 19:22:03 +01:00
.envrc initialize project 2026-02-22 13:35:43 +01:00
.gitignore test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
Cargo.lock copy the Wasmer example to check that it works 2026-02-22 13:59:01 +01:00
Cargo.toml test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
flake.lock test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
flake.nix test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
LICENSE-APACHE test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
LICENSE-MIT test assemblyscript with wasmer 2026-02-22 19:10:00 +01:00
README.md reorder the moonbit and assemblyscript sections because assemblyscript 2026-02-22 19:23:30 +01:00

WASM Scripting

A test for adding scripting to a Rust program using WASM.

In this project I'll be testing these two languages with Wasmer:

  • MoonBit
  • AssemblyScript

Running the project and working with WASM

Running the Rust code

cargo run

The Wasmer page on GitHub tells you to install Wasmer. This is only necessary if you want to run WASM programs in your machine without embedding it.

We don't have to do any of that since we use the SDK to embed WASM.

NixOS users, you know how it works, either use direnv or nix develop and then do a cargo run.

Working with AssemblyScript

To use AssemblyScript you only need Node! This is already pretty good.

For NixOS users, I've included Node with this project's flake so just nix develop.

You initialize a project with these commands:

npm init # Set the type to module, not commonjs!
npm install --save-dev assemblyscript
npx asinit .

You should now have an assembly folder with your index.ts file, which is the main file. We can compile this code with this command:

npm run asbuild

Working with MoonBit

To use MoonBit for scripting you need to install it.

You can install it with the instructions indicated here: https://www.moonbitlang.com/download


In my case, since I use NixOS I included this overlay: https://github.com/moonbit-community/moonbit-overlay into this project's flake. If you use NixOS you should have access to the moonbit toolchain if you activate the included flake with nix develop.


I tried to create a new project and running it made compilation errors. I didn't continue.