Main Menu
  • Welcome to The RPG Maker Resource Kit.

Brainfuck - the little bit "different" programming language.

Started by Blizzard, March 05, 2007, 01:52:23 PM

0 Members and 1 Guest are viewing this topic.

Blizzard

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
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Zeriab

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

Blizzard

Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Zeriab


Winged

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



Mushroom Panda

Hey guys I use this more then lisp, c#, and liberty basic combined! (i don't know any of them...)

.:Pyroken Serafoculus:.

#6
That thing is just plain weird. o.O I really haven't seen anything less efficient than that.

Brainfuck indeed.
...

Blizzard

Well, as stated in wiki it isn't supposed to be efficient, but to be a little challenge for programmers.
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Arwym

LMAO! I will have to try this someday, when I am more experienced in programming. XD