Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    sockopen's Avatar
    Join Date
    Jan 2006
    Posts
    14
    Reputation
    10
    Thanks
    0

    brainfuck Programming

    This tutorial is for the programming language Brainfuċk, I used the Brainfuċked compiler, there's also a popular Brainfuċk interpreter in PHP. The Brainfuċked compiler is 799 bytes, has syntax checking, and of course is open source. The smallest compiler in the world is for Brainfuċk, and is 171 bytes.

    Brainfuċk is a cross-platform programming language with only eight instructions, and no operands, no variables, no conditions, and of course no functions.

    Let's go through all of the possible instructions you can use with Brainfuċk:

    > move the memory pointer to the next memory block
    < move the memory pointer to the previous memory block
    + increases the memory cell under the memory pointer
    - decreases the memory cell under the memory pointer
    [ starts a 'while' loop "c while(cur_block_value != 0)"
    ] ends a 'while' loop
    . writes the contents of the memory cell under the memory pointer as an ASCII character "c putchar()"
    , reads an ASCII character input and fills the memory cell under the memory pointer "c getchar()"

    Anything that's not one of those eight characters will be ignored by the compiler and taken as comments. The memory pointer always starts on the left-most memory block, and all memory blocks start with a zero value.



    Now let's do some coding, open up Notepad, and remember to save your projects as *.b's.

    First Program
    Code:
    +++++[-]
    That's the full code for our first program in brainfuċk, normally you start with a Hello World program, but, we'll get there eventually, it's more complex than you would first imagine.

    +++++[-] does several things. First we are increasing the memory cell under the memory pointer to five. Then we enter a loop that loops subtracting our value of five by one until it reaches zero, then exits the loop. This could take up to five lines of code in a language such as C, which is also less efficient.

    Second Program
    Code:
    >>>++
    This moves our memory pointer to the third memory block and increases the memory cell's stored value by two.

    Now let's add onto this program, we'll change several memory cell's values.

    Code:
    >>>++<<+>>+++
    Now this program moves our memory pointer to the third memory block, increases the memory cell's stored value by two, goes back to the first memory block and increases that memory cell's stored value by one. Then goes back to our third memory block and increases our existing memory cell value (of two), to five by incrementing it by three.

    Final Program
    Until now, you haven't been able to see your own programs' calculations. Let's create a program that has some output, the 'Hello World' program.

    Code:
    >+++++++++[<++++++++>-]<.[-]
    >++++++++++[<++++++++++>-]<+.[-]
    >+++++++++++[<++++++++++>-]<--..[-]
    >+++++++++++[<++++++++++>-]<+.[-]
    >+++++++[<++++++>-]<++.[-]
    >++++++[<+++++>-]<++.[-]
    >++++++++++[<+++++++++>-]<---.[-]
    >+++++++++++[<++++++++++>-]<+.[-]
    >+++++++++++[<++++++++++>-]<++++.[-]
    >+++++++++++[<++++++++++>-]<--.[-]
    >++++++++++[<++++++++++>-]<.[-]
    +++++++++++++.---.-
    Since we can only work with numbers, we have to use characters' ASCII values to represent the characters we want to output.

    Program Breakdown:

    Code:
    >+++++++++[<++++++++>-]<.
    First increases the memory pointer to the first memory block, and increases the memory cell's value to nine. We then enter our loop, go back to our zero block and change it's value to eight, go back to our first memory block and decrease the memory cell's stored value to eight, and, returns back to the start of our loop until the memory cell the memory pointer is on is equal to zero. This loop continues until our zero memory block is at 72, and our first memory block is at zero. We then return our memory pointer to the zero memory block, and with our '.', we print the ASCII decimal value, which represents the letter 'H'.

    As you can imagine, it then goes through the rest of the characters and does the same.



    I hope you enjoy programming in Brainfuċk as much as I have. Once you get good with Brainfuċk, I suggest moving to Brainfork and Braintwist, which still use the core idea of Brainfuċk, with extra capabilities.

  2. #2
    RCEisForMe's Avatar
    Join Date
    Feb 2006
    Posts
    39
    Reputation
    9
    Thanks
    0
    Hang on, why would you program in brainfuck when you could program in c, or asm, or if you swing that way another pointless, esoteric language like cow? (https://en.wikipedia.org/wiki/COW_programming_language)

  3. #3
    sockopen's Avatar
    Join Date
    Jan 2006
    Posts
    14
    Reputation
    10
    Thanks
    0
    It's a challenge, which aspiring programmer would not like to know an extra language? Especially one so challenging and unique such as brainfuck?

  4. #4
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    Can't say I have heard of "BrainFuck"





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  5. #5
    gunot's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    1,861
    Reputation
    29
    Thanks
    322
    looks ugly...

  6. #6
    RCEisForMe's Avatar
    Join Date
    Feb 2006
    Posts
    39
    Reputation
    9
    Thanks
    0
    Like Cow, Brainfuck is pretty much a joke language, like that 1337-speak programming language.

  7. #7
    pepsi_dude_777's Avatar
    Join Date
    Jan 2006
    Posts
    70
    Reputation
    10
    Thanks
    0
    hmm, brainfuck program, never heard of it either, i think C++ would be easier

  8. #8
    shercipher's Avatar
    Join Date
    Dec 2005
    Posts
    108
    Reputation
    10
    Thanks
    14
    The point of brainfuck is to be hard not to be useful.

    There is one called fuckfuck (not related) in which the entire language is composed of curse words.

  9. #9
    arunforce's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    A place for amigos
    Posts
    24,703
    Reputation
    4747
    Thanks
    12,562
    My Mood
    Yeehaw
    Binary seems hardest, no matter how you look at it.



    BRING BACK BT, BRING BACK SAGA, BRING BACK VF, BRING BACK MPGHCRAFT, BRING BACK HABAMON


  10. #10
    SpiderByte's Avatar
    Join Date
    Jan 2006
    Posts
    103
    Reputation
    10
    Thanks
    3
    Binary is easy as shit

  11. #11
    Firey's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Posts
    44
    Reputation
    28
    Thanks
    22
    if you pass this, you can code binary.

    There a 10 types of people in the world, those who read binary, and those who don't.

  12. #12
    Dave84311's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    The Wild Wild West
    Posts
    35,837
    Reputation
    5782
    Thanks
    41,292
    My Mood
    Devilish
    Ugh.... RIGHT... Binary ain't easy as shit wtf. Try writing a whole program in binary...





    THE EYE OF AN ADMINISTRATOR IS UPON YOU. ANY WRONG YOU DO IM GONNA SEE, WHEN YOU'RE ON MPGH, LOOK BEHIND YOU, 'CAUSE THATS WHERE IM GONNA BE


    "First they ignore you. Then they laugh at you. Then they fight you. Then you lose.” - Dave84311

    HAVING VIRTUAL DETOX

  13. #13
    [gen]'s Avatar
    Join Date
    Jan 2006
    Posts
    11
    Reputation
    10
    Thanks
    0
    noone programs in binary anymore, binary is just how the machine interprets other programming languages..it was the whole reason assembly came to life.

  14. #14
    BaGGy's Avatar
    Join Date
    Dec 2005
    Gender
    female
    Posts
    14
    Reputation
    10
    Thanks
    0
    Brainfuck was written just for fun, and is somewhat a language but not a useful one. Or not even a language people will use.

    Also, you really didnt write that tutorial, you took it from an earlier version of the wikipedia page, damn biters...

  15. #15
    Mikoll's Avatar
    Join Date
    Dec 2005
    Gender
    male
    Location
    in the niggaz department
    Posts
    1,348
    Reputation
    11
    Thanks
    37
    it's so fnny how everyone keeps saying it and no one has said anything about the name ahahaha... Brainfuck

Page 1 of 2 12 LastLast

Similar Threads

  1. a good java program
    By snipelock in forum Java
    Replies: 18
    Last Post: 04-17-2009, 02:56 PM
  2. Ennyone know of HACKING PROGRAMS
    By daniel1322dan in forum General Hacking
    Replies: 9
    Last Post: 07-24-2008, 06:46 PM
  3. Runescape 2 auto programs
    By fabled in forum Hack Requests
    Replies: 19
    Last Post: 09-05-2007, 01:43 PM
  4. [Tutorial] Your first program
    By akimoko in forum C++/C Programming
    Replies: 10
    Last Post: 06-23-2007, 12:58 PM
  5. Problem Wit Hacking Programs
    By f5awp in forum General Gaming
    Replies: 5
    Last Post: 01-10-2006, 05:44 AM