FACTOID # 124: Teachers make up 7.8 percent of Iceland’s labor force - and they only have to teach 38 weeks per year.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RELATED ARTICLES
People who viewed "Befunge" also viewed:
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Befunge

Befunge is a stack-based, reflective, esoteric fungeoid programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid. "Arrow" instructions direct the control flow to the left, right, up or down, and loops are constructed by sending the control flow in a circle. A stack-oriented programming language is one that relies on a stack machine model for passing parameters. ... In computer science, reflection (or computational reflection) is the ability of a program to observe and possibly modify its structure and behavior. ... An esoteric programming language (sometimes shortened to esolang) is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke. ... A funge is one of a number of esoteric programming languages which execute instructions by moving a pointer in a number of dimensions by issuing commands about which direction the pointer should move. ... Computer code (HTML with JavaScript) in a tool that uses syntax highlighting (colors) to help the developer see the purpose of each piece of code. ...

Contents


History

The language was originally created by Chris Pressey in 1993, as an attempt to devise a language as hard to compile as possible — note that the p command allows for self-modifying code. Nevertheless, a number of compilers have subsequently been written. A number of extensions to the original "Befunge-93" specification also exist, including Funge-98, which extends the concept to an arbitrary number of dimensions and can be multithreaded, with multiple instruction pointers operating simultaneously on the same space. Befunge-extensions and variants are called Fungeoids or just Funges. 1993 (MCMXCIII) was a common year starting on Friday of the Gregorian calendar and marked the Beginning of the International Decade to Combat Racism and Racial Discrimination (1993-2003). ... In computer science, self-modifying code is code that modifies itself on purpose. ... A diagram of the operation of a typical multi-language compiler. ... A funge is one of a number of esoteric programming languages which execute instructions by moving a pointer in a number of dimensions by issuing commands about which direction the pointer should move. ...


The Befunge-93 specification restricts each valid program to a grid of 80 instructions horizontally by 25 instructions vertically. Program execution which exceeds these limits "wraps around" to a corresponding point on the other side of the grid; a Befunge program is in this manner topologically equivalent to a torus. Since a Befunge-93 program can only have a single stack and its storage array is bounded, the Befunge-93 language is, unlike most machine languages, not Turing-complete. The later Funge-98 specification provides Turing-completeness by removing the size restrictions on the program; rather than wrapping around at a fixed limit, the movement of a Funge-98 instruction pointer follows a model dubbed "Lahey-space" after its originator, Chris Lahey. In this model, the grid behaves like a torus of finite size with respect to wrapping, while still allowing itself to be extended indefinitely. Topology (Greek topos, place and logos, study) is a branch of mathematics concerned with spatial properties preserved under bicontinuous deformation (stretching without tearing or gluing); these are the topological invariants. ... A torus. ... A system of codes directly understandable by a computers CPU is termed this CPUs native or machine language. ... In computability theory a programming language or any other logical system is called Turing-complete if it has a computational power equivalent to a universal Turing machine. ...


Sample Befunge code

The technique of using arrows to change control flow is demonstrated in the random number generator program below. Following the arrows round, the ? instructions send the instruction pointer in random cardinal directions until the pointer hits a digit, adding it to the stack. Then the arrows navigate to the . to output the digit from the stack and return the pointer to the first directional randomiser. Note that there is no @ to terminate this program so it produces an endless stream of random numbers from 1 to 9.

 vv < < 2 ^ v< v1<?>3v4 ^ ^ > >?> ?>5^ v v v9<?>7v6 v v< 8 . > > ^ ^< 


This is an example of the classic "Hello World!" program. First the letters "olleH" are pushed onto the stack as ASCII numbers. These are then popped from the stack in LIFO order and output as text characters to give "Hello". A space is character number 32 in ASCII, which here is constructed by multiplying 4 and 8, before being output as text. The remaining code then outputs "World!" in a similar way, followed by ASCII character 10 (a line feed character, moving the output cursor to a new line). For other uses, see ASCII (disambiguation). ... In a stack, the topmost item, which is added last, is taken out first. ... In computing, line feed (LF) is a control character indicating that one line should be fed out. ...

 > v v ,,,,,"Hello"< >48*, v v,,,,,,"World!"< >25*,@ 

Instruction list

0-9 Push this number on the stack
+ Addition: Pop a and b, then push a+b
- Subtraction: Pop a and b, then push b-a
* Multiplication: Pop a and b, then push a*b
/ Integer division: Pop a and b, then push b/a, rounded down. If a is zero, ask the user what result they want.
% Modulo: Pop a and b, then push the remainder of the integer division of b/a. If a is zero, ask the user what result they want.
! Logical NOT: Pop a value. If the value is zero, push 1; otherwise, push zero.
` Greater than: Pop a and b, then push 1 if b>a, otherwise zero.
> Start moving right
< Start moving left
^ Start moving up
v Start moving down
? Start moving in a random cardinal direction
_ Pop a value; move right if value=0, left otherwise
| Pop a value; move down if value=0, up otherwise
" Start string mode: push each character's ASCII value all the way up to the next "
: Duplicate value on top of the stack
Swap two values on top of the stack
$ Pop value from the stack
. Pop value and output as an integer
, Pop value and output as ASCII character
# Trampoline: Skip next cell
p A "put" call (a way to store a value for later use). Pop y, x and v, then change the character at the position (x,y) in the program to the character with ASCII value v
g A "get" call (a way to retrieve data in storage). Pop y and x, then push ASCII value of the character at that position in the program
& Ask user for a number and push it
~ Ask user for a character and push its ASCII value
@ End program

See also

Argh! and Aargh! are fungeoid esoteric programming languages (i. ... Befreak is a purely reversible two-dimensional programming language, inspired by Befunge. ... Brainfuck is an esoteric computer programming language noted for its extreme minimalism. ... INTERCAL is a programming language parody, the canonical esoteric programming language. ... PATH is an esoteric programming language derived from the Brainfuck language. ... Whitespace with syntax highlighting Whitespace is an esoteric programming language developed by Edwin Brady and Chris Morris at the University of Durham. ...

External links


  Results from FactBites:
 
Befunge - Wikipedia, the free encyclopedia (698 words)
Befunge is a stack-based, reflective, esoteric fungeoid programming language.
Program execution which exceeds these limits "wraps around" to a corresponding point on the other side of the grid; a Befunge program is in this manner topologically equivalent to a torus.
Since a Befunge-93 program can only have a single stack and its storage array is bounded, the Befunge-93 language is, unlike most machine languages, not Turing-complete.
Befunge - Esolang (801 words)
Befunge is a two-dimensional esoteric programming language invented in 1993 by Chris Pressey with the goal of being as difficult to compile as possible.
Befunge is believed to be the first two-dimensional, ASCII-based, general-purpose (in the sense of "you could plausibly write Hunt the Wumpus in it") programming language.
Befunge has also provided inspiration to the design of subsequent languages, the most similar of these are known as fungeoids.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.