Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Befunge-93 is a 2D stack-based esoteric programming language created by Chris Pressey in 1993 as a deliberate attempt to design a language as hard to compile as possible. Instead of executing top-to-bottom like a normal program, the instruction pointer moves in two dimensions across an 80×25 grid of characters, with each character being either a stack operation, an arithmetic op, or a direction-changing arrow (>, <, ^, v). Programs can also rewrite themselves at runtime via the 'p' (put) and 'g' (get) instructions, which is what makes Befunge famously uncompilable. Run Befunge programs in this online interpreter — no cfunge, fungify, or Funge-98 setup required.
"!dlroW ,olleH">:#,_@
How it executes:
"..." pushes characters onto the stack in REVERSE order
> turns the instruction pointer rightward
: duplicates the top of the stack
# skips the very next instruction
, pops and prints the top character
_ horizontal IF: pop, go LEFT if non-zero else RIGHT
@ end program
The loop prints each character of "Hello, World!\n" by
dupe-and-print, exiting the loop when the stack hits zero.
Use Befunge-93 for code-golf challenges, esolang competitions on sites like Code Golf Stack Exchange and anarchy golf, teaching unconventional control flow, mind-bending puzzle programming, and as a gateway to other 'fungeoid' languages (Funge-98, Befunge++, Cardinal, Trefunge). Befunge-93's 2D execution model is also a useful teaching tool for explaining why most modern languages chose 1D top-to-bottom execution — and what you give up by using a deliberately weird alternative.
It pioneered the 2D programming language concept and was specifically designed to be uncompilable — the 'p' instruction lets a program rewrite its own source mid-execution, so the only way to know what a program will do is to actually run it. This makes Befunge unusually loved by esoteric-language researchers, code golfers, and compiler-theory students who use it as a counter-example for static analysis.
Befunge-93 uses a fixed 80×25 character playfield (the same dimensions as a classic VT100 terminal screen). The instruction pointer wraps around when it falls off an edge. Befunge-98 (the later spec) lifted this to an arbitrary-sized grid, but Befunge-93 keeps the original constraint and is what most online interpreters implement by default.
> sends the pointer right, < left, ^ up, v down, and ? picks a random direction. _ is the horizontal IF: pop the stack, go right if zero else left. | is the vertical version. # skips the next instruction. @ ends the program. Everything else is either a digit (push 0-9), an arithmetic op (+ - * / %), or a stack manipulator (: dup, \ swap, $ pop, p put, g get).
On a single global stack. Digits 0-9 push themselves, arithmetic operators pop two values and push the result, and there is no named variable anywhere. Because the stack underflows to zero rather than erroring in Befunge-93, popping an empty stack just yields 0. Managing that one stack while the pointer roams the 2D grid is the core challenge of writing Befunge.
Use string mode: a double quote toggles it on, and every character after it is pushed onto the stack as its ASCII code until the next double quote turns it off. You then print those codes as characters with the , instruction, usually in a loop. It's how Befunge hello-world programs load their message before emitting it character by character.
Yes. The & instruction reads an integer from stdin and pushes it, while ~ reads a single character as its ASCII code. On XCODX these run in a live terminal, so execution pauses for you to type, then the value lands on the stack for the rest of the program to use with the usual arithmetic and output instructions.
main.bfplain text — no highlighter ships for this language~ or &>25*"!dlroW olleH",,,@