Skip to content
UrubuCodePublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Zun

A JS/TS machine-language platform written in Rust — architected after the .NET runtime (CLR): a real compile step that produces a binary IL + metadata format (.zm), and a VM that loads, verifies, and executes it natively via Cranelift (interpreter Tier 0 → JIT Tier 1).

This is not a V8-style runtime. Typed TypeScript gets fixed object layouts and vtable dispatch; dynamic JavaScript (any) is the explicit, costly exception — a boxed Any value with IL-level box/unbox and a DynamicObject. You pay for dynamism only where you actually use it.

Evolved from the RTS prototype. Zun is the successor to urubucode/rts, a TypeScript→native compiler built on Cranelift. RTS proved the approach; Zun rebuilds it on a real IL + metadata contract and a verifiable VM, aiming for a more compatible and more correctly applied model of the language. One thing Zun keeps verbatim is RTS's discipline of measuring itself against real runtimes — see Cross-runtime conformance below.

Why a compile step and an IL

The compiler and the VM never share in-memory ASTs. They communicate only through the ZIL binary format, which references types and members by metadata token, never by offset. That boundary is what makes the rest possible:

  • Verification before execution. A module is checked for type- and memory-safety at load time, the way the CLR verifies IL.
  • Tiered execution. An always-correct interpreter (Tier 0) runs immediately; hot code is JIT-compiled by Cranelift (Tier 1) behind redirectable entry points, so tiering and on-stack replacement never require a redesign.
  • A single source of truth for opcodes. One master table generates the assembler, disassembler, verifier, and codegen importer — opcode knowledge is never hand-copied into a second place.

See PLAN.md for the full architecture, the crate map, and the implementation phases. Design decisions are grounded in .docs-dotnet/, a 10-area analysis of dotnet/runtime.

Cross-runtime conformance

Zun measures its own JavaScript/TypeScript compatibility the way the RTS prototype did: every fixture under tests/ is a standalone program run on Bun, Node, and Zun, with stdout compared byte-for-byte. The conformance rate is pass / reachable, where reachable excludes fixtures that have no canonical answer (Bun and Node themselves disagree) or a proven upstream defect — so the rate's ceiling is a real 100%.

The table below is regenerated by CI on every push to main. See tests/README.md for the status model, how to write a fixture, and how to run the harness locally.

Pending the first CI run — the conformance table is generated by scripts/tests_check.sh and committed by the tests workflow.

Progress per category is tracked in a single living GitHub issue per category (label conformance), each with a checklist of its fixtures and a progress bar — not hundreds of one-off issues. These numbers are Zun's own measurements, not an official conformance certification.

Quickstart

# Build the embedded engine and the `zun` binary (target/release/zun):
cargo run -p xtask -- package

# Compile and run a TypeScript program:
target/release/zun run path/to/program.ts

# Run the full workspace test suite:
cargo test

Note. cargo run -p xtask -- package builds zun_runtime in release, compresses it, and rebuilds zun_cli with the embedded payload, then runs the self-provision check end to end.

Repository layout

PLAN.md               # architecture plan (reference)
GOAL.md               # project goals
.docs-dotnet/         # .NET runtime analysis, 10 areas (reference)
docs/guides/          # engineering references (e.g. Cranelift 0.131)
crates/               # Cargo workspace — compiler, format, and VM crates
std/                  # standard library, typed TS compiled by Zun itself
tests/                # cross-runtime conformance fixtures, by category
scripts/              # tooling, incl. the cross-runtime harness
xtask/                # build/packaging tasks

The format crates (zun_il, zun_metadata, zun_module) are the contract. Compile-time crates and runtime crates both depend on the format but never on each other — only the driver/CLI links both.

Status

Zun is in active development and is not yet production-ready. The language model, the IL, and the VM are evolving together; expect sharp edges. The cross-runtime conformance numbers above are the honest, continuously-measured picture of where the engine actually stands.

License

See LICENSE if present; otherwise the repository's license applies as stated by the owner.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages