small medium large xlarge

Programming Clojure, Third Edition

by

Cover image for Programming Clojure, Third Edition

Programming Clojure, Third Edition

by

Drowning in unnecessary complexity, unmanaged state, and tangles of spaghetti code? In the best tradition of Lisp, Clojure gets out of your way so you can focus on expressing simple solutions to hard problems. Clojure cuts through complexity by providing a set of composable tools—immutable data, functions, macros, and the interactive REPL. Written by members of the Clojure core team, this book is the essential, definitive guide to Clojure. This new edition includes information on all the newest features of Clojure, such as transducers and specs.

Choose Your Format(s)

  • $26.95 In Stock
    • Beta: What do I get?

  • Ebooks are DRM free.

  • Ebook delivery options.

  • The Paper Book will ship on 2017-12-10 (roughly).

About this Title

Skill-meter-1-4
Pages: 300 (est)
Published: 2017-12-10
Release: B3.0 (2017-08-22)
ISBN: 978-1-68050-246-6

Clojure joins the flexibility and agility of Lisp with the reach, stability, and performance of Java. Combine Clojure’s tools for maximum effectiveness as you work with immutable data, functional programming, and safe concurrency to write programs that solve real-world problems.

Start by reading and understanding Clojure syntax and see how Clojure is evaluated. From there, find out about the sequence abstraction, which combines immutable collections with functional programming to create truly reusable data transformation code. Clojure is a functional language; learn how to write programs in a functional style, and when and how to use recursion to your advantage. Discover Clojure’s unique approach to state and identity, techniques for polymorphism and open systems using multimethods and protocols, and how to leverage Clojure’s metaprogramming capabilities via macros. Finally, put all the pieces together in a real program.

New to this edition is coverage of Clojure’s spec library, one of the most interesting new features of Clojure for describing both data and functions. You can use Clojure spec to validate data, destructure data, explain invalid data, and generate large numbers of tests to verify the correctness of your code.

With this book, you’ll learn how to think in Clojure, and how to take advantage of its combined strengths to build powerful programs quickly.

What You Need

  • Java 6 or higher
  • Clojure 1.9

Contents & Extracts

This book is currently in beta, so the contents and extracts will change as the book is developed.

  • Preface
  • Introduction
    • Who This Book Is For
    • What Is in This Book
    • How to Read This Book
    • Notation Conventions
    • Web Resources and Feedback
    • Downloading Sample Code
  • Getting Started
    • Simplicity and Power in Action
    • Clojure Coding Quick Start
    • Navigating Clojure Libraries
    • Wrapping Up
  • Exploring Clojure excerpt
    • Reading Clojure
    • Functions
    • Vars, Bindings, and Namespaces
    • Metadata
    • Calling Java
    • Comments
    • Flow Control
    • Where’s My for Loop?
    • Wrapping Up
  • Unifying Data with Sequences
    • Everything Is a Sequence
    • Using the Sequence Library
    • Lazy and Infinite Sequences
    • Clojure Makes Java Seq-able
    • Calling Structure-Specific Functions
    • Wrapping Up
  • Functional Programming excerpt
    • Functional Programming Concepts
    • How to Be Lazy
    • Lazier Than Lazy
    • Recursion Revisited
    • Eager Transformations
    • Wrapping Up
  • Specifications
    • Defining Specs
    • Validating Data
    • Validating Functions
    • Generative Function Testing excerpt
    • Wrapping Up
  • State and Concurrency
    • Concurrency, Parallelism, and Locking
    • Refs and Software Transactional Memory
    • Use Atoms for Uncoordinated, Synchronous Updates
    • Use Agents for Asynchronous Updates
    • Managing Per-Thread State with Vars
    • A Clojure Snake
    • Wrapping Up
  • Protocols and Datatypes
    • Programming to Abstractions
    • Interfaces
    • Protocols
    • Datatypes
    • Records
    • reify
    • Wrapping Up
  • Macros
    • When to Use Macros
    • Writing a Control Flow Macro
    • Making Macros Simpler
    • Taxonomy of Macros
    • Wrapping Up
  • Multimethods
    • Living Without Multimethods
    • Defining Multimethods
    • Moving Beyond Simple Dispatch
    • Creating Ad Hoc Taxonomies
    • When Should I Use Multimethods?
    • Wrapping Up
  • Java Interop
    • Exception Handling
    • Wrestling with the Integers
    • Optimizing for Performance
    • Creating Java Classes in Clojure
    • A Real-World Example
    • Wrapping Up
  • Building an Application
    • Scoring a Clojurebreaker Game
    • Testing the Scorer
    • test.generative
    • Creating an Interface
    • Deploying Your Code
    • Farewell
  • Bibliography

Author

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.

Stuart Halloway is a founder and president of Cognitect (formerly Relevance). He is a Clojure committer, and a developer of the Datomic database. Stuart has written a number of books and technical articles. Of these, he is most proud of Programming Clojure.

Aaron Bedra is CTO and CSO at Eligible. He is the creator of Repsheet, an open source threat intelligence toolkit, and a frequent open source contributor. He enjoys sharing his password with friends and family and wearing questionable hats.