Brainfuck

posted in Brain spasm
Published October 25, 2007
Advertisement
Brainfuck is one of those amusing little jokes which has been taken way too far. Yes, technically speaking, it is a programming language. But let's face it, what are you going to use it for??? If you can program in Brainfuck then, technically speaking, you could probably program a windmill .. or a tree .. and possibly take over the world with your devious creations. I mean this is a programming language with 8 commands, and that's it. No add, no mul, no mov. Just inc, dec, loop, jnz. To write something in that you're either a genius or a complete raving maniac!

What kind of sick mutha would inflict such a sick and cruel perversion upon the world? ... Me!

So yesterday I went one step further and wrote a Brainfuck interpreter in C++ (with source) grab it while it's hot. I'm probably going to pick this up and drop it as I feel like it, but some initial thoughts for improvement have already been considered. I hope to make it into an optimising native compiler eventually (hence the parser module). Whether I ever actually bother to get that far though is another question entirely :-)

What does it do? .. Well it runs Brainfuck programs, it can catch errors as it runs (output to std err), and it's jolly fast too! Written in all C++, if you want to support variations on the 'standard' (bwahaha) then there are handy defines and constants you can change.

The code may look slightly elaborate for what it is, but if you wanted to write a Brainfuck variation (like Brainloller or Braincopter) or a native compiler then I'm sure this would be a nice starting point :-)
Previous Entry Volumetric clouds
Next Entry New rig
0 likes 1 comments

Comments

Metorical
Wow, I just did the same the other day. I'm not sure if I implemented it entirely correctly though as I just made something based on the 8 available instructions. All the examples I found semeed to work too.

Had some great fun changing the model to allow the program to rewrite itself, generating random programs and evolving them. It's also quite fun adding new instructions although that kind of defeats the purpose of the language.

Will follow your developments ;)

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
October 28, 2007 01:32 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement