Clojure for the Brave and True
( a Book for Beginners )
Spending your nights pining for the next chapter of Clojure for the Brave and True? Then follow @nonrecursive or get email updates:
Buy the DRM-free PDF, epub, and mobi!

Introduction

*Clojure!*

For weeks, months — no! from the very moment you were born — you've felt it calling to you. Every time you've held your keyboard aloft, crying out in anguish over an incomprehensible class hierarchy; every time you've lain awake at night, disturbing your loved ones with sobs over a mutation-induced heisenbug; every time a race condition has caused you to pull out more of your ever-dwindling hair, some secret part of you has known that there has to be a better way.

Now, at long last, the instructional material you have in front of your face will unite you with the programming language you've been longing for.

Are you ready, brave reader? Are you ready to meet your true destiny? Grab your best pair of parentheses: you're about to embark on the journey of a lifetime!

Journey through the Four Labyrinths

To wield Clojure to its fullest, you will need to find your way through the four labyrinths confronting every programmer learning a new language:

Make no mistake: you will work. But this book will make the work feel exhilarating, not exhausting. That's because this book does three things:

By the end, you'll be able to use Clojure, one of the most exciting and fun programming languages in existence!

Part 1: Environment Setup

In order to stay motivated and learn efficiently, you need to be able to actually try things out and build executables. No running code in a browser for you!

Building, Running and the REPL

There's something powerful and motivating about getting a real program running. Once you can do that, you're free to experiment and you can actually share your work!

In this short chapter, you'll invest a small amount of time up front to get familiar with a quick, problem-free way to build and run Clojure programs. You'll also learn how to instantly experiment with code within a running Clojure process using a REPL. This will tighten your feedback loop, allowing you to learn more efficiently.

Read "Building, Running, and The REPL"

Using Emacs for Clojure development

Having a quick feedback loop is so important for learning that we cover Emacs from the ground up so that you're guaranteed to have an efficient Emacs/Clojure workflow.

Read "Start Using Emacs"Read "Using Emacs with Clojure"

Part 2: Language Fundamentals

The goal of this section is to provide you with a solid foundation on which to continue learning Clojure. You'll start by learning how to actually do things, and then take a step back to understand the underlying concepts.

Do Things

While you've undoubtedly heard of Clojure's awesome concurrency support and other stupendous features, Clojure's most salient characteristic is that it is a Lisp. We're going to explore this Lisp core. And this core is comprised of two parts: functions and data.

Read "Do Things"

Core Functions in Depth

In this chapter, you'll learn about a couple of Clojure's underlying concepts. This will give you the grounding you need to read the documentation for functions you haven't used before and to understand what's happening when you give them a try.

You'll also see usage examples of the functions you'll be reaching for the most. This will give you a solid foundation for writing your own code and reading and learning from others' projects.

Read "Core Functions in Depth"

Functional Programming

In this chapter, you'll begin to take your concrete experience with functions and data structures and integrate it in a new mindset, the functional programming mindset.

Read "Functional Programming"

Clojure Alchemy: Reading, Evaluation, and Macros

In this chapter, we'll take a step back and describe how Clojure runs your code. This will give you the conceptual structure needed to truly understand how Clojure works and how it's different from other, non-lisp languages. With this structure in place, we'll introduce the macro, one of the most powerful tools in existence.

Read "Clojure Alchemy: Reading, Evaluation, and Macros"

Writing Macros

This chapter thoroughly examines how to write macros starting with basic examples and moving up in complexity. We'll close by donnig our make-believe caps, pretending that we run an online potion store and using macros to validate customer orders.

Read "Writing Macros"