small medium large xlarge

Web Development with Clojure: Build Bulletproof Web Apps with Less Code


Cover image for Web Development with Clojure

Web Development with Clojure

Build Bulletproof Web Apps with Less Code


If the usual patchwork of web development tools and languages just isn’t cutting it for you, you need Web Development With Clojure. Clojure gives you the rich infrastructure of the JVM with the expressive power of a modern functional language. It combines excellent performance with rapid development—and you can exploit these virtues for web app development. With step-by-step examples, you’ll learn how to harness that power and richness to build modern web applications.

Download the author’s free guide to Clojure Clojure Distilled.

Web Development with Clojure, Second Edition is available here

Customer Reviews

This is a great resource and one I will insist all my trainee Clojure web developers

- Collin Yates

principal engineer and technical team leader, QFI Consulting, LLP

Clojure is an awesome language, and using it for developing web applications is
pure joy. This book is a valuable and timely resource for getting started with the
various libraries of the Clojure web-development toolbox.

- Fred Daoud

web-development specialist and coauthor of "Seven Web Frameworks in Seven Weeks"

In Web Development with Clojure, Dmitri Sotnikov manages to take the sting out
of getting started building real applications with Clojure. If you know the basics
but are still trying to “get” Clojure, this is the book for you.

- Russ Olsen

vice president, consulting services, Cognitect

Sotnikov illustrates Clojure’s flexible approach to web development by teaching
the use of state-of-the-art libraries in making realistic websites.

- Chris Houser

"Joy of Clojure" coauthor

With this book, you’ll jump right into web development using powerful functional
programming techniques. As you follow along, you’ll make your app more scalable
and maintainable—and you’ll bring the expressiveness of Clojure to your clientside

- Ian Dees

author of "Cucumber Recipes"

Dmitri’s book successfully walks a narrow line of introducing language features
while also solving real, modern software-development problems. This represents
a significant return on investment for the time you devote to a technical book.

- Brian Sletten

, Bosatsu Consulting, author of "Resource-Oriented Architecture Patterns for Webs of Data"

This is a fast-paced, no-cruft intro to applying your Clojure chops to making web
apps. From Chapter 1 you’re running a real web app and then adding databases,
security, JavaScript, and more. No dogma, no preaching, no fluff! To the point,
productive, and clear. This book gives you all you need to get started and have a
real app that you can continue to grow.

- Sam Griffith, Jr.

polyglot programmer, Interactive Web Systems, LLC

See All Reviews

About this Title

Pages: 232
Published: 2014-01-15
Release: P2.0 (2014-07-30)
ISBN: 978-1-93778-564-2

Modern web development needs modern tools. Web Development With Clojure shows you how to apply Clojure programming fundamentals to build real-world solutions. You’ll develop all the pieces of a full web application in this powerful language. If you already have some familiarity with Clojure, you’ll learn how to put it to serious practical use. If you’re new to the language, the book provides just enough Clojure to get down to business.

You’ll learn the full process of web development using Clojure while getting hands-on experience with current tools, libraries, and best practices in the language. You’ll develop Clojure apps with both the Light Table and Eclipse development environments. Rather than frameworks, Clojure development builds on rich libraries. You’ll acquire expertise in the popular Ring/Compojure stack, and you’ll learn to use the Liberator library to quickly develop RESTful services. Plus, you’ll find out how to use ClojureScript to work in one language on the client and server sides.

Throughout the book, you’ll develop key components of web applications, including multiple approaches to database access. You’ll create a simple guestbook app and an app to serve resources to users. By the end, you will have developed a rich Picture Gallery web application from conception to packaging and deployment.

This book is for anyone interested in taking the next step in web development.

Q&A with Dmitri Sotnikov

Why did you write Web Development with Clojure?

When I started using Clojure, I found that it took a lot of work to find all the pieces needed to put together a working application. There was very little documentation available on how to organize the code, what libraries to use, or how to package the applicaton for deployment. Having gone through the process of figuring out what works, I thought that it would be nice to make it easier for others to get started.

What are the advantages of using a functional language?

Over the course of my career, I have developed a great appreciation for functional programming. I find that it addresses a number of shortcomings present in the imperative paradigm. For example, in a functional language any changes to the data are created via revisions to the existing data. So they only exist in the local scope. This fact allows us to safely reason about individual parts of the program in isolation, which is critical for writing and supporting large applications.

Why use Clojure specifically?

Clojure is a simple and pragmatic language that is designed for real-world usage. It combines the productivity of a high-level language with the excellent performance seen in languages like C# or Java. It’s also very easy to learn because it allows you to use a small number of concepts to solve a large variety of problems.

If I already have a preferred web development platform, what might I get out of this book?

If you’re using an imperative language, you’ll get to see a very different approach to writing code. Even if you’re not going to use Clojure as your primary language, the concepts you’ll learn will provide you with new ways to approach problems.

Is the material in the book accessible to somebody who is not familiar with Clojure?

Absolutely. The book targets developers who are already familiar with the basics of web development and are interested in learning Clojure in this context. The book introduces just enough of the language to get you productive and allows you to learn by example.

What You Need

The latest JVM, Clojure 1.4+, and the Leiningen build tool, as well as an editor such as Emacs, Eclipse, or Light Table.

Contents & Extracts


  • Required Background
  • Why Functional?
  • Why Clojure?
  • Getting Your Feet Wet
  • Clojure Web Stack
    • Routing Requests With Ring
    • Defining the Routes With Compojure
    • Application Architecture
    • Beyond Compojure and Ring
    • What We Just Learned
  • Liberator Services
    • Creating The Project
    • Defining Resources
    • Putting It All Together
  • Database Access
    • Working With Relational Databases
    • Report Generation
    • Summary
  • Picture Gallery
    • The Development Process
    • What’s In a Gallery
    • Creating The Application
    • Application Data Model
    • Task A: Account Registration
    • Task B: Login and Logout
    • Task C: Uploading Pictures
    • Task D: Displaying Pictures
    • Task E: Deleting Pictures
    • Task F: Account Deletion
  • Finishing Touches
    • Adding Some Style
    • Unit Tests
    • Logging
    • Applications Profiles
    • Packaging Applications
    • Wrapping up
  • Mixing It Up
    • Using Selmer
    • Upgrading To ClojureScript
    • SQL Korma
    • Creating Application Templates
    • Wrapping Up
  • Appendix A: Alternative IDE Options
    • Installing Eclipse
    • Installing Emacs
    • Further Alternatives
  • Appendix B: Syntax
    • Data Types
    • Using Functions
    • Anonymous Functions
    • Named Functions
    • Higher-Order Functions
    • Closures
    • Threading Expressions
    • Being Lazy
    • Structuring the Code
    • Destructuring Data
    • Namespaces
    • Dynamic variables
    • Calling out to Java
    • Calling methods
    • What About Global State?
    • Writing Code That Writes Code For You
    • The Read Evaluate Print Loop
    • Summary
  • Appendix C: Document-Oriented Database Access
    • Picking the Right Database
    • Using CouchDB
    • Using MongoDB
  • Author

    Dmitri Sotnikov has been developing Web applications professionally for close to a decade. He has developed and continues to maintain several Clojure libraries as well as the Luminus framework. He has worked in both startup and enterprise environments.