r/rust • • 1d ago

🛠️ project Arm64 emulator in Rust that compiles into wasm and allows running Alpine Linux in a web browser

Hi all,

Last couple of months I've been working on the largest Rust project I've ever built (also because everything I built before were small tools), happy to share it now.

It started with me getting annoyed that to try a 2 MB TUI tool I have to install it, while my browser happily runs a 40 MB landing page with React doing massive rerenderings on every move. So I thought it MUST be possible to run a thin Linux with TUI app in the browser, taking into consideration the power of CPUs we have these days.

Many months of grinding resulted in Arm64JS. It's an interpreter runs a small VM in web browser and emulates a minimal hardware stack, so VM thinks it runs on real hardware. The whole emulator is Rust compiled to wasm32, one module instantiated per web worker, all sharing one SharedArrayBuffer as the VM's "RAM".

CPU speed is of course lower than native — but works fine for shells, TUI apps, Python/PHP and small servers. Typing lag 8 ms in the shell, 37 ms in vim, booting from a snapshot a bit more than a second (plus download if data are remote).

The code of the interpreter is not OSS at the moment, but I've made a small JS SDK to make it easy for others to create their own VMs. It's free for non-commercial use.

Feedback is welcome.

You can read more about its story here: https://arm64js.com/blog/tui-apps-in-the-browser/

And here's the link to the JS SDK I mentioned: https://github.com/kooler/arm64js-sdk

20 Upvotes

2 comments sorted by

1

u/poelzi 1d ago

I will definitely use this is my tix.im project for some remote access emergency instances. Cool project

1

u/Spiritual_Bee6614 1d ago

This is properly impressive, the boot time from a snapshot alone is wild. Running vim with 37ms lag in a browser tab is something I wouldn't have believed a couple years ago.

Keen to see where you take this, especially if the interpreter ends up open down the line.