Nim is a fun language that compiles to C (or C++, or a few more.) It feels a little like python or lua.
You can read more on the nim website (opens in a new tab). You will need nim installed (opens in a new tab) and emscripten (opens in a new tab) to use it.
Here is some example code:
src/main.nim
proc load() {.null0.} =
echo "Hello from justlog."
proc unload() {.null0.} =
echo "Ok, bye."
easy build
If you use our template (opens in a new tab) or the CLI quick-starter, it's a bit easier to get started quickly:
nimble cart
manual build
For null0, you need to import the header (opens in a new tab), and you will get the {.null0.}
pragma and some null0 functions and constants.
To compile to the correct wasm, you can use this config (opens in a new tab), which sets some flags and imports the header (opens in a new tab).
nimble install https://github.com/notnullgames/null0-nim
cd src
nim c main.nim
This will create main.wasm
, so now you can create a zip file:
zip ../mycart.null0 -r main.wasm assets/
docker
If you have docker installed, you can use it to build, without needing to install anything else (no nim, etc.)
docker run -it -v $(pwd):/cart konsumer/null0 nimble cart