What is the 20% of Clojure needed to build 80% of CRUD Apps?

I’m a novice programmer interested in web dev, basic sites with an index page, show pages, item filtering, search, auth, and a db. (zero plans for a career in development).

I know basic HTML, CSS, JS, and SQL with a slightly deeper understanding of Elixir and Phoenix. I’m drawn to the simplicity of Clojure as an escape from frameworks, arbitrary syntax and OOP.

Clojure wise, I’ve done a short udemy course and a few other small tutorials. For my main learning resource I’ve settled on
The Clojure Workshop I found it to be the most practical and up to date Clojure book, that doesn’t teach frameworks.

The Problem
At 700+ pages, with everything from hello world to macros it feels comprehensive to a fault. My naive intuition is that there’s a subset of Clojure concepts that if learned, would give me out-sized returns compared to the rest.

I’m including a list of the books contents and I’d be grateful for any feedback on which chapters/concepts could be strategically ignored from the POV of an aspiring Clojure CRUD maker?

  1. Hello REPL! (def, let, booleans, repl basics)

  2. Data Types and Immutability (maps, sets, vectors, lists)

  3. Functions in Depth (destructing, higher-order functions, multi-methods)

  4. Mapping and Filtering (map, filter, lazy evaluation)

  5. Many to One: Reducing (zipmap, group by, reduce)

  6. Recursion and Looping (loop, doseq, recur, take, repeatedly, iterate)

  7. Recursion II: Lazy Sequences (lazy-seq, thunks)

  8. Namespaces Libraries and Leiningen

  9. Host Platform Interoperability with Java and JavaScript (exceptions, errors)

  10. Testing

  11. Macros

  12. Concurrency (pmap, futures, atoms, refs, agents)

  13. Database Interaction and the Application Layer (JDBC, SQL, Connection pools)

  14. HTTP with Ring

  15. The Frontend: A ClojureScript UI (reagent, HTTP endpoints)

Full list of chapters and lessons is available here:

*cross posted in slack and reddit

80/20 for the uninitiated :

I’ll repeat my (long) answer from Slack for the benefit of searchability (and the folks that may not be on Slack):

First off, I’ll say that, unfortunately, Packt books are generally terrible. They’re poorly edited, often contain a lot of bad code and mistakes, and can be pretty outdated.

“Getting Clojure” is heavily recommended on Slack for beginners. “Programming Clojure” is also a good book to get you up and running with Clojure. And then, as a follow-on book to either of those, “Clojure Applied” (but don’t get too hooked on the emphasis it gives to records – that’s something the author would change for a second edition).

For building simple web apps, backed by a database, I’d recommend either:

  • Ring, Compojure, Component, Selmer, next.jdbc, or
  • Ring, reitit, Integrant, Selmer, next.jdbc.

There’s an example of the former at GitHub - seancorfield/usermanager-example: A little demo web app in Clojure, using Component, Ring, Compojure, Selmer (and a database) and it links to an example of the latter, created from the former, by the community.

All that said, to your original question, I’d say for what you are aiming at – simple, database-backed web apps – you would skip 7, parts of 9, 11, 12, 15. I’d recommend learning the Clojure CLI / deps.edn / tools.build instead of Leiningen (partly because they’re are a set of small, composable tools – so they have a more modern design – and they’re all from the core Clojure team so they’re documented on clojure.org).

That usermanager has just been updated to include build.clj and show how to use tools.build to run tests and build an uberjar (tonight).

10 Likes

I totally second @seancorfield on “Getting Clojure” > Clojure Workshop. Having worked through both books, “Getting Clojure” is definitely a lot clearer on explaining the language. For Clojure Workshop, I found myself asking “why did they do this??” half the time, without any clarity.

I would add that, for Web Development, there are two additional resources:

  1. Dmitry Sotnikov’s Web Development with Clojure is a pretty good book, with detailed examples that are worked through (though the app they are building in the book is perhaps a bit complex for your purposes)

  2. Eric Normand’s website has a no of free materials e.g. ClojureScript + Reagent Tutorial with Code Examples and Roll your own Clojure web stack

1 Like

My advice is to use the Feynman learning style.

Pretend like you’re already an expert and know Clojure. Start working on the project/task you want to accomplish. As you start working, whenever you find a gap in knowing how to proceed, go learn just enough to allow you to proceed to the next step. Rince and repeat.

Bonus points if after you’ve moved to the next step, you take some time to teach someone else about the part you just learned. If as you teach you realize they’re details you can’t explain, you can go research those some more.

So in your case, start making a website, and go research the parts you get stuck at only to the extent you need to get unstuck.

That’s how you minimize how much you have to learn, you specialize your learning efforts to the task at hand and only to what you need to know for it.

5 Likes

that’s great advice! thanks for sharing!

Thanks to the great advice ITT and elsewhere, I’ve put together a new plan that I’m happy with.

  1. Per @jr0cket slack suggestion replace chapter 13 with the next-JDBC docs.

  2. Complete chapter 14

  3. Switch from Leiningen to the Clojure CLI

  4. Follow @didibus “Build it and you will learn” suggestion, back-filling knowledge gaps as they arrive .

4b. Study @seancorfield demo repo and any others I can find as reference material.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.