Befunge is an esoteric language, but as all previous examples, it has specific list or rules that user has to obey when writing a code by Befunge.
- The program field is a two-dimensional torus, physically it is a rectangular matrix of commands-symbols, closed along the upper (lower) boundary and along the left (right) column.
- The command pointer moves across the field (each command is a symbol with x, y coordinates), executes the command and moves on. Movement can be in all 4 directions (by default to the right from point 0,0), and when leaving the “field” the pointer appears on the opposite side.
- The language has two commands (p, g) that change the field itself, i.e. the program “rewrites itself” during execution. The program code at the start may not be equal to the code at the finish.
Chris Pressey, the creator of Befunge noted that he wanted to build a language that was as difficult as possible to compile. And he reached his goal, actually.
The user has field made of 25 lines consisting of 80 symbols each. Also, the original 1993 version of Befunge has 36 commands and every single one of them is represented as the ASCII symbol. Here are some examples:
< - move cursor to the left;
> - move cursor to the right;
^ - move cursor to the upper line;
v - move cursor to the lower line;
@ - end of script;
& - ask the user for a number and put it into the stack; etc.
Here's the example of Fibonacci sequence code made on Befunge: