Io, by Jove!

I have been continuing the programming project I started the other week of working through the book Seven Languages in Seven Weeks, although it is already in danger of getting swamped by the many other things vying for my attention (especially, at the moment, my resurgent interest in human languages as fuelled by the Bangor Polyglots group I’ve just joined).

The second programming language in the book, and the one I’ve just finished working on, is Io.  Of all the languages covered, this was the only one I’d never even heard of, putting it at the opposite end of the spectrum from Ruby (the only one I’d used much already). The official Io website, which I’ve just linked to, describes it as “prototype-based programming language inspired by Smalltalk, Self, NewtonScript , Act1, LISP  and Lua” (check the original source to see the nature of the inspiration in each case).  While Self, NewtonScript and Act1 are also languages that I’m entirely unfamiliar with (though I’d heard of NewtonScript), I have played a bit with Smalltalk, LISP and (to a lesser extent) Lua, so I could see some resemblance.

Prototype-based languages, such as Io, Lua and Javascript, are object-oriented languages but, unlike most OO languages (such as Ruby, Java and C++) , they are classless.  Instead, each object inherits (via a process known as cloning) and extends or modifies behaviour from another object, which acts as its prototype.  This approach is supposed to encourage a very flexible style of programming.  I have previously done a fair amount of work with Javascript (though mostly via the excellent jQuery library, which hides most of the gory details out of sight) but have not fully grokked the idea of prototype-based programming.  My experiences of Io this week have deepened my understanding somewhat, although I think I’m still a very long way off full mastery of the concept.

The advanced features of Io which are the culmination of Tate’s tutorial are its facility for writing domain-specific languages (essentially by rewriting the syntax of Io itself) and its tools for handling concurrency.  Neither of these are areas of which I have much previous experience, so I’m not in a position to judge how much of an improvement Io offers over other languages for work in these areas.  I think several of the other language tutorials in the book will also be looking at concurrent programming (I’m not sure about DSLs) so hopefully by the time I’ve finished the book I’ll have a better idea which language to turn to if I should ever need to do anything like that.

The film character Tate associates with Io is Ferris Bueller, the protagonist of the 1986 movie Ferris Bueller’s Day Off.  I first saw this film (or at least a large chunk of it) very shortly after it came out, as it was shown to my primary school class on the last day of term.  In hindsight, I find it quite a surprising choice of film to show in this context since (a) it’s all about somebody skiving off school who is clearly depicted as the hero of the film and not seen to suffer any ill-consequences from his truancy (an odd message for a teacher to want to convey, surely!?) and (b) it’s 15 rated in the UK and none of us in the class were older than 11.  Still, I suppose it was the last day of term and the party mood was probably affecting our teachers too (as in, they just wanted something to keep the kids quiet while they went and made a start on their own end-of-term party).  My second viewing of the film took place only a few days ago and I enjoyed it a lot more than I thought I was going to; unlike many films of its era it doesn’t feel painfully dated by now.

Returning to the programming language, the name Io is shared with (and presumably comes from, though I’ve not been able to find anything to confirm or contradict the supposition) one of the moons of Jupiter.  Interestingly, one of the languages listed as an inspiration for Io is Lua, which is the Portuguese word for moon (to find out why, check out the Wikipedia article on Lua).  I don’t know whether that’s a coincidence or whether Lua inspired the name as well as some of the features of Io.

At first, I found Io quite fun to play with.  As I began to try to go deeper, it quickly became quite frustrating as it was so different to other languages I’ve used (although that is, really, the point of the exercise).  After a few days, some of the ideas began to click and I was able to make fairly good progress.  I was heartened to notice that Bruce Tate himself said that it took him several weeks of working with Io to really begin to get a grip on it.  I’m glad to have made its acquaintance but I don’t plan to do any more work with Io for the moment as I think my limited programming time can better be spent in other directions.  I may well return to it for another look in the future though and would certainly recommend it as an interesting language to have a look at.