In development · opening up soon

The language for agent‑written code.

Agents write more of our code every month. Tern is a compiled language built for them: syntax models already know, errors that say exactly what to write instead, and checks that catch the bugs agents make. What they write compiles to native code that outruns Rust and Go.

struct Order:
    item: str
    qty: int
    price: float

fn total(orders: [Order]) float:
    t = 0.0
    for o in orders:
        t += float(o.qty) * o.price
    return t

fn main():
    orders = [Order("tea", 2, 3.5), Order("scone", 3, 2.25)]
    busiest = orders.sort_by(fn(o) -o.qty)[0]
    print(f"total {total(orders)}, most ordered: {busiest.item}")
Output
total 13.75, most ordered: scone
Reads like Python, compiles to native code. Types are checked, and every value is a copy, so nothing can change behind your back.
10 of 10compute benchmarks ahead of or tied with Rustand ahead of Go on all 10
169krequests/s on one server threadRust axum 146k · Go 115k
0.67 soptimized rebuild of a web service after an editGo 2.5 s · Rust release 26 s
319 KBweb server binaryRust axum 1.3 MB · Go 8.1 MB

Made for agents

Easy for a model to get right. Cheap to run once it does.

We gave a coding agent the same spec, a link shortener with a database and click counts, and an empty directory in Tern, Go and TypeScript. All three apps pass the same 32 acceptance checks.

Agent-built appTernGoTypeScript
Lines of code excluding tests273805502
Redirects per second146k154k47k
CPU per redirect23 µs32 µs21 µs one thread
Deployed size408 KB13.6 MB25.8 MB
Memory at idle4.4 MB18.6 MB89.6 MB

Looks like what models know

Python-shaped syntax, so a model writes plausible Tern on the first try, and the compiler checks every type before anything runs.

Errors that say what to write

Every error names the fix, and habits from Python, Go, Rust and JavaScript get a hint: append becomes push, range(n) becomes 0..n. Machine-readable with --json.

One page to learn it

The whole language fits in a reference a model reads in one go, and a plugin teaches Claude Code to write, check and test Tern.

Benchmarks

Tern against Rust and Go, losses included.

Each benchmark is the same program written in all three languages. All three print the same answer, and they run interleaved on an Apple M4 Pro. This is ongoing work: the numbers change as Tern does, and we keep adding benchmarks.

Core language

BenchmarkTernBest RustGo
n-body floating point896 ms982 ms2,671 ms
binary-trees allocation, parallel326 ms, 99 MB343 ms, 96 MB mimalloc1,559 ms, 166 MB
word count hash map of strings122 ms, 40 MB166 ms, 40 MB foldhash207 ms, 199 MB
int map 2M keys69 ms, 67 MB106 ms, 142 MB foldhash621 ms, 121 MB
JSON encode + decode 300k structs172 ms, 107 MB249 ms, 194 MB serde809 ms, 303 MB
sort stable sort_by169 ms, 118 MB255 ms, 189 MB1,870 ms, 167 MB
lines split and scan text118 ms, 55 MB192 ms, 57 MB370 ms, 257 MB
sieve primes229 ms, 25 MB642 ms, 192 MB723 ms
fib fork-join, all cores114 ms115 ms rayon168 ms
tasks parallel for25 ms25 ms rayon36 ms

Web servers and concurrency one server thread

HTTP plaintextthousand requests/s, higher is better
Tern roost169k
Rust axum146k
Go net/http115k
With middlewarethousand requests/s, higher is better
Tern roost160k
Rust axum95k
Go net/http101k
SSE fan-outmillion events/s, higher is better
Tern roost15.7M
Rust axum3.6M
Go net/http0.47M
Server memory under loadpeak MB, lower is better
Tern roost38 MB
Rust axum39 MB
Go net/http102 MB
Spawn 1M tasks, join allms, lower is better
Tern93 ms
Rust tokio249 ms
Go326 ms
100k tasks all waitingMB, lower is better
Tern26 MB
Rust tokio29 MB
Go276 MB

Standard library one thread; Tern’s regex engine is written in Tern

