Shakespeare (programming language)
Encyclopedia
The Shakespeare Programming Language (SPL) is an esoteric programming language
Esoteric programming language
An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

 designed by Jon Åslund and Karl Hasselström. Like the Chef programming language
Chef (programming language)
Chef is an esoteric programming language designed by David Morgan-Mar. It is based on the manipulation of data values in a number of stacks; the same idea is used in assembly programming languages...

, it is designed to make programs appear to be something other than programs; in this case, Shakespearean plays.

A character
Fictional character
A character is the representation of a person in a narrative work of art . Derived from the ancient Greek word kharaktêr , the earliest use in English, in this sense, dates from the Restoration, although it became widely used after its appearance in Tom Jones in 1749. From this, the sense of...

 list in the beginning of the program declares a number of stacks
Stack (data structure)
In computer science, a stack is a last in, first out abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack,...

, 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
I/O
I/O may refer to:* Input/output, a system of communication for information processing systems* Input-output model, an economic model of flow prediction between sectors...

. The characters can also ask each other questions which behave as conditional statement
Conditional statement
In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false...

s. On the whole, the programming model is very similar to assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

, but more than an order of magnitude more verbose.

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 Personæ

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.
Each variable name must be the name of a character from a Shakespeare play.

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 GOTO labels. 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

Before "Characters" (variables) can "Act" (be acted upon) they must first be "on stage". To call a variable to the stage the Enter command is used. However, only two characters may be on stage at a time, else it is unclear who is being addressed. To tell characters to leave the stage, use the Exit command. 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 consist of the name of a character, a colon, and one or more sentences.

Example code

This is part of the standard "Hello World" program in SPL. The statements assign numerical values to the other character, and "Speak your mind" is an order to the other character to output that value as a character
Character (computing)
In computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to a grapheme, grapheme-like unit, or symbol, such as in an alphabet or syllabary in the written form of a natural language....

.


Romeo
Romeo Montague
Romeo is one of the fictional protagonists in Shakespeare's Romeo and Juliet. Romeo is the son of old Montague and his wife, who secretly loves and marries Juliet, a member of the rival House of Capulet...

, a young man with a remarkable patience.
Juliet
Juliet Capulet
Juliet is one of the title characters in William Shakespeare's tragedy Romeo and Juliet, the other being Romeo. She is the daughter of old Capulet, head of the house of Capulet. The story has a long history that precedes Shakespeare himself....

, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet
Prince Hamlet
Prince Hamlet is a fictional character, the protagonist in Shakespeare's tragedy Hamlet. He is the Prince of Denmark, nephew to the usurping Claudius and son of the previous King of Denmark, Old Hamlet. Throughout the play he struggles with whether, and how, to avenge the murder of his father, and...

, the flatterer of Andersen Insulting A/S.


Act I: Hamlet's insults and flattery.

Scene I: The insulting of Romeo.

[Enter 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!

[Exit Romeo]

Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!

[Exit Juliet]

Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
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!

[Exeunt Ophelia and Hamlet]


Act II: Behind Hamlet's back.

Scene I: Romeo and Juliet's conversation.

[Enter 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!

[Exit Romeo]

Scene II: Juliet and Ophelia's conversation.

[Enter 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!

[Exeunt]

List of reserved words

As defined in the perl implementation Lingua::Shakespeare
Negative

bad,
cowardly,
cursed,
damned,
dirty,
disgusting,
distasteful,
dusty,
evil,
fat,
fat-kidneyed,
fatherless,
foul,
hairy,
half-witted,
horrible,
horrid,
infected,
lying,
miserable,
misused,
oozing,
rotten,
smelly,
snotty,
sorry,
stinking,
stuffed,
stupid,
vile,
villainous,
worried
Neutral

big,
black,
blue,
bluest,
bottomless,
furry,
green,
hard,
huge,
large,
little,
normal,
old,
purple,
red,
rural,
small,
tiny,
white,
yellow
Positive

amazing,
beautiful,
blossoming,
bold,
brave,
charming,
clearest,
cunning,
cute,
delicious,
embroidered,
fair,
fine,
gentle,
golden,
good,
handsome,
happy,
healthy,
honest,
lovely,
loving,
mighty,
noble,
peaceful,
pretty,
prompt,
proud,
reddest,
rich,
smooth,
sunny,
sweet,
sweetest,
trustworthy,
warm
Negative

Hell,
bastard,
beggar,
blister,
codpiece,
coward,
curse,
death,
devil,
draught,
famine,
flirt-gill,
goat,
hate,
hog,
hound,
leech,
lie,
pig,
plague,
starvation,
toad,
war,
wolf
Neutral

animal,
aunt,
brother,
cat,
chihuahua,
cousin,
cow,
daughter,
door,
face,
father,
fellow,
granddaughter,
grandfather,
grandmother,
grandson,
hair,
hamster,
horse,
lamp,
lantern,
mistletoe,
moon,
morning,
mother,
nephew,
niece,
nose,
purse,
road,
roman,
sister,
sky,
son,
squirrel,
stone wall,
thing,
town,
tree,
uncle,
wind
Positive

Heaven,
King,
Lord,
angel,
flower,
happiness,
joy,
plum,
summer's day,
hero,
rose,
kingdom,
pony

External links


  • Shakespeare Programming Language on Slashdot
    Slashdot
    Slashdot is a technology-related news website owned by Geeknet, Inc. The site, which bills itself as "News for Nerds. Stuff that Matters", features user-submitted and ‑evaluated current affairs news stories about science- and technology-related topics. Each story has a comments section...

  • The A-Z of Programming Languages: Shakespeare on Computerworld
    Computerworld
    Computerworld is an IT magazine that provides information for senior IT leaders. It is published in many countries around the world under the same or similar names. Its publisher is International Data Group. Computerworld serves the needs of IT management via print and online...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK