Roadmap

Direction

jihoo2 is jihoo without dependent types. The dependent core (#![dependent_core], jihoo core, .jhc files), its lib/dependent libraries and its Lean proofs were removed and continue in jihoo. jihoo2 retains type families, histories and divisor types, and checks effect attributes structurally on MIR.

jihoo2 should make real systems programs easy to develop while retaining memory safety without lifetime annotations, a garbage collector or implicit reference counting.

Versions start again at 0.1.0. jihoo2 0.1.0, released as v0.1.0, is jihoo’s development line after 0.5.0 without the dependent core, built from the jihoo 0.5.0 seed, and it was jihoo2’s first seed. jihoo2 0.2.0, released as v0.2.0, adds library and diagnostic improvements and the drop fix for sink parameters; 0.2.1 fixes two holes in borrow checking of slices, and 0.3.0, which builds with LLVM 23 instead of LLVM 21, is now the seed. The versions in the headings below (0.1 to 0.5) are jihoo’s releases, whose work jihoo2 inherits; jihoo2’s own releases are named as such.

Keep ownership and parameter conventions stable. Borrowing views remain tracked by the compiler; long-lived owned data refers to other data by typed indices and handles. Improve scoped concurrency, libraries and tools within that model before adding more language mechanisms.

Use complementary applications to guide changes: the self-hosted compiler exercises large programs and generic data structures; Banana, the sibling ../banana terminal, exercises C callbacks, graphics resources, streaming binary input and PTYs. The sibling languages (Shalem, Ruach, Tekel, Aporia, Tohu, ASL) are a source of ideas, taken one at a time with tests. A need found in an application starts as a small reproducer. Fix it in a library when possible, and change the language only when the existing model cannot express the required behavior safely.

Ownership is also linearity: single ownership gives exclusive access to mutable state and tracks disposal, while the rule that forbids an implicit copy forbids cloning a qubit. Combined with per-operation and control-flow rules that keep state recoverable, Reversible and quantum compilation follows that from functions the compiler inverts to quantum circuits it compiles, optimizes and simulates. Each step ends in a program whose output is checked by running it, not by proof, and changes the language only under the rule above: a reproducer the existing model cannot express.

Next

The unnumbered section below is the direction new work grows in; the numbered sections are maintenance and the record of what is done, with completion criteria rather than release dates. Safety and runtime performance checks apply throughout. The reversible and quantum compilation ladder and sections 4 to 6 are complete. The open work is in sections 1 to 3 and section 7.

Reversible and quantum compilation

Linearity is already in jihoo’s core: single ownership, no implicit copies, inout updates and compiler-placed drops. Following that property instead of adding type-level encodings leads from compiler-synthesized inverse functions to reversible pebbling, automatic uncomputation and quantum circuit compilation. Every step ends in a concrete runnable artifact checked by differential runs or simulation, never by proof obligations. ASL computes finite topological and anyon data. jihoo2 compiles, optimizes and simulates circuits. Step 8 connects the two through a verified data exchange.

  1. Reversible functions (Done). #[reversible(inv)] on safe, nongeneric free functions with a body, at least one inout parameter, integer parameters (i8..i128, u8..u128), and a unit result (an attribute avoids taking rev from std.iter and adds no keyword; pub fn f produces a source-level pub inv with the same signature and parameter modes). From a typed structured representation of the body, sema/body emits both forward and inverse MIR through the same instance queue, so elab and check validate both bodies with no new trust boundary. Supported scalar updates: +=, -=, +%=, -%= and ^= where the right-hand side is pure, nontrapping and does not read the target; x *%= c for an odd constant c (inverted by Newton iteration mod 2^n); x ^= x << k (signed or unsigned) and unsigned x ^= x >> k for constant 0 < k < n (inverted by doubling shifts k, 2k, 4k, ... strictly below n); x +%= x << k (inverted by (1 + 2^k)^(-1)); x = !x, x = 0 -% x, unsigned constant rotations x = (x << k) | (x >> (n - k)) (or reversed operands) and std.mem.swap(&a, &b); pure read-only let bindings whose dependencies are not written later in the block; if whose condition reads nothing either branch writes; range loops (lo..hi or lo..=hi) with bounds untouched by the body; and non-recursive calls to either member of a reversible pair with distinct &name mutable actuals and read-only actuals independent of every mutable actual. Everything else fails with an erasure, replay or unsupported-construct diagnostic. Wrapping operations give total bijections for fixed read-only inputs; checked +=/-= gives a partial inverse on the successful forward image. Artifacts: compiled inverses of fmix64, xorshift64 and splitmix64. Checked by differential tests through interp.jh (inv(f)(f(x)) == x and reference forward outputs), tests/run/reversible_*.jh, one tests/fail/reversible_*.jh per diagnostic, LSP and formatter tests, examples/, docs/language/reversible.md (listed in docs/README.md), docs/reference/grammar.md and from-rust.md. Usable immediately in user programs and tests without bumping the seed.
  2. Pebbling and garbage-free reversal (Done). Whole-value owned inout slots can be swapped and passed through reversible pairs. One sink T slot can be moved into another reversible call that immediately refills it, then returned by value. The shared post-elab check rejects surviving drops in both compiled functions and compile-time snapshots. std.pebble provides exact bounded search and Knill’s singleton recurrence for Bennett reversible chain pebbling, plus optimal Revolve binomial checkpointing witnesses. Both planners generate slot-assigned actions for static or run-time execution. Example · Pebbling documentation
  3. Qubits and automatic uncomputation (Done).
    • 3a. CPU simulator and linear circuits (Done). Linear Qubit tokens are consumed by explicit circuit retirement, clean release, seeded measurement or discard. inverse(F) resolves a named reversible pair in direct calls and compile-time function arguments. The compiler certifies qfree compute routines over std.quantum X, CNOT and Toffoli. An ancilla guard borrows the circuit and controls while the body runs, then records the inverse and a zero check. The threaded CPU executor runs the recorded complex gates and checks scratch leakage at each release boundary. The examples demonstrate phase kickback and a five-wire clean-ancilla CCCX despite the four-wire parity obstruction. Example · Quantum circuit documentation
    • 3b. Vulkan GPU backend (Done). lib/gpu/ runs std.quantum.Circuit on discrete and integrated Vulkan GPUs (rejecting CPU/software devices such as Lavapipe) with pure-jihoo SPIR-V 1.0 shaders, f32 and optional f64 state vectors, and readback at recorded zero-check boundaries. Verified on AMD Radeon RX 9060 XT (1002:7590, RADV GFX1200) against the CPU f64 reference across Bell, GHZ, QFT/inverse QFT, Deutsch–Jozsa, Bernstein–Vazirani and five-wire CCCX, with 24-qubit (128 MiB) compute in ~9 ms. Example · Hardware check · Documentation · Next steps
  4. Clifford circuits and stabilizers (Done). std.stabilizer simulates Clifford circuits with bit-packed symplectic tableaux and seeded Pauli measurement. Signed tableau comparison checks exact projective Clifford equivalence, and signed row reduction gives a canonical stabilizer state. Breadth-first enumeration yields 24 and 11,520 projective Cliffords for one and two qubits. The example checks a 1,024-qubit cluster and measures a 2,048-qubit GHZ state. Differential tests cover Bell, GHZ, a 2D cluster, teleportation, and a five-qubit code syndrome against CpuSim. Example · Stabilizer documentation
  5. T-count optimization (Done). std.tcount extracts and synthesizes phase polynomials, decodes punctured Reed–Muller cosets exactly through five wires, and applies TODD to larger Hadamard-separated blocks. The example measures T-counts for published reversible circuits and a two-bit ripple-carry adder, and verifies each unitary on CpuSim. Example · T-count documentation
  6. Exact single-qubit synthesis (Done). std.gridsynth decomposes unitaries over ℤ[1/√2, i] with an exact minimum T-count. Ross–Selinger grid reduction, integer factorization and relative norm equations approximate Z rotations through 1e-8. Exact matrix multiplication and CpuSim verify the emitted circuits. Example · Synthesis documentation
  7. ZX-calculus rewriting (Done). std.zx rewrites unitary circuit diagrams with spider fusion, local complementation, Pauli pivots and phase gadgets. Frontier extraction uses Gaussian elimination over F₂ to recover an executable circuit. A hash-consed e-graph discovers one- and two-wire rewrites from exact projective matrices, filters redundant equations, and extracts lower-cost words. CpuSim checks all discovered rules and the reduced circuits in the example. Example · ZX documentation
  8. Error correction and the ASL bridge (Done). std.qec decodes rotated surface codes with exact Edmonds minimum-weight perfect matching. Local tableau measurements merge and split two logical patches into a Bell state. The 15-to-1 Reed–Muller factory enumerates all input error masks and checks its circuit on CpuSim. The ASL exchange validates exact modular, fusion and condensate data, then compiles toric and planar codes whose string endpoints and braiding are checked on tableaux. Example · QEC documentation

Completion (per step): its artifact is a tests/run or examples program on both targets; every rejection has a tests/fail case; inverses and circuits are checked by differential runs or simulation rather than proof obligations; and the existing test suites, compile baselines and self-hosting stay green.

Exact erasure budgets

Implemented. #[erasure(budget, record, undo)] analyzes total scalar MIR over a u8 or u16 domain, counts inputs per output, and synthesizes a recorder and decoder with the smallest side record for each output. A reusable scalar evaluator bounds compile-time work. The telemetry example rewinds a packed stream and the zero-bit example inverts an eight-bit permutation. The tests compare all 65,536 telemetry inputs in checked and release builds and pin the 12-bit budget diagnostic. Example · Documentation

Future directions

Ideas under consideration after #[erasure], each guided by the same rule as above — concrete executable artifacts checked by differential runs or exact compile-time computation, without bringing back dependent types:

  • Cellular sheaf cohomology (std.sheaf). Generalize std.divisor’s constant-sheaf graph Laplacian to finite cellular sheaves with stalk dimensions and linear restriction maps (e.g. over F2, Z or Q). Compute global sections (H^0), gluing obstructions (H^1) with concrete witnesses (w^T d = 0, w^T b = 1 over F2), and minimal synchronization cuts — bridging distributed local-view consistency with empirical-model quantum contextuality (such as Mermin–Peres and GHZ on std.stabilizer).
  • Directed cubical concurrency (Higher-Dimensional Automata). Generalize std.history from 1D traces to finite precubical complexes modeling concurrent resource schedules with forbidden mutual-exclusion holes (such as Dijkstra’s Swiss Flag). Compute deadlock corners, unavoidable doom regions, and directed homotopy classes of schedules to drive replayable minimal schedule testing.
  • Zero-tape and Revolve reverse-mode automatic differentiation (#[adjoint]). Combine #[reversible], std.pebble’s Revolve binomial checkpointing, linear cotangents and the Vulkan/SPIR-V backend to synthesize reverse-mode gradients in MIR, reconstructing reversible segments without tape storage and checkpointing non-reversible loops within a chosen memory budget.

1. Checking and editor tools

Implemented: jihoo check loads imports, checks types, evaluates compile-time obligations, elaborates moves and drops, and checks borrows without generating LLVM IR or calling a linker. --lib checks modules without an entry point. The regression suite checks valid programs without LLVM or linkers and compares negative-case diagnostics with the existing compiler path.

Implemented: --error-format=json reports source diagnostics with start/end byte positions, related notes and generic-instance context from the same data as text errors. An independent JSON parser checks the negative corpus, source locations, escaping and truncation. Command-line, file, backend and linker failures and fmt --check results use the same document, with a kind for each diagnostic, so every unsuccessful invocation has a machine-readable result.

Implemented: jihoo fmt normalizes indentation and token spacing while preserving comments, literal spellings and meaningful line breaks. --check detects files whose layout differs. Parser-selected lists wrap at a soft width of 100 byte columns, configurable with --width, as do one-line blocks and matches (the blocks of an if ... else chain together), and lines still too long break after their loosest operators. It re-lexes and reparses its output and requires the same syntax tree apart from positions. Corpus tests compare comment bytes, syntax trees, idempotence and generated LLVM IR, including the compiler and standard library on both supported targets. Narrow-width cases exercise nested lists and significant newlines. Given directories or several files, fmt --check reports every file that needs formatting and fmt --write rewrites them; the suite checks the compiler and library that way.

Implemented: jihoo lsp, a Language Server Protocol server that checks open documents, unsaved text included, with the compiler’s loader, checker and diagnostics, publishes errors with their notes as related information, finds definitions in the loaded syntax trees (the member of x.name, with any receiver, as the compiler resolved it), shows locals’ inferred types and items’ declarations on hover, finds references and renames, checking that the renamed program still checks, completes names and members, shows signatures in calls, highlights names, shows inferred types inline, offers a quick fix for an immutable binding that is changed, outlines documents (their items, fields, variants and methods), and formats documents. Checks run in a child process, so replies do not wait for them, and an edit stops a check that has become stale. A client test drives it over the protocol in both position encodings.

Implemented: jihoo test runs the #[test] functions of a file and of the modules it imports outside the standard library, each in a process of its own, so that a panic or a trap fails one test, and prints their results and the output of those that failed. Given a file of the standard library, it runs that module’s tests; the test suite checks its output and runs every std module’s tests.

Implemented: -g writes DWARF line tables: a subprogram per function and the line and column of every statement, call and check, with code from other files in their own file scopes; and every named variable and parameter with its type from types.jh’s layouts, enums as variant parts, each in a lexical block from its declaration to the end of its block, so that a debugger shows values as well as places, and a shadowed name as the one in scope; and gdb pretty printers for str, String, Vec, slices and Map embedded in the executable. The backend suite checks the IR, both optimization levels, the tables and variables in the executable (llvm-dwarfdump), and the printers in gdb.

Implemented: --sanitize=address|thread builds a native program with LLVM’s AddressSanitizer or ThreadSanitizer, for the memory errors and races that only unsafe code and C can make. The backend suite checks that each reports its error and that programs without one run unchanged; every native program of tests/run runs under both without a report.

Next:

  • Unit tests for more of the standard library, next to its code: every module with run-time code of its own has them except std.derive and the profile layers (std.sys, std.os_thread, std.uefi), which the run and uefi suites exercise. thread.scope is tested by tests/run/scoped_threads.jh, as the compiler does not join scoped jobs inside std.thread. Writing them found that Vec.resize did not compile for any element type, that {:08} padded infinity with zeros (00000inf), and that SIGPIPE made os.Error.BrokenPipe unreachable. std.rt, the 128-bit runtime of freestanding and UEFI programs, is checked against the C runtime by tests/run/int128_runtime.jh and its freestanding twin, which print the same checksum.
  • Additional formatter layout rules, retaining syntax preservation checks: the formatter only adds breaks, so a list it once expanded stays expanded after the code around it shrinks (Field( then 1 then )))); joining lines that it broke itself needs to tell them from breaks written by hand.

