I recently participated in a coding challenge where the goal was to implement the Fizz Buzz problem, a simple programming task, but do this in some unusual way.
My first thought was that I should try to use an Esoteric Programming Language. Given that I didn’t actually know any esoteric languages (esolangs?) I needed to find one that I could learn well enough in the available time in order to implement Fizz Buzz.
After looking at and rejecting options like Malbolge, which was clearly an attempt to punish someone, Whitespace, a language that only uses space, tab, and linefeed characters, I found the Shakespeare Programming Language (or SPL).
SPL is described as, “A programming language created with the design goal to make the source code resemble Shakespeare plays.”
Boy Howdy, does it ever. Here’s an annotated example of my Fizz Buzz solution, where I print Floof, Bang, or Wham instead. Why, you ask. Those were the requirements.
First, we introduce the application name and define some variables. Here, you’ll see that I’m using the Perl module Lingua::Shakespeare, which made running this in windows pretty simple:
A Play - Romeo and Juliet learn to count numbers
from 1 to some arbitrary number with some help
from Falstaff, Brutus, and Ulysses all the while
Dealing with an insulting Ghost.
Romeo, A young man who is also an integer, but whose speech provides a break.
Juliet, A young woman who moves step by step toward the ghost.
The Ghost, a deceased individual who provides a limit to the loop, and who tosses insults around.
Falstaff, who only capable of speaking a single F-word.
Brutus, who also speaks a single word, though one different than Falstaff as it begins with B.
Ulysses, who is likewise verbally challenged as the Falstaff and Brutus, though speaking only a UU-Word.
The first line is a Perl directive to treat this file as a Shakespeare program.
Following that, we have the name of the program, which starts with “A Play” and continues to the first period.
After the program name, we have the “Dramatis Personae” – the characters who participate in this “play”. Each line defines a variable with a name and an arbitrary description delimited by a comma, and ending with a period.
After this section, we enter the program flow. In Shakespeare programs, there are several concepts that need to be understood:
- The actors (variables) can only perform operations when they are “on the stage”
- Only two actors can be on the stage at the same time
- Program methods/functions appear as Acts and Scenes. The program starts with Act 1 Scene 1, and continues until all characters exit the stage.
- Branching can be done by having one actor say to another actor, “Let us proceed to Scene X”, where Scene X is the name of another Scene (aka, another method).
- If there is no branching, the Scenes flow linearly from one to another.