HOME

TheInfoList



OR:

The Shakespeare Programming Language (SPL) is an
esoteric programming language An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language ...
designed by Jon Åslund and Karl Wiberg. Like the Chef programming language, it is designed to make programs appear to be something other than programs — in this case,
Shakespeare William Shakespeare ( 26 April 1564 – 23 April 1616) was an English playwright, poet and actor. He is widely regarded as the greatest writer in the English language and the world's pre-eminent dramatist. He is often called England's natio ...
an plays. A
character Character or Characters may refer to: Arts, entertainment, and media Literature * ''Character'' (novel), a 1936 Dutch novel by Ferdinand Bordewijk * ''Characters'' (Theophrastus), a classical Greek set of character sketches attributed to The ...
list in the beginning of the program declares a number of stacks, naturally with names like "Romeo" and "Juliet". These characters enter into dialogue with each other in which they manipulate each other's topmost values, push and pop each other, and do I/O. The characters can also ask each other questions which behave as conditional statements. On the whole, the programming model is very similar to assembly language but much more verbose.


Programming in Shakespeare


Title

The first line in a Shakespeare program is called the 'title'. The compiler considers anything from the first line to the first period to be a comment.


Dramatis Personae

This is the section where variables are declared. Each variable can hold a signed integer value and is of the following form: Name, Description Where Name is the name of the variable and Description is ignored by the compiler. The compiler will recognize only those names that correspond to actual Shakespearean characters.


Acts and scenes

A piece of code in Shakespeare is broken into Acts which contain Scenes in which characters (variables) interact. Each Act and Scene is numbered with a Roman numeral and serves as a GOTO label. Any code after the colon is considered a comment. They are written in the form: Act I: Hamlet's insults and flattery. Scene I: The insulting of Romeo.


Enter, exit and exeunt

Individual lines of code generally take the form of a piece of dialogue spoken by one character to another; this is how the value of a variable (the character spoken to) is assigned, changed, or output. A character can only be addressed as "you" or "thou". Thus, there must typically be exactly two characters "on stage" whenever lines are spoken: one to speak, and the other to be spoken to. To call a variable to the stage the Enter command is used with a list of one or more characters. The Exit command tells exactly one listed character to leave the stage. Exeunt calls more than one character to leave, or in the case that no characters are listed all the characters will leave the stage. The following format is used: nter Juliet nter Romeo and Juliet
xit Romeo XIT may refer to: * XIT (band), a Native American rock group * XIT, a name briefly used by the 1960s English pop group Consortium * XIT Ranch, a cattle ranch in Texas, United States See also *Exit (disambiguation) Exit(s) may refer to: Architec ...
xeunt Romeo and Juliet xeunt


Lines

Lines are represented as dialogue spoken by a character, and consist of at least one sentence. Each sentence may assign a new value to a variable, direct a variable to output its value, or direct it to receive an input. Lines can also manipulate stacks or act as if/then or goto statements. A line starts with a character's name and a colon. Since this character is the speaker, the other character on stage is the variable that is addressed as "you" or "thou".


Constants and assignment of values

Constants are represented by combinations of nouns and adjectives; the language recognizes a finite list of each, and both lists are separated into those having positive, negative, or neutral tone, as perceived by Åslund and Hasselström. Positive and neutral nouns have a value of 1 and negative nouns have a value of -1. Any adjective multiplies a noun by 2, and adjectives can be compounded. Possessive pronouns are ignored by the parser, while words pertaining to basic arithmetic are recognized as operations, such as "sum", "quotient", and "cube". A sentence that assigns a value to a character starts with "You" or "Thou", may optionally continue with "are as
ny adjective NY most commonly refers to: * New York (state), a state in the Northeastern United States * New York City, the most populous city in the United States, located in the state of New York NY, Ny or ny may also refer to: Places * North Yorkshir ...
as", and then gives the mathematical formula in nouns, adjectives, variables, and operations for the new value. Examples of such lines follow: Hamlet: You lying stupid fatherless big smelly half-witted coward! Juliet: You are as villainous as the square root of Romeo! The mathematical formulae can also use the names of other characters (even if those characters are not on stage) to utilize the current value of that character in a computation, or "yourself" or "thyself" for the character being spoken to.


Input and output

Lines can also call for a variable to give output or receive input. "Open your heart" outputs the variable's numerical value, while "Speak your mind" outputs the corresponding ASCII character. "Listen to your heart" or "Open your mind" cause the variable to receive input from the user; the former for a number and the latter for a character.


