bendlang/bend

Bend 2: a fast language that blocks AI mistakes via proof. Install: curl -fsSL https://bend-lang.com/install.sh | sh

Bend – A Fast, Parallel Language with Built‑in Proofs

What it is – Bend is an open‑source programming language that combines a high‑performance compiler (aiming for C‑level speed on CPUs and CUDA‑level speed on GPUs) with a proof‑assistant style type system. The language lets you write laws (formal specifications) in a file called LAWS.bend; the compiler requires a mathematical proof for any code change, guaranteeing that those laws never break. It is positioned as a way to make AI‑generated code trustworthy without humans having to read every line.

Core ideas

  • Fast execution – Strong static types, purity and linearity let the compiler emit native C, Metal, CUDA or JavaScript code that runs as fast as hand‑written equivalents, even scaling to thousands of GPU cores.
  • Fast verification – The same compiler checks proofs in under a second, far quicker than traditional proof assistants such as Isabelle, Agda, Lean or Coq.
  • Implicit parallelism – No explicit threads or locks are needed; the runtime automatically splits pure computations across all available CPU/GPU cores and joins the results.
  • Law‑driven developmentLAWS.bend files encode invariants (e.g., “the sum of all balances must be zero”). When the code is edited, the compiler demands a proof that the invariant still holds, blocking any AI‑generated change that would violate it.

Typical workflow

  1. Write one or more laws in LAWS.bend.
  2. Ask an LLM (or a human) to implement or modify code.
  3. Run bend PROOF.bend – the compiler checks the proof against the laws.
  4. If the proof succeeds, the code compiles to a fast executable; otherwise the change is rejected.

Example syntax (Python‑like with dependent types)

import Base

def main() -> IO(Unit):
  do IO<Unit>:
    name : String <- IO.try(String, IO.get_env("USER"))
    IO.print("Hello, " ++ name)

A law and its proof:

law add_zero:
  for x: Nat
  {Nat.add(x, 0n) == x : Nat}

def add_zero(x):
  match x:
    case 0n: {==}
    case 1n+xp:
      %add_zero(xp) : {1n+Nat.add(xp, 0n) == 1n+_ : Nat}
      {==}

Key components in the repo

  • bend2/ – the compiler and standard library (base.bend).
  • paper/ – academic PDFs describing the type theory (BendTT) and the parallel runtime (BendRT).
  • bench/ – benchmark programs used for the performance charts.
  • tools/bend-fmt-lsp – a formatter/LSP that provides syntax‑only language‑server features.
  • demos/ – small example applications, each with its own LAWS.bend.

Installation

curl -fsSL https://bend-lang.com/install.sh | sh

The script installs the bend command‑line tool, which can then be used to compile, run bend guide, format code, etc.

Current limitations (as listed in the README)

  • Verbose code: everything must be annotated; there is no type inference.
  • No type classes, traits, or macros beyond compile‑time templates.
  • Proof search/tactics are absent; proofs must be written manually.\n- Affine values mean closures/arrays cannot be freely shared.
  • Limited standard library (no TLS, HTTP, JSON, regex, etc.).
  • Single‑file programs only; no incremental builds.
  • GPU support is limited to one device per program; no multi‑machine execution.
  • Windows is not a first‑class target (WSL works). The JavaScript target runs single‑threaded.
  • Tooling is minimal: only a formatter LSP, no debugger, profiler, REPL, or rich diagnostics.
  • The compiler itself is largely AI‑generated and has not been fully audited.

Community & resources

  • Website: https://bend-lang.com
  • Discord, Twitter/X, Reddit, and GitHub issues for support and discussion.
  • Full language guide (GUIDE.md), formal Lean model (bend.lean), and academic papers for deeper understanding.

Bottom line – Bend is a real, actively maintained language project that targets the emerging need for verifiable, high‑performance code generated by AI systems. It is still early‑stage, with many missing conveniences, but its core promise—fast execution and fast proof checking—makes it a noteworthy experiment at the intersection of systems programming, formal verification, and AI‑assisted development.

Related

  • Project
  • Project
  • Project
  • Project