Shakespeare programming language is an esoteric programming language,
designed and implemented by Kalle Hasselström and Jon Åslund.
design goal was to make a language with beautiful source code that
resembled Shakespeare plays. There are no fancy data or control structures,
just basic arithmetic and gotos.
Shakespeare is the precise opposite of
While the latter reduces syntax and structure to just a bunch of symbols,
the prior reimagines code as beautiful Shakespeare plays.
the two creator didn't make an SPL compiler, just an SPL to C converter.
to be fairly simple, since SPL can be translated directly to C, one
at a time.
► Variables are declared in a section called Dramatis Personae,
each one declared within a Shakespeare program must have the name of a
Shakespearean character, or it will be ignored by the compiler;
it can hold a signed integer value.
Where Name is the name of the variable and Description is ignored by
►Shakespearian code is divided into smaller parts, Acts and Scenes,
the code consists of one or more scenes, and each scene
consists of lines where the characters say something and enter and exit
statement, which cause characters to get on and off the stage.
Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
► To be able to speak their lines, characters must be on stage, The character they address as "you" or "thou" must be also on stage.
“Enter” is followed by a list of one or more characters. “Exit” is followed by exactly one character. The plural of Exit is “Exeunt”, which is
followed by a list of at least two characters – or none, in which case everyone leaves. An Enter directive given to a character already on stage, or the other
way around, will cause a runtime error.
[Enter Romeo and Juliet]
[Exeunt Romeo and Juliet]
► Lines : Scenes are further divided into lines. Characters on stage can talk to each other.
character : sentences.
In the above syntax, it is assumed that the sentence is made by that particular character, and the use of terms like "You" denotes the second person on the stage.
► Constants : a noun is a constant. It has got a value = 1, if the noun is nice, for example "flower" or if it is a neutral noun, for example "tree". If the noun is dirty like "pig" it has a value = -1.
When a noun is prefixed with an adjective, it has the effect of multiplying by two. For example, a "beautiful flower" has a value = 2 (2 * 1). Another adjective added, again multiplied by two and so on.
For example, "fat dirty pig" has a value = (2 * 2 * -1).
► Input To read a number, use the sentence
Listen to your heart . To read a character, use
Open your mind . The value
will be assigned to the character being spoken to.
► Output : There are two different output sentences,
Open your heart and
Speak your mind .
The first causes the character being spoken to to output her or his value in numerical form, and the other, being more literal, outputs the corresponding
letter, digit, or other character, according to the character set being used by your computer.
► Conditional statements : they come in two easy steps, as illustrated by the followingcode fragment:
Am I better than you?
If so, let us proceed to scene III.
First, someone voices a question. This is some sort of comparison, which
will be either true or false. But more on that later.
Then comes, at some later point, a conditional statement. This is constructed
by putting either “if so” (or “if not”) and a comma in front of any
sentence – that sentence is only executed if the answer to the last question
was yes (or no).
This is pretty much like how you would do conditional jumps and things
in many assembly languages.