Learn BEFUNGE with Real Code Examples

Updated Nov 25, 2025

Explain

Befunge programs run on a 2D grid instead of a linear sequence.

The instruction pointer can move up, down, left, right, or randomly.

Because instructions reside on a modifiable grid, Befunge supports self-modifying code.

It is stack-based, with most operations manipulating a central stack.

Its design intentionally frustrates optimizers and traditional compilers.

Core Features

Instruction pointer moves in four directions

Grid-addressable memory for code/data

Stack manipulation for logic and math

String mode for pushing characters

Built-in I/O operations

Basic Concepts Overview

2D grid memory model

Instruction pointer movement

Stack manipulation

String mode pushing characters

Self-modification via 'p' and 'g'

Project Structure

src/ - Befunge (.bf) files

examples/ - sample programs

tests/ - program outputs

docs/ - instruction references

tools/ - interpreters and utilities

Building Workflow

Write ASCII grid code

Run inside Befunge interpreter

Observe multidirectional flow

Modify grid to adjust behavior

Iterate and refine layout

Difficulty Use Cases

Beginner: write linear left-to-right programs

Intermediate: use 2D movement and branching

Advanced: self-modifying grid

Expert: code-golfing and puzzles

Educational: explore pointer dynamics

Comparisons

Befunge vs Brainfuck: Befunge uses 2D flow and is more visual; Brainfuck is linear and minimal.

Befunge vs Malbolge: Befunge is readable and creative; Malbolge is chaotic and nearly impossible.

Befunge vs Python: Python is structured; Befunge is playful and visual.

Befunge vs Assembly: Assembly is practical; Befunge is artistic.

Befunge vs INTERCAL: Both esoteric, but Befunge uses 2D execution.

Versioning Timeline

1993 – Befunge-93 released

1997 – Funge-98 specification created

2000s – Widespread adoption in esolang communities

2010s – Online interpreters popularized

2020s – Used heavily in code-golf

Glossary

Playfield: 2D grid where code executes

Instruction Pointer: moves across grid

Stack: stores program data

String Mode: pushes ASCII chars

Self-modifying code: modifying grid at runtime