The Interpreter Pattern Revisited

It’s the year 1994 and the world is just coming online. It’s before Netscape Navigator or Java. It was also long before smart phones and “there weren’t even Palm Pilots, people having devices in their hands was not a thing,” Rúnar Bjarnason reminds us at the start of this talk for the Northeast Scala Symposium

In that same year, the so-called "Gang of Four" (Erich Gamma, Ralph Johnson,Richard Helm, John Vlissides) published a book called Design Patterns: Elements of Reusable Object-Oriented Software, which centered around the idea of pattern languages.

[It] comes from architecture, an architect named Christopher Alexander, developed this idea of pattern languages in architecture, and so the idea of this book was to apply that to software creation.

While the book was written over 20 years ago, there are still concepts from the work that are used today, but Rúnar describers the Interpreter Pattern as an exceptional one that is often over-looked, going on to even call it “an unsung hero.”

Moreover, Rúnar finds the Interpreter Pattern to be the most useful pattern in the entire GoF book. He call its underutilized and argues that it "captures an idea that is extremely useful... and is sort-of universally applicable to almost everything."

So, to quote now from Rúnar's abstract, "Please turn to page 243 in your Gang-of-Four book and follow along. [The Interpreter Pattern's] dry description goes: "given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language." But it's so much more than that! With the interpreter pattern as our hammer, every imaginable problem becomes a nail.”

Further Resources

  • Scala Training from ProTech
  • Video & Tutorials on Scala
Published April 10, 2015