Jump to content
xisto Community
Sign in to follow this  
qwijibow

Brainf*ck - World's Smallest And Hardest Language

Recommended Posts

Has anyone Ever Programmed In BrainF*ck before ?

its not a *REAL* language in the sence that you would never use it to program anything seriouse.
but it its very interesting in that it is the smallest complete programming language.

in other words, BrainF*ck is Turing Complete !!!

in theory, any function can be written using only 8 commands.
in brainF these commands are...

Command, BrainF Symbol
Input , (comma)
output . (full stop)
Increment + (plus)
Decrement - (minus)
Left Register < (Smaller Than)
Right Register > (bigger than)
While Not Zero [ (open square bracket)
Loop ] (closed square bracket)

all other characters are ignored.

its a very hard language to learn !!!!!
and insane to de-bug.

there are many interpreters out there for those who are interested, ssearch google.

here is an example of a few programs written in Brain****.

a simple hello world porgram

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

a random number generator.
>>>++[    <++++++++[        <[<++>-]>>[>>]+>>+[            -[->>+<<<[<[<<]<+>]>[>[>>]]]            <[>>[-]]>[>[-<<]>[<+<]]+<<        ]<[>+<-]>>-    ]<.[-]>>]

this is a brain**** program to generate mandleprot images
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<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>>]+<<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<<<<<<]]>>>]

Share this post


Link to post
Share on other sites

Very nice, but appearantly these algorythms only work for one specific variable, and they don't allow storage & retreaval of data in memory?Hmm.. or they do but youave to manually control the pointer and move it around.. Sound pretty tough, even ASM is easier =P

Share this post


Link to post
Share on other sites

Very nice, but appearantly these algorythms only work for one specific variable, and they don't allow storage & retreaval of data in memory?

Hmm.. or they do but youave to manually control the pointer and move it around.. Sound pretty tough, even ASM is easier =P

<{POST_SNAPBACK}>


You can use memory, but yes you have to move the pointer around yourself.

 

for example, here is a program that will ask you to inpput your name, then it will print out your name...

like a "what is your name ?" "Hello Bob" program...

TODO: output "what is your name?"Loop round subtracting one untill the current pointer = 0[-]move to the next memory cell The first memory cell must be ZERO>Loop round accepting input untill the user hits returnThe Ascii Code for return is 10so subtract 10 from each input character so the input loop will exit,----------[>,----------]a return character was hit Return to the start of the name by looping backthrough the memory cells untill we hit the zero we put in the first cell<[<]TODO: output "Hello "now loop through the name adding 10 to each memory cell outputting untill we hit the terminating zero>++++++++++.[>++++++++++.]done !

Share this post


Link to post
Share on other sites

martian language ?

Share this post


Link to post
Share on other sites

programming in martian language is easier

prgraming in any language is easyer.. thats why BrainF*ck is an art form.

Share this post


Link to post
Share on other sites

LOL this programming language is actually physically scary. I wish I could be as good as this.I don't understand at all how>>>++[ <++++++++[ <[<++>-]>>[>>]+>>+[ -[->>+<<<[<[<<]<+>]>[>[>>]]] <[>>[-]]>[>[-<<]>[<+<]]+<< ]<[>+<-]>>- ]<.[-]>>]can be a random number generator. More than More than More than plus plus while not zero?!

Share this post


Link to post
Share on other sites
>>>++[<++++++++[<[<++>-]>>[>>]+>>+[-[->>+<<<[<[<<]<+>]>[>[>>]]]<[>>[-]]>[>[-<<]>[<+<]]+<<]<[>+<-]>>-]<.[-]>>]

translates to...

move to current memory address + 3, add 2, while current memory address doesnt equal 0

move to current memory address - 1, add 8, while current memory address doesnt equal 0

move to current memory address - 1, while current memeory address doesnt equal 0
move to current memory address - 1, add 2 ,move to current memory address +1
minus 1, return move to current memory address + 2, while..


well, you get the diea right ?
think of it as machine code :)

Share this post


Link to post
Share on other sites

It's actually very easy and simplistic. Just takes a bit more to figure things because it's low level.

Share this post


Link to post
Share on other sites

It's actually very easy and simplistic. Just takes a bit more to figure things because it's low level.

<{POST_SNAPBACK}>


lol... thats what you think... you should see an IF structure in BrainF*ck !

 

lets say you want to compare memory address 0 to memory address 1 and if they are equal DO somthing, (Without destroying the variables, you must....

 

1) make a copy of the varibales to work on in memory at address 2 and 3. (so noot to change origonal variables)

