Wednesday, November 4, 2015

Something different: Clojure!

Rather than Japan or food (I'll get to those next time, promise!), this is about learning a new programming language: Clojure, a functional programming language and dialect of Lisp.

The first time I started off learning Clojure, I was alternately going through Structure and Interpretation of Computer Programs (SICP), which is one of the most famous books out there on functional programming, and O'Reilly's Clojure Programming.

SICP starts with the absolute basics, which is where you start to realize how incredible Lispy languages really are (and functional programming in general, but the examples are in Scheme, a Lisp dialect). It very quickly goes from "yeah, I get it, that's what a variable is" to "holy crap, they did something amazing with almost no code, and I freaking get it!" That last part is where the book is excellent; it's both mind-blowing and accessible, provided you have some basis in programming.

The O'Reilly book was also extremely good, and obviously more about the language than the paradigm (though every intro or text on a functional language I've seen has at least some discussion of it, since for most programmers it's pretty foreign).

Unfortunately, when I moved to Japan, I was very limited in what I could bring, and books almost entirely failed to make the cut, being just too heavy to be realistic. So both of those gems are sitting back in Minnesota in a storage locker; I'm hoping to liberate them when I'm in the US for vacation -- or permanently if my visa doesn't work out -- but that's not until the end of the year, and damnit, instant gratification!

Fortunately, a while back, I found Daniel Higginbotham's Clojure for the Brave and True, a thorough introduction to Clojure, the functional programming paradigm, and even emacs, a geek-revered text editor (among other things) that's the de facto choice for building programs in this particular language.

Right off the bat, it's hilarious. Example code includes such things as cataloging vampires and their human/animal blood consumption, determining which part of a hobbit's body will be wounded given a random attack, and dealing with international cheese thieves. The oddball humor is worked into the material so well that it really helps engage the reader; I'm interested in learning Clojure and have been for a long time, but when I've already been working all day and want little more than to sit back, watch a movie, and vegetate, it's very helpful to actually look forward to this kind of thing as part of what could feel more like a chore given less entertaining material.

The introduction to emacs is only one chapter, but covers enough important functionality that it goes from sort of a "what, how does this crap even work" to "oh wow... oh... oh wow" pretty quickly. It hasn't yet replaced my more mundane text editor for everyday work, but I think it likely will as I spend more time with it.

So far I'm only two days in, so hopefully this attempt doesn't sputter out like the last, but at this point I (hopefully) have the advantage of not having to move to the other side of the world while also trying to learn a completely different kind of programming.

No comments: