The RPG Maker Resource Kit

RMRK General => General Chat => Topic started by: Blizzard on March 05, 2007, 01:52:23 PM

Title: Brainfuck - the little bit "different" programming language.
Post by: Blizzard on March 05, 2007, 01:52:23 PM
This is a very interesting programming language, having ONLY 8 commands. It basically works that way that it takes up an array of data (you can set up how much, I think about 32768 was default). Everything can be made by moving around in the array and processing data. Here is an example of a "Hello World." program in Brainfuck.

Quote++++++++++
[>+++++++>++++++++++>+++>+<<<<-] The initial loop to set up useful values in the array
>++.                             Print 'H'
>+.                              Print 'e'
+++++++.                         Print 'l'
.                                Print 'l'
+++.                             Print 'o'
>++.                             Print ' '
<<+++++++++++++++.               Print 'W'
>.                               Print 'o'
+++.                             Print 'r'
------.                          Print 'l'
--------.                        Print 'd'
>+.                              Print '!'
>.                               Print newline

The commands are:

Quote>   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.

Any other characters are considered comments. Basically the C/C++ equivalents are:

Quote>   ++ptr;
<   --ptr;
+   ++*ptr;
-   --*ptr;
.   putchar(*ptr);
,   *ptr=getchar();
[   while (*ptr) {
]   }

More info:

http://en.wikipedia.org/wiki/Brainfuck
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Zeriab on March 05, 2007, 02:07:19 PM
Lolz @ this language :tpg:
Wonder why they call it Brainfuck  ::)

I am definitely not going to use this, but it gave a good laugh  ;8
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Blizzard on March 05, 2007, 02:34:34 PM
Totally. I also check what "Obfuscated coding" is. Totally lolage. xD

http://en.wikipedia.org/wiki/Obfuscated_code
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Zeriab on March 05, 2007, 05:19:46 PM
It really is :tpg:
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Winged on March 11, 2007, 09:33:17 AM
Holy mother of lord! What the hell? This is the most weirdest language, but I understand it a lot better than any other language...wait till my IT teacher hears about this  ;D

~Winged
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Mushroom Panda on March 13, 2007, 02:39:19 AM
Hey guys I use this more then lisp, c#, and liberty basic combined! (i don't know any of them...)
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: .:Pyroken Serafoculus:. on March 17, 2007, 09:49:01 AM
That thing is just plain weird. o.O I really haven't seen anything less efficient than that.

Brainfuck indeed.
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Blizzard on March 17, 2007, 09:22:51 PM
Well, as stated in wiki it isn't supposed to be efficient, but to be a little challenge for programmers.
Title: Re: Brainfuck - the little bit "different" programming language.
Post by: Arwym on March 22, 2007, 04:56:36 AM
LMAO! I will have to try this someday, when I am more experienced in programming. XD