Brainf**k programming language

It is the most-recent programming language, I have came across. Yes, Brainfuck (I think I can use this word when it is about a language :roll:) is name of programming language which is designed to challenge programmers and not for practical use as its Wikipedia definition goes –

 

The brainfuck language is an esoteric programming language noted for its extreme minimalism. It was designed to challenge and amuse programmers, and is not suitable for practical use. Its name has been variously euphemized, as in brainf*ck, since its name contains the expletive “fuck”. The name of the language is generally not capitalized, despite the fact that it is a proper noun.

 

Well, I love programming, no matter what kind of, it is. So Let us go a bit deep in the historical as well as tech details of this language.

 

History

Urban Müller created brainfuck in 1993 with the intention of designing a language which could be implemented with the smallest possible compiler, inspired by the 1024 byte compiler for the FALSE programming language. Several brainfuck compilers have been made smaller than 200 bytes. The classic distribution is Müller’s version 2, containing a compiler for the Amiga, an interpreter, example programs, and a readme document.

 

 

Technical – 

The language consists of eight commands, listed below. A brainfuck program is a sequence of these commands, possibly interspersed with other characters (which are ignored). The commands are executed sequentially, except as noted below.

 

The brainfuck language uses a simple machine model consisting, besides the program, of an array of 30,000 byte cells initialized to zero, a movable pointer into the array (initialized to point to the leftmost byte of the array), and two streams of bytes for input and output (most often connected to a keyboard and a monitor respectively, and using the ASCII character encoding).

 

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.
, accept one byte of input, 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.)

 

Brainfuck programs can be translated into C using the following substitutions, assuming ptr is of type unsigned char* and has been initialized to point to an array of zeroed bytes:

brainfuck command C equivalent
> ++ptr;
< --ptr;
+ ++*ptr;
- --*ptr;
. putchar(*ptr);
, *ptr=getchar();
[ while (*ptr) {
] }

 

 

Another thing that I liked about this lang is –

Nonetheless, like any Turing-complete language, brainfuck is theoretically capable of computing any computable function or simulating any other computational model, if given an unlimited memory store

 

If I am right, it can be used as a compiler for another user-defined language based on Brainfuck platform.

 

While going through its Syntax and Semantics, I am really feeling like f***** up. Better not to write anymore about it! Wouldn’t advice you to go to its page unless you have got interest from above description.

 

 

 

Thank you, Vivek.

Leave a Reply

Your email address will not be published. Required fields are marked *