Completion: valid checks are silent and create no output files; invalid programs retain type, move and borrow diagnostics. Editor diagnostics use the same source ranges and notes. Formatting the compiler and library twice produces the same source, and formatted programs retain their behavior.

2. Application-driven library work

The native type system now supports closed type families and an experimental equality for resource histories. A protocol library can derive its peer type. A data pipeline can specify which input versions an output depends on and accept different schedules that agree for that output. Protocol duality and observer-indexed histories

  • Done: an external regression command. scripts/banana_regression.py runs the jihoo commands of a Banana checkout’s tools/test.sh (its modules checked, its parser, selection, style and PTY tests run) with the compiler under development; the ordinary suite stays independent of it. Banana, last updated for jihoo 0.3.0, passes them all with jihoo2.
  • Develop resource and callback wrappers in the application first. State registration lifetime, thread and reentrancy requirements before exposing a safe interface. Extract reusable pieces after their behavior is tested.
  • Done: binary I/O and structured OS errors. std.os has an errno-based Error and File reads and writes of one system call each, so partial reads/writes, EOF, interrupted operations and nonblocking readiness (set_nonblocking, wait_readable, wait_writable) are explicit; std.fs, io.BufReader and std.process report os.Error; a program that cannot start fails with the error number of its execve.
  • Done: the everyday library gaps that ordinary programs written as in Rust ran into, each with unit tests next to its code: Map iteration, values, clear, get_or_insert and Clone/Eq/Show; Set; iterator adapters and consumers (enumerate, skip, chain, collect, sum, min, max, rev, …); Option and Result combinators; str methods (replace, split_whitespace, strip_prefix, case, join) on String too; Vec.retain, dedup, sort, binary_search; slice windows and chunks; u8’s ASCII classes; parse_float, correctly rounded without the C library; and io.stdin_lines(). Writing them found that a sink parameter moved on only some paths was never dropped on the others, and that parse_int wrapped on overflow.
  • Done: library formatting for several values and options. std.fmt formats a tuple of values with {} patterns (positions, fill, alignment, sign, bases, width, precision, exponents), and floats print the shortest text that reads back as them, from exact big-integer digits.

