# Brine documentation

> Learn Brine, a compiled systems language with Python-like syntax, compile-time proofs, and race-free parallelism on every core, the GPU and many machines.

Source: https://docs.brinelang.org/

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.

```brine
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)
```

## Start here

[Section titled “Start here”](#start-here)

[Install brine](/getting-started/installation/)One command on Linux, macOS and Windows.

[Your first project](/getting-started/first-project/)brine new, run, check and test in five minutes.

[A tour of brine](/getting-started/tour/)The whole language, one example at a time.

[Coming from Python](/getting-started/from-python/)What's the same, what's different, and why.

## What makes Brine different

[Section titled “What makes Brine different”](#what-makes-brine-different)

Parallel by syntax

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

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 →](/proofs/overview/)

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 →](/parallelism/gpu/)

Made for agents too

Error codes, `--json` everywhere, `brine explain`, `brine guide`, and every page of these docs as Markdown. [For agents →](/agents/overview/)

## For coding agents

[Section titled “For coding agents”](#for-coding-agents)

Point your agent at [`/llms.txt`](/llms.txt) for an index of these docs, or [`/llms-full.txt`](/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`](/index.md)). Inside a project, `brine guide` prints the whole language on one page.
