[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5408":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":29,"discoverSource":30},5408,"Bend","HigherOrderCO\u002FBend","HigherOrderCO","A massively parallel, high-level programming language","https:\u002F\u002Fhigherorderco.com",null,"Rust",19372,479,122,97,0,2,5,27,6,43.04,"Apache License 2.0",false,"main",[],"2026-06-12 02:01:09","\u003Ch1 >Bend\u003C\u002Fh1>\n\u003Cp>A high-level, massively parallel programming language\u003C\u002Fp>\n\n## Index\n1. [Introduction](#introduction)\n2. [Important Notes](#important-notes)\n3. [Install](#install)\n4. [Getting Started](#getting-started)\n5. [Speedup Example](#speedup-examples)\n6. [Additional Resources](#additional-resources)\n\n## Introduction\n\nBend 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.                             \nBend 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.                     \nBend is powered by the [HVM2](https:\u002F\u002Fgithub.com\u002Fhigherorderco\u002Fhvm) runtime.\n\n\n## Important Notes\n\n* Bend is designed to excel in scaling performance with cores, supporting over 10000 concurrent threads.\n* The current version may have lower single-core performance.\n* You can expect substantial improvements in performance as we advance our code generation and optimization techniques.\n* We are still working to support Windows. Use [WSL2](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fwindows\u002Fwsl\u002Finstall) as an alternative solution.\n* [We only support NVIDIA Gpus currently](https:\u002F\u002Fgithub.com\u002FHigherOrderCO\u002FBend\u002Fissues\u002F341).\n\n\n\n\n## Install\n\n### Install dependencies\n\n#### On Linux\n```sh\n# Install Rust if you haven't already.\ncurl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh\n\n# For the C version of Bend, use GCC. We recommend a version up to 12.x.\nsudo apt install gcc\n```\nFor the CUDA runtime [install the CUDA toolkit for Linux](https:\u002F\u002Fdeveloper.nvidia.com\u002Fcuda-downloads?target_os=Linux) version 12.x.\n\n\n#### On Mac\n```sh\n# Install Rust if you haven't it already.\ncurl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh\n\n# For the C version of Bend, use GCC. We recommend a version up to 12.x.\nbrew install gcc\n```\n\n\n### Install Bend\n\n1. Install HVM2 by running:\n```sh\n# HVM2 is HOC's massively parallel Interaction Combinator evaluator.\ncargo install hvm\n\n# This ensures HVM is correctly installed and accessible.\nhvm --version\n```\n2. Install Bend by running:\n```sh\n# This command will install Bend\ncargo install bend-lang\n\n# This ensures Bend is correctly installed and accessible.\nbend --version\n```\n\n### Getting Started\n#### Running Bend Programs\n```sh\nbend run    \u003Cfile.bend> # uses the C interpreter by default (parallel)\nbend run-rs \u003Cfile.bend> # uses the Rust interpreter (sequential)\nbend run-c  \u003Cfile.bend> # uses the C interpreter (parallel)\nbend run-cu \u003Cfile.bend> # uses the CUDA interpreter (massively parallel)\n\n# Notes\n# You can also compile Bend to standalone C\u002FCUDA files using gen-c and gen-cu for maximum performance.\n# The code generator is still in its early stages and not as mature as compilers like GCC and GHC.\n# You can use the -s flag to have more information on\n  # Reductions\n  # Time the code took to run\n  # Interaction per second (In millions)\n```\n\n#### Testing Bend Programs\nThe 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 `-s`flag in most examples, for the sake of visibility)\n\n#### Sequential version:\nFirst, create a file named `sequential_sum.bend`\n```sh\n# Write this command on your terminal\ntouch sequential_sum.bend\n```\nThen with your text editor, open the file `sequential_sum.bend`, copy the code below and paste in the file.\n\n```py\n# Defines the function Sum with two parameters: start and target\ndef Sum(start, target):\n  if start == target:\n    # If the value of start is the same as target, returns start.\n    return start\n  else:\n    # If start is not equal to target, recursively call Sum with\n    # start incremented by 1, and add the result to start.\n    return start + Sum(start + 1, target)  \n\ndef main():\n  # This translates to (1 + (2 + (3 + (...... + (999999 + 1000000)))))\n  # Note that this will overflow the maximum value of a number in Bend\n  return Sum(1, 1_000_000)\n```\n\n##### Running the file\nYou can run it using Rust interpreter (Sequential)\n```sh\nbend run-rs sequential_sum.bend -s\n```\n\nOr you can run it using C interpreter (Sequential)\n```sh\nbend run-c sequential_sum.bend -s\n```\n\nIf you have a NVIDIA GPU, you can also run in CUDA (Sequential)\n```sh\nbend run-cu sequential_sum.bend -s\n```\n\nIn 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.\n\n\n#### Parallelizable version:\nFirst close the old file and then proceed to your terminal to create `parallel_sum.bend`\n```sh\n# Write this command on your terminal\ntouch parallel_sum.bend\n```\nThen with your text editor, open the file `parallel_sum.bend`, copy the code below and paste in the file.\n\n```py\n# Defines the function Sum with two parameters: start and target\ndef Sum(start, target):\n  if start == target:\n    # If the value of start is the same as target, returns start.\n    return start\n  else:\n    # If start is not equal to target, calculate the midpoint (half),\n    # then recursively call Sum on both halves.\n    half = (start + target) \u002F 2\n    left = Sum(start, half)  # (Start -> Half)\n    right = Sum(half + 1, target)\n    return left + right\n\n# A parallelizable sum of numbers from 1 to 1000000\ndef main():\n  # This translates to (((1 + 2) + (3 + 4)) + ... (999999 + 1000000)...)\n  return Sum(1, 1_000_000)\n```\n\nIn 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. \n\n##### Running the file\nYou can run it using Rust interpreter (Sequential)\n```sh\nbend run-rs parallel_sum.bend -s\n```\n\nOr you can run it using C interpreter (Parallel)\n```sh\nbend run-c parallel_sum.bend -s\n```\n\nIf you have a NVIDIA GPU, you can also run in CUDA (Massively parallel)\n```sh\nbend run-cu parallel_sum.bend -s\n```\n\nIn Bend, it can be parallelized by just changing the run command. If your code **can** run in parallel it **will** run in parallel.\n\n\n### Speedup Examples\nThe code snippet below implements a [bitonic sorter](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBitonic_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.\n\n#### Bitonic Sorter Benchmark\n\n- `bend run-rs`: CPU, Apple M3 Max: 12.15 seconds\n- `bend run-c`: CPU, Apple M3 Max: 0.96 seconds\n- `bend run-cu`: GPU, NVIDIA RTX 4090: 0.21 seconds\n\n \u003Cdetails>\n  \u003Csummary>\u003Cb>Click here for the Bitonic Sorter code\u003C\u002Fb>\u003C\u002Fsummary>\n   \n\n```py\n# Sorting Network = just rotate trees!\ndef sort(d, s, tree):\n  switch d:\n    case 0:\n      return tree\n    case _:\n      (x,y) = tree\n      lft   = sort(d-1, 0, x)\n      rgt   = sort(d-1, 1, y)\n      return rots(d, s, (lft, rgt))\n\n# Rotates sub-trees (Blue\u002FGreen Box)\ndef rots(d, s, tree):\n  switch d:\n    case 0:\n      return tree\n    case _:\n      (x,y) = tree\n      return down(d, s, warp(d-1, s, x, y))\n\n# Swaps distant values (Red Box)\ndef warp(d, s, a, b):\n  switch d:\n    case 0:\n      return swap(s ^ (a > b), a, b)\n    case _:\n      (a.a, a.b) = a\n      (b.a, b.b) = b\n      (A.a, A.b) = warp(d-1, s, a.a, b.a)\n      (B.a, B.b) = warp(d-1, s, a.b, b.b)\n      return ((A.a,B.a),(A.b,B.b))\n\n# Propagates downwards\ndef down(d,s,t):\n  switch d:\n    case 0:\n      return t\n    case _:\n      (t.a, t.b) = t\n      return (rots(d-1, s, t.a), rots(d-1, s, t.b))\n\n# Swaps a single pair\ndef swap(s, a, b):\n  switch s:\n    case 0:\n      return (a,b)\n    case _:\n      return (b,a)\n\n# Testing\n# -------\n\n# Generates a big tree\ndef gen(d, x):\n  switch d:\n    case 0:\n      return x\n    case _:\n      return (gen(d-1, x * 2 + 1), gen(d-1, x * 2))\n\n# Sums a big tree\ndef sum(d, t):\n  switch d:\n    case 0:\n      return t\n    case _:\n      (t.a, t.b) = t\n      return sum(d-1, t.a) + sum(d-1, t.b)\n\n# Sorts a big tree\ndef main:\n  return sum(20, sort(20, 0, gen(20, 0)))\n\n```\n\n\u003C\u002Fdetails>\n  \nif you are interested in some other algorithms, you can check our [examples folder](https:\u002F\u002Fgithub.com\u002FHigherOrderCO\u002FBend\u002Ftree\u002Fmain\u002Fexamples)\n\n\n### Additional Resources\n - To understand the technology behind Bend, check out the HVM2 [paper](https:\u002F\u002Fpaper.higherorderco.com\u002F).\n - We are working on an official documentation, meanwhile for a more in depth\n     explanation check [GUIDE.md](https:\u002F\u002Fgithub.com\u002FHigherOrderCO\u002FBend\u002Fblob\u002Fmain\u002FGUIDE.md)\n - Read about our features at [FEATURES.md](https:\u002F\u002Fgithub.com\u002FHigherOrderCO\u002FBend\u002Fblob\u002Fmain\u002FFEATURES.md)\n - Bend is developed by [HigherOrderCO](https:\u002F\u002Fhigherorderco.com\u002F) - join our [Discord](https:\u002F\u002Fdiscord.higherorderco.com)!\n","Bend是一种高度并行的高级编程语言，旨在提供类似Python和Haskell的表达力。它支持快速对象分配、高阶函数、递归及延续等特性，并能在大规模并行硬件如GPU上运行，几乎线性地加速核心数量，无需显式并行标注。Bend由HVM2运行时驱动，专为在多核环境下表现出色而设计，当前版本可支持超过10,000个并发线程。尽管单核性能可能较低，但随着代码生成与优化技术的进步，预期会有显著提升。该项目主要面向需要高效利用多核处理器或GPU资源进行计算密集型任务的应用场景，如科学计算、数据处理等。目前仅支持NVIDIA GPU。","2026-06-11 03:03:07","top_language"]