Pure Danger Tech


navigation
home

clojure-conj: Composable abstractions

25 Oct 2010

One big theme I felt throughout the conference was the idea that optimal Clojure code is made up of “composable abstractions” built from the essentials provided in the core. Perhaps the most fundamental pillars in Clojure are seqs and functions. A layer above that consists of the core data types like vector, map, etc and the core FP primitives like map, reduce, filter, etc.

In talk after talk we saw how focusing on these core abstractions and thinking hard about how the problem at hand, then casting a solution in terms of those core pieces results in code that is modular, composable, and interoperable with other code built from the same principles. And we saw how moving away from those core principles (in particular by overuse of macros) prevents code from being composable.

For example, we saw in Christophe Grand’s talk about DSLs how leveraging the core data types instead of creating new syntax via macros created libraries that were faster, allowed greater use of core functions, and interoperated with other DSLs better. Some of the same themes were revisited in Stuart Sierra’s macro talk on day 2.

In Mark McGranaghan’s talk on Ring, we saw the idea of a simple core abstraction (request/response based on maps) and the use of functions to represent layers of composable handlers. Similarly clear thinking was in evidence with Zach Tellman’s lightning talk about Aleph. Phil Hagelberg leverages the same ideas in Leiningen with plugins.

Stu Halloway had some great slides in his talk examining the core *orthogonal* abstractions in Clojure that can be used ala carte. And in Rich’s “rant” on day 2 we saw how thinking hard about the core abstractions was so valuable (and how to go about it!).

In all, this theme resonated deeply with me and lies at the essence of what I think makes Clojure exciting.