pathological programming
My post count is slipping. I’m too worried about writing long, polished entries with a point to them, when what I’m generally working on is short, scatterbrained and only interesting to me for short periods of time. So, who wants to ride bikes?
The shiny object of my current attention is the brainfuck language. That’s actually its name, but I’ll be referring to it in polite company as bf. A few weeks ago, while lamenting to myself the fact that I haven’t entered a horse in the Lambda Lounge Shootout race, I decided that its far too easy to write readable code in a well-established, if not widely used language. Nevermind that this was the entire spirit of the shootout — to expose developers to how real software is written in other languages — I decided that I was going to attempt to write it in a pathological language.
How pathological? bf is based around a 30,000 element array and 8 operators.
+ – > < . , [ ]
+ increments the value of the current array element
- decrements the value of the current arrayelement
> increments the current array index pointer
< decrements the current array index pointer
. prints out the value of the current array element
, stores one character of input in the current array element
[ marks the start of a loop
] marks the end of a loop
Loops can be arbitrarily nested and start execution of their bodies if the current array element is zero. When the ending ] is reached, the execution will loop only if the current array element is non-zero.
That’s it. No strings, no if statements, no methods, no threads, no concurrency, no objects. It has zero of the features that language presentations at Lambda Lounge have focused on. The language is Turing complete though, so theoretically, any computable function can be expressed in bf. I intend to put that assumption to the test this coming month.

Brainfuck’s nifty, but it’s child, Ook is even sweeter.
Ook is great because it was designed _for_ Orangutangs. Its operators correspond one-to-one to bf’s, but I love the looping operators the most. With Ook! Ook? ( ['s equivalent) and Ook? Ook! ( ]‘s counterpart) you can almost understand what it does, “Do this! Uh, if its zero?”…”Done?, Do it again!”
I had heard of bf before but never knew anything about it. I may have to try and put together a few simple programs just to see if I can. Reminds me of my college days and Finite Automata Theory.
This is awesome…please stick it out if at all possible!
[...] Awesome – Nate Young is trying to implement the vending machine for Lambda Lounge in brainf*ck [...]