Description #
Befunge is a two-dimensional, esoteric programming language where the instruction pointer can move in any direction. Code flows like a maze, creating playful, unpredictable behavior. Befunge was created to challenge the idea that code must flow linearly, as in conventional languages.
History #
Befunge was invented by Chris Pressey in 1993. His goal was to create a language that could not be parsed by conventional compilers, using a 2D grid of instructions and self-modifying capabilities.
Key milestones:
- Introduced the concept of multi-directional code execution
- Inspired many derivatives like Befunge-93, Befunge-98, and Funge-98
- Frequently used in esolang contests and academic puzzles
- Helped define the category of “fungeoids” — 2D/3D esolangs
Hello World Code #
> v
v ,,,,,"Hello"<
>48*, v
v,,,,,,"World!"<
>25*,@
This code prints Hello World!
by moving through the grid in different directions.
How to Run #
Online: #
- Go to https://tio.run/#befunge
- Paste the code and click Run
Locally: #
- Install a Befunge interpreter from https://github.com/catseye/Befunge-93
- Save code as
hello.bf
- Run:
python befunge93.py hello.bf
Key Concepts #
- 2D grid execution — code moves right, left, up, or down
>
<
^
v
— control the direction of execution@
— end program,
— output character at top of stack- Stack-based — operations work on a global stack
- Numbers — push digits onto the stack (e.g.,
5
pushes 5) - Arithmetic —
+ - * / %
operate on top two stack values - Conditional logic —
!
,_
,|
route flow based on stack value - Self-modifying — code can be changed during execution (
p
/g
) - Random execution possible using
?
Try It Online #
🔗 TIO.run – Befunge
🔗 Cat’s Eye Technologies (Original Author)
🔗 Replit – Befunge
Fun Facts #
- Befunge’s name is a mashup of “begin” and “fungal”
- Code execution bounces around like in a pinball machine
- It was created to be as hard to compile as possible
- Some Befunge programs form ASCII art that is also valid code
- It inspired a category of languages known as Fungeoids