• Late last year I stumbled across a tutorial that was featured on Hacker News. It was a How I Start article about Clojure, and using it to create a Markov Chain Twitter Bot. I pinned it to my browser with honest intentions about getting around to it, and close to a year later I did! I kept meaning to get around to it but with study, work and life, it’s been pretty tricky to find time for side projects. Anyway, I finally found the time and I wanted to chat about my experience working with Clojure.

    Since I began programming more seriously, learning a functional language has been on my to do list. I like the idea of thinking about problems in a different way, I think it would really help me to improve my problem solving skills. Also, functional languages have an air of mystique about them and I want to get up in all of that!

    I liked this tutorial for a few reasons. Firstly, I have read and heard good things about Clojure. I felt the community and documentation was quite welcoming and there were a lot of great resources to get me started. This tutorial allowed me to get straight into a project with minimal effort, and get a feel for the language. Secondly, it covered Markov Chains which are a common feature in machine learning models. I have been looking to learn more about Markov Chains, and other basic algorithms because I am pretty enthusiastic about machine learning these days. So the first thing I needed to do was my favourite thing… set up my dev environment. Oh boy, was I excited. Actually, this is my least favourite thing to do but it has to be done. Now, the tutorial recommends Emacs. Emacs has been suggested to me previously as an all around text editor, IDE, retro game center and much more! But, I really just couldn’t be bothered installing it and setting it up for such a small project. But I needed an IDE with a convenient REPL…

    Then I discovered Cursive. Cursive is an IDE for Clojure that can be integrated with IntelliJ, it has a REPL and support for Leiningen. I found it amazingly simple to set up and I was able to begin the tutorial in no time! It made my life so much easier! So there you go, you can write Clojure without Emacs. In the future, if I begin to pick up more Clojure projects I may set up Emacs, but until then… Cursive is all I need.

    The tutorial was very easy to follow, straightforward and broken down into simple steps. I read through the whole tutorial first before starting to write anything, I find this helps me when I am working through instructions. Eventually I had something compiling and it felt good! I stumbled across a couple of issues, mostly dependency related. But these were pretty easy to fix.

    Next, I needed to think about what kind of tweets I wanted to generate. I decided it would be hilarious to generate tweets based on things Kanye West has said, and considering how unintelligible his tweets are already, it was the perfect choice.

    So, I collected my data and was generating my tweets, and boy were they spicy. My twitter bot was born! I used Heroku to run the program and periodically post to Twitter.

    I really enjoyed writing this program and working with Clojure. I find the language delightfully concise. Writing the program takes a lot less work than if you were to write it in Java for example, there is a lot less boilerplate. Aesthetically, I think it looks pretty nice. It’s a lovely little lisp and I really don’t mind parentheses. I have found a few more tutorials written in Clojure I intend to work through and really get a grasp on the language.


    So please, take a look at Mr Kanye Markov and let me know what you think!

    I would highly recommend Daniel Higginbotham’s ‘Clojure for the Brave and True’ to anyone looking at learning Clojure. It’s a great introduction to the language and gets right into things without the jargon and fluff.