Category:Brainf***: Difference between revisions

From Rosetta Code
Content added Content deleted
(bnf param)
m (Added info about the construct for the language)
Line 1: Line 1:
{{language|Brainf***|bnf=http://ninh.nl/blog/2008/10/25/brainfck-birds-of-a-feather-session-take-2/}}Also known as '''Brainfuck'''. Created by Urban Müller in 1993 in an attempt to create the world's smallest Turing-complete compiler. It is noted as an [[:Category:Esoteric_Languages|esoteric programming language]], as it is not ordinarily used for applications development, but it also noted as being a minimalist language.
{{language|Brainf***|bnf=http://ninh.nl/blog/2008/10/25/brainfck-birds-of-a-feather-session-take-2/}}Also known as '''Brainfuck'''. Created by Urban Müller in 1993 in an attempt to create the world's smallest Turing-complete compiler. It is noted as an [[:Category:Esoteric_Languages|esoteric programming language]], as it is not ordinarily used for applications development, but it also noted as being a minimalist language.


The complete specification for the language can be summed up with the following eight symbols:
The construct for the language is similar to a [[wp:Turing Machine|Turing Machine]]. The commands themselves act on an array or "tape" (usually a byte or integer array and usually "infinite" on one or both ends) and a pointer to a position in that array. The complete specification for the language can be summed up with the following eight symbols:


{| class="wikitable"
{| class="wikitable"
Line 20: Line 20:
|-
|-
|style="text-align:center"|<tt>.</tt>
|style="text-align:center"|<tt>.</tt>
||output the value of the byte at the pointer.
||output the value of the byte at the pointer (usually interpreted to a character).
|-
|-
|style="text-align:center"|<tt>,</tt>
|style="text-align:center"|<tt>,</tt>
||accept one byte of input, storing its value in the byte at the pointer.
||accept one byte of input (usually interpreted from a character), storing its value in the byte at the pointer.
|-
|-
|style="text-align:center"|<tt>[</tt>
|style="text-align:center"|<tt>[</tt>

Revision as of 16:56, 15 November 2010

Language
Brainf***
This programming language may be used to instruct a computer to perform a task.
See Also:
Listed below are all of the tasks on Rosetta Code which have been solved using Brainf***.

Also known as Brainfuck. Created by Urban Müller in 1993 in an attempt to create the world's smallest Turing-complete compiler. It is noted as an esoteric programming language, as it is not ordinarily used for applications development, but it also noted as being a minimalist language.

The construct for the language is similar to a Turing Machine. The commands themselves act on an array or "tape" (usually a byte or integer array and usually "infinite" on one or both ends) and a pointer to a position in that array. The complete specification for the language can be summed up with the following eight symbols:

Character Meaning
> increment the pointer (to point to the next cell to the right).
< decrement the pointer (to point to the next cell to the left).
+ increment (increase by one) the byte at the pointer.
- decrement (decrease by one) the byte at the pointer.
. output the value of the byte at the pointer (usually interpreted to a character).
, accept one byte of input (usually interpreted from a character), storing its value in the byte at the pointer.
[ jump forward to the command after the corresponding ] if the byte at the pointer is zero.
] jump back to the command after the corresponding [ if the byte at the pointer is nonzero.

Alternatively, the ] command may instead be translated as an unconditional jump to the corresponding [ command, or vice versa; programs will behave the same but will run more slowly.

All other symbols, including traditional whitespace characters, are interpreted as comments.

Due to this minimal instruction set, Brainf*** is used as an introduction to compilers and has even been successfully implemented as a microprocessor core and the foundation to an operating system using a slightly extended syntax for output.

See also

  • RCBF - BF interpreters as a Rosetta Code task

Citations