Serious engineering for the least usable programming language ever designed.
Interpreter · Conformance suite · Playground · Battleship · Roadmap · Learn more
Malbolge was designed in 1998 to be as hard to program in as possible. It runs on a base-3 machine with an operation that matches no arithmetic you know. Every instruction encrypts itself after it runs. The first working program took two years to find, and it was found by a search algorithm, not written by a person.
This repository is East Agile's toolkit for it. We wrote a fast, spec-precise interpreter and a conformance suite that checks any interpreter against the 1998 reference. Everything runs natively and in the browser.
| 1.75x faster than the previous record | fastbolge runs MalbolgeLisp, a 371 MB Lisp interpreter written in Malbolge, about 1.75x faster than fast20.c, the fastest interpreter we could find. Output is byte-identical. |
| A conformance suite for the whole ecosystem | 42 cases pin down Malbolge's semantics, including the dark corners where the reference implementation itself is undefined. We ran it against five other open-source interpreters, and three of them fail. |
| Runs in the browser | The same Rust engine compiles to a 209 KB WebAssembly module. The playground is a single HTML file. |
| No dependencies | It uses only the Rust standard library. The core does no allocation in its hot loop. |
| A playable game written in Malbolge | Battleship runs entirely in Malbolge Unshackled, including its random fleets, which are generated by the language's own self-encryption and seeded by what the player types. It sits next to the same game in Python and Rust, with byte-identical output and a size and speed comparison. |
git clone https://github.com/EastAgile/Malbolge && cd Malbolge/interpreter
RUSTFLAGS="-C target-cpu=native" cargo build --release
./target/release/fastbolge ../conformance/cases/prog-samples-helloworld-eu-0.mbRun the conformance suite against fastbolge, or against any interpreter you like:
python3 ../conformance/run.py -- ./target/release/fastbolge -m {mode}
python3 ../conformance/run.py --mode classic -- /path/to/your-malbolgeOpen the playground in a browser:
cargo build --release --target wasm32-unknown-unknown --lib
cp target/wasm32-unknown-unknown/release/fastbolge.wasm web/
python3 ../playground/build.py && open ../playground/index.htmlMalbolgeLisp v1.2 under both interpreters. These are wall-clock seconds, median of 3 runs, on a 4-core Intel Xeon at 2.1 GHz. Both were compiled for the native CPU.
| Workload | Malbolge steps | fast20.c |
fastbolge |
Speedup |
|---|---|---|---|---|
Start up and evaluate (+ 1 2) |
2.4 billion | 9.25 s | 4.99 s | 1.85x |
Iterative Fibonacci, (fib4 6) |
18.9 billion | 55.30 s | 31.79 s | 1.74x |
Recursive Fibonacci, (fib1 6) |
35.5 billion | 98.64 s | 55.51 s | 1.78x |
Here is how it gets there. Each memory cell carries its own decoded
instruction and encryption state, so a step needs no division and no table
chase. Encryption is a single lookup. Memory is one lazily filled mmap
region on huge pages. The 371 MB program loads in parallel in about 0.3 s,
where fast20.c takes 5 to 8 s. The interpreter README
has the details and the trade-offs.
The expected results come from Ben Olmstead's original malbolge.c and from
fast20.c. They do not come from our own interpreter.
| Interpreter | Language | Pass | Fail |
|---|---|---|---|
| fastbolge (native and WebAssembly) | Rust | 37 | 0 |
reference malbolge.c (classic cases) |
C | 27 | 0 |
fast20.c (fast20 cases) |
C | 10 | 0 |
| return/malbolge | Rust | 24 | 3 |
| kmyk/malbolge-interpreter | Python | 13 | 14 |
| thimc/malbolge | Go | 3 | 24 |
Five more cases cover behaviour the reference leaves undefined. They are reported for each interpreter but not scored. See conformance/.
interpreter/ fastbolge: the Rust interpreter, its WebAssembly build and benchmarks
conformance/ language-neutral test cases, generator and runner, plus results
playground/ a single-page browser playground built on the WebAssembly module
programs/ programs written in Malbolge, starting with Battleship
The Malbolge world has a few interpreters and generators, and almost nothing in between. Here is what we plan to build next:
- A compiler to classic Malbolge. A small structured language that compiles to programs Olmstead's 1998 interpreter can run.
- A standard library and showcase programs. These include tested routines for arithmetic, number printing and strings, and real tools built on them.
- Better tooling. That means a step debugger with a trit-level memory view and editor support.
- malbolge.org covers the language, its history and the people still pushing it forward.
- The Esolang wiki is the community wiki for esoteric programming languages. See its Malbolge and Malbolge Unshackled pages.
Malbolge was created by Ben Olmstead in 1998. fast20.c and MalbolgeLisp are
by Kamila Szewczyk. The sample programs in conformance/cases/prog-samples-*
are from zb3/malbolge-tools (MIT).
MIT © East Agile.
Built by East Agile. We like hard problems.