Completion: the external regression command works with an explicitly selected compiler; core application behavior is tested without a display. Extracted wrappers have ownership and cleanup tests. Binary I/O tests cover partial operations and error recovery in the profiles that support them.

Unicode shaping, IME integration and terminal conformance are application or specialized library work; they do not by themselves require new syntax.

3. Safety and performance regression baselines

  • Done (0.2.1): slices kept the loans of what they are made from. A part of a view (t.as_str()[1..]) and a slice of an array (a[..]) used to carry no loans and could outlive what they point into, reading freed memory. A slice of an array now borrows the array (a temporary array lives to the end of its block), and an element read out of a view carries what the elements hold, apart from the borrow the view is made from, so ["a", "b"].to_vec() still borrows only the literals (tests/fail/slice_of_dropped_*, tests/run/array_slices.jh).

  • Keep negative cases for moves, borrow effects, drops, scoped threads and callback boundaries alongside accepted programs. Continue stage 1/stage 2 comparisons and native/freestanding checks on both supported targets. tests/fail now also covers moves inside loops, dropping or reassigning a borrowed value, and closures that capture where a C-compatible fnptr is required.

  • Done: compilation time and memory. scripts/benchmark_compile.py measures check and full compilation separately on the compiler, a compile-time generation program and the fusion kernels, plus Banana or any other program (--external) when given its checkout. Reports record compiler revision and version, target, options, host, elapsed time and peak process memory per sample; --baseline compares medians with a recorded report, and CI runs the structural --check-only mode on both targets.

  • Done: differential testing. Random integer programs run in Python, in the compile-time interpreter and compiled at four settings (including freestanding) must agree; the run suite checks fixed seeds. The programs also use a struct with a method, an enum with guards, Vec(i64), capturing closures, String generic functions, f64 math, Option, Result with ?, while with break, Map, dyn, std.sort, inout, generic structs and Box; their first runs found that closures borrowed a var they only read mutably, and that the compile-time interpreter had neither float % nor the math builtins.

  • Maintain the fusion benchmark as compiler and library implementations change.

