Zig and WASM

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • liwords

    A site that allows people to play a crossword board game against each other

  • We use WASM to provide in-browser Scrabble-like analysis at https://woogles.io at the end of games. The original analyzer was built in Rust and the speed is close to native.

  • book

    The Rust and WebAssembly Book (by rustwasm)

  • If you're targeting browsers then the Rust WASM book goes over using the wasm32-unknown target and wasm_bindgen to auto-generate the JS glue

    https://rustwasm.github.io/docs/book/

    If you're targeting some WASI-based platform then it's more straightforward, as there's no need to generate glue code. CF have a quick example

    https://blog.cloudflare.com/announcing-wasi-on-workers/

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • pacman.zig

    Simple Pacman clone written in Zig.

  • For a somewhat more complete example which runs in browsers, check out my little pacman.zig toy project [0]. This is cheating a bit by using Emscripten toolchain as 'sysroot' (needed for the Emscripten headers), and the Emscripten linker to create the html+js+wasm output file, but the actual code is all compiled with the Zig compiler.

    The interesting part is that the platform abstraction is provided by the sokol headers [1], with auto-generated Zig bindings [2]. It's interesting because the C headers use "Emscripten magic" (mainly embedding Javascript snippets in the C sources via the EM_JS() macro), and the Zig compiler is able to compile this (when it has access to the Emscripten headers).

    It would be nice if the "Emscripten platform" could get the same type of cross-compilation support as the desktop platforms eventually, but apart from bundling the Emscripten headers, this would also require to implement some of the "Emscripten magic" in the linker step.

    Maybe projects like WaJIC can help with this (this basically implements the "Emscripten magic" of embedding Javascript snippets in C/C++ source code, but without Emscripten (only the wasm-opt tool is needed AFAIK).

    Anyway... it's a lot of fun to tinker around with this stuff in Zig, and watch how it's all taking shape :)

    [0] https://github.com/floooh/pacman.zig

  • sokol

    minimal cross-platform standalone C headers

  • sokol-zig

    Zig bindings for the sokol headers (https://github.com/floooh/sokol)

  • wajic

    WebAssembly JavaScript Interface Creator

  • zig-wasm-test

    A minimal Web Assembly example using Zig's build system.

  • Wow, this just straight rips off my (not very great) example I've been maintaining for a while:

    https://github.com/meheleventyone/zig-wasm-test

    Thanks for the credit yurivish! :(

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • minimal-zig-wasm-canvas

    A minimal example showing how HTML5's canvas, wasm memory and zig can interact.

  • Dodgeballz

    A mini game using Zig, WASM and JS

  • zig-wefx

    WEFX is a simple graphics drawing package using Zig, WASM, and an HTML canvas.

  • zig-wasm-logger

    A simple implementation of console.log() in Zig + JS + Wasm

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts