small medium large xlarge

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

by

Cover image for Web Development with Clojure, Second Edition

Web Development with Clojure, Second Edition

Build Bulletproof Web Apps with Less Code

by

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.

Customer Reviews

The second edition continues to be an excellent resource for those new to the joy of Clojure web development.

- Colin Yates

principal software engineer, QFI Consulting LLP

A key part of building applications in Clojure is knowing how those tools fit together. Which is where Web Development with Clojure comes in: In this book Dmitri Sotnikov takes you through the process of harnessing Clojure to build a functional web application. Along the way he manages to explain just enough of the language, libraries and tools involved to orient the reader while never getting bogged down in technical trivia. Like Clojure itself, Web Development with Clojure is both functional and to the point.

- Russ Olsen

vice president, consulting services, Cognitect

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"

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

"The 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 JavaScript.

- Ian Dees

author, "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

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

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

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

Skill-meter-5-8
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.

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

Author

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.