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 a new programming language (currently at version 2) that combines a low‑level, high‑performance runtime with a dependent‑type system and a proof checker. Its purpose is to let you write laws (formal specifications) for your program and require a mathematical proof that those laws hold before the code is accepted.
  • The compiler can target native C, CUDA, Metal and JavaScript, and it can run the whole program on a GPU with unified memory.

Why it matters for AI

  • The README frames Bend as a way to trust AI‑generated code: an AI assistant must produce a PROOF.bend that satisfies the LAWS.bend you define. If the proof fails, the change is rejected, preventing the AI from introducing bugs.
  • This makes Bend relevant to AI‑augmented development, AI‑driven agents, and any workflow where you want formal guarantees that generated code respects safety constraints.

Key features (as described in the README)

Feature What the README says
Speed Claims C‑level performance on CPUs, CUDA‑level on GPUs, with benchmarks showing single‑core C parity and massive scaling on thousands of cores.
Fast proof checking Claims to verify mathematical proofs in under a second, far faster than Isabelle, Agda, Lean, Coq.
Parallelism by default No explicit threads or locks; the language automatically splits work across all available cores (CPU or GPU) using a divide‑and‑conquer model.
Law‑driven development LAWS.bend files declare invariants (e.g., “the sum of all balances must be zero”). The compiler forces a proof for any code change, making violations mathematically impossible.
Syntax Looks like Python mixed with dependent types (def, law, match, explicit Nat, U32, etc.).
Tooling bend command‑line, a formatter/LSP (bend-fmt-lsp), community LSP server, a web‑based playground, and a guide (GUIDE.md).
Targets C, Metal, CUDA, JavaScript (with plans for Lua, Luau, Python).
Open‑source Repository includes the compiler, base library, benchmarks, papers, Lean formalisation, and examples.

Typical workflow

  1. Write or ask an AI to write a LAWS.bend file describing the invariants you care about.
  2. After editing code, run bend PROOF.bend. The compiler checks the proof; if it succeeds, the change can be committed.
  3. Use bend guide to learn the language, and rely on the built‑in parallelism for heavy computation.

Installation (from the README)

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

The script installs the bend binary, which can compile projects (e.g., bend2/main.ts).

Limitations (explicitly listed)

  • Verbose code; no type inference.
  • No type classes, traits, macros, or tactic‑based proof search.
  • Only a few primitive types (Nat, U32, F32) and limited standard library (no TLS, HTTP, JSON, regex).
  • No Windows native support (WSL works). One GPU per program, no multi‑machine execution.
  • Compilation to native binaries is slow; JavaScript target is faster for iteration.
  • The compiler itself is largely AI‑written and not fully audited; the checker may still contain bugs.
  • Several language conveniences (if‑then‑else, recursion without termination guarantees, etc.) are missing or require unsafe annotations.

Community & Resources

Bottom line Bend is an ambitious, research‑grade language that aims to make AI‑generated code safe by coupling high‑performance execution with formal proof of user‑defined invariants. It is still early‑stage (many missing features and a young compiler), but it provides a concrete platform for exploring AI‑assisted development with provable guarantees.

Related