Every now and then I see people asking what Clojure and ClojureScript libraries they should be using. In this post, I’ll share my list of libraries for building full-stack Clojure/ClojureScript web applications. I’ve been building this kind of applications for a while now and I believe you can rely on these libraries.
Here’s what I’m looking for:
- Robustness. I don’t want to debug buggy libraries – I write enough bugs of my own.
- Extensiblity. With a long-lived application, you’ll end up wanting all kind custom things that the library authors didn’t anticipate. Data-driven design helps here.
- Implemetation is easy to understand. Eventually I’ll read the source anyway. Either there is a bug or there is no documentation.
This list is not meant as the final truth: there are plenty of good libraries out there and you might choose different ones based on your needs and preferences. There’s an obvious bias, too: many of these libraries were made by my colleagues at Metosin.
HTTP routing. I like the data-driven nature of reitit. It’s fast, too, and has enough extension points so that anything you want is possible. I would not use compojure-api because the implementation is way too hard to understand.
Logging. I use Timbre because it’s so easy to write custom appenders for it. Admittedly I haven’t checked out the popular Java options.
Test data generation. I only just started using specmonstah for generating graphs of test data, but I’m excited. It’s so much nicer than writing the equivalent code by hand. There’s a bit of learning curve, though.
Build tool. Figwheel works very well and its getting
better all the time. I’d either use it with Leiningen or directly with
Translations. Tempura works for me. I use a small Clojure tool for extracting the translatable strings into a PO file for editing with Poedit. The tool is proprietary right now but I hope to open source it.
Data manipulation utilities. I use the combination of Potpuri, xforms, and Specter. Potpuri is an old-fashioned “missing parts of clojure.core” library and xforms is the same for transducers. Specter is the closest thing to lenses for Clojure. It’s powerful but takes some time to learn. I recommend trying it out for some simple tasks – soon you’ll see opportunities for it everywhere.
What about …?
I haven’t included any SQL libraries, HTTP clients or servers, or async libraries, because I don’t have a clear recommendation for any of these (important!) categories.