Brainf**k in 100 Seconds

Science - Tech Channel
9 followers
2 Video Views·Oct 7, 2023
# 100 Seconds of Code
BrainFuck, a minimal esoteric programming language designed to make your brain hurt.
It's Turing-complete, but not designed to build actual software. It's more like a work of art
that challenges the status quo. It was created in 1993 by Swiss physics student Urban Mueller,
where the goal was to create a language with the smallest possible compiler. It was built
for the Amiga 2.0 operating system, and the compiler weighs in at under 200 bytes.
A BrainFuck program starts with a 30,000 byte one-dimensional array. All values are initialized
to zero, then it provides a moveable pointer that you can manipulate with eight different
commands. Use angle brackets to move the pointer left or right by one cell at a time,
then increment or decrement the value in a cell using plus or minus. Use a period to output the
byte at the pointer's current location, or use a comma to accept input and store it at the
pointer's current location. And finally, use opening and closing brackets to create a loop.
Notice how BrainFuck doesn't require silly things like variables, functions, and classes.
To get started with BrainFuck, delete your operating system and install AmigaOS,
then create a file ending in .bf, which stands for BrainFuck. Any characters that are not the
eight I mentioned previously will be ignored as a comment. At this point, we have an array
with 30,000 8-bit numbers, all set to zero. To say hi mom, we'll need to set each number to
its corresponding ASCII character. We can increment the first cell, then enter a loop
with an opening bracket. For each iteration of the loop, we'll decrement the current cell by 5,
then use an angle bracket to move one cell to the right. We'll increment that cell by 3,
then move back to the left and close the loop. The loop will continue until the original cell
goes back to zero, at which point it will exit. We now have a value of 103 at index 1. We can
move the pointer to it, increment it to 104, then use a period to output it. That corresponds to
the letter H in ASCII. We can increment it again to get 105, which corresponds to the letter I.
Now we continue this process of manipulating memory like cavemen until we output all the
characters that we need. Now to run your code, use right-click copy and paste it into one of
the many online interpreters. Congratulations, you just said hi to your mom in brainfuck.
This has been brainfuck in 100 seconds. If you want to see more brainfuck content on this channel,
make sure to hit the like button and subscribe. Thanks for watching, and I will see you in the
next one.