Completion: changes can be compared with a recorded baseline using a reproducible command. Structural and correctness checks run in CI; timing comparisons run on a controlled host with repeated samples. Self-hosting agreement is a regression check, not a proof of memory safety.

4. Parallel compilation (0.3)

Programs use threads at scale, starting with the compiler itself: its passes become parallel where the work is independent, and what that needs from std.thread and std.sync guides the library. Single-threaded costs come first, because allocation-bound code does not scale across threads.

Measured on compiler/main.jh (x86_64, 8 CPUs, -O2, 0.2.1): check took 17.0 s, of which 11.3 s was borrow-effect inference and 5.2 s the borrow checks; sema and elaboration took under 0.5 s. A full build took 36.8 s, nearly all of the rest in LLVM (opt -O2 about 12.5 s, object emission about 6.7 s on the same IR). Every phase ran on one CPU.

  • Done: the borrow kernel’s dataflow uses one flat bit vector per program point and worklists, and effect inference revisits only callers of a function whose relation grew. check takes 1.3 s and a full build 20.7 s; peak memory fell by about a quarter.
  • Done: object emission in parallel. The module is still optimized whole, so inlining is unchanged; a large one is then emitted as up to eight units of consecutive functions, each on its own thread and LLVM context, their number fixed by the module rather than the host. A full build of the compiler takes 15.6 s instead of 20.9 s, and the compiler it builds runs within measurement noise of a single-unit build (instruction and cycle counts too, within 0.2% either way); small programs are emitted exactly as before. Peak memory grows from 277 MiB to 374 MiB: the units are formed by halving so that only two copies of the module are read at once, freed memory is returned before the threads start, and the syntax trees are dropped before the backend.

