Chapter 16. Clojure and the Web

Web development can easily be considered the ubiquitous domain: with rare exception, if you are a programmer today, not only do you know how to build web applications, you probably build or work on them regularly. This being the case, any ostensibly general-purpose language had better offer a compelling workflow and set of tools for building web apps. Clojure clears that bar handily.

Being hosted on the JVM and sporting excellent interop features, Clojure didn’t have to start from scratch with bare sockets or an Apache module: all the good parts of the battle-tested array of Java web infrastructure was waiting to be leveraged. At the same time, the Clojure ecosystem has evolved its own set of idioms and principles of good web app architecture that contrasts significantly with typical Java practice.

The “Clojure Stack”

We’ve consistently repeated the mantra of good Clojure design: emphasizing common abstractions over concrete types and implementation details, pure functions with immutable data over side-effecting methods with mutable state, and the flexible assembly of these fundamentals into composites that are themselves reliable building blocks. It should then come as no surprise that there is no definitive “Clojure stack,” at least compared to the monolithic framework bonanza that often constitutes web “stacks” in other languages. Instead, the Clojure community has grown a number of modular libraries over the years that collectively satisfy all of ...

Get Clojure Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.