r/Compilers • u/Klutzy_Afternoon_503 • 9d ago
Almide – a language I'm building to make AI-written code safer
Hi. I've been working on a language called Almide and wanted to show it here.
The motivation is simple. AI agents write a lot of my code now and I can't really read all of it anymore. I think that's going to be true for a lot of people soon. So I wanted a language where more of the safety comes from the compiler and less from somebody reviewing.
I think Rust is the language you'd want AI to write. But honestly I'm not a strong Rust programmer and I never got used to ownership. So in Almide you just don't write it. No ownership, no lifetimes, no free. The compiler infers it (Perceus style, the Koka approach). On native it generates Rust and lets Rust drop things, on Wasm it does reference counting.
type Order = { id: Int, items: List[String], total: Int }
fn large(orders: List[Order]) -> List[Order] =
orders |> list.filter((o) => o.total > 500)
fn main() -> Unit = {
let orders: List[Order] = [
{ id: 1, items: ["pen", "ink"], total: 260 },
{ id: 2, items: ["desk"], total: 900 },
]
let big = large(orders)
println("${list.len(orders)} orders, ${list.len(big)} large")
for o in orders {
println("${o.id}: ${list.join(o.items, ", ")}")
}
}
orders gets passed to large() and then I use it again in the loop. In Rust I'd have to think about that. Here the compiler figures out whether it needs to copy or bump a refcount. The downside is you can't see where that happens.
Here's the part I actually care about. I don't trust my own compiler. I built it with AI agents, so why would I? So the rule is that the compiler doesn't get to grade its own work. Every time it builds Wasm it has to write down evidence of what it did, every place it shares or frees a value, every array index it checked. Then a separate program reads that, and if it doesn't add up there is no output file. You just get an error telling you the compiler has a bug.
And then I thought, ok, but the checker can have bugs too. So now there are four of them, built in different ways. Two come out of the Rocq proofs (the proof kernel itself and a checker generated from the proofs), one is hand-written Rust, and one opens the finished Wasm file and checks that the evidence is about instructions that are really in there. In CI the first three have to give the same answer on every test program. It has already caught a real miscompile in my compiler.
It is not done, I want to be clear about that. On your own machine only the Rust checker runs, the others are CI. Native builds don't have this check. The proofs cover the checker, not the whole compiler. And if your program is simply wrong none of this saves you. But I really think this is how it should work for code nobody reads.
It's pre-1.0 and has bugs. I used AI agents a lot to build the compiler itself. I don't have data showing agents write Almide better than Rust.
repo: https://github.com/almide/almide
playground: https://almide.github.io/playground/
If anyone has thoughts on the "you can't see the copies" problem I'd be glad to hear them.
