Koru Logo

Koru

Uncompromising systems language

Pre-release. Three emitters β€” native via Zig, JavaScript, and C#; the playground below is the full pipeline running client-side.

Performance

The compiler generates the specialized code; you write the readable version. State the intent, get the unrolled native loop.

64,513 vs 48,123 sieve passes/5s against the strongest Rust entry β€” same box, interleaved.

Safety

Every exit must be handled, every obligation discharged, impurity tracked to its boundary β€” or the program does not compile.

Refusals, not lints β€” the compiler names the dischargers it cannot choose between.

Developer Experience

Diagnostics that teach: a refusal names what to write instead. Bounded tors and flows give both humans and agents contracts to reason against.

error[KORU030]: Resource 'tx' <in-transaction!> has multiple discharge options: rollback, commit. Discharge explicitly.

Control

The compiler pipeline is a subflow your program can override β€” analysis, passes, emission. The default is a baseline, not a law.

std/compiler:coordinate is [comptime|abstract]. Verified at koru_std/compiler.kz:799.

Continuations

A tor declares its named exits upfront; a caller handles all of them. No hidden exceptions, no unhandled cases. A tor with a single output skips the ceremony and returns through -> T instead.

Phantom Obligations

The ! suffix mints an obligation; a parameter written <!state> discharges it. Leave a transaction open and the program refuses to compile β€” and when exactly one tor can settle the resource, the compiler inserts the call itself. All of it at zero runtime cost.

Measured, not promised: error[KORU030]: Resource 'tx' <in-transaction!> has multiple discharge options: rollback, commit. Discharge explicitly.

Taps

Observe a tor’s transitions without modifying its flow. Attach logging, metrics, or tracing as a detached layer β€” widen the pattern to tap(* -> *) and the whole program is instrumented.

Generated code

The performance claim is not "Koru is fast." It is that the program states intent and the compiler emits the specialized machine code for it. std/field:mark-multiples is a [transform]: each call site gets an unrolled, residue-specialized marker with the bit-masks baked in β€” the same machinery that compiles a regex to a DFA.

The 35-line prime sieve β€” re-measured 2026-10-10 on a dedicated Xeon 8358, interleaved against the strongest Rust entry in the field: 64,513 vs 48,123 passes/5s, correctness-pinned at Ο€(10⁢) = 78,498. The sieve, the timing loop, and the counting are all Koru; the host touches are the clock and the per-pass field allocation the benchmark's faithfulness rule demands.

Where the substrate was put under a microscope β€” pure codegen, no stores β€” the result was parity or noise. Where it wasn't, we publish that too. And where hand-written machine-level code still wins, it is one escape hatch away.

Metaprogramming

ProgramAST and Source parameters hand a compile-time tor the program's own structure β€” generate code, enforce architectural rules, or rewrite the program that called you. Typed all the way; there is no separate macro language.

Metacircular

The pipeline that compiles your program β€” elaborate, analysis, emission β€” is a subflow declared in the standard library and marked [comptime|abstract]. Your program can override it: inject passes, replace the coordinator, or drive the pipeline for your domain. Koru compile-time is host-language runtime.

Templating

Conditionals evaluate at runtime; the template compiles to format strings β€” no template engine, no allocation machinery.

Purity Tracking

Impurity is transitive and tracked across the call graph: call an impure tor and yours is impure. You always know which parts of a program perform effects β€” tracked everywhere, and enforced wherever a tor marks itself [pure].

Host Escape Hatch

Host code lives in a proc and nowhere else β€” an intrinsic, a syscall, a C library you have no intention of rewriting. The seam is typed, and everything around it stays Koru.

The host is a target, not a foundation β€” and there is no runtime: no VM, no collector, no scheduler. What little support code an emit needs is emitted, in the target language, because you used it. Three emitters today: Zig for native speed and FFI reach, JavaScript β€” which is how the playground runs the whole pipeline in your browser β€” and C#.