Introduction

Web services today can range in scope from a basic API with a few tables in a DB, to large-scale systems supporting hundreds of millions of users, with massive codebases and response times tuned to the millisecond. Depending on the task at hand, the modern developer has a wide variety of tools to choose from, with dozens of popular languages and frameworks available, each with their own particular take on how things should be done to solve a given set of problems.

Among these languages is Clojure, an increasingly popular dialect of Lisp that targets the JVM, the Microsoft CLR, JavaScript engines, and other platforms. Lisp has been around for an incredible 60 years and was developed at MIT for implementing Lambda Calculus. Clojure builds on Lisp by utilizing pre-existing runtimes (such as the JVM) and adding excellent features like thread-safe datatypes for concurrency and Java VM interop.

In this article we’ll look at how to implement a JSON REST API with Clojure and PostgreSQL, to store a collection of friends with name, nickname, and occupation, and retrieve a list of friends back from the DB.

A copy of the source code for this project is available here on GitHub.