Small programs.
Checked twice.

MUL is a statically typed language built for code that AI agents write and read. Every program goes through one verified SSA IR, then runs in a reference interpreter or compiles to native code with Cranelift, and the tests hold both to the same answer.

Read the docs Browse examples

examples/hello.mul
// Hello, world (RFC-010): `print` is an `io` operation, so `main` is `io`.
// `mul run` prints the line and exits with the value of `main`, here 0.
module demo

pub fn main() -> i32 io {
    print("Hello, world!")
    return 0
}
$ mul run examples/hello.mul; echo "exit code $?"
Hello, world!
exit code 0

Build from source

Needs rustup and a C driver for linking; the toolchain is pinned.

$ make build
$ ./target/release/mul run examples/hello.mul

What the compiler guarantees today

Each snippet below was compiled and run by mul when this page was built; the output is copied from that run.

  • Arithmetic is checked

    An i32 that overflows stops the program with MUL-R002 instead of wrapping to a wrong value, in both backends.

    module demo
    
    fn double(n: i32) -> i32 {
        return n * 2
    }
    
    pub fn main() -> i32 {
        return double(2000000000)
    }
    
    $ mul run --print-result overflow.mul
    overflow.mul:4:12: error[MUL-R002]: i32 overflow in `mul` [byte 51]
      |     return n * 2
      |            ^^^^^
    $ mul run --backend cranelift --print-result overflow.mul
    overflow.mul:4:12: error[MUL-R002]: i32 overflow in `mul` [byte 51]
      |     return n * 2
      |            ^^^^^
    
  • Effects are part of the signature

    A function that prints is io. A pure function cannot call it, so a signature tells you what a call may do.

    module demo
    
    fn greet() -> i32 io {
        print("hi")
        return 0
    }
    
    fn quiet() -> i32 {
        return greet()
    }
    
    pub fn main() -> i32 io {
        return quiet()
    }
    
    $ mul check effects.mul
    effects.mul:9:12: error[MUL-T013]: a `pure` function cannot call the `io` function `greet` [byte 99]
      |     return greet()
      |            ^^^^^^^
    
  • No implicit conversions

    bool is not a number and i32 is not a bool. A mismatch is a compile error with a stable code and a pointer to the span.

    module demo
    
    pub fn main() -> i32 {
        let ready = true
        return ready + 1
    }
    
    $ mul check types.mul
    types.mul:5:12: error[MUL-T012]: type mismatch: expected `i32`, found `bool` [byte 68]
      |     return ready + 1
      |            ^^^^^
    
  • Interpreter and native code agree

    The reference interpreter and Cranelift run the same verified IR, and the tests fail on any difference between them.

    module demo
    
    fn fib(n: i32) -> i32 {
        if n < 2 {
            return n
        }
        return fib(n - 1) + fib(n - 2)
    }
    
    pub fn main() -> i32 {
        return fib(20)
    }
    
    $ mul run --print-result backends.mul
    6765
    $ mul run --backend cranelift --print-result backends.mul
    6765
    
The MUL pipeline: source text is parsed and type-checked, lowered to SSA IR, checked by the verifier, then run by the interpreter or compiled by Cranelift, with the same result

One IR, two backends

The IR is the source of truth. Nothing runs before the verifier accepts it.

  1. The parser and the type checker resolve names, types and effects, and report errors with a stable MUL-* code.
  2. The program is lowered to SSA form with basic blocks and block parameters; mul ir prints it. Every IR node maps back to a range of the MUL source, so a run-time error points to the line that caused it.
  3. The verifier checks dominance, types and effects of that IR.
  4. The interpreter and Cranelift run the same IR. Golden, conformance and documentation tests run in both and fail on any difference.

Where to start

  • Language reference

    Syntax, types, effects and every error code with its fix. Each code block is compiled and run by the test suite.

  • Examples

    The programs from examples/ with their verified IR and output, and token counts against Go, PHP, C and Rust.

  • Compact guide

    The whole current language on one page, sized for a model's prompt. mul guide prints the same text.

From the blog

  • Identity and persistence

    Stable symbol ids and hashes, the .mulb file with an integrity check, runtime errors that point to the MUL source line, and fuzzing of the readers.

  • Welcome to MUL

    What MUL is, what compiles today, why every result is checked twice, and what comes next: identity, Go patch mode and an API for agents.