Blog

From Lex to cancho

Lex made the case in an interpreter. cancho asks whether the case survives without one

Alfonso Sastre — October 24, 2026

I. Two Questions

Lex, the first language we built, is high-level and interpreted. Its bet was that a program should be mechanically checkable for what it is allowed to do, and that this check should come before the code runs. The effects a function performs are part of its type; the grant it runs under is a contract the compiler holds it to; the examples in the source are tests.

That bet was made in a comfortable place. An interpreter sits under every Lex program, and the runtime around it, lex-os, is where the sandbox lives. So there were two things we could not tell from inside Lex.

First: are those ideas about the language, or about the runtime that came with it? Second: how much of a real software stack can be built without leaning on other people's libraries, where authority hides?

cancho is how we went looking for the answers. It is a compiled systems language with no interpreter, no garbage collector and no runtime underneath, and it is where we found out which of Lex's ideas were load-bearing.

· · ·

II. What Came Across

cancho's own related-work document lists what it took from Lex: effects in the type system, effect declarations as a function's contract, examples as tests, and content-addressed identity. It also took [budget], the agent-facing introspect and skill commands, and some ideas for version control. And it took the worldview: ownership and authority treated as one system, defined behaviour, a canonical syntax tree.

It does not take any code. cancho depends on nothing from Lex or from lex-os, and its repository says the documents that compared the two are a record of what was measured, not a plan to integrate. It also says something we should repeat here: nothing in cancho is a new idea on its own. Linear types, regions and capabilities have decades of prior work, and at least one language, Austral, reached most of this core before we did.

· · ·

III. What Had to Change

In Lex, authority is something the runtime hands out around the program. Without a runtime, authority has to be something the program itself holds. So in cancho it is a value:

fn greet[&i, &r](io: &!i Io, name: &r [byte]) -> [io_write] int {
    io.write_all(io, "Hello, ");
    return io.write_all(io, name);
}

fn main(world: World) -> [] int {
    let Split { io, ffi, fs, heap, args } = split(world);
    release(ffi); release(fs); release(heap); release(args);
    borrow mut io as &!i in { greet(i, "cancho"); }
    release(io);
    return 0;
}

split(world) is the only place a program gets authority, and it gets all of it, once. A capability is a linear value, so forgetting to release one does not compile. greet says [io_write] because it was handed an Io; a function nothing was given cannot print however much it wants to. The compiler can then write down everything a program may do as a report, and that report is something a CI job can diff.

The same move shaped what we left out. There is no garbage collector, no destructors and no exceptions: a resource is destroyed by naming the function that knows how. There is no borrow checker, because borrowing is lexical and a reference's validity can be read off the syntax. And there are no macros, because they break the stable, content-addressable identity that came from Lex.

· · ·

IV. Taking the Libraries Out

The second question turned out to be the larger project. A dependency is authority you did not write down, and we had already written about what that costs when a single line in a CI uploader changes. So cancho keeps asking what a package needs from the world and tries to make the answer smaller.

Its first real server declared twelve libc symbols of its own. The road to a toolchain with no C in it goes through typed handles for listeners, connections and pollers, then signals, then process spawning, each as a capability narrowed to what the program claims. Those stages are built, and the documents say which paths are not: the macOS signal path, for one, is written and has not been run. TLS without a C library is the furthest along and the most cautious. The primitives (ChaCha20-Poly1305, SHA-384, X25519, a big-number core, RSA and ECDSA verification) live in the standard library, and the design says nothing built from it may be called production-ready before an independent review.

The compiler is the same story. It started in Rust, because the first backend was a Rust library. A second compiler, about 22,000 lines of cancho, is now the default; it falls back to the Rust one for a build it cannot do. It compiles itself to a fixed point on three systems, and as of 2026-10-15 passes 697 of 704 conformance tests with every build going through it; the other seven are listed differences. It does not yet refuse everything the Rust one does: 256 of 333 programs that must be refused get the same rule. It still hands its output to clang to finish. We are not near a toolchain without C, and the repository does not claim to be.

Update, 6 November. Three things above have moved since 24 October. The cancho in a release is now built by cancho: it rebuilds itself to the same bytes, and installing one needs no Rust. It still needs clang to turn the compiler's output into a program, so the C-free toolchain above is no nearer. And on 5 November we decided to remove the Rust compiler: its Cranelift backend is retired, WebAssembly is ported to the compiler in cancho, Windows is out of scope, and a committed seed replaces the Rust stage that every build starts from today. That is a written plan; as of this update no Rust has been deleted. The third change is one of emphasis: Lex is no longer actively developed, and cancho is where the work is now. The conformance figures in the paragraph above are from 15 October and are not re-measured here.

cancho-ui is the same question asked of the browser. Most UI stacks let a component reach the network or the clock through an import, and leave you to find out by reading. In cancho-ui a component declares requires Clock;, and the compiler refuses the program if the declaration and the code disagree. It builds JavaScript and DOM, and reports its findings as data an agent can read.

· · ·

V. Further Down

A language that does not hide the machine can be pointed at what is below it. That is why we started experimenting with hardware descriptions, GPUs and quantum.

cancho-hdl declares the software and hardware boundary once, in a .chw file: registers, fields, interrupts, DMA. The C header, the device tree, the register RTL and CMSIS-SVD are generated from it, and contradictions such as overlapping fields are refused with a rule tag. It is being ported from Python to cancho.

cancho-gpu is a compiler for typed tile kernels, written in cancho, that emits CUDA C and Metal. On the 182 test cases that emit code it matches an independent implementation byte for byte, and both refuse the other 26. It runs Qwen2.5-0.5B and a 27B model on a Metal GPU, agreeing with their references to within the tolerances its README states. Its design work produced the most useful negative result of the project: a bounds check is free even in vectorised code, but an overflow trap is not. The memory half of cancho's no-undefined-behaviour claim survives on a GPU at no cost, and the arithmetic half cannot.

The quantum work is an experiment that is not public yet, so nothing is claimed for it here.

· · ·

VI. Where It Stands

Around the language there are packages that exist because they were the next thing the language had to prove: a cache, an MQTT broker, a reverse proxy, a DNS resolver, a webhook service, a PostgreSQL client, a web framework, a log, and tools for statistics, tables and machine learning. Each has a stage taken from its own README. Most are alpha or early. The cache answers 69 of Redis 7.0's 240 commands and has no persistence. The broker is for a trusted network. We would not run most of them in production, and we say so.

They are mapped, with runnable demos and a version for agents, at the cancho site, and listed on our home page from the same data file.

So what do the two questions come to? On the first, the ideas mostly hold without the runtime: ownership and authority as one system, refusals with named rules, a report of what a program may do. The place they do not hold without help is enforcement. A compile-time report says what a program may do; making a machine obey it is a separate job, and cancho's own measurements say the filesystem half can be enforced and the network and exec halves could not yet. On the second, the answer so far is a direction, not a destination: each piece we rebuild is smaller to audit and slower to finish.

Lex showed that the contract can be checked before the code runs. cancho is the attempt to find out how little has to sit underneath it.

Lex stays where it is: public, usable, and no longer actively developed. It was the first implementation of the manifesto, and it is still where the worldview is written down. cancho is where we find out which parts of that worldview survive when nothing else is holding them up.

— Alfonso Sastre, October 24, 2026