small medium large xlarge

Clojure Applied: From Practice to Practitioner

by

Cover image for Clojure Applied

Clojure Applied

From Practice to Practitioner

by

Think in the Clojure way! Once you’re familiar with Clojure, take the next step with extended lessons on the best practices and most critical decisions you’ll need to make while developing. Learn how to model your domain with data, transform it with pure functions, manage state, spread your work across cores, and structure apps with components. Discover how to use Clojure in the real world, and unlock the speed and power of this beautiful language on the Java Virtual Machine.

Customer Reviews

Starting your first Clojure job? Kicking off your first big open source Clojure project? This is the book you need to get started building Clojure projects. You may worry, “I don’t know what I don’t know.” This book points you to the things you need to know.

- Bridget Hillyer

Software developer, LivingSocial

While other Clojure books enumerate the beautiful, pristine qualities derived from immutability and functional programming, this book is about getting your hands very dirty. Clojure Applied takes you step by step through the process of designing, writing, and shipping robust, high-performance production systems.

- David Nolen

Software developer, Cognitect

It’s refreshing to see experts such as Ben and Alex distill their knowledge into a tome for the masses. Clojure Applied covers a myriad of subjects that perplexed me about Clojure on my own journey. I’m hopeful the book will short-circuit the journey for many.

- Ryan Neufeld

Software consultant, founder, Homegrown Labs

Clojure Applied is the book I wish I had when I started writing Clojure. This book is packed with advice and tips based on years of real-world experience. I learned something new on what seemed like every page. Buy this book and take your Clojure code to the next level.

- Larry Staton, Jr.

Senior software engineer, Hendrick Automotive Group

I had a solid foundation and collection of recipes. When I was ready for the next level, Clojure Applied gave me application patterns and instructed me on how to apply them in an idiomatic way, quickly. Clojure Applied clearly articulates the voices of the authors of the language and libraries, teaching me to design applications in the way the language and its components were designed for.

- Adam Hunter

Software development lead, TMA, Inc.

If you admire the design of the Clojure language and would like to learn how to apply the same principles to your own code, then this is the book for you.

- David McNeil

Software developer, LonoCloud

See All Reviews

Choose Your Format(s)

  • $48.00 In Stock

    Save $15.00 on the combo pack.

  • $38.00 In Stock
  • $25.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Skill-meter-5-8
Pages: 238
Published: 2015-09-01
Release: P1.0 (2015-09-01)
ISBN: 978-1-68050-074-5

Clojure Applied gives you the practical, realistic advice and depth of field that’s been missing from your development practice. You want to develop software in the most effective, efficient way possible. This book gives you the answers you’ve been looking for in friendly, clear language.

Dive into the core concepts of Clojure: immutable collections, concurrency, pure functions, and state management. You’ll finally get the complete picture you’ve been looking for, rather than dozens of puzzle pieces you must assemble yourself. First, explore the core concepts of Clojure development: learn how to model your domain with immutable data; choose the ideal collection; and write simple, pure functions for efficient transformation. Next you’ll apply those core concepts to build applications: discover how Clojure manages state and identity; spread your work for concurrent programming; and create and assemble components. Finally, see how to manage external integration and deployment concerns by developing a testing strategy, connecting with other data sources, and getting your libraries and applications out the door.

Go beyond the toy box and into Clojure’s way of thinking. By the end of this book, you’ll have the tools and information to put Clojure’s strengths to work.

Q&A with Ben Vandgrift and Alex Miller, authors of Clojure Applied

1. Why did we write Clojure Applied?

When Ben was first getting to know Clojure, he found himself awash in tutorials about syntax, toy example applications, and a few places to start. These things were immensely helpful, and he was grateful to their authors.

Eventually, there came a time when he wanted to apply Clojure to a real-world application. Something for a client. Something production-quality and deployable. The publicly available information grew a bit thin. Ben wanted to learn how to think in Clojure, not just at the function level, but across the board. He wanted to take this beautiful language and apply it to something bigger than a bread box.

Fast forward a couple of years. On several occasions, Ben and Alex had spoken about this problem. They referred to it as the 201 Problem. Programmers who understood the basic syntax and had a fair amount of experience in software development couldn’t connect the dots up to a large-scale project in Clojure.

During one of these conversations Alex said, “We need to decrease the angle of the ramp,” and the phrase stuck. Clojure is perfectly capable of solving life-size problems – wonderfully and elegantly – but developers needed a few more lines between the dots.

We joined forces on a quest to go beyond the syntax and provide a guide to practical application of the Clojure language.

2. Should the approach that Clojure Applied recommends for application development be considered idiomatic?

Together, we have used Clojure to build a number of applications from small to large. While we believe the style and forms we describe are in wide use, it’s difficult to say what is and isn’t idiomatic, especially among members of an innovative and opinionated community.

