Starting a Journey with Clojure and ClojureScript
Clojure, as described on their official page:
“Clojure is a dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language, yet remains completely dynamic – every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.
Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.”
Why Functional Programming
If you’ve never tried functional programming development, I assure you that this is one of the best time investments you can make. You will not only learn a new programming language, but also a completely new way of thinking. A completely different paradigm.
Functional programming is on the rise. Clojure, Scala, F#, Erlang, Elixir, Elm, Haskell, only to name a few. Those are all functional languages, used by the biggest companies in the world to drive their major systems.
It’s good to understand how they work, but it’s even better to be able to write something using them. Always remember one thing: “A programming language is just another tool.” You should always pick a language based on your needs, not on how hyped it is or how much you love it. FP is the biggest paradigm next to OO and learning its basics will be worth it long term.
Rich Hickey made it very clear that Clojure is, and will always be, a simple language. Minimal syntax, very condensed and short API, no types. That simplicity, when comparing to other functional languages, makes it relatively easy to learn Clojure.
There’s no better way to understand the reasoning behind the choices than to listen to the creator himself. In just an hour, you’ll get it:
If you still need convincing, here is more of his reasoning:
Even Robert C. Martin aka Uncle Bob likes it! In my eyes, that’s an extra five points in favor of “why I should choose Clojure.”
I know, people tend to hate on Java because it’s a huge monolith, yada, yada, yada, and it’s Java. And for most of them, it should be put on the cons list rather than on the pros. But take a look at it from this perspective:
- plenty of people already know Java
- you can run it on almost anything
- there are well-established tooling and libraries
- it’s battle tested
Other than for personal beliefs, I don’t see why you wouldn’t give it a try. Just like when you were introduced to new foods as a child, there’s a huge chance that “you don’t like it” without even having tried it. Yeees, I know everyone has done that at least once in their lifetime!
To paraphrase Sauron: “One language to rule them all, One language to find them, One language to bring them all and in the darkness bind them.”
What if you could kill two birds with one stone? Would that convince you even more?
“Developers hate him! See how he targeted all the biggest platforms using one simple trick!”
Java is huuuge, we all know that. But you know what’s the second biggest platform? Web. Browsers. Internet of Things. You can target all of those platforms with one language.
The best introduction to this concept is this talk: Clojure All the Way Down: Finally a Useful LISP — Ricardo J. Méndez
“Alright, but how should I approach my learning process?”
There are two ways: books and videos. Some people prefer the former and some the latter. I tried both and, to be honest, the latter one is my preferred method (although you might think it’s the other way around by the photo I chose as an intro to this post). I enjoy the feeling of being “mentored” very much. I just like it more when someone is talking to me and demonstrating how things are done, rather than just reading about it.
Clojure for the Brave and True — Daniel Higginbotham
It’s not often the case, but this book is FREE and you can jump to reading it straight away. Of course, I highly encourage you to buy a printed copy! It’s one of the best books you can find on the topic. It explores it in a very easy to digest manner and approaches it from the point of view of people completely new to the functional programming world.
Living Clojure — Carin Meier
Carin’s writing is the shortest of all the mentioned books, and it’s also the most condensed one. You’ll find everything you need to start your journey with Clojure. It’s also written somewhat as a tale about “Alice’s Adventures in Wonderland.” How cool is that?! It also contains what I found to be a great concept that could also help many of you: a “Weekly Living Clojure Training Plan!” It’s split into seven weekly assignments, and step-by-step guide to learning Clojure.
This is the best resource I’ve ever found when it comes to learning a new language from scratch. It holds your hand and guides you through all the basics, advanced topics and writing a whole complex application, explaining everything along the way.
Those two series are front-to-back introductions to Clojure. They both go through all the core concepts of the language and contain everything you need to know to start working on your projects.
This one isn’t a course “per se,” but rather a series of tutorials on Clojure and ClojureScript. Very useful when we are at a given point in our learning process and would like to dive deeper into a specific topic.
Although I’ll openly admit that I haven’t read them yet, these are books that were often recommended. I am told they provide more understanding about Functional Programming. I’ll read them one day!
- The Little Schemer by Daniel P. Friedman and Matthias Felleisen
- Structure and Interpretation of Computer Programs by Harold Abelson, Gerald Jay Sussman and Julie Sussman
- Purely Functional Data Structures by Chris Okasaki
- An Introduction to Functional Programming Through Lambda Calculus by Greg Michaelson