Conditional statements and gotos

An if/then statement is phrased as a question posed by a character. The words "as
ny adjective NY most commonly refers to: * New York (state), a state in the Northeastern United States * New York City, the most populous city in the United States, located in the state of New York NY, Ny or ny may also refer to: Places * North Yorkshir ...
as" represent a test for equality, while "better" and "worse" correspond to greater than and less than, respectively. A subsequent line, starting "if so" or "if not", determines what happens in response to the truth or falsehood of the original condition. A goto statement begins "Let us", "We shall", or "We must", continues "return to" or "proceed to", and then gives an act or scene. A scene will be parsed as that scene in the current act; a goto statement cannot call a scene in a different act. A conditional statement to call a goto would look like this: Juliet: Am I better than you? Hamlet: If so, let us proceed to scene II.


Pushing and popping stacks

Each variable is a
stack Stack may refer to: Places * Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group * Blue Stack Mountains, in Co. Donegal, Ireland People * Stack (surname) (including a list of people ...
. A variable will have an integer pushed onto its stack if a line tells the character to "remember" an appropriate value, such as "Remember me", or "Remember yourself". The topmost value in the stack is popped (i.e., the variable assumes this value) if the character is told to "recall" anything; all text after this word is treated as a comment.


Example code

The standard
"Hello, World!" program A "Hello, World!" program is generally a computer program that ignores any input and outputs or displays a message similar to "Hello, World!". A small piece of code in most general-purpose programming languages, this program is used to illustr ...
:
Do Not Adieu, a play in two acts.

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 Andersen Insulting A/S.


                    Act I: Hamlet's insults and flattery.

                    Scene I: The insulting of Romeo.

 nter 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!

xit Romeo XIT may refer to: * XIT (band), a Native American rock group * XIT, a name briefly used by the 1960s English pop group Consortium * XIT Ranch, a cattle ranch in Texas, United States See also *Exit (disambiguation) Exit(s) may refer to: Architec ...
Scene II: The praising of Juliet. nter Juliet Hamlet: Thou art as sweet as the sum of the sum of Romeo and his horse and his black cat! Speak thy mind!
xit Juliet XIT may refer to: * XIT (band), a Native American rock group * XIT, a name briefly used by the 1960s English pop group Consortium * XIT Ranch, a cattle ranch in Texas, United States See also *Exit (disambiguation) Exit(s) may refer to: Architec ...
Scene III: The praising of Ophelia. nter Ophelia Hamlet: Thou art as beautiful as the difference between Romeo and the square of a huge green peaceful tree. Speak thy mind! 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! xeunt Ophelia and Hamlet Act II: Behind Hamlet's back. Scene I: Romeo and Juliet's conversation. nter 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!
xit Romeo XIT may refer to: * XIT (band), a Native American rock group * XIT, a name briefly used by the 1960s English pop group Consortium * XIT Ranch, a cattle ranch in Texas, United States See also *Exit (disambiguation) Exit(s) may refer to: Architec ...
Scene II: Juliet and Ophelia's conversation. nter 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! xeunt


See also

*
Natural language programming Natural-language programming (NLP) is an ontology-assisted way of programming in terms of natural-language sentences, e.g. English. A structured document with Content, sections and subsections for explanations of sentences forms a NLP documen ...
*
Esoteric programming language An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language ...
* Inform 7 *
Timeline of programming languages This is a record of notable programming languages, by decade. Prior to 1950 there were 8 unique programming languages, where 6 were unique languages and 2 were combinations of unique languages. By 1960 there were around 45-50 unique programming ...


References


Inline references


General references

* * * * * * *


External links


Homepage

SourceForge page

Shakespeare Programming Language
on
Slashdot ''Slashdot'' (sometimes abbreviated as ''/.'') is a social news website that originally advertised itself as "News for Nerds. Stuff that Matters". It features news stories concerning science, technology, and politics that are submitted and evalu ...

The A-Z of Programming Languages: Shakespeare
on
Computerworld ''Computerworld'' (abbreviated as CW) is an ongoing decades old professional publication which in 2014 "went digital." Its audience is information technology (IT) and business technology professionals, and is available via a publication website ...

SPL Interpreter written in PythonGitHub repository

Shakespeare to C Compiler written in Python
on
GitHub GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, co ...

shakespearelang.org
{{Shakespeare Esoteric programming languages William Shakespeare