View this file with a real REPL here.
documentation • specification • tutorials • implementation • community
Try it online below (arrow at the right for more samples and shift-enter to run), on this page, or in our chat. Use CBQN offline; details here.
Looking for a modern, powerful language centered on Ken Iverson's array programming paradigm? BQN now provides:
- A simple, consistent, and stable array programming language
- A low-dependency C implementation using bytecode compilation: installation
- System functions for math, files, and I/O (including a C FFI)
- Documentation with examples, visuals, explanations, and rationale for features
- Libraries with interfaces for common file formats like JSON and CSV
BQN will provide:
- State of the art array performance: CBQN beats the fastest array languages much of the time, but not always!
- A standard system to install and use libraries and packages, and support for package managers
I think BQN is a good choice for learning and enjoying array programming, scripting, prototyping, and number crunching at a single-CPU scale. For some examples of BQN in action, this repository holds the dreaded self-hosted compiler and the friendlier markdown processor used to generate the site. See also awesome BQN repositories, examples on RosettaCode, or something else from the community page.
It's three letters, that happen to match the capitals in "Big Questions Notation". You can pronounce it "bacon", but are advised to avoid this unless there's puns.
BQN aims to remove irregular and burdensome aspects of the APL tradition, and put the great ideas on a firmer footing. It maintains many of the ideas that made APL\360 revolutionary in 1966:
- Human-friendly infix notation has no precedence rules to remember.
- Built-in array operations handle any number of dimensions easily.
- Higher-order functions allow basic functions to be applied in more powerful ways.
It incorporates concepts developed over years of APL practice:
- With the leading axis model, simpler primitives span the same functionality.
- Trains and combinators enable tacit programming.
- Lightweight anonymous functions (like dfns) borrow some power from Lisp.
But it's redesigned from the ground up, with many features new to the array paradigm:
- The based array model eliminates the surprise of floating arrays and the hassle of explicit boxes, while dedicated array notation does away with the gotchas of stranding.
- Context-free grammar makes it easier for machines and humans to understand code, and naturally leads to first-class functions, which can even be used to reinvent control structures.
- New symbols for built-in functionality make the syntactic role of every primitive instantly visible, and aim to be more consistent and intuitive.
- No-nonsense namespace syntax encapsulates data and even allows for a little object-oriented programming.
Not sold? See why BQN? for an outline of what all these features add up to in terms of programming power.
Right at the beginning, you can use the bar above the online REPL to enter BQN code: hover over a character to see a short description, and click to insert it into the editor. But you'll soon want to skip the clicking and use keyboard input. I type the special characters using a backslash escape, so that, for example, typing \
then z
writes ⥊
(the backslash character itself is not used by BQN). The online REPL supports this method out of the box, and the editor plugins include or link to ways to enable it for editors, browsers, shells, and so on.
The font comparison page shows several fonts that support BQN (including the one used on this site, BQN386). Most other monospace fonts are missing some BQN characters, such as double-struck letters 𝕨
, 𝕩
and so on, which will cause these characters to be rendered with a fallback font and possibly have the wrong width or look inconsistent. The double-struck characters also require two bytes in UTF-16, which breaks rendering in some Windows terminals. Windows Terminal itself fixed this in 2023, and VS Code and wsl-terminal also support them with an appropriate font.
Chat forum links below; either of the bold ones will open in a browser without much hassle if you just want to get on quickly. Further forum details here.
Discord | Matrix | …in Element | |
---|---|---|---|
All rooms | Invite | #array:matrix.org | Space |
BQN room | #bqn:matrix.org | Room |
Discord is a popular commercial chat client and Element is a similar UI for the open chat protocol Matrix. They're bridged together so that messages in one appear in the other. Most discussion happens on these (they're quite active), but see also the community page for activities and such in other places.
Also feel free to contact me personally via Github issues or with the email address shown in my Github profile.
BQN's tutorials are intended as an introduction to array programming with BQN. They assume only knowledge of elementary mathematics, but will probably be hard to follow if you have no programming experience. BQN has a lot in common with dynamically-typed functional languages like Lisp, Julia, or Javascript, so knowledge of these languages will be particularly helpful. The tutorials end abruptly right now, so you'll have to switch to the documentation, which is less structured. The documentation has a quick start page which is a nice way to dive in.
If you're already an array programmer, you might start with the documentation right away, using the BQN-Dyalog APL or BQN-J dictionary as a quick reference where appropriate. Be aware of two key differences between BQN and existing array languages beyond just the changes of primitives—if these differences don't seem important to you then you don't understand them! BQN's based array model is different from both a flat array model like J and a nested one like APL2, Dyalog, or GNU APL in that it has true non-array values (plain numbers and characters) that are different from depth-0 scalars. BQN also uses syntactic roles rather than dynamic type to determine how values interact, that is, what's an argument or operand and so on. This system, along with lexical closures, means BQN fully supports Lisp-style functional programming.
A useful tool for both beginners and experienced users is BQNcrate, a searchable collection of BQN snippets to solve particular tasks. If you have a question about how you might approach a problem, give it a try by typing in a relevant keyword or two.