Repeated local builds now support a compiler worker limit and two content-addressed cutoffs. JIHOO_THREADS caps workers while preserving codegen unit boundaries. JIHOO_CACHE_DIR enables LLVM object reuse. jihoo deps --manifest supplies actual source inputs for incremental tests. The runner can also cut off pure test executions when a rebuilt compiler produces the same IR and build recipe. Cold runs and the default selfhost comparison remain the baseline. Compiler caches · Incremental tests

Remaining for 0.3.0, in this order. Each step keeps the full test suite, the self-hosting comparison and the recorded baseline (benchmarks/compile/baseline-x86_64.json) green, and states its measured effect in the commit and here.

  1. Done: phase timings. --time-passes writes each phase’s elapsed time, CPU time and peak memory on standard error (phase timings), and scripts/benchmark_compile.py --time-passes records them. Every other output is unchanged, and so is the compiler’s speed (within noise of the baseline). Medians of five full -O2 builds of the compiler: load 0.08 s, sema 0.25 s, elaboration 0.11 s, effect inference 0.17 s, borrow checks 0.62 s, IR generation 0.19 s, LLVM parsing 0.46 s, LLVM optimization 11.7 s, emission 2.0 s (9.5 s of CPU) and linking 0.20 s, 15.7 s in all. check takes 1.24 s, half of it borrow checks; peak memory grows from 258 MiB after the checks to 377 MiB during emission.
  2. Done: borrow checks and elaboration in parallel. Each function is elaborated and checked independently, the costliest first (statements times locals predicts the time well), and errors are reported in function order, as before. Effect inference runs in rounds: every function whose callees’ summaries grew is inferred at once from the previous round’s summaries, which reaches the same least fixed point. The per-block loan sets now have rows only for the locals that can hold loans (views, arguments, borrowed locals and those assigned through a pointer, under half in the largest functions); without that, checking the four largest functions at once raised check’s peak memory from 258 MiB to 400 MiB. Types is only read by these passes. Medians of five runs: elaboration 0.11 s to 0.025 s, effect inference 0.17 s to 0.03 s, borrow checks 0.58 s to 0.08 s, check 1.26 s to 0.53 s (1.3 s of CPU) at 274 MiB; a full build takes 15.2 s, its peak unchanged at 365 MiB. The borrow checks cannot go below the largest function, Sema.call_decl_inner, which alone takes 0.1 s.
  3. Done: the library work step 2 needed. thread.each, map and each_mut halve their range by index, which left the compiler’s largest functions, adjacent in sema.jh, on one thread (borrow checks 0.37 s, 1.7 CPUs busy). each_uneven, map_uneven and each_mut_uneven start a thread per processor that each take the next item when free, at an atomic addition per item (threads). Malloc contention did not show up, and the compiler shares no data that would need a Send-like rule: the passes only read the program and types.
  4. Measured: the LLVM optimization time (11.7 s of a 15.2 s build) is mostly the whole-module simplification pipeline around the inliner, and neither lever the plan named helps much. With every function first cleaned up by SROA, CSE, InstCombine and SimplifyCFG (a third of the IR’s lines left), default<O2> still takes 11.4 s instead of 13.0 s (opt, one CPU); SROA alone saves 0.7 s, an upper bound for emitting fewer allocas and copies from llvm.jh. Only the function pipeline after inlining (about 1.4 s) could run per code generation unit without changing what is inlined where, and it would still see module-wide analyses (GlobalsAA) differently. Neither is done for 0.3.0; a full build stays about 2.4 times faster than at 0.2.1.
  5. The release: README’s Status describes 0.3, and this section records the final numbers. The seed need not move first: std.thread is already in 0.2.1.

