I like to use Twine to introduce students to text-based programming, usually in late elementary or middle school. Twine is a tool for creating interactive fiction (aka choose-your-own adventures stories) as webpages. Writing interactive fiction is a high engagement activity for students. They get to express themselves and create digital artifacts that they can share with friends and family. Twine is a low floor, high ceiling tool. A creator can start making stories or games with just the basic link syntax: [[link name]]. As one's skill develops, Twine also provides variables, conditional statements, arrays and datamaps. The most advanced users can extend their projects with Javascript.

Twine is a great option for integrating computer science with language arts or social studies. There are natural links to writing skills and grammer and easily made connections to literature, culture, and historical research. These connections make Twine especially useful for reaching students who think of themselves as "language arts" people. Those who are turned off by more mathematical introductions to programming, such as Processing or Bootstrap, benefit from a language-based intro to programming. Throughout this tutorial I will give examples of projects that can be used or adapted to integrate the CS concepts with subject matter in these fields.

The big challenge of a text-based language as compared to a drag-and-drop language like Scratch is syntax: the fear of the missed semicolon. Twine has features that make it an excellent envirnoment for introducing syntax. First, consider why programming languages need syntax to begin with. With Twine, most of what we type is the content of the interactive fiction story. The Twinescript syntax lets us tell the computer that something we're typing is for the computer to interprete rather than for the end user. The reason for programming syntax is clear: syntax lets us direct comments to the computer.

Another benefit of the syntax of Twine (specifically, the Harlowe story format) is that it resembles natural english language. For example, here's how to set the value of a variable: (set: $name to "Alice"). Moreover, by using parentheses, these commands read like a side note addressed to the computer.

Finially, writers and students in a language arts class are already in the mindset of thinking about syntax and grammer. They know that each sentence needs to end with a period, and each sentence needs a verb. The fact that each twine command needs a name and is enclosed in parentheses is a similar kind of rule. Introducing text-based programming in a writing context reinforces the idea that programming languages are languages.

Next up: let's see what Twine can do.


Here's what other people are saying about using Twine with children and teenagers.