Programming Clojure
Book information
Description
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. 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 higherClojure 1.9 Acknowledgments......Page 10 Introduction......Page 11 Who This Book Is For......Page 12 What’s in This Book......Page 13 How to Read This Book......Page 15 Notation Conventions......Page 17 Web Resources and Feedback......Page 19 Downloading Sample Code......Page 20 1. Getting Started......Page 21 Simplicity and Power in Action......Page 22 Clojure Coding Quick Start......Page 31 Navigating Clojure Libraries......Page 37 Wrapping Up......Page 41 2. Exploring Clojure......Page 42 Reading Clojure......Page 43 Functions......Page 50 Vars, Bindings, and Namespaces......Page 56 Metadata......Page 63 Calling Java......Page 65 Comments......Page 69 Flow Control......Page 70 Where’s My for Loop?......Page 74 Wrapping Up......Page 78 3. Unifying Data with Sequences......Page 79 Everything Is a Sequence......Page 81 Using the Sequence Library......Page 86 Lazy and Infinite Sequences......Page 96 Clojure Makes Java Seq-able......Page 99 Calling Structure-Specific Functions......Page 105 Wrapping Up......Page 114 4. Functional Programming......Page 115 Functional Programming Concepts......Page 116 How to Be Lazy......Page 121 Lazier Than Lazy......Page 130 Recursion Revisited......Page 136 Eager Transformations......Page 146 Wrapping Up......Page 151 5. Specifications......Page 152 Defining Specs......Page 155 Validating Data......Page 157 Validating Functions......Page 165 Generative Function Testing......Page 173 Wrapping Up......Page 178 6. State and Concurrency......Page 179 Concurrency, Parallelism, and Locking......Page 180 Refs and Software Transactional Memory......Page 182 Use Atoms for Uncoordinated, Synchronous Updates......Page 189 Use Agents for Asynchronous Updates......Page 191 Managing Per-Thread State with Vars......Page 197 A Clojure Snake......Page 202 Wrapping Up......Page 213 7. Protocols and Datatypes......Page 214 Programming to Abstractions......Page 215 Interfaces......Page 219 Protocols......Page 221 Datatypes......Page 226 Records......Page 232 reify......Page 238 Wrapping Up......Page 239 8. Macros......Page 240 When to Use Macros......Page 241 Writing a Control Flow Macro......Page 242 Making Macros Simpler......Page 249 Taxonomy of Macros......Page 255 Wrapping Up......Page 265 9. Multimethods......Page 266 Living Without Multimethods......Page 267 Defining Multimethods......Page 270 Moving Beyond Simple Dispatch......Page 274 Creating Ad Hoc Taxonomies......Page 276 When Should I Use Multimethods?......Page 281 Wrapping Up......Page 285 10. Java Interop......Page 286 Creating Java Objects in Clojure......Page 287 Calling Clojure From Java......Page 292 Exception Handling......Page 293 Optimizing for Performance......Page 298 A Real-World Example......Page 308 Wrapping Up......Page 312 11. Building an Application......Page 313 Getting Started......Page 314 Developing the Game Loop......Page 315 Representing Progress......Page 317 Implementing Players......Page 319 Interactive Play......Page 323 Documenting and Testing Your Game......Page 327 Farewell......Page 332 Bibliography......Page 333
Similar books
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF
The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians
1809 · PDF
Professional Linux kernel architecture ''Wrox programmer to programmer''--Cover. - ''What you are reading right now is the result of an evolution over more than seven years: After two years of writing, the first edition was published in German by Carl Hanser Verlag in 2003. It then described kernel 2.6.0. The test was used as a basis for the low-level design documentation for the EAL4+ security evaluation of Red Hat Enterprise Linux 5, requiring to update it to kernel 2.6.18 (if the EAL acronym does not mean anything to you, then Wikipedia is once more your friend). Hewlett-Packard sponsored the translation into English and has, thankfully, granted the rights to publish the result. Updates to kernel 2.6.24 were then performed specifically for this book''--P. ix
2008 · PDF