Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Befunge

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.

View all 10 Befunge code examples →
Hello World in BefungeBefunge Simple AdditionBefunge Print Numbers 0-9Befunge Echo InputBefunge Loop ExampleBefunge Print ABefunge Multiply Two NumbersBefunge Subtract Two NumbersBefunge Clear Stack ExampleBefunge Hello Befunge

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

Installation Setup

Install a Befunge interpreter (e.g., Funge-98 interpreter)

Choose between Befunge-93 or Befunge-98

Run programs via CLI tools

Verify with a simple 'Hello World'

Experiment with grid editing

Environment Setup

Install interpreter

Choose Befunge-93 or Funge-98

Test with simple examples

Optional: configure debugger

Run ASCII grid programs

Config Files

Not required

Optional interpreter config

Debugger configuration

Grid size adjustments

Execution logs settings

Cli Commands

befunge program.bf

funge program.bf

befunge --debug program.bf

befunge --version

befunge --help

Internationalization

ASCII-only instruction set

Docs mostly in English

Global esolang participation

Language-independent logic

Universally shareable programs

Accessibility

Runs in any interpreter

Low dependency footprint

ASCII-based source

Online interpreters available

Tutorials accessible globally

Ui Styling

Pure ASCII layout

2D grid visualization optional

Terminal output

Online editors may highlight flow

Minimalist design

State Management

Stack holds temporary data

Pointer direction stores flow state

Grid content reflects program logic

Self-modification updates state

Interpreter tracks runtime variables

Data Management

Stack data only

Grid cells store program instructions

ASCII-based I/O

No persistent storage

Extended Funge variants add I/O

Architecture

2D playfield grid (commonly 80×25)

Instruction pointer with direction state

Stack-based data handling

Self-modifiable grid memory

ASCII instruction set

Rendering Model

ASCII grid text input

Pointer moves across grid

Grid cells treated as instructions

Stack updates display output

2D layout influences behavior

Architectural Patterns

2D instruction grid

Stack-driven computation

Directional branching

Self-modification via p/g

Implicit loops via movement

Real World Architectures

Code-golf competitions

Educational flow-visualization tools

Interpreter development

Algorithm puzzles

Experimental computing labs

Design Principles

Challenge traditional compiler design

Use 2D execution flow

Enable creativity via layout-based logic

Make programs self-modifying

Encourage playful experimentation

Scalability Guide

Limited by grid size

Avoid large-scale projects

Keep logic compact

Use direction tricks for loops

Funge-98 allows larger spaces

Migration Guide

Copy text file across systems

Ensure interpreter compatibility

Check for Befunge-93 vs Funge-98 features

Re-test pointer behavior

Adjust grid size if needed

Performance Notes

Interpreters usually efficient

Complex 2D flows may slow debugging

Self-modifying code handled safely

Grid size fixed/expandable depending on version

Minimal runtime requirements

Security Notes

Isolated execution inside interpreters

No built-in file/network access in Befunge-93

Extended Funge-98 has to be handled carefully

Self-modification may hide logic

Safe for experimentation

Monitoring Analytics

Pointer tracking visualization

Stack depth monitoring

Grid modification logs

Execution speed metrics

Instruction flow graphs

Code Quality

Organize grid cleanly

Avoid unintended direction changes

Minimize stack misuse

Document tricky flows separately

Use testing tools regularly

Practical Examples

Hello World program

Simple math calculators

Flow-control mazes

Self-modifying demos

Randomized path generators

Troubleshooting

Check pointer direction

Track stack values manually

Ensure string mode closed

Avoid unintentional self-modification

Use visualization tools for debugging

Testing Guide

Test pointer direction changes

Verify stack operations

Check branching logic

Test self-modifying commands carefully

Compare outputs with expected results

Deployment Options

Run in local interpreter

Use online Befunge runners

Embed in esolang showcase projects

Include in code-golf solutions

Not suited for traditional deployment

Tools Ecosystem

Funge-98 interpreters

Befunge-93 CLI tools

Online Befunge editors

ASCII grid visualizers

Code-golf platforms with Befunge support

Integrations

Embedding interpreters in other languages

Educational visual tools

Puzzle platforms

Code-golf websites

Custom interpreters for experimentation

Productivity Tips

