Follow us on Twitter!
Ideas are far more powerful than guns.
Saturday, April 19, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 23
Guests Online: 20
Members Online: 3

Registered Members: 82838
Newest Member: w1zarrd
Latest Articles

BrainFuck

Arrow Image A great language.



Programming in BrainFuck.
By BobbyB.

This article is going to teach you the worlds most simple and hilarious language:
BrainFuck.

Basically, all BrainFuck does is manipulate a huge line of 30000 bytes, with only 8 commands.

Just imagine a string of 30000 bytes. At the start of the program, there is a pointer at the one right

at the left. Now, we can move this pointer along the string of bytes with two operators:

> -move the pointer to the next byte on the right
< -move the pointer to the next byte on the left

Whilst at these bytes, we may either increase their values or decrease their values with these two

commands:

+ -increase the value of the byte at the pointer by one
- -decrease the value at the byte at the pointer by one

Also, we can either input data in to these pointers, or out put data from these pointers, with two more

operators:

, -input ascii value of key pressed in to byte at the pointer
. -output ascii value of the pointer as a character

So, a program to say \'Hello\' could look something like this is BrainFuck:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Changes the value of the byte at the pointer to 72,or \'H\' in ascii

.
Outputs ascii the character of the byte at the pointer

+++++++++++++++++++++++++++++
Changes the value of the byte at the pointer to 101, or \'e\' in ascii

.
Outputs ascii the character of the byte at the pointer

+++++++
Changes the value of the byte at the pointer to 108, or \'l\' in ascii

..
Outputs ascii the character of the byte at the pointer twice

+++
Changes the value of the byte at the pointer to 111, or \'o\' in ascii

.
Outputs ascii the character of the byte at the pointer


In BrainFuck, there is no need for comment marks, as any other characters other that the eight

characters used as commands are simply ignored.

Now, there are two more commands in BrainFuck, and these are loop commands, they are rather difficult

to get your head round at first, but soon become clear. They are

[ and ]

These work by the commands inside the [] commands being repeated until the byte the pointer was at just

before the [ operator becomes zero.

So, to print out a capital H thirty times, the BrainFuck code would look like this:

++++++++++++++++++++++++++++++
Make the value of the first pointer 30

>
Go to the next pointer on the right

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Make the value of the byte at this pointer 72, or \'H\' in ascii

<
Go back to the previous pointer

[
Start the loop

>.<-]
Make it so the value of the next pointer is displayed as an ascii character and the value of the

previous pointer is decreased by one, so when the letter has been displayed thirty times the first pointer reaches zero and the loop stops.

And finally, for one last BrainFuck program, we will take user input of one letter and the display it back again. The code is this:

,.

That\'s it. As soon as , assigns the ascii value of the key pressed to the pointer . displays it back again.

A good BrainFuck compiler can be found at http://home.arcor.de/partusch/html_en/bfd.html

That\'s all there is to this wonderful language.

Comments

Cynoxx_on December 28 2005 - 19:03:57
What can you do with brainfuck?
only_samuraion September 08 2006 - 16:07:59
wtf man? seriously. what can you do with this? why would you want to do something with this?
dw0rekon October 16 2006 - 23:00:06
BrainFuck is really a nice language, its too bad that not more people use it. Pfft
rain_zoneon November 04 2006 - 16:40:16
what the fuck is this
T-Metal-Risenon November 18 2006 - 09:51:44
kiyoura: I can assure you that pointer manipulation (however simplistic it may be, lol) is more advanced than clicking and dragging in Visual Basic. I'd also like to note that BobbyB is not 'noob' as you so willingly assumed.
FakePlaceboon March 18 2007 - 17:57:18
I like the article since not much people use brainfuck, its a fun language. and for all the people here who think it sucks, it gives you a good understanding of programming and logic and altho its not the best language to program in, you can see it as a great challenge.
Tak11on January 11 2009 - 05:19:40
lmfao this is great, should also be an article on malbolge Pfft
Post Comment

Sorry.

You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.