Wednesday, October 14, 2009

In my spare time, I decided to make a programming language that had its instructions encoded in the rhyme and meter of poems. The instructions would be a rather boring stack-based machine with strings as the only datatype. I originally thought to call the language "What rhymes with that", since "what" and "that" are sight-rhymes. After writing some code, though, I decided to call it doggerel.

Here's hello world in the doggerel programming language:

Behold the earth and all the stories.
Let every voice be free to sing
through all the mines and all the quarries
for greeting all with words that ring.

Beneath the caves in which the sounds
and echoes linger as reminders,
no longer moves the fist that pounds
great drums in anger at the blinders

which never swiftly crossed the crowded skies
or softly fell upon the ears of princes
repeating rumors and the racy lies
like deftly sweeping gusts of wind evinces
devout compulsion subtly as it dies.

Selected whispers take their time
providing filler for the crime
collecting every dirty dime.

How clean the hand! How hard
enough the noise it covers
like holding bells and jarred
lapels of foreign lovers
on leave from watching guard!

Stop the day to fear.
Time is very dear.
Find the breath to cheer.
Use the second year
...never to appear.

The first thing to figure out was how to determine the rhyme and meter of the text. I looked into text-to-speech packages to see if I could extract the text-to-phoneme conversion. It would be more work than I wanted to put into it, and I wound up implementing it by just looking up the words in a CMUdict file, and then doing a few minor tweaks on what syllables are stressed.

No comments:

Post a Comment