Lazy Weekend Reading: A love letter to Clojure

I had no idea that Gene Kim, author of three books that have garnered wide-spread public acclaim, was doing Clojure programming. (They are DevOps Handbook, Phoenix Project, and Accelerate – we've ordered them recently for the Helpshift Library). He published a love-letter to Clojure this weekend, and I think it is an absolute must-read for all programmers (whether you write Clojure or not). The blog-post covers the following areas:

General software philosophy

  • Choose tools that are good to think with
  • Most bugs are due to programmers not understanding all the possible states their code may execute in. Make state and it's mutation explicit. Put it in a specific place and mutate it with a small set of specific functions.
  • Conventions matter. They help readability of code, which is critical.
  • Make systems simple to change. Don't "trap yourself in a system of work where you can no longer solve real business problems easily. Instead, you’re forced to merely solve puzzles all day, trying to figure out how to make your small change, obstructed by your complected system".
  • Developer productivity is enhanced when they follow the ideals listed below. Invisible structures around us either help or hinder in this regard.
    • The first ideal: Locality and Simplicity
    • The second ideal: Focus, Flow and Joy
    • The third ideal: Improvement of Daily Work
    • The fourth ideal: Psychological Safety
    • The fifth ideal: Customer Focus
  • "Practice as a transcendental experience" and "Practice as hard work and perseverance" are both needed for developers to level up.
  • Bugs can be introduced by not understanding programming language constructs (eg: in Ruby, strings are mutated if you use the << operator).

Specific Programming Practices

  • Pure functions are trivial to test – build input, look at output. If it's hard to write a test for your code, that's a sign that it is complicated. Try to simplify it by pulling pure functions out of it and writing tests for those.
  • Push side-effects (impure functions) to the edge of the program / piece of code that you are writing. Not practicing this leads to code becoming increasingly untestable and difficult to change.
  • Pushing I/O to edges reduces the need for mocks and stubs

Here is an example of good vs bad way:

;; good way: steps are composed together, which each compiler phase
;; indepdendently executable and testable.

(-> (tokenize-source-files!)

;; bad way: all the intermediate steps buried inside other functions,
;; no longer reachable or inspectable.


The Joy of Clojure

  • Ease of writing short, beautiful code that just works.
  • Simpler syntax frees your brain to think about the problem you want to solve.
  • The REPL experience enables developer to stay focused and in flow state. The developer experiences joy in REPL driven development.
  • Clojure is a high-level language that gets out of your way. "A programming language is low-level when its programs require attention to the irrelevant." - Alan Perlis

Other notes

  • The brightest days of infrastructure, operations and security are still ahead of us.
  • They involve providing platforms to developers that hide the complexity of these things and allow the developer to focus on the business problem they want to solve.


Published On: Sun, 13 Oct 2019.