- •Contents
- •Foreword
- •Acknowledgments
- •Preface
- •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
- •Why Clojure?
- •Clojure Coding Quick Start
- •Exploring Clojure Libraries
- •Introducing Lancet
- •Wrapping Up
- •Exploring Clojure
- •Forms
- •Reader Macros
- •Functions
- •Vars, Bindings, and Namespaces
- •Flow Control
- •Metadata
- •Wrapping Up
- •Working with Java
- •Calling Java
- •Optimizing for Performance
- •Creating and Compiling Java Classes in Clojure
- •Exception Handling
- •Adding Ant Projects and Tasks to Lancet
- •Wrapping Up
- •Unifying Data with Sequences
- •Everything Is a Sequence
- •Using the Sequence Library
- •Clojure Makes Java Seq-able
- •Adding Properties to Lancet Tasks
- •Wrapping Up
- •Functional Programming
- •Functional Programming Concepts
- •How to Be Lazy
- •Lazier Than Lazy
- •Recursion Revisited
- •Wrapping Up
- •Concurrency
- •The Problem with Locks
- •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
- •Making Lancet Targets Run Only Once
- •Wrapping Up
- •Macros
- •When to Use Macros
- •Writing a Control Flow Macro
- •Making Macros Simpler
- •Taxonomy of Macros
- •Making a Lancet DSL
- •Wrapping Up
- •Multimethods
- •Living Without Multimethods
- •Moving Beyond Simple Dispatch
- •Creating Ad Hoc Taxonomies
- •When Should I Use Multimethods?
- •Adding Type Coercions to Lancet
- •Wrapping Up
- •Clojure in the Wild
- •Automating Tests
- •Data Access
- •Web Development
- •Farewell
- •Editor Support
- •Bibliography
- •Index
- •Symbols
Acknowledgments
Many people have contributed to what is good in this book. The problems and errors that remain are mine alone.
Thanks to my co-workers at Relevance for creating an atmosphere in which good ideas can grow and thrive. Clojure helps answer questions that working at Relevance has taught me to ask.
Thanks to Jay Zimmerman and all the speakers and attendees on the No Fluff, Just Stuff conference tour. I have sharpened my ideas about Clojure in conversations with you all over the United States— sometimes in the formal sessions but equally often in the hotel bar.
Thanks to the kind folks on the Clojure mailing list1 for all their help and encouragement. Tom Ayerst, Meikel Brandmeyer, Bill Clementson, Brian Doyle, Mark Engelberg, Graham Fawcett, Steve Gilardi, Christophe Grand, Christian Vest Hansen, Rich Hickey, Mark Hoemmen, Shawn Hoover, Chris Houser, Parth Malwankar, J. McConnell, Achim Passen, Timothy Pratley, Randall Schulz, Stuart Sierra, Paul Stadig, Mark Volkmann, and many others helped with specific questions I had along the way.
Thanks to everyone at the Pragmatic Bookshelf. Thanks especially to my editor, Susannah Pfalzer, for good advice delivered on a very aggressive schedule. Thanks to Dave Thomas and Andy Hunt for creating a fun platform for writing technical books and for betting on the passions of their authors.
Thanks to all the people who posted suggestions on the book’s errata page.2 Special thanks to David Sletten for dozens of detailed, wideranging suggestions.
1.http://groups.google.com/group/clojure
2.http://www.pragprog.com/titles/shcloj/errata
Prepared exclusively for WG Custom Motorcycles
ACKNOWLEDGMENTS 13
Thanks to my many technical reviewers for all your comments. Craig Andera, Paul Barry, Aaron Bedra, Ola Bini, David Bock, Aaron Brooks, Tim Ewald, Andrey Fedorov, Steve Gilardi, Rich Hickey, Tom Hicks, Chris Houser, Scott Jaderholm, Scott Leberknight, Tim Riddell, Eric Rochester, Nate Schutta, Stuart Sierra, Brian Sletten, Paul Stadig, Travis Swicegood, Jeremy Sydik, and Joe Winter contributed numerous helpful suggestions.
Thanks to Rich Hickey for creating the excellent Clojure language and fostering a community around it.
Finally, thanks to my wife, Joey, and my daughters, Hattie, Harper, and Mabel Faire. You all make the sun rise.
Prepared exclusively for WG Custom Motorcycles
Report erratum
this copy is (P1.0 printing, May 2009)