Devlog: First attempts at Clojure

  |   Source

I've been wanting to learn functional programming for quite sometime. I've had two failed attempts at SICP and the Scala course on coursera, so in my first week at Hackerschool, I'll decided to take a swing at Clojure.

For the first day I worked through reading the Clojure Programming book, and solving problems at 4clojure.com, but I grew really restless doing that. I thought doing a tiny project may get me into the groove better, so decided a small IRC bot. After some discussion on the Hackerschool internal IRC like chat, Zulip, I decided to build a bot with the Zulip API, with @ptn.

The goal was to build a command line tool that anyone could configure with their own Zulip bot API keys, and it would help them read on terminal only content from streams they subscribed the bot to, helping to read only specific content, freeing from the noise on Zulip when you wanna work distraction free but still wanna catch important announcements. The full code is here.

Interesting thing I learnt was how easy it is to read and parse data structures from other clojure files. This is all that is needed to read a file and convert it into it's original data structure, a map in our case.

(read-string (slurp "config.clj"))

For HTTP requests to the Zulip API we made use of the clj-http library. And for parsing the string JSON responses and converting them to Clojure maps, the data.json library.

Post that I've started doing the SICP lectures once again. One lecture, related book reading, and exercises done. Although I'm trying to do those in Clojure. Code for the SICP stuff is here.

I've also moved from bash to zsh, only because it seemed like a cool thing to try.

Now to do more the coming week.

Comments powered by Disqus
Share