Thursday, December 10, 2009

Befunge

A few years ago I had a look into my first esoteric programming language, Brainfuck. Why? Because an IRC channel I frequented required users to message a bot with Brainfuck code, of, at most, a certain number of bytes depending on how long your nickname was, to output your IRC nickname to get voice status so you could actually chat in the channel! I ended up writing an interpreter for it in Perl in ~130 characters too! Not bad considering I was seventeen years old at the time.

So for the few days this week that I was home sick, I looked into Befunge; an esoteric, stack language. Why? Because I could ;)

Easily the most interesting part of the language, for me at least, is the four operations that change the direction of the program counter, allowing programs to read in all different directions. For example, conventional programming languages start from the top and read left-to-right. In a Befunge program you can change the direction to read operations in the left, right, upward or downward directions. This can be used to create some very interesting programs.

Anyway, here's my first, and, so far, only, Befunge program:

v          v                 ,<
                        >:"z"`|
>"!raB ooF">:#@!_:"a"1-`|     >84*-v
           ^           ,<          <
It simply capitalises some text. Nothing special.

The things you do when you're sick at home...

Tuesday, December 8, 2009

Profiling Common Lisp Code

I just finished reading (and applying to my own projects) an article on profiling and optimising Common Lisp code using SBCL's profiler. The article is here. The whole series that the article belongs to is good reading for any novice-to-intermediate Lisp programmer actually, but this one stands out more for me.