jakub holý

building the right thing, building it right, fast

Clojure for beginners

The key information, resources, community places, tools, and tricks you as a starting Clojure developer will find helpful.

(See the Clojure page for more and more general stuff.)

How to become truly productive in Clojure

You can be very productive with Clojure, much more than e.g. in Java thanks to its interactive development, simplicity, and powerful tools such as macros. However there are some preconditions, as Eric Normand writes in PurelyFunctional.tv Newsletter 266:

When you don’t have the stuff above (paren[these] management, integrated REPL, hot code reloading, and experience debugging the errors), the [development] cycle can be much slower than the descendants of punchcard languages.

So to really experience the productivity and pleasure of Clojure(Script), you need:

  1. Learn and fully embrace REPL-driven development (and debugging). Don’t underestimate this, it is a fundamental shift of how you develop. Most people struggle with this mind shift for a while.
  2. A tool to enable effective, productive (structural) editing of Clojure code, such as Parinfer (integrated in all popular Clojure editors)
  3. A good editor with an integrated REPL so that you can evaluate your code and interact with your running application in a frictionless way. Cursive (paid for commercial use) and Emacs (powerful but very steep and long learning curve) are the most popular, but there are also special ones for beginners such as Nightcode and (simpler, web-based) Lightmod. (Many editors have some Clojure support but the quality and depth and thus user experience vary a lot.)
  4. ClojureScript: hot code reloading (which shadow-cljs does perfectly (together with everything else you might need for frontend development)).
  5. Experience debugging errors - sadly you have to learn that though tools such as Ultra/Pretty (see below) and Expound for Spec do help. Pyro also looks great.
  6. Not to hesitate to ask for help and advice at the Clojurians Slack community :-)
  7. Understand Clojure philosophy and the Clojure way to approach and solve problems. Don’t try to apply what you learned in OOP/…, that would hurt. Understand the core principles and their benefits and downsides.

Learning Clojure

Learning Clojure is reportedly both easy and quick and a long-term process. New developers can start writing code within a few weeks but it might take months or years to master or Clojure core functions (you just keep stumbling on treasures in the core library) and to undo your OOP learning and start designing FP systems.

Getting started

The free online book Clojure for the Brave and True has been highly recommended to me for beginners. To get your hands dirty, go through the programming exercises at 4clojure and/or through the even more beginner (and non-programmer) friendly Maria: learn Clojure with Shapes.

Always keep the Clojure Cheatsheet close by and read through it (and the referenced resources) regularly. Make sure to study the Programming at the REPL guide early on (and perhaps invest in Eric Normand’s video course Repl-Driven Development in Clojure; the first lesson is free, so check it out.)

I would also highly recommend reading the first chapter about Clojure philosophy from Joy of Clojure.

Last but not least: remember that you don’t need to learn all at once. You will most likely never need STM or agents (atoms are perfect for perhaps 99% state management needs, use core.async for non-trivial async needs) so feel free to skip those, at least for now. Datatypes and protocols and multimethods are something you will eventually need but you can likely get very far without them. Similarly, macros, transients, transducers, reducers, compilation and class generation can wait until you need them, certainly a few months.

Leveling up

Ok, so you know the language and want to learn how to create systems and to deepen your understanding. Check out these:

  • Clojure Applied: From Practice to Practitioner by Ben Vandgrift, Alex Miller (2015) - even in 2019 this is the best and still highly relevant book about building systems in Clojure, tackling topics such as namespace organization, creating and connecting components, composing applications, handling configuration.
  • Elements of Clojure by Zachary Tellman (2018) - “It provides a framework for making better design choices, and a vocabulary for teams to discuss the software they collaborate on.”
  • Programming Clojure 3rd edition by Alex Miller, Stuart Halloway, Aaron Bedra (2018) - a handy, comprehensive reference

See all Clojure books at the Clojure site.

Resources for beginners

Official sources

Help & learning

Community, advice, fora

  • Clojurians - the official Slack organization with channels for Clojure, ClojureScript, and most popular libraries and topics. Leading developers and authors often answer questions.
  • Clojure and ClojureScript Google Groups - for advice, announcements, keeping informed
  • Clojureverse - friendly discussion fora
  • Newsletters to keep updated about the latest development, useful libraries, etc.

  • Podcasts

    • Cognicast by Cognitect, the company behind Clojure - interviews with interesting people
    • defn - “A loud, irreverent podcast discussing the delights of Clojure, ClojureScript with leaders and folks of the Community”

Beginner-friendly tools and starting packages

  • Beginner-friendly, all-in-one. getting-started IDEs: Nightcode and (simpler, web-based) Lightmod
  • Professional dev environments: The most popular tools for developing in Clojure(Script) are Emacs with Cider and IntelliJ with Cursive. But people also use VS Code with Calva (and Bracket Pair Colorizer) and Atom with Chlorine.
  • Web dev: Luminus is the recommended web “framework,” i.e. a curated and integrated set of libraries for web (backend and frontend) development in Clojure(Script) (developer tools, logging, security etc). So that you don’t need to assemble your own.
  • Editing code

    • Parinfer - provides for efficient and simple structural editing of Clojure/Lisp code using just Tab (compared to the older Paredit with its numerous key-bindings). A must-have for efficient and productive experience with any Lisp.
  • Building and running code

    • Ultra - a Leiningen (the primary Clojure build tool) plugin for an absolutely kick-ass development environment (i.e. REPL) - better stack-traces (via Pretty), human-friendly test output, colors, syntax-highlighting.