Brainfuck Coding Language
This language appeared in 1993 and is designed to challenge and amuse programmers. Not for practical use though. This console-based language only works with and displays integers and strings, it has no power whatsoever.
Check out the Hello World! script in Brainfuck:
The language is very easy to learn but hard to work with, there are only eight commands:
================================================================================= > Increment data pointer (point to next cell to the right) < Decrement data pointer (point to next cell to the left) + Increment (increase by one) the byte at the data pointer - Decrement (decrease by one) the byte at the data pointer . Output the ASCII Decimal CharCode value at the data pointer , Accept one byte of input, storing its value in the byte at the data pointer [ If byte at data pointer is 0, execution jumps to command after matching ] ] If byte at data pointer is non-0, execution jumps to command after matching [ =================================================================================
For the hello world above this is how it works:
First you have 10 + signs that add ten bytes to cell. Then it goes into a loop which is surrounded by [ and ] signs, this keeps looping until the value of bytes within the current cell becomes 0 (Right now our current cell is cell). In the loop it moves to the next cell to the right (cell) and adds 7 bytes to this cell. Then another > sign to move to the next cell to the right (cell) and then it adds 10 bytes to this cell. It does the same thing adding 3 bytes to cell and 1 byte to cell. Next it moves 4 times to the left back to cell and takes away one byte from this cells value, this is where it loops afterward since the current cell (cell) is not equal to 0 bytes it will keep looping to [ until the current cell contains 0 bytes. Since cell originally had 10 bytes the loop will loop 10 times which means after the loop cell = 0, cell = 70, cell = 100, cell = 30, cell = 10.
Here’s where it starts making sense: Now after the loop we should be on cell so now it moves to cell, adds 2 bytes to it and uses a period (.) to display the ascii value of the current cell; in this case it is 72: in ascii it is the decimal character code for “H” therefore it outputs “H” to the console. Now it moves forward to cell, adds 1 to it and displays chr(101) which is “e”. Next it adds 7 to the current cell and displays it two times outputting chr(108) “ll” (these are L’s). Add 3 and display chr(111). And it should keep doing this to spell out hello world with ascii decimal codes. And finally at the end it prints the ascii code 10 which is the text termination.