Friday, 17 November 2017

Introduction to Brainfuck

Brainfuck is a programming language created by Urban Müller in 1993. Brainfuck comes under esolang (esoteric programming language) category.

What is esoteric programming language?
As per Wikipedia “An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language (particularly functional programming or procedural programming languages), or as a joke.”

Reference

Architecture of Brainfuck
Brainfuck consist of
a.   Array of at least 30000 bytes, all are initialized to zero by default
b.   A data pointer, used to move around the 30000 byte array. At the time of program initialization, it points to left most byte of the array
c.   Two streams of bytes for input and output

Commands
Brainfuck programming language operates with only eight commands. Below table summarizes all the eight commands.

Command
Description
> 
Move the pointer to next cell in the right
< 
Move the pointer to previous cell in the left
+
Increment the byte at the pointer
-
Decrement the byte at the pointer
.
Output the byte at the pointer
,
Input a byte and store it in the byte at the pointer
[
if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
]
if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.

What are the brainfuck implementations?
There are many open source implementation available to experiment with brainfuck language. Refer https://esolangs.org/wiki/Brainfuck_implementations

Can I run brainfuck code in online?
Yes, there are many available. I am going to use below one.
Previous                                                 Next                                                 Home

No comments:

Post a Comment