Pre-West Interview: Nathaniel Smith and Ruth Linehan

Free Beginner Workshop

From OO to Clojure Workshop!

Watch my free workshop to help you learn Clojure faster and shift your paradigm to functional.

Talk: One Binder to Rule Them All: Introduction to Trapperkeeper

Nathaniel Smith and Ruth Linehan's talk at Clojure/West is about Trapperkeeper, a Clojure services framework.


Trapperkeeper is PuppetLabs' application services framework for Clojure and other JVM languages. It provides a coherent set of core services and a means for you to define new services. Those services can depend on each other and can be configured through standard config files. As applications become bigger and more complex, standardizing on a configuration mechanism and communication medium is a must.

As background, I suggest you read the intro article and the more technical follow-up article.

About Nathaniel Smith

Homepage - GitHub - Twitter

About Ruth Linehan

GitHub - Twitter


Nathaniel Smith and Ruth Linehan generously agreed to do an interview about their talk at Clojure/West. They will be talking about Trapperkeeper. The background to their talk is available, if you like.

Interview How did you get into Clojure?

Ruth Linehan: I started using Clojure about a year and a half ago, when my team at Puppet Labs started working on a new project in it. Previously I had mostly worked in Ruby and Javascript, and while switching to Clojure required a bit of a mind shift, I really enjoy it!

Nathaniel Smith: I had never used it, but was offered a job at Puppet Labs two years ago to write it full time. I thoroughly enjoyed learning it on the 5 hour flight to my first interview there and have loved writing it ever since (in other words, I got the job :) ) What does Trapperkeeper offer the Clojure developer?

RL: Great question! Trapperkeeper is great for complicated Clojure applications. It allows you to easily break up your code into modular pieces (what we call "services"), and it serves as a binder for these pieces of code. Any state a service needs can be stored in a map in the service context, rather than kept globally. It provides a consistent way for expressing the lifecycle of these services - what happens at startup and shutdown - and for managing dependencies between services. It has built in config file parsing, and it initializes a logging system using logback for you, so that you don't have to worry about this. It also has some useful test helpers that allow you to start up a Trapperkeeper application in code and test the whole system.

NS: A better way to compose the various services (Database, job queue, web server, logging, configuration...) that one has in a large, long running Clojure application. Trapperkeeper leads to more maintanable and reusable code. How does breaking everything into small services help build a large application?

NS: You have well-defined, protocol-enforced APIs for you various services and get to leverage TK's dependency management to ensure clean statups/shutdowns of all of your JVM infrastructure bits.

RL: Frequently, some of the code that's necessary to build a large application is code you (or someone else) had to write to build a different application. Breaking it down into smaller, more modular services means that you can more easily reuse that code across multiple applications. Furthermore, each service manages the state that it needs, so you don't end up with a huge mess of global state. It also makes testing much easier - you can test a service on its own, rather than having to set up the entire system to test it. Are there any similar systems in Clojure or elsewhere?

NS: A few, but none of them met our needs at Puppet Labs. We think that Immutant and Components and other similar projects are great, but they weren't a good fit for our needs.

RL: Trapperkeeper was heavily influenced by Stuart Sierra's "Clojure, Reloaded" workflow, and it has a number of similarities with other frameworks motivated by this, such as Jig and Component. Our way of turning on and off services and managing service dependencies borrows a lot from OSGi's service registry. Where can people follow you online?

RL: Nathaniel and I are both on twitter: I'm @ruthlinehan, he's @nate_smith. If you want to follow Trapperkeeper, we ("we" meaning many of the folks at Puppet Labs who work on or with Trapperkeeper) hangout on IRC on freednode in #trapperkeeper. We'd love to see folks there!

NS: I publish poetry and other esoterica at If Clojure were a food, what food would it be?

RL: Hm... maybe a melon? From the outside it seems hard and impenetrable, but once you get inside it's awesome and delicious! Also, a slice of melon looks like a parenthesis. :)

NS: Delicious whole wheat bread (ooh, or oat bread) used to make function sandwiches.