ebook img

Programming Clojure PDF

341 Pages·2017·1.626 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Programming Clojure

Programming Clojure, Third Edition by Alex Miller, with Stuart Halloway, and Aaron Bedra Version: P1.0 (February 2018) Copyright © 2018 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trust—you can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein. About the Pragmatic Bookshelf The Pragmatic Bookshelf is an agile publishing company. We’re here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com. Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while it’s still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. We’re here to make your life easier. New Book Announcements Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog. About Ebook Formats If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/shcloj3, the book's homepage. Thanks for your continued support, Andy Hunt The Pragmatic Programmers The team that produced this book includes: Andy Hunt (Publisher), Janet Furlow (VP of Operations), Brian MacDonald (Managing Editor), Jacquelyn Carter (Supervising Editor), Paula Robertson (Copy Editor), Potomac Indexing, LLC (Indexing), Gilson Graphics (Layout) For customer support, please contact [email protected]. For international rights, please contact [email protected]. Table of Contents Acknowledgments Introduction Who This Book Is For What’s in This Book How to Read This Book Notation Conventions Web Resources and Feedback Downloading Sample Code 1. Getting Started Simplicity and Power in Action Clojure Coding Quick Start Navigating Clojure Libraries Wrapping Up 2. Exploring Clojure Reading Clojure Functions Vars, Bindings, and Namespaces Metadata Calling Java Comments Flow Control Where’s My for Loop? Wrapping Up 3. 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 4. Functional Programming Functional Programming Concepts How to Be Lazy Lazier Than Lazy Recursion Revisited Eager Transformations Wrapping Up 5. Specifications Defining Specs Validating Data Validating Functions Generative Function Testing Wrapping Up 6. 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 7. Protocols and Datatypes Programming to Abstractions Interfaces Protocols Datatypes Records reify Wrapping Up 8. Macros When to Use Macros Writing a Control Flow Macro Making Macros Simpler Taxonomy of Macros Wrapping Up 9. Multimethods Living Without Multimethods Defining Multimethods Moving Beyond Simple Dispatch Creating Ad Hoc Taxonomies When Should I Use Multimethods? Wrapping Up 10. Java Interop Creating Java Objects in Clojure Calling Clojure From Java Exception Handling Optimizing for Performance A Real-World Example Wrapping Up 11. Building an Application Getting Started Developing the Game Loop Representing Progress Implementing Players Interactive Play Documenting and Testing Your Game Farewell Bibliography Copyright © 2018, The Pragmatic Bookshelf. Early praise for Programming Clojure, Third Edition Programming Clojure is an inspiration of Clojure knowledge and has furthered my understanding of the nuances of Clojure. One of the new sections includes a step-by- step on building an application that made me want to drop everything and code along. →Nola Stowe CTO/Founder, Ruby Geek LLC If you are interested in learning the ins and outs of the Clojure language, Programming Clojure will provide you with a valuable resource. The book not only covers the basics of the language, but also builds on the basics to allow readers to understand and apply more advanced concepts like spec and macros. →Joy Clark Consultant, innoQ Deutschland GmbH This book is very effective at teaching Clojure’s unique take on functional programming and data manipulation. It explains concepts clearly and covers the mechanics of nearly every part of the language, with helpful commentary that goes beyond the code. →Ghadi Shayban Engineer, healthfinch The third edition of Programming Clojure is an excellent resource for new and old Clojure programmers. It provides a thorough account of the language’s rationale and features, including approachable explanations of more recent features like transducers and spec. →Michael Fogleman Developer Acknowledgments Many people have contributed to what is good in this book. The problems and errors that remain are ours alone. Thanks to Rich Hickey for creating the excellent Clojure language and fostering a community around it. Thanks to the awesome team at Cognitect (formerly Relevance) for creating an atmosphere in which good ideas can grow and thrive. Thanks to the Clojure community for using Clojure and turning an idea into a working ecosystem. Thanks to all the readers and technical reviewers who have suggested improvements across all three editions of the book. Jeff Brown suggested the coin toss problem in Lazier Than Lazy​. David Liebke wrote the original content for Chapter 7, ​Protocols and Datatypes​. Thanks to everyone at Pragmatic Bookshelf. Thanks especially to our editor, Jacquelyn Carter, and former editors Michael Swaine and Susannah Pfalzer for focus and advice. Thanks also to Dave Thomas and Andy Hunt. Thanks to my wife and family for their love, support, and the precious gift of time to create.—Alex Thanks to my wife, Joey, and to my children, Hattie, Harper, Mabel Faire, and Truman. You all make the sun rise.—Stuart Thanks to my wife, Erin, for endless love and encouragement.—Aaron Copyright © 2018, The Pragmatic Bookshelf.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.