Code Poems

Jul 18, 2021

Writers are constantly pushing the boundaries of language. Code poems are poetry written in a programming language. They can compile to show a visualization, output something interesting, be read aloud, or just interpreted by the language.

I came across an old code poem called "Black Perl" by an anonymous programmer, which exits on the first line and produces no output. The rest of the lines are parsed but not executed.

BEFOREHAND: close door, each window & exit; wait until time.
    open spellbook, study, read (scan, select, tell us);
write it, print the hex while each watches,
    reverse its length, write again;
    kill spiders, pop them, chop, split, kill them.
        unlink arms, shift, wait & listen (listening, wait),
sort the flock (then, warn the "goats" & kill the "sheep");
    kill them, dump qualms, shift moralities,
    values aside, each one;
        die sheep! die to reverse the system
        you accept (reject, respect);
next step,
    kill the next sacrifice, each sacrifice,
    wait, redo ritual until "all the spirits are pleased";
    do it ("as they say").
do it(*everyone***must***participate***in***forbidden**s*e*x*).
return last victim; package body;
    exit crypt (time, times & "half a time") & close it,
    select (quickly) & warn your next victim;
AFTERWORDS: tell nobody.
    wait, wait until time;
    wait until next year, next decade;
        sleep, sleep, die yourself,
        die at last

Code Golf is another example of playing with code. Code Golf is about writing code that does something in the least amount characters. Here's an example that computes the digits of pi in GolfScript (a language made for code golfing):