2DFIM
Two instructions on a grid, and the only jump is a step down.
2026 · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
2DFIM takes the idea of Ultimate bf instruction minimalization! into two dimensions. The skip command becomes "go down one". What is left is two real instructions, < and (, on a tape of bits. Every other character does nothing, so a program carries its comments on the same lines as its code.
Read the story
The specification calls 2DFIM a family and gives two versions, each with a Python implementation. This implementation runs version 1. Version 2 changes what happens at the end of a line, and its text and its Python disagree.
The machine
The tape holds bits and grows to the right. The code pointer starts on the third bit.
| Char | Does |
|---|---|
< | Move the code pointer one bit left, unless it is on the first |
( | Move it one bit right and flip that bit; if the bit is now 0, go down one row |
| line end | Back to the start of the same line if the bit is 1; halt if it is 0 |
The second bit does input and output. When a ( sets it to 1, bits 4 to 11 are printed as one byte, or when they are all 0 a byte of input is read into them. Then it goes back to 0. The end of a line is the end of the longest one, and going down from the lowest row leads to the top.
Example
A single character cat.
A single character cat. The pattern (<( clears a bit whatever it held. If the bit was 0 the first ( sets it and the second clears it and goes down; if it was 1 the first ( clears it and goes down. Both ways meet at the ( on the next row. The last line reads a byte on its second pass and prints it on the third.
The compact cat from the specification loops on its first line for as long as there is input.
The compact truth machine prints 0 and halts on 0. On 1 it prints 1 forever.
The reference asks the user for more input when it runs out. This implementation ends the run there instead.
Patterns it teaches
- Two-dimensional control flow: a flip to 0 is the only branch, and it branches down.
- Turing tarpit: two instructions, a tape of bits and one bit for all I/O.
Further
See also
2DFIM builds on Brainfuck.
Two-dimensional languages
Brainfuck derivatives
Write your own in Run Convert a program from 2DFIM
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: 2dfim.
Command line
shib run 2dfim -e '<(<( (<( <
(<( (<(
(<( (<(
(<( (<(
(<( <<<<<<<<<<(<(((<(
' --input 'Hi!'shib manual 2dfimSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/2dfim.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org