Javascript

  • See cart structure for more info about how callbacks work.
  • See API for more info about the null0 API.
  • See examples
  • WASI is exposed, and std and os are available
  • Check out the JS template project
  • Your code is interpreted with quickjs compiled as a cart (full WASI & null0 API is available & global.)
  • Include main.wasm in your cart-zip, along with any assets you are using, and make a main.js.

A simple cart might look like this:

Which looks like this:

And then you can compile to a cart with:

mkdir -p cart
curl https://github.com/notnullgames/null0/releases/latest/download/cart-js.wasm > cart/main.wasm
cp *.js cart
cd cart
zip -rq ../mygame.null0 .

See build.sh for an example of how I build for this example-site.

For zip command, you can skip packaging some files (like .DS_Store) with -x ".DS_Store" "__*" (after all the other options.)

If you want a similar language, but with more efficient cart-code, maybe try out assemblyscript. It's not exacly the same, and a bit less "loose", but the syntax is pretty similar, and it doesn't need to include the entire quickjs interpretor in your wasm, so it creates a smaller & more efficient cart.