Wednesday, August 7, 2013

Getting started on Clojure

One of my task last week is to write Tic Tac Toe in Clojure. Seeing code like this, of course I freaked out: I have no idea what it is saying. If I don't understand it, I didn't like it! I want to crawl back to Ruby. Ruby is much more English-like and way easier to read. It doesn't have a million parenthesis like Clojure. However, after spending a whole week in Clojure, I hate to admit it, but I'm beginning to like it. I like how easy it is to do a lot of things. For example, if I want to say get a total of a few numbers, this is all I have to write:
(+ 1 2 3 4 5)
Ruby
 1 + 2 + 3 + 4 + 5
In this example, I have to say Clojure wins on account of simplicity. It is easy to read and write this statement. I don't know if you can get any easier than this.

Enough background, here is how I would have started to learn Clojure:

  1. Blackstag - It is a really simple guide to get you started. You will not learn everything you need, but it's a good place to start. (I skipped installation because it's already installed on my computer so I'm not sure if it's still relevant.)
  2. Clojure API - I read most of the methods in here. It will help you become familiar with what Clojure has to offer.
  3. Roman Numerals Kata - Write your own roman numeral kata. I looked at others to see how they do it. Look up keywords that you don't understand.
  4. Read other people code. I look at several Clojure implementations of TicTacToe because mainly I have to write it. But it really helps because I have an idea of how the game is suppose to work. That is not to say I read and understand everything I read. Anyway, here's a list of Github you want to checkout:
    1. Rylan Tic Tac Toe
    2. Micah
    3. Colin
    4. Wai Lee
    5. Clojure Cookbook - I didn't look at it, but it sounds promising.
  5. Clojure Docs - This is my best friend once I got an idea of what function I want to call. 
Note: I recommend using Emacs with rainbow parenthesis when you write Clojure code. If you are writing in Clojure, it is worth the time and effort to learn how to use Emacs. 

I got most of my Clojure Tic Tac Toe code done by reading Blackstag, Clojure API, and others code. I am much more comfortable with the language now.

0 comments:

Post a Comment