Learn Befunge - 10 Code Examples & CST Typing Practice Test
Befunge is a two-dimensional esoteric programming language where code flows across a grid in multiple directions, allowing self-modifying behavior and unusual program structures.
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
Frequently Asked Questions about Befunge
What is Befunge?
Befunge is a two-dimensional esoteric programming language where code flows across a grid in multiple directions, allowing self-modifying behavior and unusual program structures.
What are the primary use cases for Befunge?
Code-golf challenges using 2D logic. Educational demonstrations of non-linear control flow. Studying self-modifying grid-based programs. Obfuscation and creative puzzle programs. Esoteric language experimentation
What are the strengths of Befunge?
Visually interesting 2D code layout. Great for puzzles and creativity. Self-modifying code built-in. Compact, expressive programs. Vibrant esolang community support
What are the limitations of Befunge?
Not suitable for large applications. Hard to debug due to non-linear flow. Limited standard libraries. Hard for beginners to understand. Optimizing compilers struggle with its design
How can I practice Befunge typing speed?
CodeSpeedTest offers 10+ real Befunge code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.