TinyWeb in Clojure

Now let’s take TinyWeb and translate it into Clojure. This is going to be a bigger leap than the translation from Java to Scala, so we’ll take it slowly.

The most obvious difference between Clojure and Java is the syntax. It’s very different than the C-inspired syntax found in most modern programming languages. This isn’t incidental: the syntax enables one of Clojure’s most powerful features, macros, which we’ll cover in Pattern 21, Domain-Specific Language.

A Gentle Introduction to Clojure

For now let’s just have a gentle introduction. Clojure uses prefix syntax, which just means that the function name comes before the function arguments in a function call. Here we call the count function to get the size of a vector, ...

Get Functional Programming Patterns in Scala and Clojure 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.