Clojure for beginners
- How to become truly productive in Clojure
- Learning Clojure
- Resources for beginners
- Beginner-friendly tools and starting packages
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.)
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:
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.
A tool to enable effective, productive (structural) editing of Clojure code, such as Parinfer (integrated in all popular Clojure editors)
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.)
ClojureScript: hot code reloading (which shadow-cljs does perfectly (together with everything else you might need for frontend development)).
Not to hesitate to ask for help and advice at the Clojurians Slack community :-)
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 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.
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.
The 14min video Clojure Syntax - The odd bits introduces the weird symbols of Clojure, such as
! in function names,
* around a var name,
& before an argument,
#(some-fn …) etc. It will make reading Clojure less confusing.
Ok, so you know the language and want to learn how to create systems and to deepen your understanding. Let’s get started!
Tip: A gradual approach works best. Don’t try to learn too much at once. Start with a simple, Clojure-only server, perhaps only using Ring and Hiccup and nothing more. Then add a routing library, … . Integrate with a database and/or an external API. Only when you are really comfortable with this, start with ClojureScript and its complexities. Personally I recommend using ClojureScript with shadow-cljs because it is an all-in-one tool (build, REPL, …) focused on developer ergonomics, with a great documentation and active support. Start perhaps with a simple React wrapper such as Reagent.
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.
A great way to learn is by studying code.
seancorfield/usermanager-example - This is a simple web application using Component, Ring, Compojure, and Selmer connected to a local SQLite database. Intended as a demonstration for beginners.
next.jdbc - a Clojure wrapper for JDBC, created in 2019 to replace clojure/java.jdbc based on many years of experiences with maintaining and developing it, by a very skilled developer.
Help & learning
ClojureDocs - the language function documentation with examples
cljdoc - documentation and API docs of Clojure libraries
Maria: learn Clojure with Shapes - a cool, beginner-friendly ClojureScript notebook-style editor with a built-in introduction to Clojure(Script) using graphical programming
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.
Clojureverse - friendly discussion fora
Newsletters to keep updated about the latest development, useful libraries, etc.
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.
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