ArticleslgStudy

science

Shakespeare Programming Language

Shakespeare Programming Language is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Shakespeare Programming Language rather than just read about it. In short: The Shakespeare Programming Language (SPL) is an esoteric programming language designed by Jon Åslund and Karl Wiberg. Like the Chef language, it is designed to make programs appear to be something other than programs – in this case, Shakespearean plays.

Key takeaways

  • Shakespeare Programming Language belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Shakespeare Programming Language to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Shakespeare Programming Language from memory before moving on to harder problems.

Reference excerpt

The Shakespeare Programming Language (SPL) is an esoteric programming language designed by Jon Åslund and Karl Wiberg. Like the Chef language, it is designed to make programs appear to be something other than programs – in this case, Shakespearean plays. A character list in the start of the program declares some 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 input/output (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", "Thou", or "Thee". 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:

[Enter Juliet] [Enter Romeo and Juliet] [Exit Romeo] [Exeunt Romeo and Juliet] [Exeunt]

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", "Thou", or "Thee".

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", "Thou", or "Thee", may optionally continue with "are as [any adjective] 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 [any adjective] 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. 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: The idea is to generate the ASCII values for each character of the string and print it using the "Speak your mind" command. For instance, the first line of dialog said by Hamlet uses a combination of arithmetic operations to assign the decimal value 72 (binary 1001000) to the other protagonist Romeo, which in ASCII corresponds to the letter 'H'.

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.

[Enter Hamlet and Romeo]

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Shakespeare Programming Language

Start with the simplest possible case. Write down what Shakespeare Programming Language claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Shakespeare Programming Language before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Shakespeare Programming Language ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Shakespeare Programming Language

In research
Shakespeare Programming Language appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Shakespeare Programming Language in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Shakespeare Programming Language is common in secondary-school and first-year university syllabi. It links to neighbouring topics Esoteric programming languages, William Shakespeare, so understanding it makes those chapters shorter.
In everyday life
Look for Shakespeare Programming Language outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Shakespeare Programming Language” →

How to study Shakespeare Programming Language in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Shakespeare Programming Language means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Shakespeare Programming Language out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Shakespeare Programming Language in simple terms?

The Shakespeare Programming Language (SPL) is an esoteric programming language designed by Jon Åslund and Karl Wiberg. Like the Chef language, it is designed to make programs appear to be something other than programs – in this case, Shakespearean plays.

Why does Shakespeare Programming Language matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Shakespeare Programming Language?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Shakespeare Programming Language.

Tags

  • Esoteric programming languages
  • William Shakespeare

Keep exploring