Learning computing with metaphors

Don’t think of an elephant!

Now what are you thinking about? Of course, it’s an elephant.

This sentence is the title of a book by George Lakoff, a contemporary linguist who makes that case that we frame our thinking with the words and metaphors we use. By consciously recognizing this, we can understand our own thinking better and become more persuasive.

Inspired by Lakoff’s work, Alvaro Videla published an essay Metaphors We Compute By in the October 2017 Communications of the ACM. As a computer scientist and software engineer, Videla recognized the extent to which we make sense of concepts in computing via metaphors. He gives this example:

Say you could program a computer to command other computers to perform tasks, respecting their arrival order. This description is already difficult to understand. On the other hand, you could describe the solution by describing a queue server that assigns jobs to workers based on a first-come, first-served queue discipline.

Consider all the examples from daily life in the description of the solution: A “queue” is something with which all of us are familiar—that’s a “line” for those of us speaking American English! “First-come, first-served” is how most everyday lines operate, “workers” and “jobs” are people and roles from our daily lives.

With this metaphor, it makes sense. The everyday concepts translate into computational artifacts. A worker becomes an operating-systems process. A job becomes an algorithm carried out by that process on some particular data. The line becomes a FIFO queue.

This idea of using metaphors goes back far in our field. Some of the early CS education research focused on how the names of words chosen to be language commands helped (or hindered) students’ understanding. For example, in the 1987 article The Buggy Path to Development of Programming Expertise, Pea, Soloway and Spohrer reported on how students expected parallelism in BASIC code with “IF… THEN” statements. They thought the computer could evaluate any statement as needed, firing when a condition became true—as it might be in daily life.

I’ve used metaphors to explain function application—a concept in functional programming. It’s similar to how parameters or arguments are supplied to C or Java functions. I brought a rubber mallet to class, and described function application as the mallet “pounding the parameters on the head.” So if you have a function increment, which adds one to its parameter, then increment sees a 3, pounds it, and produces a 4. Then “functional mapping” is walking down a list, pounding each parameter in turn. In Scheme: (map increment (list 1 2 3 4)) produces the list (2 3 4 5).

Later during the semester, I could just pretend I was holding the mallet to bring back the idea of function application.

What metaphors have you introduced to your students to help them understand computing concepts? Did they work? Have you changed them over time? Please share with your colleagues!

head shot of Fred Martin, chair of board of directors

Fred Martin, chair of board of directors

This entry was posted in Teaching Methods, Tips & Tricks by Fred Martin. Bookmark the permalink.

About Fred Martin

Fred Martin is a faculty member at the University of Massachusetts Lowell, where he is associate dean for teaching, learning, and undergraduate studies in the Kennedy College of Sciences and professor of computer science. He has been serving on the board of CSTA since 2014, and is past-chair of CSTA's Board of Directors.