"Brainfuck" Interpreter
“Brainfuck” is an esoteric programming language consisting of 8 commands, forming a simple Turing machine. I wrote a simple interpreter / debugger for it as a web page.
Although I’ve never gone out of my way to write a program in “Brainfuck” myself, I thought it’d be an interesting challenge to build the state machine required to run programs written in it. Having done that, it wasn’t a great leap to add a bit of UI to show exactly what the program was doing, and what was happening in the machine’s RAM.
Adding the ability to auto-step through instructions slowl makes for interesting animated execution, which could be an educational tool… that is, if anyone were to teach this mostly useless language.
It does not accept user input as part of the programming, so the ,
command is not technically implemented.
This project was done in roughly two days.
Work Involved
- Designing a state machine to emulate the “Brainfuck” machine
- Implementing cleaning of input code, parsing to commands
- Implementing each of the commands
- Implementing UI representation of inner systems
- Some design, CSS
Links
- Play with it on brainfuck.michd.me
- View the source on GitHub
- Learn more about “Brainfuck” on the esolangs wiki
Note that this was written in 2012; I would not necessarily structure my code like I did back then today.