“B” is for Brainfuck.
In early February, Stack Overflow data scientist Julia Silge published an article titled “What Programming Languages Are Used Most on Weekends?“. The data used to deduce what’s hot and what’s not among our fellow nerds during the weekend, is what tags are used on Stack Overflow questions.
Haskell, a function programming language, saw most questions during the weekend. Now, a high number of questions on Stack Overflow doesn’t necessarily mean that a language is immensely popular. It might just mean that Haskell programmers are dumb. Oh, I kid, I kid. I’m sure Haskell programmers are quite intelligent – and I’m hoping they have a sense of humor.
Anyway. What the data from Stack Overflow do show, is that programmers are focusing on very different things during our workweek than we do during the weekend. While a workweek is filed with cringe worthy topics like SharePoint, TSQL, and (gasp!) VBA, the weekend tend to be for experimenting with new things.
Brainfuck is the creation of Urban Müller, who introduced the language back in 1993. As the name suggests, it’s not totally trivial to understand. Brainfuck has a total of 8 commends, each of which consists of a single character1:
|increment the data pointer (to point to the next cell to the right).|
|decrement the data pointer (to point to the next cell to the left).|
|increment (increase by one) the byte at the data pointer.|
|decrement (decrease by one) the byte at the data pointer.|
|output the byte at the data pointer.|
|accept one byte of input, storing its value in the byte at the data pointer.|
|if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, title=”Branch (computer science)”>jump it forward to the command after the matching |
|if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching |
Brainfucked by example
Creating a small program that outputs “Hello World!” is a common way to create a simple example that explains the basics of a programming language. Here’s such an example written in Brainfuck:
And you thought badly written Java code was a bitch, eh? Brainfuck’s version of “Hello World!” might look like a mess, but the language is Turing-complete, which means that it is “capable of computing any computable function or simulating any other computational model, if given access to an unlimited amount of memory.”
If you’re looking to be properly brainfucked, I recommend that you go ahead and watch the 2004 movie Primer. It’s about four aspiring entrepreneurs who accidentally builds a time machine, and the rather confusing events that follow. Many great minds have tried to explain Primer, but I’m still thoroughly confused. Randall Munroe of XKCD fame is probably the one who comes closest to explaining the movie in a way I understand.
- The table is shameless copypasta from Wikipedia.