Inspiration

MLH - LHD Day 5

What its about

In this hack we learn about various weird or unique programming languages.

About

BrainFunk Language Brainfuck is an esoteric programming language created in 1993 by Urban Muller Notable for its extreme minimalism, the language consists of only eight simple commands and an instruction pointer. While it is fully Turing complete, it is not intended for practical use, but to challenge and amuse programmers. Brainfuck simply requires one to break commands into microscopic steps.

Various Commands are

  • increment the data pointer (to point to the next cell to the right). < - decrement the data pointer (to point to the next cell to the left).
    • - increment (increase by one) the byte at the data pointer.
    • - decrement (decrease by one) the byte at the data pointer. . - output the byte at the data pointer. , - accept one byte of input, storing its value in the byte at the data pointer. [ - if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command. ] - if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.

(Alternatively, the ] command may instead be translated as an unconditional jump to the corresponding [ command, or vice versa; programs will behave the same but will run more slowly, due to unnecessary double searching.)

[ and ] match as parentheses usually do: each [ matches exactly one ] and vice versa, the [ comes first, and there can be no unmatched [ or ] between the two.

Examples - Adding two values As a first, simple example, the following code snippet will add the current cell's value to the next cell: Each time the loop is executed, the current cell is decremented, the data pointer moves to the right, that next cell is incremented, and the data pointer moves left again. This sequence is repeated until the starting cell is 0.

[->+<]
++       Cell c0 = 2
[        Start your loops with your cell pointer on the loop counter (c1 in our case)
< +      Add 1 to c0
> -      Subtract 1 from c1
]        End your loops with the cell pointer on the loop counter

At this point our program has added 5 to 2 leaving 7 in c0 and 0 in c1
but we cannot output this value to the terminal since it is not ASCII encoded.

To display the ASCII character "7" we must add 48 to the value 7.
We use a loop to compute 48 = 6 * 8.

++++ ++++  c1 = 8 and this will be our loop counter again
[
< +++ +++  Add 6 to c0
> -        Subtract 1 from c1
]
< .        Print out c0 which has the value 55 which translates to "7"!

link

We have learned about other unique languages like -

Cow Language Example mOo - Moves current memory position back one block. link Cactusi Language Example Underscore(_) Print Equal(=) 1 Vertical bar 0 link

Accomplishments that we're proud of

Learned about 3 different languages.

What we learned

Cow language, Cactusi and Brainfunk

What's next for Share a Unique Language

write some basic code in these languages :D

Built With

Share this project:

Updates