Chapter 2. Drinking from the Clojure fire hose
This chapter covers
- Scalars: the base data types
- Putting things together: collections
- Making things happen: functions
- Vars are not variables
- Locals, loops, and blocks
- Preventing things from happening: quoting
- Using host libraries via interop
- Exceptional circumstances
- Modularizing code with namespaces
This chapter provides a quick tour of the bare necessities—the things you’ll need to know to understand the rest of this book. It may seem odd to provide a tutorial-like chapter right away, but we felt that it was more important to introduce the ideas of the language first rather than the mechanics.[1] If you’ve been programming with Clojure for a while, this may be a review, but otherwise it should give you everything you need to start writing Clojure code. In most cases throughout this chapter, the examples provided will be perfunctory in order to highlight the immediate point. Later in the book, we’ll build on these topics and many more, so don’t worry if you don’t grasp every feature now—you’ll get there.
1 Clojure is a language built on thoughtful design. In many ways, we see the ideas behind Clojure’s design as more important than the language itself.
Interaction with Clojure is often performed at the Read-Eval-Print Loop (REPL). When starting a new REPL session, you’re presented with a simple prompt: