small medium large xlarge

Web Development with Clojure, Second Edition: Build Bulletproof Web Apps with Less Code


Cover image for Web Development with Clojure, Second Edition

Web Development with Clojure, Second Edition

Build Bulletproof Web Apps with Less Code


Modern web applications deserve modern tools. Harness the JVM’s rich infrastructure while taking advantage of the expressive power and brisk performance of a modern functional language. Exploit Clojure’s unique advantages for web development. Step by step, apply the fundamentals of programming in Clojure to build real-world, professional web applications. This edition features new libraries, tools, and best practices, and focuses on developing modern single-page applications.

Choose Your Format(s)

  • $46.00 In Stock

    Save $14.00 on the combo pack.

  • $36.00 In Stock
  • $24.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Pages: 306
Published: 2016-07-15
Release: P1.0 (2016-07-19)
ISBN: 978-1-68050-082-0

Stop developing web apps with yesterday’s tools. Today, developers are increasingly adopting Clojure as a web-development platform. See for yourself what makes Clojure so desirable, as you create a series of web apps of growing complexity, exhibiting the full process of web development using a modern functional language. Journey through all the steps in developing a rich Picture Gallery web application—from conception to packaging and deployment. You’ll work hands-on with Clojure and build real-world, professional web apps.

This fully updated second edition reveals the changes in the rapidly evolving Clojure ecosystem. Get up to speed on the many new libraries, tools, and best practices. Gain expertise in the popular Ring/Compojure stack using the Luminus framework. Learn how Clojure works with databases and speeds development of RESTful services. See why ClojureScript is rapidly becoming a popular front-end platform, and use ClojureScript with the popular Reagent library to build single-page applications.

This book is for you, whether you’re already familiar with Clojure or if you’re completely new to the language.

Five Questions about Clojure and Web Development
by Dmitri Sotnikov, author of Web Development with Clojure, Second Edition

Q: What’s Clojure like?
A: Clojure is a small, elegant, and extensible language whose primary goals are simplicity and correctness. As a functional language, it emphasizes immutability and declarative programming. It is hosted on the Java Virtual Machine, giving it a mature and highly performant environment with great tooling and deployment options.

Q: What’s so special about Clojure?
A: Anything that can be expressed in one high-level language can also be expressed in any other. But the practical question is how well the language maps to the problem to be solved. Does the language let you think in terms of your problem domain, or do you have to keep translating domain concepts in the constructs of the language? The best case is when you can use the language without thinking about it. This is where Clojure shines. It allows you to easily derive a solution expressed in the terminology of the problem domain.

Q: Why use a functional language for web apps?
A: Functional languages are ideal for writing large applications because by default they eschew global state in favor of immutability. Having data that can’t change its value off-stage allows us to safely reason about parts of the application in isolation. In addition, the focus on immutability makes it much easier to tackle the difficult problems of parallelism and concurrency. While there is no silver bullet for addressing either problem, a functional language can go a long way in helping you reason about them.

Q: Why write web apps in Clojure?
A: Clojure boasts tens of thousands of users, and web development is one of the major domains where it’s used. But many other platforms are available for doing web development, so why should you choose Clojure over one of them? Well, most popular platforms force you to make trade-offs: sacrificing performance, infrastructure, conciseness, or ease of development. By hosting a modern functional language on the JVM, Clojure’s creator doesn’t ask you to sacrifice anything.

Q: Are there Clojure frameworks like Rails for Ruby?
A: The Clojure community has settled on using libraries coupled with project templates in favor of frameworks. Libraries can be easily composed in a way that makes sense for your particular project. Meanwhile, the templates allow creating projects quickly without the need for the inversion of control seen in frameworks. Many web developers find that this model has clear advantages over the framework-based approach. I think you will too.

Read the reviews .

What You Need

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

Contents & Extracts

  • Introduction
    • What You Need
    • Why Clojure?
    • Why Make Web Apps in Clojure?
  • Getting Your Feet Wet
    • Set Up Your Environment
    • Build Your First Web App
    • Refine Your App
    • What You’ve Learned
  • Luminus Web Stack
    • Route Requests with Ring
    • Extend Ring
    • Define the Routes with Compojure
    • HTML Templating Using Selmer
    • What You’ve Learned
  • Luminus Architecture
    • Manage the Project
    • Think in Terms of Application Components
    • Managing Stateful Components
    • What You’ve Learned
  • Add ClojureScript
    • Understand ClojureScript
    • Configure ClojureScript Support
    • Add ClojureScript Support
    • Build the UI with Reagent
    • What You’ve Learned
  • Real-time Messaging With Websockets excerpt
    • Set Up Websockets on the Server
    • Make Websockets from ClojureScript
    • Websockets Using Sente
    • What You’ve Learned
  • Writing RESTful Web Services
    • Use Compojure-api
    • Creating the API
    • What You’ve Learned
  • Database Access
    • Work with Relational Databases
    • Use HugSQL
    • Generate Reports
    • What You’ve Learned
  • Picture Gallery
    • The Development Process
    • What’s in a Gallery
    • Create the Application
    • Configure the Database
    • 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
    • Adding Some Color
    • What You’ve Learned
  • Finishing Touches
    • Unit Tests
    • Package the Application
    • What You’ve Learned
  • Clojure Primer
    • A Functional Perspective
    • Data Types
    • Using Functions
    • Anonymous Functions
    • Named Functions
    • Higher-Order Functions
    • Closures
    • Threading Expressions
    • Being Lazy
    • Structuring the Code
    • Destructuring Data
    • Namespaces
    • Dynamic Variables
    • Polymorphism
    • What about Global State?
    • Writing Code That Writes Code for You
    • The Read-Evaluate-Print Loop
    • Calling Out to Java
    • Calling Methods
    • Summary
  • Authentication with OAuth
    • Why Use OAuth
  • Document-Oriented Database Access
    • Picking the Right Database
    • Using CouchDB
    • Using MongoDB
  • Writing RESTful Web Services With Liberator
    • Using Liberator
    • Defining Resources
    • Putting It All Together
  • Leiningen Templates
    • What’s in a Template


Dmitri Sotnikov is a passionate Clojure developer who enjoys building web applications. He has developed a number of popular Clojure libraries and is the author of the Luminus micro-framework.