BQN

BQN (pronounced "bacon") was designed by Marshall Lochbaum, who also worked on Dyalog APL, and released in 2020. It takes the array model of APL and J and rebuilds it with a simpler, more regular syntax, so learners face fewer historical exceptions.

Paradigm: Array-Oriented Programming

What Makes BQN Special

  • Left-to-right reading. Functions are written as expressions with a clear structure, and arguments are always 𝕨 (left) and 𝕩 (right) in block functions.
  • Three kinds of functions and modifiers. BQN separates functions, 1-modifiers (like ´ fold) and 2-modifiers, and even capitalization signals which is which: Avg is a function.
  • Trains. A sequence like +´÷≠ is a train and reads as "sum divided by length".
  • Nested arrays and namespaces. Lists can contain lists (1‿2‿3 is a list), and namespaces and imports support larger programs than classic APL.
  • Excellent tooling and docs. The online REPL and thorough documentation explain why each design choice was made. Implementations exist in C, JavaScript and Rust.

Example: Average and primes

Avg ← +´÷≠
Avg 2‿4‿4‿4‿5     # 3.8

Primes ← {(2=+˝0=(↕𝕩)|⌜↕𝕩)/↕𝕩}
Primes 30         # ⟨ 2 3 5 7 11 13 17 19 23 29 ⟩

How It Works

  • Avg ← +´÷≠ is a train: +´ folds addition over the list (19), ≠ is its length (5), and ÷ divides. The name starts with a capital letter because it is a function.
  • 2‿4‿4‿4‿5 is the list literal, using the "ligature" character ‿ between items.
  • ↕𝕩 counts from 0. |⌜ makes a table of remainders, and 0= marks exact divisors, as in the APL and J versions.
  • +˝ counts divisors per column, 2= keeps numbers with exactly two divisors, and / filters the counting list. The result is the primes below 30.

History and Where It Is Used

BQN is used for hobby projects, teaching, competitive programming and exploring array ideas, and has an active community. Its documentation is often recommended even to APL programmers, and it is a nice way to see how array languages can be redesigned. BQN glyphs use the APL grammar for highlighting here.

Learn More