Jolly Roger   

Talk Like a Pirate

Nifty Assignments - SIGCSE 2004

   Jolly Roger

David Reed
Creighton University
davereed@creighton.edu
www.creighton.edu/~davereed

Summary Talk Like a Pirate: this series of assignments involves designing and implementing programs that translate English text into Pirate jargon.
Topics A pirate translation program can be used to investigate GUI, event-driven programming, meta-programming, and string operations (including regular expression matching).
Audience Versions 1 and 2 of the translator are perfect for a CS0 course using HTML/JavaScript, or for a CS1 course using C++ or Java. Version 3 could be tackled in CS1 or in a more advanced course such as Web Programming or HCI.
Strengths The great strength of these assignments is that they are fun and stimulate creativity. Assignments can be tailored to address several programming/design concepts at different levels of the curriculum.
Weaknesses These are not particularly deep assignments. Versions 1 and 2 of the pirate translator involve very little programming, and even version 3 is still pretty straightforward (except for the regular expression details). However, additional features can be added if a greater programming challenge is desired.
Dependencies Versions 1 and 2 of the translator require basic understanding of programming concepts, and familiarity with a language such as JavaScript, C++, or Java. Familiarity with the Web and HTML would be a plus, but not necessary in a CS1 course. Version 3 requires a deeper understanding of programming and, in particular, the manipulation of strings. A language that supports regular expression searches is preferable.
Variants Several variants and extensions to the translators are described, including more advanced features using regular expressions.


This series of assignments was inspired by International Talk Like a Pirate Day, an unofficial holiday first proposed by John Baur and Mark Summers in 1995. As they designed it, Talk Like a Pirate Day (September 19) is a day in which people from around the world are encouraged to have fun and talk like pirates, saying things like "Arrrr" and "Ahoy, matey" whenever possible. Their holiday has been popularized by Dave Barry in his columns, and attracts thousands of visitors each year to the Web site www.talklikeapirate.com. To assist would-be pirate talkers, the Web site even contains a simple English-to-Pirate translator in the form of an interactive Web page. My student have found this translator fun and entertaining, and I have found it to be the inspiration for several nifty assignments.


Pirate Translator: Versions 1 and 2

In a recent Web-based CS0 course, the English-to-Pirate translator was used to motivate discussions on interface design, event-driven programming, and meta-programming. Initially, students critiqued the interface provided by the online translator, and designed a more general interface involving a separate button for each word or phrase to be translated. Students then implemented their own translators (Version 1) in the form of embedded JavaScript code in a Web page, and embellished the translator by improving its layout and extending its vocabulary.

As students extended the vocabulary of their translators, they quickly recognized the amount of repetition involved. The next part of the assignment involved using JavaScript to automate the generation of the buttons. By doing so, students experienced the value of code factoring and meta-programming, resulting in a translator (Version 2) that was easier to extend, debug, and keep consistent.

While these assignments were given in a CS0 course using HTML and JavaScript, they could easily be adapted to a CS1 course using C++ or the Java GUI.


Pirate Translator: Version 3

A third, more advanced version of the pirate translator was recently assigned in an upper-level Web programming class. There, students designed and implemented a program that utilized string operations (substring matching, regular expressions, substring replace) to provide a more general translator (Version 3). Unlike earlier versions, this advanced version allowed for arbitrary text as input, substituting pirate jargon where applicable but leaving unrecognized text alone. Using regular expressions, as provided in JavaScript and Java, for example, complex patterns were found and selectively replaced, yielding a robust translator with minimal effort.


Be sure to check out my highly entertaining Nifty Panel Talk.


Extra info about this assignment: