All languages

Bend languageexperimental

Pure, affine, dependency-typed: Bend compiles to native CPU and GPU code, and its checker proves the laws stated beside the code, so a program and its correctness proof live in one file.

Overview

Bend is a pure, statically typed language whose checker is also a proof assistant, in the tradition of Lean. Programs and their proofs live together: a law states a fact, a definition discharges it, and the compiler emits native CPU and GPU code that spreads independent calls across every core.

Code

import Base
def main() -> String:
  +a = (6 * 7 : U32)   # `+` may be copied; operators are Base names
  b  = U32.to_nat(a)   # conversions are T.to_x and T.from_x
  U32.show(a) ++ " = " ++ Nat.show(b)
Literals with operators; a list matched, then effects in an IO monad; closures, templates, parallel calls and a GPU call; a law proven by a def.

Distinctive traits

  • Affine by default, resource-aware like Rust: a value has one owner, so a match frees the node it opens and no garbage collector runs.
  • Laws and proofs share one file: a law states a fact, a def of the same name proves it.
  • Parallel calls are the idiom: an independent pair forks, and ! sends the whole subtree to the GPU.
  • Dependent types without universes: Type : Type holds, because running code may not copy a function - what Coq forbids for consistency.
  • Termination is checked, not assumed: recursive calls must consume a smaller part of their input.
  • One C file per program is both the CPU binary and the GPU kernel, so one source runs on either chip.

Status

Young but fast-moving: Bend 2.0.39 (October 2026) ships under Apache-2.0 with Python-shaped syntax and C, Metal, CUDA and JavaScript targets. The type theory is mechanized in Lean, but the checker itself is unproven, and Windows is unsupported.

History

Started in 2023 as HVM-Lang, an intermediate representation for the HVM runtime; it took the name Bend in May 2024 and shipped to crates.io as bend-lang. Bend 2 is a ground-up rewrite that carries no Bend 1 programs over: the interaction-net runtime was dropped for a flat, stackless evaluator, and the type system became an affine dependent type theory.

Sources & references