Evolving environment tooling the bare repl eclipse emacs table contents


Clojure Programming
by Chas Emerick, Brian Carper, and Christophe Grand
Copyright © 2012 Chas Emerick, Brian Carper, and Christophe Grand. All rights reserved. Printed in the United States of America.
Revision History for the First Edition:
2012-03-28 First release
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information con-tained herein.
ISBN: 978-1-449-39470-7
1. Down the Rabbit Hole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
|
|---|
|
|
|---|
|
|---|
iv | Table of Contents
In Summary 157
4. Concurrency and Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
|
|---|
Debugging Macros 237
Macroexpansion 237
Hygiene 244
Gensyms to the Rescue 246
&env 252
&form 254
Protocols 264
Extending to Existing Types 266
Inline Implementation 281
Reusing Implementations 285
7. Multimethods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
|
|---|
|
|---|
Part III. Tools, Platform, and Projects
|
|---|
Table of Contents | vii
12. Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 Dependency Injection 459 Strategy Pattern 462 Chain of Responsibility 463 Aspect-Oriented Programming
466 Final Thoughts 47013. Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
14. Using Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
| Download from Wow! eBook <www.wowebook.com> |
|
491 |
|---|---|---|
| 494 | ||
| 496 | ||
| 496 | ||
| 498 | ||
|
498 | |
|
499 | |
| 500 | ||
| 503 | ||
| 503 | ||
| 506 | ||
|
506 | |
|
507 | |
| 509 | ||
| 512 | ||
| 512 | ||
|
514 | |
|
514 | |
| 516 | ||
| _changes: Abusing CouchDB as a Message Queue | 520 | |
| 522 | ||
| 525 | ||
|
527 | |
|
529 | |
| 529 | ||
| 531 | ||
| 532 | ||
| 534 | ||
|
535 | |
|
545 | |
| 546 | ||
| 554 | ||
|
|---|
Table of Contents | ix
19. Introducing Clojure into Your Workplace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Just the Facts… 577
(dissoc Clojure 'JVM) 583
ClojureCLR 583
Pallet 586
Avout 587
Clojure is a dynamically and strongly typed programming language hosted on the Java Virtual Machine (JVM), now in its fifth year. It has seen enthusiastic adoption by pro-grammers from a variety of backgrounds, working in essentially all problem domains. Clojure offers a compelling mix of features and characteristics applicable to solving modern programming challenges:
• Functional programming foundations, including a suite of persistent data struc-tures with performance characteristics approaching typical mutable data structures
Clojure offers a compelling practical alternative to many who strain against the limi-tations of typical programming languages and environments. We aim to demonstrate this by showing Clojure seamlessly interoperating with existing technologies, libraries, and services that many working programmers already use on a day-to-day basis. Throughout, we’ll provide a solid grounding in Clojure fundamentals, starting from places of common expertise and familiarity rather than from (often foreign) computer science first principles.
Who Is This Book For?
Engaged Java Developers
There are millions of Java developers in the world, but some fewer number are working in demanding environments solving nontrivial, often domain-specific problems. If this describes you, you’re probably always on the hunt for better tools, techniques, and practices that will boost your productivity and value to your team, organization, and community. In addition, you’re probably at least somewhat frustrated with the con-straints of Java compared to other languages, but you continue to find the JVM eco-system compelling: its process maturity, massive third-party library selection, vendor support, and large skilled workforce is hard to walk away from, no matter how shiny and appealing alternative languages are.
![]() |
|
|
|---|---|---|
| • |
|
|
| • | ||
| • | ||
In formulating our approach to this book, we wanted to provide a fair bit of concrete detail and practical examples that you could relate to, but stay clear of what we thought were generally unsuccessful approaches for doing so. In particular, we’ve been frus-trated in the past by books that attempted to thread the implementation of a single program or application through their pages. Such approaches seem to result in a dis-jointed narrative, as well as the dominance of a tortured “practical” example that may or may not apply or appeal to readers.
With that in mind, we split the book in two, starting with foundational, instructional narrative that occupies roughly two-thirds of the book, followed in Part IV by a number of discrete, practical examples from real-world domains. This clear segmentation of content with decidedly distinct objectives may qualify this book as a “duplex book.”(This term may have been coined by Martin Fowler in .) In any case, we can conceive of two obvious approaches to reading it.
Preface | xiii
Who’s “We”?
The founder of Snowtide (), a small software company in Western Massachusetts, Chas’s primary domain is unstructured data extraction, with a partic-ular specialty around PDF documents. He writes about Clojure, software development, entrepreneurship, and other passions at .
Brian Carper
As an independent consultant, he develops, coaches, and offers training in Clojure. He also writes about Clojure at .
xiv | Preface
The quality of this book would be far less than it is were it not for the efforts of our technical reviewers, including Sam Aaron, Antoni Batchelli, Tom Faulhaber, Chris Granger, Anthony Grimes, Phil Hagelberg, Tom Hicks, Alex Miller, William Morgan, Laurent Petit, and Dean Wampler. We’d also like to thank all of those who provided feedback and comments on the early releases and Rough Cuts of the book, both on the O’Reilly forums and via email, Twitter, and so on.
Michael Fogus and Chris Houser have inspired us in many ways large and small. One of the smaller ways was the style and presentation of the REPL interactions in their Clojure book, The Joy of Clojure, which we shamelessly copied and iterated.
To my parents, Charley and Darleen: my compulsive curiosity about how things work, my love of language and rhetoric, and my interest in business—all of these can be traced back over the years to your consistent influence. Without it, I am certain I would not have found my unique path, started a software company, or written this book, each done against all odds.
Preface | xv
—Brian Carper, February 2012
To Rich Hickey for creating Clojure and fostering such a friendly community. To this community for having brought me to higher standards.To my coauthors, Brian and Chas: it has been a great honor to work with you. A mon professeur Daniel Goffinet, et à ses exercices improbables, qui a radicalement changé mon approche de la programmation et de l’informatique—sur ces sujets je lui suis plus redevable qu’à nul autre.
xvi | Preface
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
|
|---|
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Clojure Programming by Chas Emerick, Brian Carper, and Christophe Grand (O’Reilly). Copyright 2012 Chas Emerick, Brian Carper, and Christophe Grand, 978-1-449-39470-7.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .
| Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to |
|---|
O’Reilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from O’Reilly and other pub-lishers, sign up for free at .
How to Contact Us
To comment or ask technical questions about this book, send email to:
For more information about our books, courses, conferences, and news, see our website at .





