Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

Bend

> 编程语言
Open source

A massively parallel, high-level programming language

19.8K stars0 likes4 views
WebsiteGitHub

About

A massively parallel, high-level programming language

Bend

A high-level, massively parallel programming language

Index

  1. Introduction
  2. Important Notes
  3. Install
  4. Getting Started
  5. Speedup Example
  6. Additional Resources

Introduction

Bend offers the feel and features of expressive languages like Python and Haskell. This includes fast object allocations, full support for higher-order functions with closures, unrestricted recursion, and even continuations.
Bend scales like CUDA, it runs on massively parallel hardware like GPUs, with nearly linear acceleration based on core count, and without explicit parallelism annotations: no thread creation, locks, mutexes, or atomics.
Bend is powered by the HVM2 runtime.

Important Notes

  • Bend is designed to excel in scaling performance with cores, supporting over 10000 concurrent threads.
  • The current version may have lower single-core performance.
  • You can expect substantial improvements in performance as we advance our code generation and optimization techniques.
  • We are still working to support Windows. Use WSL2 as an alternative solution.
  • We only support NVIDIA Gpus currently.

Install

Install dependencies

On Linux

bash
# Install Rust if you haven't already.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# For the C version of Bend, use GCC. We recommend a version up to 12.x.
sudo apt install gcc

For the CUDA runtime install the CUDA toolkit for Linux version 12.x.

On Mac

bash
# Install Rust if you haven't it already.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# For the C version of Bend, use GCC. We recommend a version up to 12.x.
brew install gcc

Install Bend

  1. Install HVM2 by running:
bash
# HVM2 is HOC's massively parallel Interaction Combinator evaluator.
cargo install hvm

# This ensures HVM is correctly installed and accessible.
hvm --version
  1. Install Bend by running:
bash
# This command will install Bend
cargo install bend-lang

# This ensures Bend is correctly installed and accessible.
bend --version

Getting Started

Running Bend Programs

…

Testing Bend Programs

The example below sums all the numbers in the range from start to target. It can be written in two different methods: one that is inherently sequential (and thus cannot be parallelized), and another that is easily parallelizable. (We will be using the -sflag in most examples, for the sake of visibility)

Sequential version:

First, create a file named sequential_sum.bend

bash
# Write this command on your terminal
touch sequential_sum.bend

Then with your text editor, open the file sequential_sum.bend, copy the code below and paste in the file.

python
# Defines the function Sum with two parameters: start and target
def Sum(start, target):
  if start == target:
    # If the value of start is the same as target, returns start.
    return start
  else:
    # If start is not equal to target, recursively call Sum with
    # start incremented by 1, and add the result to start.
    return start + Sum(start + 1, target)  

def main():
  # This translates to (1 + (2 + (3 + (...... + (999999 + 1000000)))))
  # Note that this will overflow the maximum value of a number in Bend
  return Sum(1, 1_000_000)
Running the file

You can run it using Rust interpreter (Sequential)

bash
bend run-rs sequential_sum.bend -s

Or you can run it using C interpreter (Sequential)

bash
bend run-c sequential_sum.bend -s

If you have a NVIDIA GPU, you can also run in CUDA (Sequential)

bash
bend run-cu sequential_sum.bend -s

In this version, the next value to be calculated depends on the previous sum, meaning that it cannot proceed until the current computation is complete. Now, let's look at the easily parallelizable version.

Parallelizable version:

First close the old file and then proceed to your terminal to create parallel_sum.bend

bash
# Write this command on your terminal
touch parallel_sum.bend

Then with your text editor, open the file parallel_sum.bend, copy the code below and paste in the file.

…

In this example, the (3 + 4) sum does not depend on the (1 + 2), meaning that it can run in parallel because both computations can happen at the same time.

Running the file

You can run it using Rust interpreter (Sequential)

bash
bend run-rs parallel_sum.bend -s

Or you can run it using C interpreter (Parallel)

bash
bend run-c parallel_sum.bend -s

If you have a NVIDIA GPU, you can also run in CUDA (Massively parallel)

bash
bend run-cu parallel_sum.bend -s

In Bend, it can be parallelized by just changing the run command. If your code can run in parallel it will run in parallel.

Speedup Examples

The code snippet below implements a bitonic sorter with immutable tree rotations. It's not the type of algorithm you would expect to run fast on GPUs. However, since it uses a divide and conquer approach, which is inherently parallel, Bend will execute it on multiple threads, no thread creation, no explicit lock management.

Bitonic Sorter Benchmark

  • bend run-rs: CPU, Apple M3 Max: 12.15 seconds
  • bend run-c: CPU, Apple M3 Max: 0.96 seconds
  • bend run-cu: GPU, NVIDIA RTX 4090: 0.21 seconds
Click here for the Bitonic Sorter code
…

if you are interested in some other algorithms, you can check our examples folder

Additional Resources

  • To understand the technology behind Bend, check out the HVM2 paper.
  • We are working on an official documentation, meanwhile for a more in depth explanation check GUIDE.md
  • Read about our features at FEATURES.md
  • Bend is developed by HigherOrderCO - join our Discord!

Issues· 88 open

View all issuesOpen on GitHub
  • #1231

    A goal or error that mentions a self-referential `@unsafe` placeholder never prints: the checker unfolds it forever

    Updated Oct 1, 2026
  • #1212

    --verdict: safe.ts's group_of picks a group by a def's first later-filled name, not by membership — a dead forward reference to a law crashes -o/--verdict, emits a non-member selector, or (with a name_tt collision) PASSes a book computing a different value

    bugUpdated Sep 30, 2026
  • #1204

    def_inst reuses template specializations across unrelated functions due to un-scoped term_key collisions

    bugUpdated Sep 30, 2026
  • #1206

    bend hangs (no verdict, ~1 GB/s memory growth) on a 5-line file with a recursive type alias

    bugUpdated Sep 30, 2026
  • #1131

    BendTT name escaping merges distinct constructor labels across module paths

    Updated Sep 30, 2026
  • #1211

    A failing --verdict, --check-only, run or --checkup exits 0 if its output goes to a reader that has already exited (cli_say's EPIPE branch calls process.exit(0)); pipefail doesn't catch it

    bugUpdated Sep 30, 2026
  • #1205

    The unsafe/foreign gate misses an @unsafe dependency that appears only in a datatype's is Kind(..)

    bugUpdated Sep 29, 2026
  • #1182

    BendTT mismatch for opaque higher-order template with dependent equality result

    Updated Sep 29, 2026
  • #1175

    A spliced inline lambda applied to a rebuilt column emits an un-annotated beta-redex, so --verdict rejects what bend2 accepts

    Updated Sep 29, 2026
  • #1164

    A zero-argument recursive type definition checks, but --verdict and -o stack-overflow elaborating it

    Updated Sep 29, 2026

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言