# Alm - an Elm compiler written in Rust

**URL:** <https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870>\
**Category:** Show and Tell\
**Created:** [August 2, 2026, 9:14am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870 "2026-08-02T09:14:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![boxed](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/boxed/32/5664_2.png) [@boxed](https://discourse.elm-lang.org/u/boxed)\
**Post date:** [August 2, 2026, 9:14am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/1 "2026-08-02T09:14:17Z")

</div>

> **[GitHub - boxed/Alm](https://github.com/boxed/alm)**
>
> Contribute to boxed/Alm development by creating an account on GitHub.

This has been a summer hobby project of mine that kind of got out of hand 😅

Some highlights:

- Faster compilation
- Exactly the same error messages as 0.19
- Faster or the same runtime performance
- Experimental WASM and native outputs
- Hot reload built in
- Source maps

Here’s some benchmarks: [Claude Artifact](https://claude.ai/code/artifact/b1b7ef79-c8ba-4386-ab1a-b2560420e458)

---

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [August 2, 2026, 10:27am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/2 "2026-08-02T10:27:42Z")

</div>

I was curious about how you implemented the virtual DOM in the WASM version, so I had Calude analyze the implementation for me. Here is what it said:

“The Elm Architecture runs inside wasm: vdom diff/patch, the CPS task scheduler, the \_Platform effect-manager protocol, ports, Http/Time/Random. The browser is reached through **48 imported host functions** (wasmgc.rs:283) — dom\_create\_element, dom\_insert\_before, dom\_add\_event\_listener, host\_push\_url, host\_http, Math.\* for transcendentals, etc. — plus a small set of exports (alm\_browser\_start, alm\_event, alm\_port\_in, alm\_tick). Strings cross via the module’s linear memory (ptr+len), DOM nodes are integer handles into a JS-side table, and a batched dom\_build opcode stream builds whole subtrees in one host call. Finished modules are tree-shaken by re-parsing the binary, BFS-ing the call graph from exports, and stubbing dead bodies with unreachable without renumbering anything.”

The bit that caught my attention is: DOM nodes are integer handles into a JS-side table, and a batched dom\_build opcode stream builds whole subtrees in one host call.

Is this analysis correct ?

I had the exact same idea for how to do this, but have not implemented it. But basically you put all the static DOM fragments from the Elm program into a table on the JS side. Then compile elm/virtual-dom to a bytecode that you chuck over to the JS side in one go, and it assembles the DOM from the fragmets.

Great stuff, I love it.

Have you also handled the return direction ? When an event occurs on the JS side, you get an event object, and Elm might run a JSON decoder on that to extract details of the event. Where do you do this JSON decoding, and how do you get the decoded event back to the WASM side efficiently ?

---

<div class="post-metadata">

**Author:** ![boxed](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/boxed/32/5664_2.png) [@boxed](https://discourse.elm-lang.org/u/boxed)\
**Post date:** [August 2, 2026, 3:07pm UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/3 "2026-08-02T15:07:56Z")

</div>

Yea, I went back and forth a bit on that design but ultimately the DOM API calls are basically optimized away by the web runtime anyway so it doesn’t matter a huge amount if you batch it or not :shrug:

Re return events: I don’t really remember. I think the wasm target passes all the same test suites, which is the total test suite of all packages in the package manager, but not sure about apps. I haven’t had a ton of time to test on my work code yet as I’m still on vacation.

---

<div class="post-metadata">

**Author:** ![uweg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/uweg/32/2541_2.png) [@uweg](https://discourse.elm-lang.org/u/uweg)\
**Post date:** [August 3, 2026, 7:16pm UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/4 "2026-08-03T19:16:10Z")

</div>

This is great! It’s crazy how many new Elm or close to Elm compilers are released these days. This was unimagible just a year ago and makes me wonder what the future might bring.

---

<div class="post-metadata">

**Author:** ![creminology](https://avatars.discourse-cdn.com/v4/letter/c/e47774/32.png) [@creminology](https://discourse.elm-lang.org/u/creminology)\
**Post date:** [August 5, 2026, 6:07am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/5 "2026-08-05T06:07:14Z")

</div>

When I read “native outputs”, I presumed that was Rust and assumed that was how you had WASM support…

---

<div class="post-metadata">

**Author:** ![boxed](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/boxed/32/5664_2.png) [@boxed](https://discourse.elm-lang.org/u/boxed)\
**Post date:** [August 5, 2026, 7:23am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/6 "2026-08-05T07:23:06Z")

</div>

I tried that but the llvm wasm target doesn’t support wasm gc which created huge binaries and bad performance.

---

<div class="post-metadata">

**Author:** ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)\
**Post date:** [August 5, 2026, 8:54am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/7 "2026-08-05T08:54:55Z")

</div>

Interesting and 🙁 - LLVM WASM target was what I was hoping to do for eco.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [August 15, 2026, 8:55am UTC](https://discourse.elm-lang.org/t/alm-an-elm-compiler-written-in-rust/10870/8 "2026-08-15T08:55:01Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
