Skip to content
ALB Wiki

Befunge

Befunge

Befunge is a two-dimensional programming language — its source code is a grid, and its instruction pointer travels across that grid like a cursor with a mind of its own. Chris Pressey invented it in 1993 with a design goal that stands out even among esolangs: not merely to be hard to write, but to be as difficult to compile as possible. A language that fights the compiler, not just the programmer.[1]

Its name is itself an artifact of the culture that produced it: "Befunge" began life as a typo for the word "before," typed by a user named Curtis Coleman at 4 AM on a BBS chat system. Pressey's community then reverse-engineered a fake etymology for it — "be-" as a corruption of "bi-" (two) plus "-funge" from fungible — "to interchange program code with data in two dimensions." A language born from a typo, retroactively dignified with a morphology. It is pronounced /biːˈfʌndʒ/.[2]

The playfield

A Befunge-93 program lives on a fixed 80×25 toroidal grid — the size of a classic terminal screen, which wraps around at every edge. Execution is handled by an instruction pointer that starts in the top-left corner moving right and simply keeps going until something redirects it. There are no jumps in the conventional sense; control flow is achieved by pushing the pointer in a new direction:

CommandEffect
> < ^ vsend the pointer right, left, up, down
?send it in a random direction
_ ``horizontal/vertical conditional — pop a value, go one way if zero, the other if not
"toggle string mode — push each character's ASCII value until the next "
#trampoline — skip the next cell
p gput/get — write to or read from any playfield cell, making code self-modifying
@halt

Everything else is Forth-like stack machinery: digits push values, + - * / % ! ` ` do arithmetic and comparison, : \ $ duplicate, swap, drop, and . , & ~` handle I/O. The smallest possible Befunge program demonstrates the whole model — a four-cell infinite loop:

>v
^<

The pointer moves right, hits v, turns down, hits <, turns left, hits ^, turns up, hits >, and repeats forever — a program that is also a picture of itself running.[3]

Self-modifying by design

The p and g commands are where Befunge stops being a curiosity and becomes a genuine machine: any program can write new instructions into its own playfield mid-execution and then steer the pointer into them. Code is data on a grid, addressable by coordinate, mutable at runtime — the von Neumann insight rendered as a party trick. This is also what makes Befunge nearly impossible to compile: a compiler cannot emit fixed machine code for a program that may rewrite itself while running. Pressey's goal was achieved structurally, not just aesthetically.

The heritage is honest, too — Pressey has cited AmigaVision, the flowchart-based multimedia tool, and Forth's stack model as the two influences. Befunge is what happens when a visual programming environment collides with a concatenative stack machine at 4 AM.

The Funge family

Befunge-93 spawned an entire dimensional family. Befunge-96 and Funge-97 were intermediate experiments; Funge-98 formalized the lineage into a proper specification, dignifying the wraparound topology with the name Lahey space and generalizing the concept: Unefunge is one-dimensional, Trefunge three, Nefunge n-dimensional, and so on — a whole geometry of cursed control flow. Today the language's most visible living artifact is fungot, an IRC bot written in Befunge whose source is small enough to fit on a T-shirt — perhaps the only production software on this site that is also wearable.[4]

Where it sits in the wing

Each member of the early esolang canon attacked a different assumption: INTERCAL attacked seriousness, Brainfuck attacked size, Malbolge attacked the programmer, and Whitespace attacked visibility. Befunge attacked dimensionality — the assumption that a program is a line of text read top to bottom. It remains the canonical answer to a question nobody else thought to ask: why should code only go one way?

Check your understanding

  • What is the playfield, and what does "toroidal" mean for the instruction pointer?
  • What makes Befunge uniquely hard to compile rather than merely hard to write?
  • Which two commands let a program modify itself mid-run?
  • Where did the name "Befunge" actually come from?
Show answers

1 — the playfield is a fixed 80×25 grid of instructions; toroidal means the edges wrap — fall off the right and you reappear on the left. 2 — p lets a program rewrite its own code while running, so no fixed compiled form can capture what the program will do. 3 — p (put) writes a value into a playfield cell; g (get) reads one — source becomes mutable data. 4 — it was a typo for "before," typed at 4 AM on a BBS; the bi-/fungible etymology was invented afterward to justify the accident.

Footnotes

  1. ↑ Befunge, esoteric-languages wiki — Pressey's design goal, the playfield model, and the Funge family
  2. ↑ Befunge etymology — the 4 AM BBS typo and the invented morphology
  3. ↑ Befunge-93 instruction set — the complete command table and playfield semantics
  4. ↑ Funge-98 and the Befunge entry — the dimensional family, Lahey space, and fungot
This page was last edited 2026-10-22 13:14:14 UTC by ALB Team. What links here