Sema’s instance queue stays sequential unless measurements show it dominates: it shares the type interner.

Completion: on the controlled host, a full -O2 build of the compiler is several times faster than 36.8 s and check uses the available CPUs; the output of every compilation, diagnostics included, is identical to a sequential one, and the programs it builds are no slower. At 0.3.0: a full build takes 15.2 s (2.4 times faster), check 0.53 s (32 times faster, on 2.5 CPUs), with the same output.

5. Functional composition without cost (0.4)

jihoo already removes most functional abstraction at compile time: enums and match, comptime closure parameters and std.iter pipelines compile to the loop a C programmer would write, and the fusion benchmark checks it. 0.4 closes the places where a functional program still has to pay, or fall back to flags and copies. Each item below starts from a reproducer that the 0.3.0 compiler rejects or accepts with a runtime failure; that is the condition the Direction section sets for changing the language. Lazy evaluation, garbage collection, implicit reference counting and higher-kinded types remain out of scope: they conflict with predictable memory, not with any one feature.

  1. Done: owned closures with static types (design). A borrowing fn cannot leave the function that made it, and a dyn fn costs an allocation and an indirect call, so a function could not return a pipeline whose closure captures its own locals:

    fn scaled(n: i64) -> iter.MapIter(iter.Range, i64) {
        let k = n
        iter.range(0, 5).map(fn(x) { x * k })   // error: borrows `k`
    }

    move fn(x) { ... } owns its captures with a type of its own, so calls stay direct and nothing is allocated; -> impl Iterator and -> impl fn(A) -> R name such types in results, and comptime F: impl fn(A) -> R takes them as type parameters. map and filter hold either kind of closure, so the reproducer is fn scaled(n: i64) -> impl Iterator with move fn(x) { x * k } (tests/run/move_closures.jh, tests/fail/move_closure_*, tests/fail/impl_*). The fusion benchmark’s iterator_returned kernel returns such a pipeline; its optimized IR has no allocations and no callbacks, the other kernels’ optimized IR is unchanged, and dyn fn is unchanged.

  2. Done: patterns and match as expressions. Three gaps pushed programs toward flags and clones:

    • Done: A(x) | B(x) binds the same names in every alternative, with the same types and var-ness, in match arms (guards included) and in let (tests/run/or_patterns.jh, tests/fail/or_pattern_*).
    • Done: let t = match o { Some(t) => t, None => return 0 } with o borrowed. When the first arm that gives a value gives a place it cannot move out of, the match is a view (a borrow of what each arm gives), checked by the borrow kernel like any other view (tests/run/match_views.jh, tests/fail/match_view_*).
    • Done: let Some(t) = o else { return 0 }, a pattern that must match, with a diverging else that does not see its names (tests/run/let_else.jh, tests/fail/let_else_*).

    Each form has tests/run and tests/fail cases (borrowed and owned scrutinees, values with destructors, moves on only some paths), from-rust.md and the pattern reference describe them, and the formatter preserves them (tests/format/input.jh).

  3. Done: format patterns checked while compiling. A function’s #[literal_check(param, check)] runs check in the interpreter for a literal argument; std.fmt checks syntax, placeholders against the values and integer or float kinds against their types (tests/fail/fmt_*). The checks run after the program is lowered and the functions only they need are dropped, so valid calls give the same IR. On 200 checked calls with 8 value types, check takes 0.18 s and 33 MiB instead of 0.055 s and 22 MiB, a full build 1.0 s and 87 MiB instead of 0.90 s and 77 MiB (each checking instance keeps its prepared functions while the checks run); the compiler workload, which does not use std.fmt, is unchanged.

  4. Done: the release. 0.4.0 is tagged and the seed is 0.4.0, so the compiler now uses these features: let ... else replaces 39 matches that only unwrapped an Option or left. Map.get results with a str key stay matches until the next seed: in 0.4.0 the String such a key is lent as ends with the statement, while let ... else keeps it borrowed; it now lives to the end of the block (from Rust). The editor work in section 1 (sema-resolved definitions, hover) continues alongside.

