Introduction: Simple Addition Program in Shakespeare Programming Language

Shakespeare Programming Language (SPL) is an example of an esoteric programming language, one that is perhaps interesting to learn about and fun to use, but not particularly useful in real life applications. SPL is a language where the source code reads like a Shakespearean play, with characters being variables and their dialogue being the actual code itself. It is important to note that the language is very flexible, so you can add extraneous words, sentences, and lines of dialogue without impacting the functionality of the code. This allows for the written source code to move beyond functionality and into the realm of written entertainment if the time is taken to do so.

Step 1: Requirements

It is going to be assumed that anyone attempting to follow this instruction set is familiar with the basics of programming, and the basics on navigating through folders in Command Prompt. Currently when working with SPL code, in order to compile and run your code it first needs to be translated into C using this library, Sam Donow’s Shakespeare Compiler. The link will automatically download the library, which then needs to be unzipped to be used. In order to compile your code, you will need to have already installed Python 2 or above onto your computer. If you do not currently have Python installed on your computer, you can get it from here. You can still follow along this instruction set and write yourself a basic program without compiling your code.

Step 2: Simple Addition Program

The first part of this instruction set is how to write a simple program to add numbers. The program will be run on the command line, and the user will input two numbers and then the program will return the product of them and exit.

Step 3: Create a Source File

Create a source file for your program. For this example, the file will be named additionprogram.spl. In order to keep things simple, put this file in the spl-master folder that contains the file This will make compiling your code much easier. Open your source file in a text editor. I recommend Notepad ++.

Step 4: Create a Title

Write a title for your play! All programs written in SPL must have a title. This can be anything you want, as long as it ends with a period.

Step 5: Introduce Your Two Characters

Introduce your two characters! These are your two variables that you will use to add together. Remember, their names have to be actual characters from Shakespeare plays. Here is a list of all valid character names. The format is the character’s name, a comma, a character introduction, and then a period. For this example, I created two characters, Romeo and Juliet. The character introduction can be anything you would like, feel free to get creative!

Step 6: Start Act I

Start Act I. To create an Act, write “Act “, the act number in Roman Numerals, a colon, and then a name for the act followed by a period. This can be named anything you can think of.

Step 7: Start Scene I

Start Scene I. To create a scene, write “Scene “, the Scene number in Roman Numerals, a colon, and then a name followed by a period. Once again, you are free to choose any name you would like. Note that in the example code, multiple scenes are used. For the intents of this program, all this does is help organize your source code, and you can write a fully functional program using only one scene.

Step 8: Enter Your Two Characters

Enter your characters onto the stage! In order to enter your two characters to the scene, write “[Enter NAME1 and NAME2]”, where NAME1 and NAME2 are the names of the two characters you want to enter the scene.

Step 9: Write Input Statements

Write input statements for your two characters to have them assigned to user chosen values. Having a character speak in SPL is as simple as writing the character name, followed by a colon, and then a properly punctuated sentence. In order to have your character accept a user specified value, you must make your character say “Listen to your heart.” This allows the user to input a value from the command line, which will then be assigned to the character speaking the line.

Step 10: Add the Values Together

Add the values stored in your two characters together. In order to set the character speaking to the value of itself and the opposing character in the scene, you can write “I am the sum of you and I”. If you would like for the other character to take on the value of the sum of both characters, you might say something like “You are now the sum of yourself and I.”

Step 11: Print the Value

Print your added value. In order to have a character output their value into standard output, you must have the other character in the scene tell them to “Open your heart.” Make sure that you are telling the right character to output their value. If you sum the values into one character, the other character in the scene should be the one who says “Open your heart.”

Step 12: Exit Characters From Stage

Exit your characters from the stage. You can do this by saying “[Exit NAME1 and NAME2]”, or you can just say “[Exeunt]”, which automatically exits all characters on the stage.

Step 13: Congrats!

Congratulations! You have now written a basic addition program in Shakespeare Programming Language. The next step is to compile your code.

Step 14: Compiling Your Program Into C Code

In order to compile your SPL code into C, you must have installed Python 2 or newer and must have downloaded Sam Donow's Shakepeare Compiler.

Copyright © 2014-2015 Sam Donow

Step 15: Open Command Prompt and Navigate to Code Directory

Open Command Prompt, and navigate to your folder containing the code you have just written and the file If you are not familiar with how to navigate through the command line, here is a basic guide to get you started.

Step 16: Run and Compile Your Code

In the Command Prompt, write “py yourprogramname.spl > yourprogramname.c” replacing ‘yourprogramname’ with the name of your source file.

Step 17: Congrats and Troubleshooting Tips

Congrats! You now should have a translated version of your program in C code! If there were any errors, try going back to your source .spl file and look for any errors with punctuation. Note that the only time the colon can be used is to make a character speak a line; it cannot be used in a sentence spoken by a character. Also make sure that your characters are properly entered into the scene they speak in, and that their names are spelled correctly. Keep in mind that the Acts and Scenes must be in order, starting from 1 onward.

Step 18: Having Fun With It (Optional)

When reading the source code of additionprogram.spl, it has the structure of a Shakespearean play but it doesn’t quite read like one. The example above has the exact same functionality, but is more in the spirit of an actual play, with some semblance of a story. You can feel free to embellish your current program to make it more fun, or you can just leave it as it currently is. The choice is yours, it functions the same