The two languages at a glance
Befunge-93 is the original two-dimensional language: a fixed rectangle of cells, a stack, a pointer that moves in four directions, and a compact set of single-character instructions. Funge-98 is a later, broader specification that includes a Befunge of its own, usually called Befunge-98, along with one- and three-dimensional relatives. Most small Befunge-93 programs run unchanged under a Funge-98 interpreter, but the two are not identical, and the differences are worth knowing before you port anything.
The fixed playfield and its limits
The best-known restriction of Befunge-93 is its size. A program lives on a playfield of 80 columns by 25 rows, which is 2,000 cells in total. Everything has to fit: the code, any text you want to print, and any cells you use as variables through the get and put instructions. Reading or writing outside that rectangle is not something a portable program can rely on.
The pointer wraps at the edges. Leave on the right and you return on the left of the same row; leave at the bottom and you return at the top. That wrapping makes the field behave like a torus, a theme covered under the toroidal playfield idea. Because the field is small, wrapping is also a practical tool: a loop can be a single row that wraps back onto itself.
Funge-98 removes the fixed rectangle. Its space is unbounded in principle, so a program can use coordinates far from the origin, including negative ones. Real interpreters are limited by memory and by how they store cells, but the language no longer forces you to squeeze everything into 2,000 positions. Wrapping still exists, but it follows a rule written for unbounded space rather than for a small box, so programs that relied on wrapping at column 80 may behave differently.
The original command set and what Funge-98 adds
The Befunge-93 instruction set is small: digits, arithmetic, logical not, a greater-than test, four direction arrows, a random direction, two conditional branches, string mode, stack manipulation, get and put, input, output, a one-cell skip, and the end instruction. That is almost everything.
Funge-98 keeps those and adds many more. Some examples:
- Hex digits: the letters a to f push the values 10 to 15, so what takes arithmetic in Befunge-93 is one character.
- Character fetch: an apostrophe pushes the character in the next cell, so printing the letter A is a short program.
- Skipping: a semicolon starts and ends a region the pointer ignores, and a jump instruction moves the pointer ahead by a count.
- Repetition and control: an iterate instruction repeats the next instruction, split creates another pointer, and reflect turns the pointer around.
- Turning: left and right turn instructions rotate the direction without needing an arrow aimed at a specific side.
- Environment: instructions for reading system information, for file input and output, and for ending the whole program with a return code.
A small comparison shows the flavor. To push 15 in Befunge-93 you might write 96+, which pushes 9 and 6 and adds them. In Funge-98 the single letter f does the same job. Neither is wrong; the second is simply shorter, which matters in contests built around code golf.
Stack and space semantics
Both languages have a stack of integers, and popping an empty stack gives zero rather than an error. The details diverge in what surrounds it. Funge-98 turns the one stack into a stack of stacks, with instructions to begin and end a new stack. That feature has its own deeper explanation under the stack stack topic. The original program stack is simple by comparison, and some programmers prefer that.
Funge-98 also adds a storage offset, which shifts where get and put look. This supports relocatable code, a technique that has no real equivalent in Befunge-93 since there everything is addressed from a fixed corner. For anyone interested in self-modifying code, that offset makes it easier to write routines that edit the grid wherever they happen to be placed.
Unknown instructions and other defined behavior
Befunge-93 leaves some situations loosely specified, and early interpreters did not always agree. Funge-98 is more explicit. An unknown instruction, for example, causes the pointer to reflect: it turns around and goes back the way it came. The details are discussed under reflect behavior. Spaces are also handled with more care, so that runs of spaces do not cost extra steps and behave sensibly inside string mode.
Stopping differs slightly. In Befunge-93 the end instruction halts the program, since there is only one pointer. In Funge-98 the same instruction ends only the pointer that executes it, and a separate quit instruction ends the entire program, optionally returning a value to the operating system.
Porting and compatibility in practice
If you have a Befunge-93 program and want it to run under Funge-98, check three things. First, does it write outside the 80 by 25 area, or depend on edge wrapping at exactly column 80? Second, does it use any character as an instruction that Funge-98 now defines, such as a letter or an apostrophe, perhaps inside dead cells that were meant to be ignored? Third, does it assume that unknown characters do nothing? In Funge-98 an unknown instruction reflects the pointer, so stray letters in the grid can change behavior.
Going the other way is harder. A Funge-98 program that uses jumps, iteration, multiple pointers or fingerprints cannot run on a strict Befunge-93 interpreter at all. If portability is your goal, a good compromise is to write in the common subset and keep Funge-98 features to a minimum. Interpreters that are fast at the common subset also tend to be easier to write, a point that comes up when thinking about interpreter performance.
Which one should you learn first?
Befunge-93 is the better place to learn the ideas because the rules fit on a page and the small field forces tidy layouts. Funge-98 is the better place to explore afterward, once the limits start to feel like limits rather than puzzles. Many puzzle-minded programmers enjoy both for exactly this reason: the first rewards compression, the second rewards exploration.