Completion: the three reproducers compile and run, or fail while compiling with a diagnostic, on both targets in both profiles; the fusion benchmark and the compile-time baseline show no regression; README’s Status and the language pages describe 0.4.

6. Structural effect checks and certified extents

#[no_alloc] and #[no_panic] are checked on elaborated MIR after ownership checking. The checks follow calls and drops and report a chain to the operation that violates the attribute. CLI checking, code generation and the language server share this pipeline.

Certified slice extents check a restricted set of shape and order facts during lowering. Accepted extent_at and extent_slice accesses generate no bounds assertion. Ordinary indexing and slicing retain their runtime safety checks.

7. Ideas from the sibling languages

The sibling repositories (Shalem, Ruach, Tekel, Aporia, Tohu, ASL) solve some of jihoo’s problems from other directions. Done, each with its tests:

  • From Shalem: std.modint.
  • From Ruach: Box.map, reuse of an allocation that ownership already says nothing else refers to, as a library function rather than a compiler pass. Ruach’s and Shalem’s C benchmarks, compared with clang and GCC (versus C).
  • From Tekel: effect attributes that apply through the call graph.

Tekel’s amortized analysis suggests compile-time cost bounds over the MIR interpreter’s steps. A comptime workload could state its budget and have a bound checked before evaluation starts.

0.1: the rewrite

Done (design):

  1. One language and one compiler: a Rust crate writing LLVM IR text, with no VM, no garbage collector and no C++ backend.
  2. Ownership: moves, explicit copies, destructors and drop flags; let, var and inout locals.
  3. Borrowing: parameter conventions (inout, sink), projections (-> ref T, -> inout T), views and their lifetimes, and a borrow kernel that checks exclusivity on MIR.
  4. Structs, enums, tuples, arrays, slices; match with exhaustiveness checking; for over ranges, collections and iterators.
  5. Generics as compile-time parameters, inferred; traits with default methods, generic impls and associated types; marker traits from the compiler.
  6. Closures that borrow, comptime closure parameters, function pointers.
  7. Option, Result and ?; panics, and #[panic_handler] to report them another way.
  8. unsafe: raw pointers, static globals, extern fn (with ...), export fn, system calls, atomics, volatile accesses; kernel code without the red zone or vector registers.
  9. The standard library in jihoo: Vec, String, Map, Box, sorting, files, arguments, the environment, running other programs (std.process), printing; native and freestanding.
  10. x86_64 and aarch64 Linux. Native C FFI includes shared libraries (std.ffi), structs by value, nested structs and arrays, 128-bit integers, aggregate callbacks and variadic function pointers with C default argument promotions and checked C signatures on both targets. LLVM 23’s C API handles optimization and object emission in process; clang remains an optional comparison backend.
  11. Speed: on the benchmarks (recursion, a sieve, matrix multiplication, n-body), within measurement noise of C compiled by clang at -O2, with bounds checks on.

0.2: self-hosting and tools

Done, in the 0.1.x releases and since 0.1.3:

  • The compiler in jihoo. Every pass is ported, and the compiler in jihoo builds itself (stage 2) and writes the same LLVM IR as the Rust compiler did for every program. It is now the only compiler: the Rust one was removed after 0.1.1, and the released binary of the previous version bootstraps the next (self-hosting).
  • Compile-time evaluation of ordinary function calls, recursion, control flow and fixed aggregates, through a separate MIR interpreter that uses the target’s layout. const items, comptime expressions, array lengths and compile-time arguments use it.
  • Compile-time heap: the interpreter provides the allocator and runs destructors, so Vec, String and Map work in comptime code, and String and Vec results become static str and slice constants (the heap).
  • Dynamic dispatch: owned dyn Trait values, called through a table of functions, and dyn fn closures that own what they capture, so they can be returned and stored (dynamic dispatch). Left: traits with parameters, methods that return borrows, and a borrowed dyn that does not allocate.
  • Functional composition: lazy iterator adapters and consumers in std.iter, with generic callback result inference and capture and forwarding of statically known closures.
  • Checking and editor tools: jihoo check without code generation, JSON source diagnostics, jihoo fmt with syntax preservation checks (Next, step 1), compile-time resource reports, and jihoo --version.
  • No experiments in the repository: functional fusion is a benchmark, and the proof experiments left it (completed milestone 5).

