#12in23 02: Clojure

Cover image for #12in23 02: Clojure

It's month 2 of the #12in23 challenge, and this month's theme was "Functional February". I have no experience with functional programming languages, so I blindly chose Clojure. Exercism offers concept-based training, there were some good resources online, and I'd heard of it at least!

What is Clojure?

Clojure is a general-purpose, functional programming language. It's a modern dialect of the Lisp programming language, emphasizing immutability and the use of persistent data structures.

Clojure has quite a minimal syntax and is structured around the concept of simplicity. In the Clojure sense of the term, simplicity is about how constructs and concepts are related to one another. Simplicity allows a programmer to break down problems into small parts and easily solve them with off-the-shelf Clojure components.

Clojure is used for all sorts of things, anything from a shell script to creating a templating language/library. The strong support for concurrency and parallelism makes it a great language for data processing and managing large datasets.

How Did I Learn Clojure?

I used a few different resources. The Exercism track has a good overview with targeted exercises and offers helpful concepts to introduce you to Clojure. I read/worked through the book Clojure for the Brave and True, which really helped my understanding.

I also spent a lot of time with the Clojure Docs. They're community-built, which is different. I really appreciate how many examples there are. That's incredibly helpful, especially when learning a new programming paradigm.

The last tool I've been using is GitHub Autopilot. I know it's not a tool made specifically for learning, but it turns out it's incredibly helpful. One way was the introduction of new functions/code structures. Whenever I was stuck, and autopilot suggested a new function, I'd go to the Clojure docs and read up. Then I rewrite the suggested code in a different way to make sure I'm grasping the concepts. I also love spending less time writing boilerplate code, although that's less relevant, thanks to Clojure's concise syntax.

The Good and the Bad

A month is not enough time to have real opinions about any programming languages, especially with no opportunity for real-world applications. That said, here are a few thoughts.

One thing I loved was the interactive REPL (Read-Eval-Print-Loop), and the tooling in general. I didn't use emacs ( the most popular setup), but I found a VS Code extension that loads an interactive REPL and debugger and makes it feel like a dedicated Clojure setup. It's very cool executing your code inside the document it's written on and seeing the immediate output.

I also dug the opportunity to try writing code in a totally new way. Functional programming is a different way of thinking, and it challenged my brain in many unexpected ways. I'm walking away from this month full of new ways to think about programming.

The last thing I want to call out is the immutable data structures Clojure uses. I'm definitely not used to that, with the imperative programming I'm doing day-to-day. This was a challenging concept to wrap my head around, especially regarding looping over data, but by the end, I had really come to appreciate how easy this makes specific types of debugging.

It's not all fun and games over here in Clojure land. One huge downside is that it's not a popular programming language. This means there aren't many resources to learn or practice with. There's also not a huge community (although Clojure fans tend to be proselytizing superfans).

The functional programming paradigm and the immutable data structures were an overall benefit, but they make debugging more difficult. I'm used to imperative programming, so figuring out what was happening in the middle of a function was not always easy.

Will I Keep Using Clojure?

Probably not on a regular basis. It was fun to get my brain to think in a new way and to understand what all the () are about. I can definitely see revisiting Clojure as a sort of programming puzzle. I just don't really have a use case for Clojure in my day-to-day. If I do get into AI/ML, I will definitely revisit Clojure as a tool for processing large datasets.

What's Happening Next?

March is "Mechanical March," so I'll be focusing on C. I've been using C a bit for some computer science classes I've been taking. I'm excited about the opportunity to keep trying this new language!