{:title "Why Clojure?" :date "2018-09-08" :tags ["clojure", "programming","thoughts"]}

Why Clojure?

First published: 2018-09-08 Sat
Last updated: 2018-10-03 Wed

I am currently learning Clojure, mostly because I wanted to learn functional programming principles and Rich Hickey gives amazing talks, but also because it is a functional programming-focused lisp dialect that can be hosted both on the web with ClojureScript (via compiling to optimized JavaScript) and the on the JVM (via Clojure). The real reason is hard to articulate, but I think it is more than just the leverage. I am trying to articulate the reason what Clojure captured my interest more in the piece below.

Why not just learn JavaScript?

You can do the same thing with JavaScript and NodeJS– right? Well yea, kind of, but I don't really want to learn JavaScript in depth. This is partly because I have limited time, but the real reason is that JavaScript doesn't seem to offer any interesting new paradigms or ideas apart from what I already know from Python and R. All I get from learning JavaScript would be a new syntax and more of the same headaches (and apparently a lot more headaches– see Gary Bernhardt's wat and the birth and death of javascript).

Leverage, new paradigms and a rich ecosystem

Compared to JavaScript (or really any other language I have seen) Clojure appears to be an extremely well thought out language that allows me to explore the world of Lisp and functional programming with immutable data structures. The icing on the cake is that Clojure can compile to and leverage all of JavaScript with ClojureScript.
Note: I think this figwheel for ClojureScript development demo by Bruce Hauman is reason alone to learn Clojure(Script)!
By learning Clojure, I get a lot more leverage (all of the JVM, Lisp, functional programming, and web programming/JavaScript) than I would get from any other language!

Learning a craft rather than getting a thing

A lot of people learn a programming language to use or get a thing. Python has pandas for data, django for websites, and many more tools that people come to the language specifically to learn. Similarly, R has the tidyverse, and Ruby has rails (I know they both have a lot more to offer too, but I don't use them as much). JavaScript has the web and single page apps. Huge communities build up in the language around those tools and the languages are richer and more popular because of it. There is really nothing wrong with this. I learned python and R reasonably well, for the data analysis and automation bits but– I am not a professional programmer.

Programming and building software is my favorite hobby, and I use it a lot in my scientific work, but I am not currently being paid anything to write or learn code. I think I am lucky for this reason. It frees me up to pick what I want to learn based on how much value it brings to the table and how much enjoyment it brings me to use it, rather than based on what my company uses or whatever is popular now.

A lot of thought went into the design of Clojure and it has a lot of power behind it (immutable persistent data structures and all of the JVM among other things). It is not exactly simple or intuitive when you first pick it up (like Python is), but as Rich Hickey said in one of my favorite talks he gave,"musical instruments are not made for beginners". He explains they are made for professionals because you are only a beginner for really short period of time. There is not a shortcut for becoming an excellent piano player, but there is also no limit to the depth and complexity of the music you can create with that instrument. I am not a musician, but I love writing code in my spare time so any language that gives me the kind of leverage that lisps do is definitely worth my time.

Skills you have to put work into are skills that are worth acquiring. One of my favorite essays is "The Lisp Curse" by Rudolf Winestock (http://www.winestockwebdesign.com/Essays/Lisp_Curse.html). If that doesn't inspire you to learn Lisp then I don't know what will. Maybe a few of Paul Graham's essays (especially this one http://www.paulgraham.com/avg.html) will drive this point home.

Everything I have read about the amount of time put into designing the Clojure language and the amount of power you get from lisps in general makes this an extremely attractive language to learn. By learning Clojure I am not getting a big, flashy car or an expensive power tool. I am getting a set of extremely versatile, battle hardened hand tools (another of my favorite talks is Tim Ewald's Programming with Hand Tools https://www.youtube.com/watch?v=ShEez0JkOFw). As Tim Ewald explains in that video, with those hand tools I can do anything you can do with your power tools, but I will have a much deeper understanding and appreciation for what I am doing and I will be making things simpler and likely a lot more reliable.

I want to build tools that help people (but mostly myself) and enjoy doing it. Python is great for this– it was my first real programming language and will always hold a special place in my heart and toolbox. But Clojure (and lisp in general) is my current interest and the more I learn and practice the more I can do, the more I understand, and the more I love this tool.

Favorite Clojure talks

The talks below have had a big influence on me. I learned a lot from them and return to them often.