Completed milestones

These capabilities are available already; they are not the next work queue.

1. Reflection, and derive in the library

Done (reflection and derive), with Default and field_type; derived bounds on generic types and user-written derives are left:

  • inline for accepts the same exclusive (a..b) and inclusive (a..=b) ranges as ordinary integer loops, with at most 65536 compile-time indices. inline if c compiles only the branch its compile-time condition selects.
  • Builtins that describe a type (field_count, field_name, variant_count, variant_name, variant_field_count, is_struct, is_enum), name its parts (field(x, i), variant_of(x), variant_field(x, v, j)), and build values from parts (make(T, fn(i) { ... }), make_variant(T, v, fn(j) { ... })).
  • #[derive(Clone, Eq, Ord, Hash, Show)], written in jihoo in std/derive.jh with those builtins. The compiler only connects the attribute to the library code. Privacy holds: reflection reads or builds another module’s private fields only in the derived code of a type that asked for it.
  • Default uses field_type to name field types at compile time.

2. Concurrency that borrows

Done (threads). std.thread has scope, join, each, map and each_mut, on POSIX threads in native programs and clone in freestanding ones. A closure that runs on several threads at once is checked at compile time with captures_mut.

  • Done: scoped threads (thread.scope(fn(s) { s.spawn(...) })), with heap-backed capture tuples, consuming result handles and compiler-inserted joins before captured locals die, including on early returns. The scope retains loans and owns jobs even when handles are forgotten.
  • Done: #[interior] memory, which changes behind shared borrows (no readonly/noalias there), and on it std.sync.Atomic and Mutex.
  • Done: channels (std.sync.Channel, bounded or not) and once-cells (Once), on the same foundation.
  • A Send-like rule, if a type that one thread only may use ever exists. Today #[interior] types promise to be safe from several threads.
  • Done: threads in freestanding programs: a thread-safe allocator, clone and futexes.

3. The data-oriented standard library

Done (data by index): std.arena.

  • Typed indices (Id(T)) and arenas that hand them out.
  • Generational handles, which detect a use after the slot was reused.
  • Soa(T), a struct-of-arrays vector built from T’s fields at compile time with reflection (step 1).

Closed monotone arena worlds add a closed arena entry, first-order same-world helpers, and typed MIR element projections. They cover append-only activation-local storage with check-free lookup, including for IDs loaded from ordinary containers.

4. Errors in one function

Done: one run reports every function’s errors, in source order. A use after a move notes each move that reaches it, a borrow conflict notes where the borrow started, and an error in a generic instance notes the chain of uses that made it.

  • Notes that show where a moved value went and where a borrow started.
  • More than one error per run.

5. Closing the experiments

The repository no longer has experimental directories:

  • Functional fusion is the benchmark in benchmarks/. Its iterator API is std.iter; CI runs its correctness, allocation and optimized-IR checks without timing, and tests/run keeps the iterator, trap order, streaming parser and compile-time closure regressions.
  • The Horn kernel port, the general proof development and the checked codec left the repository with their history, and are not part of jihoo2. The compiler keeps what they needed from it: compile-time resource reports and the evaluator speedups.

6. UEFI applications (0.4.1)

Done (profiles): a third profile, #![uefi], for programs that firmware starts.

  • PE32+ images for x86_64 and aarch64: COFF objects with the Windows calling convention, linked by lld’s COFF linker, with efi_main, __chkstk and the memory functions written by the compiler.
  • The Microsoft x64 C ABI in cabi.jh, checked against clang with the aggregate C oracle.
  • std.sys on the boot services (consoles and memory pools), and std.uefi for the firmware’s tables.
  • The uefi test suite runs the programs of tests/uefi and most of tests/run under OVMF in QEMU.

Left: files (the simple file system protocol), program arguments from the loaded image’s options, and calling a service through a field of a raw pointer without (*p).

Deferred features

  • Dependent types and Lean proofs continue in jihoo.
  • Generic derives: inferred derived bounds on generic types and user-written derives, when concrete library users need them.
  • Dynamic dispatch extensions: traits with parameters, methods returning borrows, and borrowed trait objects without allocation.
  • Project tooling: use the existing graft setup while collecting concrete requirements for project manifests, dependency management and caching. A package registry is not an immediate milestone.
  • The standard library on another operating system: a library object with a #[panic_handler] makes no system calls of its own, but std.sys (allocation, output) is Linux’s, libc’s or UEFI’s. A std.sys that the program supplies through extern fns would let a custom kernel use Vec and String.
  • Tail calls that never grow the stack.
  • Macros, if reflection turns out not to cover what they would do.
Esc