Clojure dev setup links
Collected dev setup tips from my first week of playing with Clojure.
Getting started
Download the Clojure CLI (invoked as clj
on OSX). Here’s the starter guide on dependencies and running scripts using the CLI.
Build tooling
Leiningen, invoked as lein
, is a commonly used Clojure project manager that helps you manage dependencies, run tests, package your project, etc.
lein
quickstart by BraveClojure, with bonus explanation of how Clojure utilizes the JVM
Workflow tips
When in doubt, pair!
After I complained about my confusion in the relevant RC chat channels, a kind soul offered to show me recommendations for an ergonomic Clojure workflow and point out some common beginner mistakes, almost all of which I was making. Thank you!! I wish I had gotten this walkthrough three days ago, but also am thankful that I got this walkthrough so soon into my functional programming journey.
Recommendations
The aforementioned kind soul sent me a bunch of useful recommendations to improve my workflow:
- “Afraid of Clojure Stacktraces? Fear no more”: A lightning talk at IN/Clojure that explains the traces, how to break them down and read them, and tooling support available to query/pretty-print the traces.
vim
+ Clojure/Script workflow
- 5 minute video demonstration of an ergonomic Vim-based Clojure(Script) workflow
- Handy plugins
Hot-loading ClojureScript
figwheel
, a tool which builds & hot-loads ClojureScript into the browser as you write it- Video example of a
figwheel
workflow - Video of a fuller exposition of all the things
figwheel
enables
Debugging frustrations
Very little of the open source Clojure I’ve been checking out contains comments for some reason. While I get my footing, I’ve been finding clojure.core/pr-str
useful to sanity check what’s happening inside my lazy sequences: (println (pr-str x))
I’m used to verbose error handlers, and Clojure error stacks are rather arcane. This is additionally frustrating when I clone a 3rd-party library and I don’t know how to debug the examples without reading the entire library. There must be some way to debug the horrific error stacks coming out of functional that I just haven’t found yet.
notes on debugging Clojure - Eli Bendersky
Lazy sequences
Type errors involving lazy sequences seem to surface often in Clojure error stacks.
- Great writeup here on lazy sequences in Clojure, how they’re treated differently by various list operators, and why one might want to use them.
- Making Clojure Lazier