Nimony in your pocket, for Advent of Code
This app compiles Nimony to WebAssembly inside your browser. There is no server and no C compiler: Nimony's own compiler tools, compiled to wasm by Nimony, run in a worker next to the page.
Source, patches and build scripts: github.com/pietroppeter/aoc-nimony (MIT).
Version 1 · 1 December 2026
Using it
Pick the day with the arrows at the top. In Input, paste the puzzle's example and the answers it should give (add more examples if the puzzle has several), then your personal puzzle input. Write your solution in Code and tap Test (every example, each checked against its own answers) or Input (your puzzle input). Your program always reads the chosen text as input.txt; example.txt and puzzle.txt are there too.
Puzzle, before Test, opens the day's text under the header, restyled to read on a phone. It arrives with a bookmark you tap on the adventofcode.com page (the panel shows how to add it): the bookmark sends the puzzle text and, when you are logged in, your puzzle input, straight to this page and nowhere else. Each example block in the text has a Use as example button. A page cannot restyle or read adventofcode.com in a frame, which is why the text is brought in rather than embedded.
The output view shows each Part N: value line as a card, checks it against the expected answer, and has a Copy button for pasting into adventofcode.com. A compile error links to its line in the editor. Code, inputs and answers are saved per day in this browser.
Share under the editor makes a link with your code and your name, compressed into the URL; inputs and answers never leave your browser. The person who opens it sees your code read only and can run it on their own input, fork it into their own day, or tap a line number to leave a note or a question. Send notes makes a new link with the code and the whole discussion, to send back, or copies it as Markdown.
import std/aoc gives lines(), blocks(), grid(), ints(s), ints64(s), answer(part, value) and run(solve). The Std tab browses and searches Nimony's standard library as it is in this build, with its docs and source, plus the language manual and a short "Nimony for AoC" guide.
Do we need a C compiler? No
The project you linked, benagastov/Nim-WASM-Compiler, runs Nim 2.2.4 in the browser and then needs a real C toolchain there: Nim emits C, clang.wasm (LLVM 8, 31 MB) compiles it and lld.wasm (19 MB) links it, with a 9 MB C sysroot and 11 MB of Nim. About 70 MB before your first run.
Nimony does not need any of that. Besides its C backend and its native backend (arkham + nifasm, no C, no libc), it has a web backend, jorogumo, in the nim-lang/nativenif repository: it turns Nimony's mid-level IR (Leng, the .c.nif files) straight into a wasm module, or into JavaScript. nimony w hello.nim gives a 23 KB .wasm with no C anywhere. So the question became: can Nimony's own tools run in a browser? They can.
The pipeline in the worker
When you tap Test, the worker replays the build plan nimony w would run, one tool at a time, each a wasm module:
main.nim into main.p.nif · 171 KBmain.s.nif · 1.0 MBmain.x.nif · 830 KB.c.nifSizes are gzipped; the artifact host serves no .gz, so they travel as base64 text, a third larger. The standard library comes precompiled: the semchecked .s.nif, their indexes and the lowered .x.nif for 40 modules (everything an AoC solution usually imports, plus std/aoc), 2.2 MB, and the std sources for import resolution and the Std tab, 0.9 MB.
Getting Nimony's tools into wasm
The four tools are compiled by Nimony itself, with its own wasm backend:
nimony w -d:linux -d:posix -d:nimNoLibc src/nimony/nimsem.nim
jorogumo w --host-imports … # relink: syscalls become wasm imports
The defines make the standard library believe it runs on raw-syscall Linux, so its file code (open, read, stat, getdents64, rename…) compiles unchanged. A small JavaScript "kernel" answers those syscalls over an in-memory file system holding the std, your code and the intermediate NIF files. It took a handful of patches, none of them deep:
| Where | Change | Why |
|---|---|---|
| jorogumo codegen | with --host-imports, every syscall except write/exit becomes an env import | they trapped before: wasm had only nim_write and nim_exit |
| jorogumo wasm renderer | export the entry as nim_main(argc, argv, envp) | _start passes zeros, the tools need their arguments |
| std memfiles | a wasm arm that reads the file into the heap | the NIF reader maps files; there is no mmap |
| std osalloc, linux types, cpuinfo, errorcodes | keep the wasm page allocator; give wasm32 the i386 ABI arm; one CPU; posix errno values | pretending to be Linux must not pull in mmap or a missing layout |
| std system | contains, .. and ..< for int mixed with int64 | on wasm32 int is 32 bits; the compiler mixes them where they coincide on 64-bit hosts |
| compiler (4 lines) | explicit int() conversions, an initialised result, the version constant | the same 32-bit mismatches, and one compile-time call that needs a host sub-compile |
Sizes and timings
| What | This app | clang route |
|---|---|---|
| Download before the first run | 7.3 MB (5.4 MB gzip, sent as base64 text) | ≈ 70 MB |
| Toolchain ready after download | ≈ 0.3 s | n/a |
| Compile day 1 (headless Chromium, laptop-class CPU) | 0.9 to 1.2 s | n/a |
| A compile error (stops after nimsem) | ≈ 0.1 s | n/a |
| Size of the compiled day 1 program | 51 KB | n/a |
Most of a compile is dead code elimination: one shoggoth de run per reachable std module. A phone will be slower than these numbers; I have not measured one yet.
What is Nimony and what is JavaScript
- Nimony: the four compiler tools;
std/aoc; and the app itself,app.nim(750 lines, compiled withnimony j --browser): every view, the Nim highlighter, the std outline and search, the Markdown guides, the answer checks. - JavaScript, the host: the syscall kernel (150 lines), the build plan (45), the workers (80), the pack reader (20), and the page glue for editor keys, storage and workers (≈ 170). The kernel has to be JavaScript: it is what a wasm module calls out to.
Limits and bugs found
intis 32 bits on Nimony's wasm target. AoC answers often are not: useint64.- Only the 40 precompiled std modules can be imported, and a solution is one file. Importing a second file of yours needs the per-module build graph, which nifmake does; it is not run in the browser yet.
- No macro plugins: they are host programs that Nimony compiles and runs natively.
- Bug: tools built with
-d:releasefor wasm get every command line argument 3 bytes short (--portablePathsarrives as--portablePa); the C backend is fine. The app's tools are built without-d:release. Worth a minimal repro for nativenif. - Bug: on
--os:standalone, importing some std modules (parsecsv,strtabs) fails inerrorcodes_posixwith "unsynchronized access to global variable"; mapping standalone to the Linux errno table avoids it. - Puzzle inputs are pasted by hand: the page cannot fetch adventofcode.com (it needs your session cookie, and the artifact viewer blocks other hosts).
- Saving uses
localStorage; inside the claude.ai viewer it may be unavailable, and then nothing is kept between visits.
Next steps
- Time it on your phone, then cut the dead code elimination step: one wasm instance for all the
deruns, or precomputed liveness for std. - Upstream the two jorogumo patches and a proper wasm arm in std, so
nimony wcan build the toolchain without the Linux pretence. - Make the GitHub Pages version installable and usable offline.
- Multi-file solutions by running nifmake's plan, and a shared
utils.nimacross days.