Every application is unique, but they share common problems and patterns. Whether you begin with the data structures and push outward, or at the component or subsystem level and slice downward, you’re going to need to make decisions about which processes to push into the background, how to manage state, component life cycles, inter-process communication, etc. There are many common points of decision when constructing an application.

Instead of laying down hard and fast rules, we focus on the Clojure-specific tradeoffs related to each topic. We recommend some practices, introduce several advanced concepts as options, and provide context to help support good decision-making. This approach will apply to all Clojure developers in their professional practice.

Additionally, we try and impress on the readers the flow of Clojure development. Developing in Clojure means adopting some of its values and history. We want them to be able to swim with the current, rather than against it.

3. As a growing community, why call out libraries and tools that may change?

In Clojure Applied, we point out several libraries that we use regularly for communication, configuration management, validation, and other functionality most applications will need. Yes, they may change, and our recommendations might change with them. That’s the nature of open source software. We have chosen libraries that are useful right now.

Over time, we might choose differently. Other tools may come to the fore.

When that happens, we’ll update the readers via clojure-applied.com and through digital updates and future editions. Clojure is mature for its age, but much of its ecosystem is still a moving target. As authors and contributors, we have to move with it.

Our goal was to provide a leg up, a good start. A talented software developer will do their own homework and make their own choices around tooling. It’s nice, however, to have a few places to start. As we mentioned earlier, our goal is to decrease the angle of the ramp. It’s equally important that we don’t try and reinvent wheels—especially early in our practice when learning a new language.

4. Any final words?

Solving a life-size problem is entirely possible in Clojure—-simpler, in fact, than it would be in many other languages. Getting to that point from bare syntax is the journeyman’s tale. We’ve had the good fortune to work alongside many skilled Clojurists, and learn from their examples.

Not everyone is this lucky, and so we’re passing on our hard-won knowledge. This is why we’ve written Clojure Applied. We hope you enjoy the journey, and we’ll see you on the other side.

What You Need

To follow along with the examples in the book, you will need Clojure 1.6, Leinegen 2, and Java 6 or higher.

Contents & Extracts

Introduction
  • Foundations
    • Model Your Domain
      • Modeling Entities
      • Constructing Entities
      • Modeling Relationships
      • Validating Entities excerpt
      • Domain Operations
      • Wrapping Up
    • Collect and Organize Your Data
      • Choosing the Right Collection
      • Updating Collections
      • Accessing Collections
      • Building Custom Collections
      • Wrapping Up
    • Processing Sequential Data
      • Mapping Values
      • Reducing to a Value
      • Filtering and Removing Values
      • Take and Drop
      • Sorting and Duplicate Removal
      • Grouping Values
      • Putting It All Together excerpt
      • Wrapping Up
  • Applications
    • State, Identity, and Change
      • Modeling a Change
      • Tools for Managing Change
      • Living with Change
      • Wrapping Up
    • Use Your Cores
      • Push Waiting to the Background
      • Queues and Workers
      • Parallelism with Reducers
      • Thinking in Processes
      • Wrapping Up
    • Creating Components excerpt
      • Organizing with Namespaces
      • Designing Component APIs
      • Connecting Components with Channels
      • Implementing Components
      • Wrapping Up
    • Compose Your Application
      • Taking Things Apart
      • Implementing with Component
      • Putting Things Together
      • System Configuration
      • Wrapping Up
  • Practices
    • Testing Clojure
      • Interactive REPL Tests
      • Example-Based Tests with clojure.test
      • Organizing and Running Your Tests
      • Example-Based Tests with expectations
      • Property-Based Tests with test.check
      • Wrapping Up
    • Formatting Data
      • Data Serialization Formats
      • Extensible Data Notation
      • JSON
      • Transit
      • Wrapping Up
    • Getting Out The Door
      • Publish your Code
      • Choose a Deployment Environment
      • Deploy to a Platform
      • Provision Your Own Servers
      • Wrapping Up
    • Roots
      • Reasonability
      • Lisp
      • Macros and Metraprogramming
      • Persistent Data Structures
      • Lazy and Delayed Evaluation
      • Futures and Promises
      • Concurrent Channels
      • Multiversion Concurrency Control
      • Wrapping Up
    • Thinking in Clojure
      • Make Reasoned Choices
      • Be Reasonable
      • Keep It Simple
      • Build Just Enough
      • Compose
      • Be Precise
      • Use What Works
      • Wrapping Up

Author

Ben Vandgrift struggles daily with a compulsion to solve problems. His decades-old journey has most recently led him to Clojure, allowing him to solve many software problems elegantly and efficiently. He works as a software engineer when he’s not being mauled by his rescue panther.

Alex Miller was about to give up on programming as irretrievably complex when he found Clojure, which renewed his love for code. Alex works by day on improving Clojure and spends his off hours organizing the Strange Loop conference and playing music with his kids.

Upcoming Author Events