Donate to us!
The important thing is not to stop questioning. - Albert Einstein
Saturday, June 23, 2018
 Need Help?
Members Online
Total Online: 84
Guests Online: 83
Members Online: 1

Registered Members: 105564
Newest Member: wulver1130
Latest Articles


Arrow Image A small language.

I know there has been an other article about Brainfuck but I thought I could do better at some points so I decided to write my own.

Now to begin with, I saw comments on the other Brainfuck article which were like:
"wtf man? seriously. what can you do with this? why would you want to do something with this?"
"what the fuck is this"
"Brainfuck....HAHAHAHAHAHAHAHAHAHA learn asm,C++/C,html, and even visual fucking basic compared to this bull shit. you noobs make me laugh"

I hope you can get an answer to these "questions" in this article.

Now what is Brainfuck?
Brainfuck is the most simplistic programming language there is. It uses only 8 operators and it's meant as a challenge, and to amuse programmers. Its really the smallest language there is. There are compilers out there which are smaller than 200 bytes! And the language uses only 8 operators and everything you can do in any other language, is possible with these operators too. You just have to be creative to figure out how to. Now you don't have to tell me this language isn't practical because I know it isn't. But it's alot of fun to program in brainfuck and it stimulates creativity and logic thought. And it also helps me kill time in boring classes :P

Brainfuck uses a list of bytes, which all start at 0, and a bytepointer, which, as the name says, points to a byte. The operators are: ><+-[].,

> moves the bytepointer one byte to the right.
< moves the bytepointer one byte to the left.

+ increases the byte where the bytepointer is currently pointing to with 1.
- decreases the byte where the bytepointer is currently pointing to with 1.

[ if the byte which the bytepointer is currently pointing to equals 0, jump to the corresponding ].
] if the byte which the bytepointer is currently pointing to does not equal 0, jump back to the corresponding [.

. output of the value of the byte which the bytepointer is currently pointing to.
, get input from user, and store its value in the byte which the bytepointer is currently pointing to.

Output is usually the character with the ascii value of the byte, but it could be anything, like for example, the color for a pixel.
Input is usually the ascii value of the key which is used for input (eg A would write 65 in the byte and 0 would write 48 in the byte).

Yes, that's all there really is to it.

Some simple code would be:

Let's analyze it:

+++++++++++++++++++++++++++++++++++++++++++++++++ Will first put the byte's value at 49 (the ascii value of 1).
Then . will output this, so it would output 1.
Then +. will increase it, and output the new value, which will then be 2.
Then another +. will increase it, and output the new value again. which will then be 3.

So the output will be: 123.

Now we can do a nifty trick here to make the code much, much shorter:

What did we do? As you can see the end is still the same. but alot of the +s are gone.

We replaced ++++++++++++++++++++++++++++++++++++++++++++++++ (thats 48 of them)
with ++++++++[->++++++<]>

So first, the byte is put at 8 (the ++++++++ does that).
then, it checks if the byte is nonzero, yes it is. so we will decrease the byte and it will be left at 7.
then we go one byte to the right, and increase it with 6.
then we go one byte to the left (that's the one wich was at value 7) and it checks if its nonzero. Yes it is, so we repeat what's in between the [].

What this does, is add 6 to the second byte, 8 times. so it will then, in the end, be 48.
Then after that, the > moves the bytepointer to the byte which is at 48, and it then repeats the lasts steps from the first example.
So again, the output will be 123.

That's just one of lots of little tricks you can make up with these operators, like [-] will clear a byte, and [<] will find the first empty byte at the left of the bytepointer. I'm sure you can think of many more tricks like this.

Now a simple little script might look like this:
I think this was the first script I wrote myself.

It's a simple script which asks for 2 numbers, and then outputs the sum of the numbers. The sum can't be larger than 9 or it won't give the right outcome.

The simplicity of the languages also allows for fun ascii art scripts. Like you could hide your script in a steganographic way in an ascii art picture :D I unfortunately couldn't put an example of this in here because html and this font don't like ascii art. -_-

Well that's all the basics, and some more advanced aspects, of Brainfuck. I hope you guys liked it, and finally got a better view on Brainfuck and what you can do with it.

Here's the interpreter I use: .
I haven't tested alot of them but I like this one but there are many more, and probably some better than this.


JohnDoeon March 19 2007 - 18:05:14
Looks cool. Im lazy, could you put a link to the compiler or something =D
system_meltdownon March 19 2007 - 18:27:32
Google for one, there's quite a few out there Pfft
UnknownFromHellon March 19 2007 - 18:50:22
No Hello World???? Nice Stuff Though, I Used To Program In Brainfuck About Two Years Ago And Later On Shifted To Boolfuck And Double Fuck. I'll Rate It Good...
only_samuraion March 19 2007 - 18:53:07
much better artcile Smile i'll have to give it a go
kaksiion March 19 2007 - 20:38:31
boolfuck, doublefuck, shitfuck, assfuck.... nice article btw
sakarinon March 19 2007 - 23:49:05
while ure at it you can try my sig challenge (click on my name to see the sig and a link to the thread) you need to know what bf is in order to complete it
DarkShadow1990on March 20 2007 - 02:42:27
I think this article was very well put together and clearly explained BrainFuck. I rate this article "Awesome". Smile
mozzeron March 20 2007 - 11:00:27
You missed out the most important thing about brainfuck. It is Turing complete and therefore you can do anything with it
FakePlaceboon March 20 2007 - 12:31:36
thanx for all the positive comments guys, and mozzer, ur right I didnt say it was turing complete, but I did note that anything is possible with it
Happysmilemanon March 20 2007 - 18:39:21
Never understood (or tried to understand) brainfuck before, but I understand it now Pfft
Nickon March 20 2007 - 19:28:06
lmao y'all crack meh up XD good article btw
Uber0non March 21 2007 - 18:25:20
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. That's a simple 'Hello World' code Wink
Uber0non March 21 2007 - 18:25:49
Btw this tutorial was really good. I appreciate it Grin
kaksiion March 22 2007 - 13:09:54
Uber0n, that is very long Hello World. I might try something, but I think I will get confused.
FakePlaceboon March 22 2007 - 15:46:52
@Uber0n, pitty u copied that code from wikipedia eh... well it is one of the shortest hello worlds, I tried to make a shorter one but I couldn't find a way =/ so kaksii, goodluck trying to improve it xD
sakarinon March 23 2007 - 13:29:44
dw0rekon March 26 2007 - 23:13:08
i know that the compiler itself is usually very small for brainfuck, but what about the compiled programs. how large does "hello world" get once compiled for instance? oh and nice article.
ranmaon July 29 2007 - 21:01:32
You could make this into a decryption challenge
Post Comment


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