Tomato v

A statically typed, reference-counted language with indentation syntax, compiled through LLVM. Its compiler is written in Tomato and compiles itself.

An implemented subset. The core language runs today; some decided features are not built yet. The guide shows what works, and the reference marks the rest.

Try it in your browser Download Read the guide

def fib(n: int) -> int:
    if n < 2:
        return n
    return fib(n - 1) + fib(n - 2)

@main
def main():
    print(fib(20))   # 6765
    print(10 / 4)    # 2.5
    print(2 ** 100)  # whole numbers do not overflow

Familiar and typed

Indentation blocks and familiar syntax, with types checked at compile time.

Native through LLVM

Programs compile to LLVM IR and link with a small C runtime. Only clang is needed to build the compiler and your programs.

Self-hosted

The compiler is written in Tomato. It builds itself to a byte-for-byte fixed point, and the checked-in IR bootstraps a machine that has only clang.

Exact where it matters

Whole numbers grow without limit or use a fixed width with overflow errors. float is 64-bit; rational (a library module) is exact.

Speed

Twenty-five benchmarks, each written in Tomato, Go, Rust, Python and eight other languages and checked to print the same answer, are on the Benchmarks page, with the method and the caveats. Tomato is young: in the v0.51 results (an Apple M3 Pro Mac) it beats Python on all 25 (by 4× to 91×), is faster than Rust on three of them (wordcount, revcomp and strings), within 5% of it on five more, and 1.1× to 2.8× slower than Rust on the other seventeen.

Version

The current version is v: the compiler written in Tomato, the only implementation. The command is tomato.