Seven Languages, Seven Weeks – Io

I’ve fallen behind, but not given up, on my seven week tour of different languages as I read Bruce Tate’s Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages. The second language in the tour is Io, a prototype-based language created by Steve Dekorte. Io is not mainstream, and perhaps not yet fully production ready, but it is interesting. In fact, part of my delay has been in digesting the very different paradigm that Io presents.

In a language like Io there are no classes – to create an instance, you clone something – either Object or something else that has ultimately been created by cloning Object or something else that has been created by cloning Object or something else… well, you get the idea. And everything about an object can be overridden, since those attributes are “slots” that can be arbitrarily assigned.

In Io everything is handled as messages passed to objects, and the way that any object handles any message (a slot, again) can be overridden. So in Io, ‘hello world’ becomes:

“Hello, world” print

That is, send the print message to the “Hello, world” object. And what’s in the print slot can be redefined. Once you get in the habit of looking at things that way a lot of options open up. Add to that some pretty slick concurrency handling and Io starts to look pretty intriguing.

I can’t describe Io in the small space of a blog post, so I’m not going to try. And in fact that would be exactly my criticism of Seven Languages. For such a different (from the procedural/OO norm) language, the text gets the reader in to deep water very fast. The thinness of explanation in the text quickly lead me to the web, which is sort of what the author intended. The problem is that looking at Io material on the web quickly became more absorbing than the text (what’s this? Python bindings for Io?) and it was only belatedly that I came back and played with the books’ examples.

And since I carped about it in an earlier post, I have to mention that I found it a little irritating that the author had to describe overriding an object’s forward method (the mechanism for searching prototypes to find a method) as being equivalent to Ruby’s method_missing, which seems to be a bit of a stretch (and a bit Ruby-centric). Io isn’t Ruby, and while it can be made to do something equivalent, it simply doesn’t have the same features.

On the other hand, I found the choice of Io to be a good one, and completely in line with the intention of the book. I didn’t really have any feel for prototype-base languages before, and now I feel I do.

One of the comments on my post about the Ruby chapter suggested that if I was upset about Ruby, Io would give me a heart attack. In fact, my heart rate ended up being quite low. I had quite a bit of fun playing around with Io and figuring out how to create a DSL to produce XML. I think the reason is Io’s consistency and simplicity. EVERYTHING is objects with slots being passed messages, and that’s pretty much it. Once you accept that, Io behaves as you would expect.

While I’m not entirely sure that Io is ready for production use, I can definitely see implementing a DSL in it, and I may well be be back to experiment more.

About these ads

8 Responses to Seven Languages, Seven Weeks – Io

  1. craig ferry says:

    Just wondering whether it has had any effect on your understanding of javascript?

    • Vern Ceder says:

      Indeed. While I don’t normally do that much with javascript, having played with Io does help things make more sense.

  2. When I read Tate’s comment about overriding an object’s forward method as being similar to Ruby’s method_missing feature, I just took it that he was comparing it to Ruby since that was the only other language he had introduced at that point in the book.

    Maybe if he had introduced Io first, he would have compared Ruby’s method_missing to Io’s forward method.

    • Vern Ceder says:

      Actually I was thinking more of the summary of “What We Learned in Day 3″, where he says, “Next, we built an XML generator that used Method Missing to print XML elements.”

      I know, I’m being cranky about this… and I agree it’s no big deal, but somehow I just can’t help myself.

      • craig ferry says:

        I wonder how much of this is a zen of python outlook (There should be one– and preferably only one –obvious way to do it) than a programming outlook.
        If you were a perl programmer (There’s more than one way to do it, but sometimes consistency is not a bad thing either) would you still be bothered about this?

      • Vern Ceder says:

        I would be happy (even proud) to plead guilty to a “Zen of Python” outlook. :)

        However, in this case, I think I’m more bothered by the mis-application of the term “Method Missing”. Io (and Python for that matter) can be made to mimic method_missing easily enough, but it’s a Ruby concept, not an Io concept.

        In the context of the XML printer exercise, I didn’t really object to the act of overriding forward, although I did wonder how “native” Io programmers would feel about it.

        Ah well, we all have our twitches, and we’ve just discovered one of mine. :)

  3. Bruce Tate says:

    I think you captured what I was trying to do very well. Your criticisms about the depth and speed of the dives and about being Ruby-centric are painfully accurate. They are the two problems I combat every day as I finish this book.

    You’re right about getting deep quickly. This book is all about rapid deep dives. The reason is two fold. First, it’s the only thing that keeps this book from being about “Installing Seven Languages in Seven Weeks”. Second, I need readers to find their own support, so the exercises ask readers to find other resources out there. I just don’t know enough about all of the languages to support all of them. I struggled with the idea of writing the book at all. I told myself that to make the book worthwhile, I would need to solve a nontrivial problem in each of the languages.

    I do want to address the Ruby-centric appearances. The reason that I included Ruby as a programming language was that it’s a language that many of the target readers will know as many of the readers are earlier customers of Pragmatic Press books. I then had a basis of comparison for other languages. I did struggle with this concept, and judging from your comments, didn’t get them exactly right.

    I’ll be interested in your comments as you finish up your walk through the rest of the languages in the book. Thanks for all of your words, those kind and those not so kind, but keenly observant.

    • Vern Ceder says:

      Bruce, first let me emphasize that I understand the struggles and trade-offs you face. In my own book, I had to face the same issues in striving to keep it “quick” as opposed to “complete”.

      In general, I think you’ve struck a reasonable balance on the depth vs. coverage issue, given that it’s an almost impossible dilemma. I guess what I miss most is a “cheat sheet” of syntax basics for quick reference as I work on the exercises. Something like that, even just a link to an existing one online, would be useful, I think (but maybe not practical to produce).

      OTOH, sending the people off on their own, as I know from dealing with high school students, is risky – they may not find their way back! :)

      As to the suggestion of (and my carping about) Ruby-centrism, I think it’s fair to use Ruby as a reference point. OTOH, once other languages have been introduced, Ruby should not be the only reference point. From what I’ve read in the Prolog chapter, I would guess that’s your intention.

      My other concern in this regard is how Ruby affects the approaches to the other languages. I don’t mind at all a comparison between Ruby and Io, but I don’t want to be guided into writing Io code that looks like Ruby (or Java or even Python), if that makes sense. And it was exactly that concern that lead to my comments above.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 131 other followers

%d bloggers like this: