A 256-Character Program to Generate Poems (2008)
In 2008, Nick Montfort wrote a poem generator for the new year. In 256 characters of perl code.
This is the entire source code of the original version of the generator:
perl -le'sub w{substr(“cococacamamadebapabohamolaburatamihopodito”,2*int(rand 21),2).substr(“estsnslldsckregspsstedbsnelengkemsattewsntarshnknd”,2*int(rand 25),2)}{$l=rand 9;print “\n\nthe ”.w.“\n”;{print w.“ ”.substr(“atonof”,rand 5,2).“ ”.w;redo if $l–>0;}redo;}’
It makes slightly more sense if you understand Perl, though there are some very clever optimizations going on here. Like the string “atonof”, in which every pair of adjacent letters forms a valid English word that can link the longer, slightly less coherent words generated with the w() function.
You can read more about how it works at Nick’s blogpost about it, including the connection to cut-ups and fragments. I found the discussion of the struggle to balance the quality of the output with the diversity to be very relatable.
I rather like some of the words that come up when you smush two of the four-letter nonsense words together:
Nick would go on to make a series of 256-character poem generators. There’s an updated version of the first generator, plus six others.
A reminder for all of you aspiring generative artists out there: Generators don’t have to be big things. Sometimes they can be quite small.