Week 2: Io

August 24th, 2013

After I had some fun with the Ruby exercises, week 2 brings a language that’s new to me. Or at least it was new to me as I started reading about the Io language about half a year ago. Like I wrote in the introduction post I spent some more time with Io and came to write iospec, a small BDD-style test library that is inspired by Ruby’s RSpec.

Io is a prototype language, like Lua or JavaScript. Hence every thing is an object, and every object is a clone of another object. You interact with an object through messages. Io is an interesting language that provides a lot of flexibility. It’s syntax is simple enough so that you can learn it in about 15 minutes.

The character Bruce chose to represent the Io language is Ferris Bueler. Let him take you for a day and you’re in for a real treat, and end up seeing things you’ve never considered before. Io uses normal order evaluation, meaning that it delays evaluation of method arguments until they are required (i.e. lazy evaluation).

Being a homoiconic language (meaning that program structure is, like data, represented in a primitive data structure of the language) Io offers lots of flexibility, making Io a great language for implementing DSLs. It’s this flexibility that made it possible to create the iospec test library. Io is almost like an object-oriented Lisp.

Io is relatively new with a small community. Development started in 2002 by Steve Dekorte, to help him better understand how interpreters work. It is inspired by Smalltalk, Self and Lisp. Io is used in different environments, like router configuration language and a scripting language for video games. Its small footprint, rich concurrency (it supports the actor model) and simple integration with C makes it highly suitable for embedded systems.

I loved spending time with Io, doing the exercises of the book and creating iospec. Unlike Ruby there are not much syntactic sugars, but because of its awesome flexibility adding some yourself is fairly simple.

My solutions to the more interesting exercises in the book are available in the 7-languages-in-7-weeks repository on my Github profile. These exercises include a Fibonacci sequence (both recursive and destructive), a two-dimensional array including transpose, and an XML builder DSL.

Io is an amazing language. Maybe it will have a lasting impact, maybe not. Learning Io gained me many insights in how JavaScript actually works.

Now it’s time to move on with the next language: Prolog.