Why are Clojure beginners just like vegans searching for good cheese?
By Ariel Alexi
Have you ever wondered what to do if you love cheese but you want to be a vegan and how this affects you when you learn Clojure?
This was my question too. I love cheese, but I wanted to find a good vegan cheese replacement for my breakfast sandwich. This wasn’t a fun journey, all the vegan cheese substitutes weren’t like the real deal! After a talk with one of my vegan friends, he told me that my point of view over cheese replacement in the sandwich was wrong. Instead of searching for a good and tasty vegan cheese replacement, just replace it with an avocado. Avocado is a good replacement for your morning sandwich without the compromising that you would do with tasteless vegan cheese substitutes.
In my opinion, there is a similarity between a Clojure beginner and a vegan trying to find a good replacement for cheese. Instead of enjoying what the vegan world has to offer, a lot of vegans are constantly on the lookout for the synthetic cheese substitute that is like real cheese. Between you and me, most of these substitutes are not tasty. I wonder, why do those vegans keep looking for the things that are “similar to…” instead of looking for the things that are delicious in the vegan world? Why not accept that in the vegan world there is no cheese or something as tasty as really good cheese, but you can just enjoy what you do have, like stir-fried vegetables and hummus?
What were my resources and what happened to me?
I started just like everyone else. I started to learn Clojure from the books (Clojure for the Brave and True by Daniel Higginbotham and Clojure Programming: Practical Lisp for the Java World by Chas Emerick, Brian Carper, and Christophe Grand). I also practiced some coding questions from 4Clojure. While some other people found all these resources helpful, I felt like I was just learning a lot of words, instead of learning how to create sentences in this new language - Clojure.
When I wanted to write something, all the little examples I saw were nothing like what I wanted to do. They showed different algorithms such as changing strings or sorting lists, etc. To solve coding problems in Clojure I was trying to force in concepts from other languages that I was familiar with, as it was in my journey hunting for new cheese. I was forcing myself to find a new kind of cheese. Much like the lack of taste in the substitutes, I was missing something in those code examples and sources.
I never saw the use of maps, channels, or other things which are widely used in Clojure when you start to develop something like a server.
What eventually helped me more than anything?
The first time I was able to understand Clojure and write code myself was when I had to add new features to a program already written in Clojure and not write something from scratch. The very fact that I could change something in simple pre-existing code allowed me to see how things are written, and to continue through trial and error and debugging to understand the language more deeply.
This was my AVOCADO!

So, what was my avocado you must have been wondering.
For me, I went back to the origins. I mean, I thought about how I have learned new coding languages at the university through coding projects. That is why I have decided on a project that I will be excited about, and at the same time will be able to build in steps. This means that in each step everything must work and I can understand what the next step will be that I need to take.
I searched for a basic game I could work on. I created a 2D desktop game based on Oakes/play.clj, which I converted to a Pac-Man game. This was my avocado.
Creating a game allowed me not just to practice different Clojure syntax but also to run the game and check if the functionality works on the screen right away. Which means having a visual addition and not just evaluating functions on the REPL.
Seeing the whole game created in small steps and not evaluating algorithms is just as good as avocado in the vegan world which is more than just a synthetic cheese.
In addition, I think that without functional programming expertise it’s hard to start coding Clojure from scratch, but when you have a simple program with examples, and at each step, you know what you want to change, then you can see right away if it works or not. I found it much more helpful to start from working code, and then change it to what I want it to be, than to write it from scratch.
Bear in mind, like a work of art - it’s very difficult to start from scratch, but once you have an example it’s easier to go from there. If you want to try this approach all you need to do is to think about what you want to learn - client or server-side or even maybe games, then find a sample code on the internet that is not more than 50 lines of code and start adding features.
If you ask me then my advice would be that when you start to learn Clojure, start from example code. If you want to learn Clojure and not just Ctrl-F
or to Google all the time “how to… in Clojure”, you should be learning it by using other Clojure code itself. Remember, if you want to develop in Clojure, you don’t need to be a vegan searching for the best cheese substitute, you just need to use what already exists and enjoy your avocado…
Good project hunting, Good luck!
Comments ()