Skip to main content

Brainfuck Programming language


Brainfuck is an esoteric programming language. Its notation is extremely minimalism. This language use only eight single character as command and a instruction pointer.

Why was this language created?
In 1993, young computer programmer named “Urban Müller” set out to make the smallest possible compiler, because smaller the compiler  lesser time and energy it takes for the machine to respond.
In the end, he came up with “Brainfuck” a new programming language whose compiler uses only 240 bytes of memory making it around 11,000 time smaller than C++ compiler.
However, making such a smaller compiler, Muller has sacrificed practically.  

In Brainfuck, you can only use eight command have single character:



Character

Meaning

>

increment the data pointer (to
point to the next cell to the right).

<

decrement the data pointer (to
point to the 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 byte at the data
pointer.

,

accept one byte of input,
storing its value in the byte at the data 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.



That it.
Can you imagine yourself writing codes with this language? Now you can relate why the name of this language is brainfuck. The language stick to its name. We should give credit to the founder giving this incredible name.
So, basically how it works?
This language work on ASCII code. You have to code in such a way the you get the ASCII value of the character you want to print.
Example: You want to print “A”
1.      ++++++++++++…. +++                [65 time (each “+” add a [0]=i++]
2.      .                                                     (“.” to print the “A”)
Its works on shifting operation it has an array who’s default value is “zero”.
So here what happens is when the array get the value 65 and print command is executed then the compiler will look for who’s ASCII value is 65 and show the output when it get it.
>: move to next array index in right


Now, let to do a program which all programmer do when they starting learning  a new language print “Hello world!”

The code for the program is:

++++++++++[>+++++++>++++++++++>+++>+<<<<->++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.

To better understand the step, click on this LINK.

For more understanding the concept.

Related link: Stack-overflow


Comments

Popular posts from this blog

TCP Segment

A TCP segment is made up of a TCP header and a data section. Source Port :  A source port is a high numbered port chosen from a special section of ports known as ephemeral ports. A source port is needed so that when the web server replies, the computer making the original request can send this data to the program that was actually requesting it. It is in this way that when it web server responds to your requests to view a web page that this response gets received by your web browser and not your word processor. Destination Port : port on which the client in request the data( The destination port is the port of the service the traffic is intended for ) Sequence Number :This is a 32-bit number that's used to keep track of where in a sequence of TCP segments this one is expected to be.There are limits to the total size of what we send across the wire. In Ethernet frame, it's usually limited in size to 1,518 bytes, but we usually need to send way more data than that. At the transp...

Port Forwarding

Your friend wants to connect to your computer using RDC (remote desktop connection).   Friend send request to your computer for Remote Desktop Connection to your public IP address with specific port number. A port is logical connection is used by program and service to exchange information. Ports uniquely identify    this program and services that are running on a computer. In this case remote desktop connection uses 3389. So, the request will make a way from computer to your router. Now you need to know where to forward the request for port 3389 because without any port forwarding configured your friend will not be able to connect because your router doesn’t know what to do with this request this is where port forwarding comes into play .So now we our going to tell our router to send or forward any request that is coming from 8339 and send to this computer. To do this we need to login into our router configuration page by in the routers internal IP a...

Troubleshooting and debugging

Troubleshooting is the process of identifying, analyzing, and solving problems.  Debugging is the process of identifying, analyzing, and removing bugs in a system. We sometimes use troubleshooting and debugging interchangeably.  But generally, we say troubleshooting when we're fixing problems in the system running the application, and debugging when we're fixing the bugs in the actual code of the application. Debuggers let us follow the code line by line, inspect changes in variable assignments, interrupt the program when a specific condition is met, and more. System calls are the calls that the programs running on our computer make to the running kernel.   A reproduction case is a way to verify if the problem is present or not. Where to check for log file in OS? On Linux , you'd read system logs like /var/log/syslog and user-specific logs like the .xsession-errors file located in the user's home directory. On MacOs , on top of the system logs, you'd go through...