We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
BEATFuck
BEATFuck is an esoteric programming language written in Rust where a drum pattern is the program. Each track contains a sequence of steps; on every tick the interpreter executes one step from each track, from top to bottom.
Current implementation
| Property | Current behavior |
|---|---|
| Package version | 0.1.0
|
| Implementation | Rust 2021, no external dependencies |
| Tape | 256 cells, 8 bits per cell |
| CLI | run, parse and ticks
|
| Tests | 14 passing tests, verified with cargo test
|
| Tempo | Stored in the header; it does not change computational state |
| Audio | Not currently played by the CLI |
The current binary has no CLI option for supplying stdin to C.
The Rust execution API accepts input bytes directly.
Program format
A program is a text file. Blank lines and lines beginning with #
are ignored.
BPM 120 TIME 4/4 GRID 16 DATA 72 101 108 [track] K H . O
The header is optional. Defaults are BPM 120, TIME 4/4
and GRID 16.
| Element | Syntax | Meaning |
|---|---|---|
| Tempo | BPM N |
Musical tempo stored in the header |
| Time signature | TIME N/D |
Meter numerator and denominator |
| Grid | GRID N |
Musical subdivision of the bar |
| Initial data | DATA 0..255 ... |
Loads consecutive cells from cell 0 |
| Track | [name] pattern |
A track with its own repeating pattern |
TIME and GRID describe the musical context. The
interpreter uses each pattern's actual length when calculating the execution
cycle.
Instructions
| Sound | Opcode | Brainfuck equivalent | Effect |
|---|---|---|---|
| kick | K |
> |
Move the pointer right |
| snare | S |
< |
Move the pointer left |
| hat | H |
+ |
Increment the current cell |
| ghost hat | h |
- |
Decrement the current cell |
| open hat | O |
. |
Output the current cell as a byte |
| clap | C |
, |
Read one input byte when available |
| rest | . |
— | Change nothing, but consume one tick |
| loop begin | : | [ |
Skip to the matching end when the current cell is zero |
| loop end | ] |
Jump to the matching begin when the current cell is non-zero |
Decimal numbers in a track, such as 65, are parsed as
Data(65). They are loaded during initialization and do not perform
an operation when visited during execution.
Tape and pointer
The tape contains 256 cells, indexed from 0 to 255. Each cell is an unsigned 8-bit value:
- incrementing 255 produces 0;
- decrementing 0 produces 255;
- moving left from cell 0 wraps to cell 255;
- moving right from cell 255 wraps to cell 0.
Execution model
On every tick, every non-empty track executes exactly one step. Tracks are processed in source order, from top to bottom. Two sounds on the same tick are therefore not concurrent: the first track can change the pointer or a cell before the second track executes.
Rest advances its track and consumes a tick. Data has
already been loaded and only advances the track position when visited.
Polymeter
Each track wraps independently at the end of its pattern. The base cycle is the least common multiple of the lengths of all non-empty tracks:
[kick] K . . . . . . . . . . . . . . . # 16 steps [hat] H H H H H H H H H H H H # 12 steps
The combined cycle is LCM(16, 12) = 48 ticks.
Loops
\|: and :\| are matched within one track. The loop
tests the current tape cell:
DATA 5 [count] |: h :|
The cell starts at 5, h reduces it once per iteration, and the
loop ends at zero. This fixture produces 15 ticks.
Programs have no halt instruction. In version 0.1.0, a program without loops ends after the base LCM cycle. A program with loops ends when no loop remains active. Execution is capped at 10,000,000 ticks; exceeding that limit returns an error for a possible infinite loop.
Events
The Rust API returns observable events for output, input, pointer movement,
cell changes, loop jumps and ticks. run --verbose displays state
events but omits individual Tick events to keep output readable.
Examples
The canonical fixtures live in programs/:
| File | Demonstrates |
|---|---|
01_straight_4_4.beat |
4/4 pattern and zero net displacement |
02_syncopated.beat |
Different timing with the same sounds |
03_collision.beat |
Top-to-bottom ordering on a collision |
04_polymeter.beat |
16-step and 12-step patterns; 48-tick cycle |
05_tempo_invariance.beat |
Same state at different BPM values |
06_silence_timing.beat |
Rests consume ticks |
07_hello_world.beat |
DATA and ASCII output |
08_countdown.beat |
A loop that decrements to zero |
Hello World fixture
cargo run -- run programs\07_hello_world.beat
Observed output:
ticks: 11 pointer: 5 output: Hello\x00 tape[0..16]: [72, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
The final null byte is expected from the fixture: it contains six
O operations, and the last one runs after the pointer moves to
cell 5.
Inspecting a pattern
cargo run -- parse programs\04_polymeter.beat cargo run -- ticks programs\03_collision.beat
parse prints the header, data and tracks. ticks lists
the index and type of every step without executing the program.
Building and development
The project requires stable Rust and Cargo:
cargo build --release cargo test
The release executable is target\release\beatfuck.exe on Windows.
The test suite was verified on 10 September 2026 with:
test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
| Path | Responsibility |
|---|---|
src/parser.rs |
Header, DATA, tracks, opcodes and syntax validation |
src/interpreter.rs |
Tape, polymeter, loops and execution events |
src/lib.rs |
Public machine types and runtime state |
src/main.rs |
CLI and result presentation |
programs/ |
Behavioral fixtures |
Common mistakes
KandSare the pointer operations;>and<are not valid BeatFuck opcodes..is silence; output isO.- Loops use
\|:and:\|, not square brackets. BPMdoes not change computational output.- Musical simultaneity does not imply concurrent execution.
Computational status
No computational-class claim is made. The implementation has mutable tape, arithmetic, loops and input/output primitives, but this documentation does not assert Turing completeness.
Implementation
The reference implementation is available at BEATFuck on GitHub and is released under the MIT license.