nNim is a fun language that compiles to C (or C++, or a few more.) It feels a little like python or lua.
- See cart structure for more info about how callbacks work.
- See API for more info about the null0 API.
- See examples
- You can use WASI too, so all regular C stdlib-file stuff should work.
- Check out the Nim template project
- You will need wasi-sdk and nim installed.
- The definitive header is here, so use that to ensure yours is up-to-date
A simple cart might look like this:
And then you can compile to a cart with:
mkdir -p cart
curl https://raw.githubusercontent.com/notnullgames/null0/refs/heads/main/carts/nim/null0.nim > null0.nim
CC=/opt/wasi-sdk/bin/clang nim c --threads:off --noMain --cc:env -d:release -d:wasi -d:useMalloc --cpu:wasm32 --os:any --passC:"-D_WASI_EMULATED_SIGNAL" --passL:"-lwasi-emulated-signal" --passL:"-Wl,--allow-undefined" -o:cart/main.wasm main.nim
cd cart
zip -rq ../mygame.null0 .
See build.sh for an example of how I build for this example-site.