Pre-West Interview: Nathan Sorenson

Talk: Domain Specific Type Systems

Nathan Sorenson's talk at Clojure/West is about type systems for DSLs.


Clojure is a dynamically typed language. The types are encoded in the classes of objects. However, when we develop a DSL, we are designing a new language and are free to build in a static type system for that DSL. Nathan Sorenson's talk addresses some of the hardest but most important work in developing a type system: the error messages and interoperability. And it seems practical: he'll be developing a query DSL for Datomic.

If you're new to macros, you may want to read the macro chapter from Clojure for the Brave and True. If you're really interested in Type Theory, you're in for a treat with this recording of Robert Harper.

About Nathan Sorenson

GitHub - Twitter

This interview was graciously conducted by Nola Stowe. She's a programmer, the co-founder of DevChix, and a prolific teacher. She recently ran ClojureBridge Austin. Please shout out to her and say thanks!


Nathan Sorenson is the next interview participant. He is giving a talk at Clojure/West about DSLs. The background to his talk is available, if you like.

Interview with Nathan Sorenson

Nola: How long have you been doing clojure and how did you get into it?

Nathan: I've been using Clojure for 6 years. I got into the language during grad school: the libraries I needed to use for my master's research were all on the JVM, but I was becoming frustrated with the time it took to turn my ideas into experiments in code. I found Clojure and Incanter, and the REPL-based interactive workflow I experienced was incredible. There's no way I'd have been able to spend so much time exploring my problem space without Clojure.

Nola: What languages did you do before Clojure?

Nathan: Mostly Java and C++.

Nola: Your talk is about DSLs, what other language have you used in the past if any to write DSLs?

Nathan: It's often nice to write DSLs in typed FP languages. A DSL's syntax is a quintessential example of an "algebraic data type," and ADTs combined with pattern matching will make it easy to interpret your syntax correctly. Haskell has some particularly useful features: the "deriving" mechanism, for example, gives you traversal operations for your syntax for free. Haskell also has type classes that enable an interesting style of specification called "tagless final." This approach lets you sidestep the typical interpretation overhead and compile your DSL as though it were a first-class member of the host language.

Nola: What advice would you give a new programmer to Clojure?

Nathan: I came from an imperative, object-oriented mindset and had to do a great deal of un-learning before I could grok the basics of functional programming. I personally found classic Scheme books like The Little Schemer and SICP helpful in this journey. However, everyone learns differently based on where they are coming from, so it's important not to get frustrated if you don't find someone's advice, book recommendations, or metaphors useful!

Nola: What is the average airspeed velocity of an unladen Clojure REPL?

Nathan: Lots of people get distracted quibbling about the difference between European REPLs and African REPLs but that's the wrong idea. The trick is to decomplect the question into three simpler ones: what are the average airspeeds of the Starling, the Kestrel, and the Identity bird?

Nola: Thanks for the interview. It was very informative.