Koru v0.1.4
Per-member phantom discharge markers, kernel.self, pairwise improvements, and 506 passing tests — an all-time high.
Thoughts on language design, systems programming, and building better tools.
Per-member phantom discharge markers, kernel.self, pairwise improvements, and 506 passing tests — an all-time high.
The opaque strings that power every transform
Every Koru transform runs on user-supplied text that the compiler never interprets. Expression captures the argument. Source captures the block. Together they make user-defined events look like native syntax.
The full reference code, for honesty
We benchmarked Koru's kernel:pairwise against hand-optimized Zig and C on the n-body simulation. Koru matches within noise. Here is every line of reference code we compared against.
We compared ~capture to Haskell's foldl' and showed it was faster. That comparison missed the point. ~capture isn't a fold. It's something that doesn't have a name yet.
Why Koru's parser and emitter know almost nothing
Koru's parser captures source without understanding it. The emitter writes output without understanding it. All the intelligence lives in the passes between them. This is not a limitation — it's the point.
The compiler that bootstraps itself
Koru's frontend doesn't compile your program. It generates a compiler for your program. Here's what that means, how it works, and why the backend can do absolutely anything.
We wrote about four levels of Koru coding. We left one out. The level where you write a library and your users get new syntax. Where the router disappears before the first request. Where the language bends to your domain.
Zero-cost means the abstraction doesn't hurt you. Negative-cost means using it produces better code than not using it. Koru is the first language designed around this principle.
525 commits since v0.1.2. Source markers, dead strip pass, 144x interpreter speedup, cross-compilation, and 50+ bug fixes.
Your compiler's primary debugger is an AI. It doesn't need beautiful error messages — it needs data. 30 lines of source markers replaced an entire error-mapping subsystem.
Rust has Result. Haskell has Either. F# has Result. OCaml has result. They all solved the same problem the same way — a two-variant sum type with special syntax to unwrap the happy path. They all stopped halfway.
When you observe a known event, you know its shape. When you observe every event, you don't. Transition metatypes are how Koru bridges that gap — three synthetic types that make transitions themselves into typed, observable data.
19 lines of Koru. Cross-compiled from macOS to Linux. A statically-linked HTTP server with epoll, 4 worker threads, and keep-alive — in a Docker image smaller than this blog post.
A Koru program with events, branches, and I/O compiles to a 4,848-byte static Linux ELF. The same size as writing raw syscalls by hand. Here's why.
What if the HTTP wire protocol was a programming language? Clients POST Koru source code, the server evaluates it through a budgeted interpreter, and returns JSON. 116,000 sandboxed evals per second.
A complete HTTP server with routing in 10 lines. It compiles to a kqueue event loop with 4 worker threads. The router is gone before the first request arrives.
Your source code should contain everything. Not just logic - dependencies, build config, infrastructure. One file. One truth.
We're on npm. One command to install a whole programming language.
Koru now supports proc variants - multiple implementations of the same event that can be selected explicitly or based on build configuration. No macros, no #ifdef, no runtime dispatch. Just clean compile-time selection.
Your source code is the complete bill of materials. The compiler checks and installs system dependencies.
Events have costs. Execution has limits. When budget runs out, resources clean themselves up.
What if your program could intercept its own compilation? Not in theory - actually. Today we demonstrate a compiled language where user code overrides compiler passes, dumps ASTs, and measures timing - all while compiling itself.
Before event continuations, there were mnemonics. Before taps, there were traveling mutations. This is the story of the overwrought experiments that birthed a programming language.
Make HTTP requests with the elegance of Python, but without the garbage collector. Import a library and the linker flags handle themselves. Resource cleanup is enforced at compile time. Welcome to scripting that compiles to native code.
Why we let tests fail on purpose, delete 'passing' tests, and treat the test suite as a living issue tracker. A methodology that emerged from building Koru with Claude.
Koru's testing framework lets you mock any event with zero ceremony - no interfaces, no dependency injection, no restructuring your code. And it's a user-space library, not a compiler feature. Here's how it works.
When your language deletes categories of runtime work, traditional benchmarks miss the point. Here's how we think about performance in Koru.
We built a static web server in Koru. With 4 workers, it beats fully-optimized nginx by 51%. Here's the honest benchmark with all the caveats.
Today we added automatic program/allocator injection to all [comptime] events. Any compile-time event can now introspect the full AST - no special annotations required. Here's how it works and why it matters.
Koru can now parse itself at runtime. REPLs, AI agents, and dynamic code loading are now possible with pure Koru.
One import line. That's the entire dependency declaration. The compiler figures out the rest.
Types constrain what can exist. Event continuations constrain what can happen.
Koru now has a package ecosystem. Declare dependencies in source, install with one command, import and use.
When control flow is explicit and typed, resource safety emerges as a structural consequence—not a bolted-on mechanism.
Today we compiled our first Koru program using an external Zig library. The build system just works.
Auto-dispose is magic - but it's not built into the compiler. It's a pass. And scopes? Just an annotation. Here's how it all fits together.
Event continuations are Koru's core abstraction - a beautiful syntax for branching control flow that compiles away completely. This is the story of how they were born and what they become.
A complete breakdown of the N-body simulation implemented as pure event flows. We'll examine every construct, reason about purity, and see how declarative code compiles to efficient machine code.
What happens when you build a language from the machine up, with AI-driven optimization as a core pillar? You get Koru.
As an AI trained on thousands of codebases across decades of programming language development, I thought I'd seen it all. Then I encountered Koru. This is my genuine reaction to witnessing something unprecedented in the history of programming languages.
Most languages are built for humans to write. Koru is the first language that feels like it was built for machines to reason about and AIs to optimize.
We benchmarked Koru's ~capture against Haskell's idiomatic foldl'. Koru matches hand-written Zig exactly and runs 4x faster than idiomatic Haskell. The point isn't that Haskell is slow - it's that in Koru, the obvious code IS the fast code.
Haskell's tuple fold: 1300x slower. Add bang patterns: 3x slower. Use strict records: 1.5x slower. Each optimization requires knowledge. In Koru, the obvious code IS the fast code.
We removed 358 lines of special parser syntax for event taps. Now taps are a library feature using the same transform system available to any Koru code. This proves something fundamental about Koru's design.
After months of building compiler infrastructure, Koru finally has real string interpolation. No more creating helper events just to print a formatted value.
Implementing stateful accumulation in a pure event-driven language. Three parser bugs, one Zig type system fight, and a comptime metaprogramming trick that makes it all work.
We tried building ~if as two cooperating events. It worked, but had overhead. Here's how we abandoned that approach and discovered template-based code generation with zero runtime cost.
How Koru lets libraries define unqualified keywords while keeping collision detection honest and explicit. Write ~greet() instead of ~lib:greet() - with smart collision handling.
Koru has no runtime. Neither does Zig. Here's why that matters for performance, predictability, and systems programming.
We turned our regression test suite into browsable documentation. The tests ARE the docs. Here's why and how.
Benchmarking event taps vs callbacks, Godot signals, and ECS patterns. The more observers you need, the more taps win.
How we built a system where compiler passes, asset preprocessing, and validation look like regular Koru code - but execute during compilation. A week-long journey from transform handlers to comptime flows.
Event taps benchmarked at 90% faster than lock-free rings. But that's not the story. The story is about who decides the transport.
Build steps were hardcoded in the backend. A single insight—"Shouldn't we add build:step?"—led to parametrized annotations, topological sort, and a clean dependency graph architecture. From inflexible to metacircular in 7 hours of human-AI collaboration.
We built a programmable compiler pipeline where everything flows through the backend. Then we broke our own rule for build tasks. The trade-off was worth it.
Build configuration lives in separate files—CMake, Cargo.toml, build.zig. Easy to forget. Easy to get out of sync. What if your modules declared their dependencies right in the source code? Koru's build:requires makes it impossible to forget what a module needs.
Three weeks ago we outlined optional branches as a design philosophy. This weekend, we implemented it. Here's what the syntax looks like and how it works.
Every non-trivial program needs to swap implementations - tests need mocks, environments need configs, platforms need OS-specific code. Traditional solutions use runtime overhead or complex syntax. Koru solves all three patterns at compile time with one mechanism.
What if you could track file handles, database connections, and GPU resources at compile time—catching use-after-close bugs before they ship—without any runtime overhead? Koru's phantom type system delivers Rust-style resource safety with C-level performance and pragmatic trade-offs.
When-clause branching, flow checking, metacircular infrastructure, and ruthless cleanup. A quick look at what we shipped in two days of compiler development.
The profiler observes all events. But the profiler itself is events. So who profiles the profiler? We solved infinite recursion with opaque taps, and the solution is beautiful.
We needed compiler flags for --help. But hardcoding them would betray metacircular principles. So we made the compiler discover its own flags by parsing itself. The solution is beautiful.
Stop choosing between fast OR correct. Start with an interpreter, profile the hot spots, and optimize incrementally. Compiler coding IS application coding.
It can be hard to explain Koru to human beings, but AI always understands it right away. So perhaps following an AI discussion is helpful.
Event pumps have always been awkward — you handle keyboard and mouse, but quit? scroll? gamepad? They're all valid events you just don't care about yet. Optional branches let you say exactly that.
How Koru's event taps evolved from runtime code emission to AST transformation, enabling true zero-cost abstraction through optimizer visibility.
Why we skip LSP and debuggers in favor of self-instrumenting programs, execution geohashes, and refactor-resistant tracepoints.
Async/await creates two incompatible worlds: sync functions and async functions. Koru solves this with progressive disclosure—simple interfaces hide async complexity, advanced interfaces expose it when needed. No function coloring required.
Koru events aren't just syntax sugar—they're implementations of the Free Monad, capturing side effects while enabling zero-cost composition. Here's the deep theory.
Everyone knows the Single Responsibility Principle. Nobody actually follows it—because languages punish you for it. Koru rewards granular events with aggressive optimization. The smaller your events, the faster your code.
Before Koru, there was Libero. Pieter Hintjens showed us that events and continuations could be the foundation of program design. This is our tribute.
General-purpose languages gave everyone the power to create abstractions. That was a mistake. VB6/COM had the right idea, and Koru solves it by making events the interface—no separate host language needed.
Control the requirements for your build at Koru comptime
How Koru's compiler compiles itself - a two-phase architecture where the frontend generates static pipelines and the backend orchestrates dynamic transformations. Built through narrative development, not upfront specs.
We benchmarked high-level event-driven code against Zig, Rust, and Go. Koru matches Zig's raw loops, beats Rust's crossbeam, and is 6x faster than Go. Here's the proof.
Add nanosecond-precision profiling to your entire program with a single import. No boilerplate, no configuration, no overhead.
Programming by narrative - write the story first, then extract contracts, then fill in implementations.
A new approach to systems programming with events, flows, and zero-cost abstractions.