Skip to content

zig-utils/zig-js

Repository files navigation

zig-js

A pure-Zig JavaScript engine with a JavaScriptCore-shaped C API. No JSC, V8, or external C libraries; no compatibility promises before stabilization.

const js = @import("js");

const ctx = try js.Context.create(allocator);
defer ctx.destroy();

const value = try ctx.evaluate("let x = 40; x + 2");

Status

profile result evidence
configured test262 53,175 / 53,175 run · data
nine-profile WebAssembly matrix 87,838 / 87,838 applicable matrix · reproduce

Performance

zig-js vs JavaScriptCore

Latest accepted report · 1,540 raw samples. Equal-work checks, alternating order, dispersion limits, and a 50 ms timing floor are enforced by the harness.

mode lanes wins vs JSC zig-js / JSC throughput zig-js scaling JSC scaling
direct warmed context 1 10 / 10 2.43x
independent steady contexts 8 10 / 10 2.71x 4.67x 4.13x
independent cold lifecycles 8 9 / 10 2.53x 4.40x 4.07x
shared realm, no GIL 8 no public-JSC equivalent 3.84x

Ratios above 1.00x favor zig-js. JSC has no public shared-realm embedding equivalent.

WebAssembly

  • SIMD: 3.67–4.58x eight-lane scaling; 0.10–0.14x JSC throughput (report · samples).
  • Threads: 17.23 M/s contended adds and 287,444 wait/notify handoffs/s at eight workers (report · samples).

Full methodology and results: Performance benchmarks.

Use

zig build installs libzig-js.a and compatible headers under zig-out/. See the Zig API, C API, architecture, WebAssembly, and threads/GC.

Build And Test

Requires Zig 0.17.0-dev.

zig build                       # library and headers
zig build test                  # main test root
zig build test262               # configured tc39/test262 corpus
zig build test-c-api            # C and C++ embedding fixtures
zig build benchmark-comparison  # zig-js single/multithread vs JSC

Run zig build --help for the full command list.

What Is Not Implemented

  • remaining JSC framework/private and Bun/Home ABI surfaces;
  • 24 dispositioned PR-249 shell/JIT/GC/Wasm cases (inventory);
  • moving/multi-age GC, parallel minor collection, and an optimizing JIT.

The release matrix tracks #134; removal of this section is gated by #246.

License

MIT — see LICENSE. Used by home-lang/craft.