{"slug": "bend-2-is-here", "title": "Bend 2 Is Here", "summary": "Bend 2 has launched with a new `LAWS.bend` file that forces AI coding agents to write mathematical correctness proofs, using Bend's compiler to guarantee declared rules always hold. The language's developers claim Bend compiles to executables as fast as hand-written C on a single CPU core and faster across thousands of cores, and that the compiler verifies mathematical proofs in under a second — work they say takes other projects minutes. The release positions `LAWS.bend` as \"`AGENTS.md` backed by proof,\" blocking AI-generated bugs that would otherwise be merged.", "body_md": "In the post-AGI economy, humans will eventually stop writing and reading code, but we still need an ambiguity-free language to communicate our intents to the AIs building the world around us. Bend is that language.\n\nWith **laws**, intents can be more precise than natural language. With\n**proofs**, we can mechanically verify the AI implemented our prompts correctly.\nAnd with a **fast compiler**, we can run that code at peak compute.\n\nThat's Bend - and nothing else.\n\n**Target:** be as fast as C on the CPU, as fast as CUDA on the GPU. **Status:**\n\nThanks to strong types, purity and linearity, Bend compiles to fast executables as fast as hand-written C (single-core), and even faster (on 10000s cores). The entire language runs on the GPU, with full memory unification.\n\n**Target:** outperform every proof assistant by several OOMs. **Status:**\n\nBend's compiler is so powerful it can verify mathematical proofs. Usually, this is slow. Bend is not. It checks, in under a second, files that other projects would take minutes, making proofs way more practical.\n\nNo threads, no locks, no kernels to write. Split the work in two, and Bend\nspreads the calls over every core it can find, then joins them back. Below,\n`pow2(20)` divides until one task sits on each of 4,096 GPU cores:\n\nPROBLEM: How can you **trust** AI code, without reading it?\n\nSOLUTION: By forcing your AI to write a **correctness proof**.\n\nBend introduces `LAWS.bend`, a file where you declare rules that your app must\nnot break. Bend's compiler then **guarantees** that these laws always hold, by\ndemanding **mathematical proof** whenever your code is edited. For example,\nconsider a game with one law: *winning is impossible*. Here's how it plays out:\n\n**Law**: winning is **impossible*** So far, it works!*\n\n**New feature:** \"Claude, make the board wrap around\"\n\n**Without LAWS.bend:*** Laws broken. AI mistake: **merged**.*\n\n**With LAWS.bend:*** Laws intact. AI mistake: **blocked**!*\n\nWithout `LAWS.bend`, a bug was merged. With it, the AI had to retry, until no\nbugs were left! In this case, it added a wall, but it could have moved the flag,\nmade the room kill you, or whatever. The only thing it can't do is commit a bug,\nbecause it is **mathematically impossible** to break laws in `LAWS.bend`. The\ncompiler *enforces* it.\n\nUsing `LAWS.bend` is simple.\n\n1. \nAsk your AI to formalize your app's rules in `LAWS.bend` . Example:\n  - \nLAW: *\"the sum of all balances must be zero\"*\n  - \nLAW: *\"players can never pass through solid walls\"*\n  - \nLAW: *\"list_sort() must always return ascending numbers\"*\n  - \nLAW: *\"array_set() may never be called out-of-bounds\"*\n  - \nLAW: *\"winning is impossible\"* (the demo above!)\n  - \nAnd so on. Anything you can spell can become a law.\n2. \n3. \nAsk your AI to run `bend PROOF.bend` after editing any code.\n4. \nThat's it. Rejoice as your app never again breaks or violates your rules.\n\nYou can also edit `LAWS.bend` yourself. Here's how it looks:\n\n```\n# LAWS.bend\nlaw you_cant_win:                           # \"winning is impossible\"\n  for moves: List<Game.Move>                # any sequence of moves\n  board = Game.replay(Game.start(), moves)  # replayed from the start\n  {Game.is_won(board) == False{} : Bool}    # never leads to victory\n# PROOF.bend\ndef Laws.you_cant_win(moves):\n  # ... written by the AI\n```\n\nIn short, `LAWS.bend` is `AGENTS.md` backed by **proof**.\n\nWith `LAWS.bend`, *\"make no mistakes\"* becomes enforceable.\n\n[Skeptical? Edit the demo's code and break the \"you can't win\" law!](https://bend-lang.com/#lab)\n\n```\ncurl -fsSL https://bend-lang.com/install.sh | sh\n```\n\nAdd this to your `AGENTS.md`:\n\n```\nWhen using Bend:\n- run `bend guide` to learn it\n- use `LAWS.bend` to keep important rules\n- run `bend PROOF.bend` before committing\n- parallelize the code whenever possible\n```\n\nThen, just say: \"use Bend\"!\n\nHints:\n\n- \nAsk it to write laws for anything that can't break.\n- \nAsk it to parallelize anything you want to be fast.\n- \nBend is young. If anything goes wrong, ask it to open an issue. <3\n\nBend works best on the back-end, on Linux or macOS.\n\n``` php\nimport Base\n\n# Performs effects on the CPU.\ndef main() -> IO(Unit):\n  do IO<Unit>:\n    name : String <- IO.try(String, IO.get_env(\"USER\"))\n    IO.print(\"Hello, \" ++ name)\npython\nimport Base\n\n# Computes 2^d in parallel: a tree of d levels, one leaf per unit.\ndef pow2(+d: Nat) -> U32:\n  match d:\n    case 0n:\n      1\n    case 1n+p:\n      a b = pow2(p) pow2(p)\n      (a + b : U32)\n\n# Runs pow2 on the GPU, via `!`.\ndef main() -> IO(Unit):\n  result = pow2!(20n)\n  IO.print(U32.show(result))\npython\nimport Base\n\n# CLAIM: for every nat x, x + 0 equals x.\nlaw add_zero:\n  for x: Nat\n  {Nat.add(x, 0n) == x : Nat}\n\n# PROOF: induction on `x`, one rewrite (`%`) per step.\ndef add_zero(x):\n  match x:\n    case 0n:\n      {==}\n    case 1n+xp:\n      %add_zero(xp) : {1n+Nat.add(xp, 0n) == 1n+_ : Nat}\n      {==}\n```\n\n- Guide: [GUIDE.md](https://github.com/bendlang/bend/blob/main/guide/GUIDE.md) , also printed by`bend guide` .\n- Demos: [demos/](https://github.com/bendlang/bend/blob/main/demos) , apps, servers and proofs, each with its`LAWS.bend` .\n- Base: [base.bend](https://github.com/bendlang/bend/blob/main/bend2/base.bend) , the base library, also printed by`bend base` .\n- Paper: [BendTT: An Affine Dependent Type Theory](https://github.com/bendlang/bend/blob/main/paper/BendTT.pdf) .\n- Paper: [BendRT: A Parallel Runtime for CPUs and GPUs](https://github.com/bendlang/bend/blob/main/paper/BendRT.pdf) .\n- Formalization: [bend.lean](https://github.com/bendlang/bend/blob/main/bend2/bend.lean) , Bend's core in Lean.\n\n- Website: [https://bend-lang.com](https://bend-lang.com)\n- Discord: [https://discord.bend-lang.com](https://discord.bend-lang.com)\n- Twitter/X: [https://x.com/bendlang](https://x.com/bendlang)\n- Reddit: [https://www.reddit.com/r/bendlang/](https://www.reddit.com/r/bendlang/)\n- Issues: [https://github.com/bendlang/bend/issues](https://github.com/bendlang/bend/issues)\n\n```\n- Bend 2 is a new language. Bend 1 programs and HVM do not carry over.\n- Everything is annotated and nothing is inferred, so code is verbose.\n- No type classes, no traits, and no macros beyond compile-time templates.\n- Bend has no tactics or proof search; proving theorems takes extra effort.\n- Values are affine: closures and arrays cannot be shared.\n- Recursion must be terminating. (Use `@unsafe` to disable this checker.)\n- Computed matches (`match f(x)`) aren't supported. Must split it manually.\n- There is no syntax for if-then-else: a branch is a match on True and False.\n- Numbers are Nat, U32 and F32 only: no U64, I64 or F64 (Metal has no f64).\n- F32 is axiomatic: nothing about floating point can be proven.\n- Strings are linked lists of characters, so text processing is slow.\n- Base is small: expect to write helpers other languages ship built in.\n- Effects are few: print, env, time, sleep, spawn, channels, files, TCP, UDP.\n- No TLS, HTTP library, JSON or regex for now (but you can add them as foreigns).\n- Targets are C, Metal, CUDA and JavaScript; Lua, Luau and Python are planned.\n- The JavaScript target runs on one core and has no graphics or audio.\n- Parallelism requires balanced calls. Flexible parallelism will be added later.\n- Sharing arrays with atomics across threads is experimental and needs `@unsafe`.\n- One GPU per program, one event loop, and no multi-machine execution yet.\n- One C file per program: no separate compilation, no incremental builds.\n- Compiling to native is slow (clang/CUDA/Metal). For fast development, use JS.\n- The compiler is young and has blind spots (unusually slow programs). Report.\n- We don't have as many benchmarks as we'd like yet, especially for the checker.\n- The compiler (not kernel) is 99% AI-written and has not been fully audited yet.\n- The Lean formalization and bend.ts mismatch. Early consistency bugs may occur.\n- A binary needs clang 14+; ! needs 19+, Metal or CUDA 12.\n- No Windows (WSL works); on Linux, Window and Audio need X11 and ALSA headers.\n- The hub has no names, versions, accounts or search yet. Packages are hashes.\n- Error messages are terse; no debugger, profiler, formatter, REPL or LSP.\n- No editor support, no test framework and no documentation beyond the guide.\n- And more that escape me. Be patient, report bugs and request features!\n\nMost of these limitations are being addressed and will improve over time!\n```\n\n**BEND IS YOUNG. EXPECT BUGS AND [REPORT THEM](https://github.com/bendlang/bend/issues).**", "url": "https://wpnews.pro/news/bend-2-is-here", "canonical_source": "https://github.com/bendlang/bend", "published_at": "2026-09-17 20:38:15+00:00", "updated_at": "2026-09-17 20:55:40.980045+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-safety", "large-language-models"], "entities": ["Bend", "Bend 2", "LAWS.bend", "Claude", "CUDA", "C"], "alternates": {"html": "https://wpnews.pro/news/bend-2-is-here", "markdown": "https://wpnews.pro/news/bend-2-is-here.md", "text": "https://wpnews.pro/news/bend-2-is-here.txt", "jsonld": "https://wpnews.pro/news/bend-2-is-here.jsonld"}}