Programming in Clojure
Programming in Clojure
Quickly get up to speed with this modern and powerful Lisp based JVM language
About the Book
Hello, thanks for stopping by and checking out my book about the Clojure programming language. If you have any questions then please feel free to contact me and I'll try to get back to you within a reasonable time frame.
Why write this book?
After I finished writing the (printed) book "Pro Vim" for Apress Publishing, I had decided I didn't want to write another book because quite frankly it can be a bit soul destroying. You make no money from it and it takes an unbelievable amount of time and effort to write something of decent quality.
So why go through that process again?
Well, I felt it needed to be written. I've bought lots of Clojure books - both printed and self-published (either via Leanpub or other means) - and there are some great books out there, but I felt they were overly complicated and focused on things I as a beginner Clojure developer either wasn't interested in or was stuff I was never going to use (and not just me, other people I know who have read the same books would claim a similar feeling, and in some cases felt they were being spoken down to by the author).
So my aim with this book was to make it useful for people like me (at the end of the day who else are you better posed to write for than yourself). But more so, I've always held the belief that I am the lowest common denominator; i.e. if I can understand it, then anyone can.
Who's the book aimed at?
This book is aimed at anyone who has written code. Not back-end or front-end but anyone who has written code. Where ever possible I try not to assume the reader has knowlege of the same things I do, and so I aim to explain things in as simple a form as possible (again, if I can understand it, then anyone can).
This book is also useful for anyone that looked at Clojure in the past and then was put off by the idea it was too complicated. Clojure is just a programming language like any other. The fact that it looks a little different (i.e. it's a Lisp based language - I cover this in the book) doesn't mean it's difficult to learn or write.
I was worried when I first saw Clojure because of a few reasons, but the main two were: it looked complex! but when I learnt the syntax I realised how amazingly straight forward it actually is and second: the amount of parenthesis! but almost immediately after writing some Clojure code for the first time I realised how not a problem this was and in fact Lisp code can be really beautiful, concise and elegant.
Don't be fooled into thinking this is just a top level look at the language, it's not! For a small read (152 pages at last count) it goes quite deep in places where I feel it necessary, and that's in order to help you to really understand specific features within the language. Only then can you properly take advantage of these features, when you know them intimately.
I kick-start with what Clojure is and why you should care (many of you may have heard of it, and that it's functional but not much else). Unlike some books on the subject I don't waste pages and pages on this because quite frankly you want to get started learning Clojure syntax and how to get up and running, not learn the history of the language and where its inspirations come from (hell that's what Google's for).
I move swiftly onto data structures and the general language syntax, then to functional programming (FP) concepts. Although not critical to getting code to work, understanding FP is essential for writing concise and elegant code. I then discuss the concept of sequences, destructuring, pattern matching, polymorphism (yep, you know, that word you might have heard used a lot in Object-Oriented design).
I spend a fair amount of time on the subject of concurrency, as it's an important feature and selling point of the Clojure language. Everything from delays, promises, futures, atoms, locks, agents, refs, channels - and I aim to make understanding the when as important as the what (in the beginning, writing my first Clojure application I didn't really understand the difference between let's say an atom or a ref, or what the difference was between promises and futures? nothing I read on the internet really helped to explain it in a simple/clear way - so this was another reason I wanted to write this book).
I discuss how Namespaces work in Clojure (again, this is an underplayed important part of writing applications); I explain how you can add your own features into the language thanks to its built-in Macro system. I also look at Object-Oriented Programming techniques available in Clojure (yes Clojure aims to be a functional language, but it's not a "pure" one, and on top of that it tries to be a bit more practical in terms of real-world usage by incorporating some useful OOP concepts too).
I then look at the popular Leiningen project management tool. Explain how it all works and how to use it (you'll pretty much use it all the time so it's important to understand how it all comes together). As part of this I explain how to build a very simple "hello world" web application to help get you started with Leiningen (the idea being that web applications are a book unto itself - but learning the basics really sets you up properly for building all types of applications using Leiningen).
We'll then detour slightly from the use of a REPL (which I use for the majority of the book - as it helps make it easier to test example code I present in the book) and I'll explain how you can write and run code directly within Vim (a popular text editor - see Pro Vim if you'd like to learn more)
Finally, I show you how to create a simple command line application, just to demonstrate the diversity of the Clojure eco-system.
What's with the cover art?
Clojure to me always seemed scary from the outside? When reading some Clojure books I felt a little like I was stuck in a little dingy lost out in choppy waters and so this cover seemed to represent the mood I think a lot of people have when they come to Clojure initially.
But the specific imagery has a "hopeful" quality to it. You have the dark brooding sea below but above clear bright skys above you, signalling sunshine and warmth. The horizon also helps give a feeling of endless breadth and possibility (much like the Clojure language itself).
Sure, it's a bit of a hippy sounding explanation - but hey, it's just a picture right. What's important is the book contents. So go read it! :-)
What is Clojure?
- Why should you care?
- The name?
- Getting started
Data Structures and Syntax
- Vars and Symbols
- Referential transparency
- First-class functions
- Partial Application (and Currying)
- Recursive iteration
- List Comprehension
- Sequence Abstraction
- Lazy Sequences
- Pattern Matching
- Thread Safe
Organisation with Namespaces
- What is a namespace?
- Loading namespaced files
Change the language via Macros
- Expanding all the way down
- Writing your own Macros
Projects with Leiningen
- 10 second example
- Project file
- Different flavours of Compojure?
- Real world example
- Getting your code ready for deployment
- Where to next?
Creating Command Line Apps
- Running via Leiningen
- Running via Jar
- Running via Binary
- Understanding the CLI code
Writing Clojure from Vim
- Rainbow Parentheses
- Sexp Mappings for Regular People
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
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
El Manual del ManagerKeyvan Akbary, Félix López, and Álvaro Salazar
¿Has deseado alguna vez el haber tenido una buena introducción al rol del Engineering Manager? En este libro aprenderás lo necesario para ejercer el rol de una manera efectiva: Expectativas y Responsabilidades del Rol, 1-1s, Ayudar a Crecer, Objetivos, Planes de Carrera, Cultura, Feedback, Contratación, Cultura de Producto y mucho más.
Ansible for KubernetesJeff Geerling
Ansible is a powerful infrastructure automation tool. Kubernetes is a powerful application deployment platform. Learn how to use these tools to automate massively-scalable, highly-available infrastructure.
Functional Design and ArchitectureAlexander Granin
Software Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
CCIE Service Provider Version 4 Written and Lab Exam Comprehensive GuideNicholas Russo
The service provider landscape has changed rapidly over the past several years. Networking vendors are continuing to propose new standards, techniques, and procedures for overcoming new challenges while concurrently reducing costs and delivering new services. Cisco has recently updated the CCIE Service Provider track to reflect these changes; this book represents the author's personal journey in achieving that certification.
CCIE SP v4.1 - WorkbookŁukasz Bromirski, Piotr Jablonski, and Nicholas Russo
Are you striving to prepare to and pass CCIE SP lab exam? Take the opportunity and get this workbook! With the attached initial cfg files you will prepare yourself for the CCIE SP exam as well as learn SP technologies applicable to all kinds of today modern networks! This workbook covers blueprint topics and provides challenging examples.
Ansible for DevOpsJeff Geerling
Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Code Faster in DelphiAlister Christie
This book will make you a faster Delphi developer, it doesn't matter if you are just starting out, or have been using Delphi since version 1, you will find all sorts of tips, tricks and hacks to boost your productivity.
R Programming for Data ScienceRoger D. Peng
This book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Composing SoftwareEric Elliott
All software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
The Hundred-Page Machine Learning BookAndriy Burkov
Everything you really need to know in Machine Learning in a hundred pages.
11 BooksIn this bundle, you will find 10 different agile books. They are about different aspects of being agile. - finding a job - doing coding dojo's - Retrospectives - Personal kanban - a non-typical coaching book and even a book that gives you an insight in the lives of some agile people.
WTFlop 6M + HU - Beta Bundle
Fifty Quick Ideas
3 BooksGet all three books for the price of two! Fifty Quick Ideas books are full of practical, real-world techniques that you can use to improve teamwork, build better products and build them in a better way.
Growing Agile: Coach's Guide Series
4 BooksThis bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity instructions to run a number of...
Marionette.js A to Z
Build A Better Backbone App
3 BooksThe best way to learn new development skills is through experience, but that takes time you don't have.Get the best of both worlds with this bundle: you'll learn how to produce modern web applications by learning from experienced developers like Derick Bailey and David Sulc. BackboneJS is one of the favorite tools on the web today, but it...
People Skills—Soft but Difficult
7 BooksPerhaps you've been told that "lack of people skills" has been holding you back. No wonder: you may have had hundreds of hours of technical training, but little or no "people skills" guidance.You've heard it said that people skills are "soft," whereas technical skills are "hard." For you, though, technical skills are "easy," but people skills...
SurviveJS - Webpack + React
2 BooksGet both SurviveJS - Webpack and SurviveJS - React for a single price!
Experiential Learning Bundle
4 BooksThis bundle provides all four volumes of the popular Experiential Learning Series at a savings of $20 over the price if purchased separately.