Skip to content
ALB Wiki

Diff — Shakespeare Programming Language

Comparing rev 2 → rev 3

{{infobox
| title = Shakespeare Programming Language
-
| designer = Karl Hasselström & Jon Åslund
+
| designer = Kalle Hasselström & Jon Åslund
| first appeared = 2001
| paradigm = esoteric · stack-based · theatrical
| typing = characters hold integer stacks
| filename extensions = .spl
| influenced by = the works of William Shakespeare
| influenced = the natural-language branch of esolangs
}}
# Shakespeare Programming Language
-
The **Shakespeare Programming Language** — SPL — is a language whose programs are written as Elizabethan stage plays, and whose stated design goal was to make source code *beautiful*. Karl Hasselström and Jon Åslund created it in 2001, producing the only programming language in which arithmetic is performed by insulting people in iambic cadence and output is achieved by telling them to speak their mind.[[cite: [Shakespeare](https://esolangs.org/wiki/Shakespeare), esoteric-languages wiki — Hasselström & Åslund, 2001, and the design goal of "beautiful source code"]]
+
The **Shakespeare Programming Language** — SPL — is a language whose programs are written as Elizabethan stage plays, and whose stated design goal was to make source code *beautiful*. Kalle Hasselström and Jon Åslund created it in 2001, producing the only programming language in which arithmetic is performed by insulting people in iambic cadence and output is achieved by telling them to speak their mind.[[cite: [Shakespeare](https://esolangs.org/wiki/Shakespeare), esoteric-languages wiki — Hasselström & Åslund, 2001, and the design goal of "beautiful source code"]]
A program is a play: it has a title, a dramatis personae, acts and scenes, stage directions, and dialogue. The variables are characters — restricted, by the specification, to names from actual Shakespeare plays — and they hold integer values on stacks. To compute, characters must take the stage and speak to each other; to print a character, someone must say **"Speak your mind!"**; to print a number, **"Open your heart!"** Input arrives when a character is told to **"Open your mind"** or **"Listen to your heart."**[[cite: [SPL language overview](https://esolangs.org/wiki/Shakespeare#Instructions) — the stage-direction model and the four I/O utterances]]
# Drama as control flow
The staging rules are the machine. At most **two characters may be on stage at once** — every `[Enter]` and `[Exit]` is effectively register allocation. Acts and scenes are not structure but **labels**: "let us proceed to Scene II" is `goto`, and conditional jumps are achieved by one character asking another *"Am I better than you?"* — followed, if so, by an exit to the appropriate scene.[[cite: [SPL language overview](https://esolangs.org/wiki/Shakespeare#Language_Overview) — the two-character stage limit and scenes-as-labels]]
Arithmetic is where the design becomes deranged in a rigorous way:
- A **noun is worth 1** if complimentary (a *rose*, a *summer's day*) or **−1** if insulting (a *codpiece*, a *festering wound*).
- Each **adjective doubles** the noun's value — so "a beautiful fair warm peaceful sunny summer's day" is 1 × 2⁵ = 32.
- *"You are as lovely as the sum of Hamlet and a brave tree"* assigns Juliet the value of Hamlet plus 2 — a compliment that is simultaneously an addition statement.
- Insults are therefore not optional: negative numbers *must* be delivered as abuse.
Which produces the language's famous consequence: **to print ASCII characters, you must construct their numeric values out of compliments and insults**, so every output program reads as an escalating drama of flattery and offense.[[cite: [SPL expression rules](https://esolangs.org/wiki/Shakespeare#Instructions) — noun/adjective valuation, similes, and "the sum of / difference between" operation expressions]]
# The Hello World that insults a Danish company
The canonical SPL Hello World is a genuine three-scene play: Hamlet — billed in the dramatis personae as *"the flatterer of Andersen Insulting A/S"* — takes the stage and, by alternating abuse and praise at Romeo, Juliet, and Ophelia, drives each one's value to the ASCII code of the next output character:
```
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!
```
That produces a character of output. The whole program is several scenes of this — Romeo getting insulted into punctuation. It is possibly the only Hello World in computing that reads as a defamation lawsuit.[[cite: [SPL Hello World](https://esolangs.org/wiki/Shakespeare#Hello_World.21) — the full program, Hamlet's insults included, as distributed with the language]]
```fact
The "flatterer of Andersen Insulting A/S" in the cast list is a layered pun — "A/S" is the Danish/Norwegian equivalent of "Inc.", and "Andersen Insulting" ribs the consulting giant then called Andersen Consulting. The dramatis personae descriptions are free text, so every SPL program contains a cast biography nobody will enforce.
```
Shakespeare is Turing-complete — a Brainfuck-to-SPL translator exists (Brain2Speare), which means every computable function can be staged as a tragedy. Whether anyone *should* watch the performance is a separate question.
# Where it sits in the wing
Where [[LOLCODE]] attacked vocabulary by borrowing a meme, SPL attacked it by borrowing **literature** — the assumption that source code should look like a program at all. Alongside [[Whitespace]] (programs as absence) and [[Piet]] (programs as paintings), it completes the trio of languages whose source code you could show a civilian without them recognizing it as code.
## Check your understanding
- [ ] What does "Speak your mind!" do — and what outputs a number instead?
- [ ] How is a negative integer written in SPL?
- [ ] What are acts and scenes used for mechanically?
- [ ] How many characters may be on stage at once, and why does that matter?
```hide Show answers
1 — **"Speak your mind!"** outputs the addressed character's value as an ASCII character; **"Open your heart!"** outputs it as a number.
2 — as an **insult** — negative nouns (codpiece, festering wound) are worth −1, and each adjective doubles the magnitude.
3 — they are **goto labels** — "let us proceed to Scene II" is control flow, and conditional questions direct the jumps.
4 — **two** — it is the register file: only the two on-stage characters can exchange values, so `[Enter]`/`[Exit]` is resource management.
```
[[Category:Languages]]
[[Category:Esoteric languages]]
[[Category:Programming]]
[[Category:History]]