Shakespeare Programming Language


The Shakespeare Programming Language or SPL is a programming language created by Karl Hasselström and Jon Åslund in February 2001. The source code written in SPL programs like a play . It is inspired by languages like Malbolge or Brainfuck and is named after the playwright English William Shakespeare 1 .

Write a program in SPL

The developer writes his or her source code in the form of a play that meets the following conventions 2 :

  • The first lines of the program form the title (until a point is encountered) and are ignored. They have only aesthetic purpose and are stricto sensu of the comments;
  • The following lines are a list of the characters in the room, each one corresponding to a variable. There is only one type of variable, which can contain a signed integer (positive or negative). All variables must be declared. Only the names of characters of Shakespeare can be used (eg Romeo , Juliet , Hamlet …);
  • The program is a set of acts and scenes, serving both aesthetic cutting of the piece and label for the parser. Each act or scene is announced by a line beginning with the word Act or Scene followed by a Roman number, and possibly a title that will be considered as a commentary (eg Scene I or Act III: The tree revolution );
  • Each scene can start with a character entry. For a variable to be used in this scene, it must be mounted on the boards before it can be used. This entry results in a crochet line in the form [Enter Romeo and Juliet] ;
  • Each scene can also close with an output of the variables in the form of a line like [Exit Lady MacBeth] or, if there are several variables, [Exeunt Achilles and Paris] . If a character exits and enters later, the variable will not retain its previous value and will be reset;
  • Between the lines of entry and exit of the characters, come the replicas containing the instructions of the program. Each replica begins with a character (eg Ajax 🙂 and one or more sentences;
  • Except as specified below, each sentence will assign a value. Each name corresponds to a constant 1 if it is pretty, -1 otherwise. Thus, flower , joy or angel will be worth 1, while devil , bastard or death will be -1 3 . Other names, more neutral, like tree will also be worth 1. Any adjective preceding a name will multiply it by two. Thus, in order to construct numbers, it is generally necessary to write a sum or difference of powers of two. Thus, to the following sum: ” a charming cute golden flower and the silly beggar ” will be assigned the value of 6

Note for non-English speakers: indeed, charming , cute and golden are adjectives, flower is pretty, silly is an adjective , and beggar is not pretty. Hence the above formula.

Notes and references

  1. ↑ ( in ) Karl Hasselström Jon Åslund, ” Shakespeare Programming Language Design Goals [ archive ] , on http://shakespearelang.sourceforge.net/  [ archive ] , (Accessed 2 February 2008 ) .
  2. ↑ ( in ) Karl Hasselström Jon Åslund, ” Hello World –other small and softwares in SPL walkthrough [ archive ] , on http://shakespearelang.sourceforge.net/  [ archive ] , (Accessed 2 February 2008 ) .
  3. ↑ ( in ) File source Shakespeare.pm available for Perl implementation Lingua :: Shakespeare  [ archive ] .