Published: September 2015
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.
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.
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.
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.
Published: September 2015