Brainf*ck is an esoteric language with a total of eight operations, none of them very useful.
You can only add and subtract one from a pointer, and the memory address referred to by the pointer. This makes programming anything a very difficult process.
For example, the source code for a program to print the text "Hello World!" is:
++++++++++[>+++++++> ++++++++++>+++>+<<<< -]>++.>+.+++++++..++ +.>++.<<++++++++++++ +++.>.+++.------.--- -----.>+.>.
I implemented an intepreter for this language in Second Life, using the built-in scripting language LSL. Unfortunately, the language was never designed for executing inefficient languages, and the "Hello World program" takes 8.5 seconds total to run.
This was one of the first programs/scripts I've written where I felt a need to optimize it, and I learned a lot about the value of profiling code. At first, I figured I could get a large speed boost by converting multiple repetitive commands into one internally, and I stored the values as ASCII characters.
Unfortunately, in LSL, converting a character to its ASCII value is a very slow operation, and that optimization only made it slower. I ended up changig it to write a 4 digit number in place instead, which I could quickly cast to an integer.
Go back to the main page.
Site created by Rob Bloom.