Archive for November, 2013

Experiments in BrainFuck

Thursday, November 7th, 2013

I’ve enjoyed learning about esoteric programming languages ever since I began programming. One of my favorites is BrainFuck, which feels very much like programming a turing machine directly. It has 8 commands

  • +/- increment / decrement the current data cell
  • </> move the data pointer one position left / right
  • [ if the current data cell is zero, goto the matching close brace
  • ] if the current data cell isn’t zero, goto the matching open brace
  • . print the value of the current data cell
  • , receive input into the current data cell

[] are it’s looping / conditional construct, most interesting things are built using them.

Here’s what hello world looks like

As an experiment, I tried writing a BF interpreter in Mirah (mirah-brainfuck). At this point it’s 120 some lines of code and it totally works. My next crazy idea is to write an embedded brain fuck program that works like embedded ruby. You supply a .ebf¬†file, and it gives you back a brainfuck program. Maybe I could use it to write a brainfuck web framework :p. For example, it might look like
Because this is a terrible experiment, I’ve been trying to write it in BrainFuck itself, which makes things really awkward/interesting. Because there is only one looping / conditional and it’s dependent on modifying cells on the data tape, figuring out how to compare input characters is really obtuse. But I like working with BrainFuck because it forces me to think weirdly about problems.

RockyMountainRuby 2013

Wednesday, November 6th, 2013

Rocky Mountain Ruby 2013 was at the end of September this year. I taught a workshop on writing external DSLs that was fun and difficult to put together. You can look through my class notes, if you are interested.

I also gave a short lightning talk on Muskox, a small library I’ve been working on. The talk’s up on Confreaks / YouTube now, which is awesome. The TL;DR is that populating input data structures willy-nilly from some generic language like JSON or especially XML can be dangerous, so you should prevent bad data from entering your system during parsing.