Use visual editors

Plan 2D flow before coding

Master stack operations

Use self-modification sparingly

Leverage direction control carefully

Challenges

Tracking pointer manually

Understanding multi-directional flow

Managing stack errors

Self-modifying bugs

Code-golf constraints

Learning Path

Learn stack operations

Understand pointer movement

Study basic 2D program layouts

Experiment with self-modifying examples

Join code-golf challenges

Skill Improvement Plan

Week 1: Basic instructions + stack practice

Week 2: Direction control and branching

Week 3: String mode + I/O mastery

Week 4: Self-modification via p/g

Week 5: Code-golf optimization

Interview Questions

What is Befunge and what makes it unique?

Explain the 2D execution model.

How does Befunge support self-modifying code?

Compare Befunge with linear esolangs.

What are typical use cases of Befunge?

Cheat Sheet

>: Move right

<: Move left

^: Move up

v: Move down

p/g: Modify/read grid cell

Books

Esoteric Programming Languages Handbook

Befunge and 2D Code Flow

Creative Coding with Esolangs

Code-Golf Strategies

Unconventional Programming Models

Tutorials

Befunge basics and stack operations

2D flow control

Self-modifying code with p and g

Code-golf optimization

Pointer direction strategies

Official Docs

https://esolangs.org/wiki/Befunge

https://github.com/catseye/Befunge-93

Community Links

Esolangs.org Befunge page

Reddit r/esolangs

GitHub Funge interpreters

Online interactive editors

Code-golf puzzle forums

Community Support

Esolangs.org Befunge page

Reddit r/esolangs

GitHub interpreter repos

Code-golf communities

Programming puzzle forums

Monetization

Workshops or teaching content

Books on esolangs

Puzzle competitions

Code-golf sponsorship

No direct monetization usually

Future Roadmap

More powerful online IDEs

Expanded Funge-98 toolchains

Better debugging visualizers

New creative 2D languages inspired by Befunge

Community-driven learning resources

When Not To Use

Production software

Large-scale systems

Safety-critical applications

Maintainable codebases

Performance-heavy tasks

Final Summary

Befunge is a 2D esoteric language with a playful design.

Self-modifying code and multi-directional flow define its uniqueness.

Common in puzzles, challenges, and experimental computing.

Simple yet expressive stack-based instruction model.

Remains one of the most beloved esolangs.

Faq

Is Befunge free?

Yes - entirely free and open-source.

Which version should I use?

Befunge-93 for simplicity, Befunge-98 for extended features.

Can Befunge be self-modifying?

Yes, using 'p' and 'g' instructions.

Is Befunge Turing-complete?

Yes - it supports loops, conditions, and unbounded memory (in extended versions).

Are there online interpreters?

Yes - many web-based Befunge editors exist.

Code Sample Descriptions

1

Hello World in Befunge

>25*"!dlroW ,olleH":v
    v:,_@
    >  ^

A classic 'Hello, World!' in Befunge demonstrating 2D control flow.

Let’s Try →
2

Befunge Simple Addition

2 3 + .

Adds two numbers and prints the result.

Let’s Try →
3

Befunge Print Numbers 0-9

0"0123456789",,,,,,,,,,

Prints digits 0 to 9 sequentially.

Let’s Try →
4

Befunge Echo Input

, & @

Reads a single character from input and prints it.

Let’s Try →
5

Befunge Loop Example

9:v
    >1-:_
    @

Decrements a number and prints until zero.

Let’s Try →
6

Befunge Print A

65 .

Prints the letter 'A'.

Let’s Try →
7

Befunge Multiply Two Numbers

3 4 * .

Multiplies two numbers and prints the result.

Let’s Try →
8

Befunge Subtract Two Numbers

8 3 - .

Subtracts second number from first and prints it.

Let’s Try →
9

Befunge Clear Stack Example

9 8 7 6 5 4 3 2 1
    $ $ $ $ $ $ $ $ @

Clears the stack and halts execution.

Let’s Try →
10

Befunge Hello Befunge

>25*"!egnufeB ,olleH":v
    v:,_@
    >  ^

Prints 'Hello Befunge' demonstrating 2D control flow.

Let’s Try →

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.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypherGremlinPartiqlHaskellElixirFsharpView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.