Skip to content

Documentation

Brine documentation

Brine is a compiled systems language for programs that need to be fast, parallel and correct at the same time. You write code that reads like Python. The compiler turns it into native code, proves what it can about it (array bounds, overflow, your own contracts), and spreads it across every core you have, or onto a GPU, with results that are the same bits on any machine.

fn index_of(xs: [int], target: int) -> int:
ensures -1 <= result < len(xs) # proven by the compiler
var lo = 0
var hi = len(xs)
while lo < hi:
invariant 0 <= lo <= hi <= len(xs)
let mid = lo + (hi - lo) / 2
if xs[mid] == target: # bounds check proven: removed
return mid
if xs[mid] < target:
lo = mid + 1
else:
hi = mid
return -1
fn main():
let squares = par [i * i for i in 0..1_000_000] # runs on all cores
let total = par sum(float(x) for x in squares) # same bits on any machine
print(index_of(squares, 144), total)

Parallel by syntax

par for, par [...], par sum(...) and par(a, b) use every core. A data race is a compile error. Parallelism →

Rules can't be broken

requires, ensures and invariant are proven at compile time. There is no unsafe and no flag to turn checks off. Proofs →

GPUs, no annotations

Big par constructs move to an NVIDIA or Apple GPU on their own when that’s faster, with the same result bits. GPU offload →

Made for agents too

Error codes, --json everywhere, brine explain, brine guide, and every page of these docs as Markdown. For agents →

Point your agent at /llms.txt for an index of these docs, or /llms-full.txt for all of them in one file. Every page is also available as Markdown: add .md to its URL (this page is /index.md). Inside a project, brine guide prints the whole language on one page.