After I recently got interested in Clojure, I decided to use it for a small “project”, namely a script which will download all the enclosures from an RSS 2.0 feed to the current working directory. The program itself is very concise, with only 9 lines of actual code (the rest are comments and library imports).
My impressions: for somebody with little previous exposure to Lisp (some CL and very little Scheme) and no Java background the learning curve can be a bit steep in the beginning, especially since documentation is still a bit (too) sparse. However, if you are willing to spend some time on Google or reading the actual source code of Clojure and clojure-contrib you’ll generally find what you are looking for. Besides that people in the Clojure community seem to be quite friendly and my question on #clojure got satisfactorily answered within a minute.
It’s a definitely too early for any real assessment of the language, but I quite like what I saw so far, so there probably will be some more Clojure-related posts in the near future.
Clojure definitely is one of the hottest new programming languages around and just recently hit a very important milestone. Setting up a nice Clojure development environment on OS X still can be a bit of a pain though, which can be seen by the number of HOWTOs and installation notes floating around on the web. I therefore decided to expand one of those into ClojureX, which I believe is the easiest way to get up to speed with Clojure development on Leopard.
ClojureX can
download and build the source code for Clojure, clojure-contrib and JLine (a readline like library for Java)
download editor support packages for TextMate and Emacs
create a symlink for the Clojure startup script in /usr/local/bin
keep your Clojure installation up to date via a simple “git submodule update && ant”
I hope this will come in handy for other people interested in trying out Clojure on Mac OS X, if you have any feedback please post it in the comment section.
On ruby-talk somebody was asking for a method which will be used to generate a random string, by returning either a lowercase letter or one of the digits 0-9 when called. As an example he posted the following Pascal program:
Hash.new with a block is a sexy beast: you can specify default hash values and when a key is first used, the value will be calculated and inserted into the Hash. Based on that behavior I took a couple of minutes to hack together a small proof of concept class for lazy lists:
As I said, this is quick and dirty, especially since you have to pass the entire Hash.new block to LazyList.new right now. Other than that I quite like it though. I know there are at least twoother lazy list implementations for Ruby, but it seems like both haven’t been updated in a while and I don’t particularly like their interfaces. Dunno, if I manage to simplify list definition, I may actually try to develop this into something. Don’t hold your breath though…
If you are new to Ruby, this may very well be the book you are looking for, since the author was really serious about the “well-grounded” in the title. Together the first six chapters form Part 1, aptly called “Ruby Foundations”. Here you’ll learn about objects, modules, classes, self and control-flow techniques. Although this part may not be the most interesting for more experienced Rubyists, it’s certainly well-written and manages to present a lot of very fundamental Ruby right at the beginning. True, at first I was a bit surprised to see that singleton methods were – implicitly – introduced before classes, but when you follow the author’s logic, it all makes a lot of sense. What I really like about this approach is that it exposes the reader to concepts needed for some quite advanced Ruby coding right away, and in a very light-hearted and “natural” manner. Well done!
Part 2 (“Built-in classes and modules”) covers everything from strings, over symbols to regular expressions and file I/O. What I really like about this part is that the author dedicated two whole chapters to collections and iterators/enumerators, which are essential for everyone striving to become fluent in Ruby.
Last but not least Part 3 (“Ruby dynamics”) talks about singleton methods, procs, lambdas, Symbol#to_proc, the various eval methods, bindings and introspection, thus equipping the reader with all the necessary tools for metaprogramming, one of the many things that make Ruby that sexy little beast it is.
Oh yeah, since I didn’t mention this before, “The Well-Grounded” Rubyist" covers Ruby 1.9.1, which means you’ll learn about the coolest Ruby around. Don’t worry though, most of what you read will also apply to 1.8.6, but isn’t it about time that we all slowly moved on?
Since my trip last year I have been fitter than I’ve been for ages, thanks to a weight-loss of about 25kg, more exercise and a healthier diet. Through kyrah’s tweets I learned about a workout program called one hundred pushups and decided to have a closer look today. I took the initial test and only managed a meager 12 good-form pushups, but they were always one of my weak spots. At least I start from the most challenging category. Through the site I also found the two related programs two hundred situps and two hundred squats, where the initial tests looked a lot friendlier: with 35 situps and 40+ squats both programs suggest that I start from week 3. :-)
Now let’s see how effective these workouts will turn out to be.
While browsing through my Delicious bookmarks the other day, I realized that over time I had accumulated quite a few dead links (about 5% of my collection). I then looked for a simple tool to automatically remove them, but couldn’t find one that appealed to me, so I wrote my own script called unsavory which you can find on GitHub:
It uses HTTParty to generate a list of all your bookmarks, which then get checked individually with Net::HTTP. Every link that returns an HTTP status code of 404 will automatically be removed (no questions asked, no undo), links with a status code other than 200 (OK) won’t be changed but will display some information in case you want to fix them manually. Here’s some example output (links anonymized for this post):
A couple of month ago I first heard about Clojure, a Lisp-like language sitting on top of the JVM. Alas I didn’t yet have time to have a closer look at it, so I decided to get myself the PeepCode screencast.
This 65 minute video is the first to use PeepCode’s new post-production workflow, and it’s very well done! In just a little over an hour you go from learning about Clojure’s basic concepts and syntax to writing a multi-user text based adventure game, tackling topics such as data structures, thread safety, lazy collections, unit testing and packaging of Clojure apps. All of that is clearly presented and easy to follow, which makes for an ideal first overview of the language. If you are curious about Clojure but have little time, consider investing the money for this screencast!
On a more general note it’s interesting to see that more and more languages seem to target the JVM. I never really had any interest in Java and also totally ignored Groovy, but now that JRuby, Scala and Clojure entered the stage, I might start looking into the Java platform a bit more. Especially Scala with its mixed Ruby/Haskell feel appeals to me, but as antifuchs showed, there’s also pretty neat stuff (GitHub project) one can do with Clojure.
If you are surprised by how many times (no pun intended) I called time, it’s just because I was benchmarking Project Euler solutions in several languages, everything else is quite regular (and suggests I don’t use the Finder much ;) ).