Elements of Clojure
This book is 100% complete
Completed on 2018-12-16
About the Book
This book tries to put words to what most experienced programmers already know. This is necessary because, in the words of Michael Polanyi, "we can know more than we can tell." Our design choices are not the result of an ineluctable chain of logic; they come from a deeper place, one which is visceral and inarticulate.
Polanyi calls this "tacit knowledge", a thing which we only understand as part of something else. When we speak, we do not focus on making sounds, we focus on our words. We understand the muscular act of speech, but would struggle to explain it.
To write software, we must learn where to draw boundaries. Good software is built through effective indirection. We seem to have decided that this skill can only be learned through practice; it cannot be taught, except by example. Our decisions may improve with time, but not our ability to explain them.
It's true that the study of these questions cannot yield a closed-form solution for judging software design. We can make our software simple, but we cannot do the same to its problem domain, its users, or the physical world. Our tacit knowledge of this environment will always inform our designs.
This doesn't mean that we can simply ignore our design process. Polanyi tells us that tacit knowledge only suffices until we fail, and the software industry is awash with failure. Our designs may never be provably correct, but we can give voice to the intuition that shaped them. Our process may always be visceral, but it doesn't have to be inarticulate.
And so this book does not offer knowledge, it offers clarity. It is aimed at readers who know Clojure, but struggle to articulate the rationale of their designs to themselves and others. Readers who use other languages, but have a passing familiarity with Clojure, may also find this book useful.
The first chapter, Names, explains why names define the structure of our software, and how to judge whether a name is any good.
The second chapter, Idioms, provides specific, syntactic advice for writing Clojure which is clean and readable.
The third chapter, Indirection, looks at how code can be made simpler and more robust through separation.
The final chapter, Composition, explores how the constituent pieces of our code can be combined into an effective whole.
If you'd like to discuss the book, visit the mailing list.
- Naming Data
- Naming Functions
- Naming Macros
When using inequalities, prefer
- If a function accumulates values, support every arity
- Use option maps, not named parameters
No one should have to know you’ve used
If you have mutable state, use an
doblock implies side effects
- Use the narrowest possible data accessor
letfnfor mutual recursion
- Java interop should be obvious
forto create cartesian products
nilshould be the absence of only a few values
- When using inequalities, prefer
- Method Dispatch
- What is an Abstraction?
- A Model for Modules
- Consequences of our Model
- Systems of Modules
- A Unit of Computation
- Building a Process
- Composing Processes
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...