OpenJai is an open source implementation effort for a Jai-style systems
programming language and compiler. The project is guided by
docs/open_jai_spec.md, with the current bootstrap
compiler implemented in Zig under bootstrap/.
The goal is to build a fast, ahead-of-time compiled, low-level language for game programming, general-purpose systems work, and metaprogramming-heavy development. OpenJai is intended to prioritize developer productivity first, then performance, then safety.
This repository currently contains an early Zig bootstrap compiler. It is not yet the final self-hosting OpenJai compiler.
The bootstrap compiler has the start of the full pipeline:
source -> lexer -> parser -> AST -> semantic analysis -> bytecode -> LLVM object -> linked executable
Current support is still incomplete, but the bootstrap compiler now covers a large example-driven surface, including compile-through checks for the example corpus. The complete language described in the spec remains work in progress.
bootstrap/ Zig implementation of the bootstrap compiler
src/ Jai port of the bootstrap compiler, kept structurally aligned
docs/ Language spec and compiler implementation notes
examples/ Jai/OpenJai example programs used as compiler milestones
test/ Jai-style test framework and example-derived tests
out/ Generated build output, ignored by git
Important docs:
CONTRIBUTING.md: clean-room contribution rules.docs/public_sources.md: public-source bibliography and provenance guidance.docs/open_jai_spec.md: language goals and specification notes.docs/OpenJai_implementation_notes.md: bootstrap compiler architecture and implementation plan.docs/open_jai_test_spec.md: Jai-style test framework design and example-test conventions.
The current bootstrap build expects:
- Zig 0.16
- LLVM installed under
/usr/local/llvm /usr/local/llvm/bin/llvm-config/usr/local/llvm/bin/clang++- macOS SDK tools available through
xcrun
The language goals include broader platform support, but the current bootstrap build script is wired to this local LLVM/macOS toolchain.
Build the bootstrap compiler:
make bootstrapThis writes generated files under out/:
out/bootstrap/bin/openjai
out/bootstrap/lib/openjai_runtime.o
out/zig-cache/
Build the current staged compiler chain:
make buildToday this means:
stage0: Zig bootstrap seed
stage1: Jai compiler source built by stage0
The Makefile also defines the later self-hosting checks:
make stage2
make stage3
make fixpointThese are intentionally strict and are not expected to pass until the Jai-built
compiler can compile src/main.jai. make fixpoint byte-compares the stage2
and stage3 compiler outputs once both stages exist.
Build the currently supported example subset:
make examplesmake examples checks every *.jai file under examples/ by default.
Generated outputs are written under out/examples/, mirroring the source tree.
Run all repository tests:
make testThis runs the Zig bootstrap tests, the example compile sweep, and the Jai-style test harness.
Check the Jai source port:
make selfhost-checkThe Jai compiler port lives under src/ and mirrors the Zig bootstrap compiler
module boundaries. The Zig bootstrap compiler remains the trusted compiler until
the Jai port can compile examples/hello.jai end-to-end.
Clean generated output:
make cleanAfter make bootstrap, compile a supported source file with:
out/bootstrap/bin/openjai examples/03/3.1_hello_sailor.jai \
-o out/examples/03/3.1_hello_sailor \
--runtime out/bootstrap/lib/openjai_runtime.oThe compiler CLI is currently:
openjai <input.jai> [--check] [-o output] [--runtime runtime.o]
make examples runs the broad compile-through acceptance sweep for the example
corpus. The SUPPORTED_EXAMPLES list is discovered dynamically from
examples/**/*.jai.
You can also override the example list:
make examples EXAMPLES="examples/03/3.1_hello_sailor.jai examples/05/5.1_literals.jai"The project has two layers of tests:
make test-bootstrap: Zig unit tests for the bootstrap compiler.make test-jai: Jai-style tests described bydocs/open_jai_test_spec.md.
Use make test for the full local suite.
Build products are intentionally kept out of the source tree and ignored by git:
out/**/.zig-cache/**/zig-out/**/.build/
Generated artifacts should go under out/, not next to source files.
Zig cache policy:
build.jaicentralizes Zig caches underout/zig-cache/and prunes stale object-cache hashes automatically before Zig bootstrap builds.- Use
openjai build.jai ... - cache-cleanto remove all centralized Zig caches plus legacybootstrap/.zig-cacheartifacts. - Avoid raw
cd bootstrap && zig build; Zig will create a second cache atbootstrap/.zig-cache. If a direct Zig command is required, pass--cache-dir ../out/zig-cache/bootstrap --global-cache-dir ../out/zig-cache/global.
The OpenJai compiler is MIT licensed.