to make a copy of memory address 0 to memory address 2 you need to loop through subtracting one from address zero, adding one to memory address 2 and 5(temp) on each loop... then loop through address 5 subtracting one, and addinng one to address 0 on each loop.

 

all of that just to make a copy of a varrable.. and you have to do that twice....

 

here is the brainf*ck code to copy a variable

#copy address 0 to address 1.[->+>+<<]   #this will set address 0 to zero, but make copys in address 1 and 2.>>[-<<+>>] #this them moves address 2 into address 0. (leaving address 2 at zero again)now both address 0 and address one contain the origonal value of address 0

2)NEXT... you need to determine if the coppied variables are equal.

loop through coppied variable one subtracing one on each loop from itself, and coppyied variable 2.

if the variables are equal, then the body of a while next loop will not be entered from the address of coppied variable 2.....

 

code for "If A is not equal to B"

>>  # move to address 2[->-<]  #subtract one from each variable untill the first variable is ZERO>[  (THE VARIABLES ARE NOT EQUAL)  [-] ]   #the [-] sets this adress value to 0, so the loop will only run once

to make a "If A is equal to B" test, you would need to set anouther variable to one, and then enter it with a while loop... but if the NOT EQUAL code is executed, it sets the one variable to zero, preventing the while loop from being entered....

 

like so...

>>[->-<]>>+<< #set address +2 to 1 to allow the TRUE code block to run, this will be set to 0 if the  FALSE code block runs.>[ FALSE [-]>[-]] #the [-]>[-]code zero's this loop, and the next loop, preventing the TRUE code block from running.

 

SO.......

In assembly, an if statement is as simple as a jump instruction, with a condition, and an address...

in BrainFu*k an if code looks like this.......

 

My Example of a rainF8CK IF THEN ELSE statement

,>,<[->+>+<<]>>[-<<+>>] >[->+>+<<]>>[-<<+>>] <[->-<]>>+<[FALSE[-]>[-] ]>[TRUE]

and ontop of that, you have to make sure the code you insert into the TRUE and FALSE doesn not interfere with any ariables the IF THEN ELSE code uses.

 

i havent debuged that, its just off the top of my head, so dont be surprised if it doesnt work

 

 

Ohhh, and iif you think that looked complicated, you dont even want to know what an "IF A is bigger than B" looks like !!!!

Share this post


Link to post
Share on other sites

LOL this programming language is actually physically scary. I wish I could be as good as this.

 

I don't understand at all how

 

<snip>

 

can be a random number generator. More than More than More than plus plus while not zero?!

<{POST_SNAPBACK}>


Someone pointed out that that's actually "move pointer 3; add 2; while (not zero) {". But understanding the semantics of the language is just the first step. If anyone wants to actually understand how the program works, the first step is to read my explanation at http://www.hevanet.com/cristofd/bf/random.txt which assumes some familiarity with the language and with cellular automata too; and the second step is to ask me questions, if it still isn't clear (and you're still interested).

Good luck;

-Daniel Cristofani.

Share this post


Link to post
Share on other sites

lets say you want to compare memory address 0 to memory address 1 and if they are equal DO somthing, (Without destroying the variables, you must....

 

1) make a copy of the varibales to work on in memory at address 2 and 3. (so noot to change origonal variables)

<{POST_SNAPBACK}>


Not entirely necessary. Here's another approach:

 

,>,[<->>+<-][a-b 0 b 0 0]+<[ A!=B >->>]>[ A==B ->>>][a-b 0 b 0 0]<<[<<+>+>-][a b 0 0 0]

-Daniel.

Share this post


Link to post
Share on other sites

your code makes no sence to me....

[a-b 0 b 0 0]

this executes straigth after a closed loop... the the contents of the memory will alsways equal zero, so this loop is never entered.. and if it was entered, it would just loop round subtracting one untill it was at zero...

Share this post


Link to post
Share on other sites

this executes straigth after a closed loop... the the contents of the memory will alsways equal zero, so this loop is never entered..

<{POST_SNAPBACK}>


Exactly. That part is a comment. The actual working code is these three lines:

 

,>,[<->>+<-]+<[ A!=B >->>]>[ A==B ->>>]<<[<<+>+>-]

and then to explain what it was doing I added comments which are a map of the memory, so for instance when I wrote

 

,>,[<->>+<-]a-b 0 b 0 0

I meant that after this line of code is done executing, the first cell has (A minus B), the second cell has a zero, the third cell has B, and the fourth and fifth cells have zeroes.

 

Then, to prevent the "-" in the comments from being executed as a brain**** command, I put the comments in loops that would never be executed, because the cell was known to be zero. Maybe I should have explained that to begin with?

 

-Daniel.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.