Regex (?i)error|warning|fatalMB/s, higher is better
Tern1,854
Rust regex904
Go regexp26
Regex with capture groupsdates; MB/s, higher is better
Tern2,429
Rust regex1,961
Go regexp59
CSV, parse every rowMB/s, higher is better
Tern928
Rust csv211
Go encoding/csv421
gunzipMB/s, higher is better
Tern2,936
Rust flate2963
Go623
ChaCha20-Poly13051 MiB messages; MB/s, higher is better
Tern1,326
Rust709
Go (assembly)1,214
Argon2id password hash19 MiB, t=2; ms, lower is better
Tern10.4 ms
Rust argon211.0 ms
Go x/crypto18.4 ms

Builds, binaries and WebAssembly

Rebuild after a one-line edita JSON API on PostgreSQL + Redis; optimized builds; seconds, lower is better
Tern0.67 s
Go2.54 s
Rust --release26.4 s
Clean build, empty cachessame service; seconds, lower is better
Tern1.67 s
Go9.69 s
Rust --release44.9 s
WebAssembly binary-trees, 14 threadsms, lower is better
Tern482 ms
Rust + mimalloc630 ms

Where Rust still wins: single-threaded WebAssembly binary-trees against Rust with mimalloc (2.84 s vs Tern’s 3.75 s), and binary-trees memory natively (96 vs 99 MB). SHA-512 is a tie.

Rust release builds on the build charts; Rust’s unoptimized debug build rebuilds in 0.94 s.

Built with Tern

We’re using it to build real products.

The best test of a language is what you can ship with it. These two products are written in Tern.

ternTS

TypeScript, transpiled exactly like tsc. Many times faster.

A TypeScript-to-JavaScript transpiler whose output is identical to tsc’s on 37,000 files from NestJS, VS Code, Grafana, Excalidraw, Immich and Twenty, decorator metadata included. Compiled to WebAssembly, the whole transpiler is 1 MB, so you can run it on your own project in your browser.

Try it in your browser →
32 mstranspile all 1,959 NestJS files
swc 202 ms · tsc 1.44 s
1.33 sall 13,454 VS Code files (177 MB)
swc 6.07 s · tsc 40.2 s
108 msNestJS save-to-restart
nest start --watch 676 ms

StackGrep

Grep the source code of the web.

Search the HTML of tens of millions of websites by text or regex, to find who uses a library, a tracker or a pattern. The whole thing is written in Tern: crawler, live fetcher, HTML-to-Markdown converter, a trigram index served straight from S3, the API and its MCP server for AI agents.

Visit StackGrep →
38Mhomepages from Common Crawl indexed;
the server starts in 0.5 s with 374 MB of RAM
15×less CPU converting HTML to Markdown than Firecrawl’s Go converter
5× less than Rust’s fast_html2md
4,000 sitesfetched live in 68 s on 2 vCPUs, in 63 MB
half the CPU of Go’s net/http

Safe without references

The compiler catches the race.

Tern has no pointers and no borrow checker to satisfy. Because values can’t point at each other, three simple rules are enough to rule out dangling data, aliasing bugs and data races:

  1. Everything is a value. Nothing dangles, nothing forms a cycle, and reference counting frees it all.
  2. Exclusivity. An argument passed as &x can’t overlap any other argument of the call.
  3. Race freedom. In parallel code, what one task writes no other task touches.

Errors say what’s wrong and what to write instead, including when the code looks like Python, Go, Rust or JavaScript.

race.tn
fn main():
    xs = [3, 1, 4, 1, 5, 9, 2, 6]
    total = 0
    parallel for i in 0..len(xs):
        total += xs[i]
    print(total)
tern check race.tn
race.tn:5: error: iterations of `parallel for` run at the same time, so writing `total` from every iteration would race; store per-iteration results in an array indexed by `i`, or combine results after the loop

Batteries included

Everything a server needs, in one small binary.

Parallel by default

parallel: blocks and parallel for loops on a work-stealing scheduler, checked for races at compile time.

roost, the web framework

Axum-style routing, middleware, WebSockets and SSE on green-thread tasks. No async/await anywhere.

Typed SQL

PostgreSQL and SQLite, with migrations and generated query functions: a renamed column is a compile error.

Runs everywhere

macOS, Linux (even a static binary in an empty container), WebAssembly with threads, iOS and Android.

Talks to C

Call C with no binding generator, or build Tern as a library for C, Swift, Kotlin, Python and JavaScript.

Sub-second rebuilds

An optimized rebuild after an edit takes well under a second, so an agent’s edit, compile and test loop stays fast.

Tern isn’t public yet.

We’re opening it up soon: the compiler, the standard library, the docs and a package index. In the meantime, ternTS runs in your browser today.