» «

# Brainf*ck

10 replies to this topic
Svip
• ##### Svip

I eat babies

• The Connection
• Joined: 12 Nov 2001
• Best Returning Member 2014

### #1 Posted 01 May 2005 - 02:49 PM Edited by Svip, 01 May 2005 - 02:59 PM.

Some of you might have heard of Brainf*ck, Brainf*ck is a programming language that only operates with 8 operators.

There are many guides and such you can find with google, but this topic is both a guide and a discussion of Brainf*ck.

Now, in order to understand the complex of Brainf*ck, you'll need to know how it works.

In Brainf*ck there is a pointer called 'The Pointer' or p, p points to what element in the array ( which is per standard 30,000 bytes ), the pointer can be moved around through the elements, and numbers can be added/subtracted.

Operators:
 < moves the pointer one down or to the left, depends on how you see it, or you would say decreases > moves the pointer the other way, or increases - subtracts 1 from the respective element in the array + adds 1 to the respective element in the array , allows the user to type in a letter or string . prints out the respetive element [ starts a while loop that will go on untill the element is 0 or in C: while(*p != 0) ] ends the while
In order to understand how you should output a character, you need to have a ASCII chart, I've written one for you that you can use which is written on the left side, so you can have your text editor open while looking at it.

 32 space 64 @ 96 ` 33 ! 65 A 97 a 34 " 66 B 98 b 35 # 67 C 99 c 36 \$ 68 D 100 d 37 % 69 E 101 e 38 & 70 F 102 f 39 ' 71 G 103 g 40 ( 72 H 104 h 41 ) 73 I 105 i 42 * 74 J 106 j 43 + 75 K 107 k 44 , 76 L 108 l 45 - 77 M 109 m 46 . 78 N 110 n 47 / 79 O 111 o 48 0 80 P 112 p 49 1 81 Q 113 q 50 2 82 R 114 r 51 3 83 S 115 s 52 4 84 T 116 t 53 5 85 U 117 u 54 6 86 V 118 v 55 7 87 W 119 w 56 8 88 X 120 x 57 9 89 Y 121 y 58 : 90 Z 122 z 59 ; 91 [ 123 { 60 < 92 \ 124 | 61 = 93 ] 125 } 62 > 94 ^ 126 ~ 63 ? 95 _ 127
Another usefull ASCII charater is 10, which makes a breakline.

Now that you know what it prints, and what the operators is, you should grap a calculator, otherwise it will live up to it's name for you.

Let's go through some basics. In order understand the pointer, I've made some small codes that would help you:

 CODE >>>+++

This will go to '4 ( being element number 4 in the array ) and then add 3 to it. So it would somewhat simlar to this:

 CODE Array: [0] [0] [0] [3] [0]                             ^

^ being the pointer.

In case we want to move that 3 to '3 instead of '4, it can be done with a loop command, which in this example should keep on untill '4 is 0;

 CODE >>>+++[<+>-]

Now, I am going to go much through this, if you want a more detailed tutorial, look here;
http://neworder.box....hp?newsid=13065

Now, if you want a compiler for it, one can be caughted here:
http://esoteric.sang...impl/compilers/
Note: You have to replace the * with u in the adress bar since this sh*tty forums edits 'f u ck' to 'f*ck'.

I will start showing off a program that says; "Hi, svip":

 CODE >+++++++++[<++++++++>-]<.[-]++++++++++[<++++++++++>-]<+++++.[-]++++[<++++++++++>-]<++++.[-]+++++[<++++++>-]<++.[-]+++++++++++[<++++++++++>-]<+++++.[-]+++++++++++[<++++++++++>-]<++++++++.[-]++++++++++[<++++++++++>-]<+++++.[-]+++++++++++[<++++++++++>-]<++.

Discuss.

Credit to Segosa for telling me of Brainf*ck, and for the tutorial link.

magical_trevor
• ##### magical_trevor

Propaganda Inc.

• Members
• Joined: 06 Nov 2004

### #2 Posted 01 May 2005 - 03:17 PM

Is it me, or does this seem unnecessarily difficult? Nonetheless, it is pretty cool, but I don't think I'll be mastering it anytime soon.

segosa
• ##### segosa

Ghetto Star

• BUSTED!
• Joined: 15 May 2002

### #3 Posted 01 May 2005 - 03:35 PM

 QUOTE (magical_trevor @ May 1 2005, 17:17) Is it me, or does this seem unnecessarily difficult? Nonetheless, it is pretty cool, but I don't think I'll be mastering it anytime soon.

It's meant to be difficult. It's useless and it's meant to be a brain exercise, something to get you to use your brain in a way you haven't before. With a bit of imagination you can do quite a lot with it.

Svip
• ##### Svip

I eat babies

• The Connection
• Joined: 12 Nov 2001
• Best Returning Member 2014

### #4 Posted 01 May 2005 - 03:46 PM

QUOTE (Segosa @ May 1 2005, 17:35)
 QUOTE (magical_trevor @ May 1 2005, 17:17) Is it me, or does this seem unnecessarily difficult? Nonetheless, it is pretty cool, but I don't think I'll be mastering it anytime soon.

It's meant to be difficult. It's useless and it's meant to be a brain exercise, something to get you to use your brain in a way you haven't before. With a bit of imagination you can do quite a lot with it.

Well.

Not exactly, Urban Müller wanted to create the smallest compiler possible.

And 171 in bytes must be the smallest to date.

segosa
• ##### segosa

Ghetto Star

• BUSTED!
• Joined: 15 May 2002

### #5 Posted 01 May 2005 - 04:06 PM

QUOTE (Svip @ May 1 2005, 17:46)
QUOTE (Segosa @ May 1 2005, 17:35)
 QUOTE (magical_trevor @ May 1 2005, 17:17) Is it me, or does this seem unnecessarily difficult? Nonetheless, it is pretty cool, but I don't think I'll be mastering it anytime soon.

It's meant to be difficult. It's useless and it's meant to be a brain exercise, something to get you to use your brain in a way you haven't before. With a bit of imagination you can do quite a lot with it.

Well.

Not exactly, Urban Müller wanted to create the smallest compiler possible.

And 171 in bytes must be the smallest to date.

It isn't a compiler, it doesn't create a binary file, it simply outputs the C equivalent and then compiles with GCC. It is an interpreter.

PatrickW
• ##### PatrickW

GTA Juggernaut

• Moderator
• Joined: 07 Jan 2004
• Best Script 2013 [DYOM]
Best Script 2012 [DYOM]

### #6 Posted 03 May 2005 - 07:45 PM

Thanx guys for bringing this up....
I really love these things

@Segosa,
it really is a compiler. Compilers are pieces of software that transform the source-format into a target format (not neccesary executable). An Interpreter is a piece of software that reads a source format, and executes the instructions contained, which is here clearly not the case.

Octember
• ##### Octember

propaganda inc

• BUSTED!
• Joined: 29 Oct 2004

### #7 Posted 04 May 2005 - 12:16 AM

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

'nuff said.

G twenty-nine
• ##### G twenty-nine

Location: /home

• Members
• Joined: 16 Apr 2005

### #8 Posted 04 May 2005 - 02:18 AM

>+++++++++[<+++++++++>-]<++++++++.->+++++++[<+++>-]<.++++++.[-]>++++++++[<++++>-]<.++>+++++++++[<+++++++++>-]<.++.>+++++++++[<-->-]<.++++++++.[-]>++++++++[<+++++>-]<++++.>++++++++[<++++>-]<.[-]>+++++++++[<+++++++++>-]<++.>+++++++[<+++>-]<+.+++++++++.[-]>++++++[<++++++++>-]<--.
You suck, sir.

I think I got it right, but I didn't use the compiler and all...

segosa
• ##### segosa

Ghetto Star

• BUSTED!
• Joined: 15 May 2002

### #9 Posted 04 May 2005 - 06:37 AM

 QUOTE (G twenty-nine @ May 4 2005, 04:18) >+++++++++[<+++++++++>-]<++++++++.->+++++++[<+++>-]<.++++++.[-]>++++++++[<++++>-]<.++>+++++++++[<+++++++++>-]<.++.>+++++++++[<-->-]<.++++++++.[-]>++++++++[<+++++>-]<++++.>++++++++[<++++>-]<.[-]>+++++++++[<+++++++++>-]<++.>+++++++[<+++>-]<+.+++++++++.[-]>++++++[<++++++++>-]<--.You suck, sir.I think I got it right, but I didn't use the compiler and all...

[email protected] bin \$ ./a.out
Yms suck,LSir.
[email protected] bin \$

G twenty-nine
• ##### G twenty-nine

Location: /home

• Members
• Joined: 16 Apr 2005

### #10 Posted 04 May 2005 - 11:13 PM

Aw, f*ck, well I was close for a first time, aye?

Johnno
• ##### Johnno

WD&P Ogre

• Members
• Joined: 15 Sep 2002

### #11 Posted 05 May 2005 - 09:49 AM

I've always been interested in esoteric programming languages, and might learn one shortly.

Brainf*ck certainly sounds interesting.

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users