Shakespeare Programming Language

2 March 2014

As a Computer Science major, I wasn’t expecting there to be a lot on this trip that would intersect with my major. As influential as Shakespeare was, though, I guess in hindsight I shouldn’t have been surprised that he had managed to cross into the realm of programming. During my research for a class presentation, I stumbled onto a programming language called “Shakespeare,” which was designed so that its code would look like Shakespeare plays. It’s impractical, but it let me write a blog post indulging both the English and CS geek in me, so here goes. (This is the simplified version, but if for some reason you’re a CS major who’s reading this and wants to actually try writing something in this insane language, you can read more about it here: http://shakespearelang.sourceforge.net/.)

Every Shakespeare program begins with a Dramatis Personae section, where the programmer defines the different variables used to store data as the program runs. Each variable must be named after a Shakespearean character. The rest of the program is divided into Acts and Scenes, in which the characters talk to each other, which changes the numerical values assigned to the variables. Basically, if a character insults another one, that lowers the second variable’s value, and praise raises the value. Characters can also command each other to “open your heart” or “speak your mind” to output the numerical value or ASCII character associated with it.

Here is the code for the “Hello world” program (the simplest program in any language, which simply displays the phrase “Hello world”) in Shakespeare:

 

Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Ophelia.

                      Act I: Hamlet’s insults and flattery.
                   Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]

Hamlet:

You lying stupid fatherless big smelly half-witted coward! You are as
stupid as the difference between a handsome rich brave hero and thyself!
Speak your mind!
You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer’s
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!
You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.
Speak your mind!

[Exit Romeo] 

                  Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:

Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!

[Exit Juliet]

                   Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:

Thou art as lovely as the product of a large rural town and my amazing
bottomless embroidered purse. Speak thy mind!
Thou art as loving as the product of the bluest clearest sweetest sky
and the sum of a squirrel and a white horse. Thou art as beautiful as
the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]

                        Act II: Behind Hamlet’s back.
                   Scene I: Romeo and Juliet’s conversation.

[Enter Romeo and Juliet]

Romeo:

Speak your mind. You are as worried as the sum of yourself and the
difference between my small smooth hamster and my nose. Speak your
mind!

Juliet:

Speak YOUR mind! You are as bad as Hamlet! You are as small as the
difference between the square of the difference between my little pony
and your big hairy hound and the cube of your sorry little
codpiece. Speak your mind!

[Exit Romeo]

                   Scene II: Juliet and Ophelia’s conversation.

[Enter Ophelia]

Juliet:

Thou art as good as the quotient between Romeo and the sum of a small
furry animal and a leech. Speak your mind!

Ophelia:

Thou art as disgusting as the quotient between Romeo and twice the
difference between a mistletoe and an oozing infected blister! Speak
your mind!
[Exeunt]