Call me slow, but I hadn’t come across the Io language before today. I popped over to its site (http://iolanguage.org/) and played for an hour. It seems to have a lot going for it:
- full OO (like Smalltalk)
- very simple semantics (even assignment is a message)
- nice orthogonal structure
- very compact
- fast enough
- different enough to be interesting, similar enough to be easy to learn
You can even get Io T-shirts and mugs at www.cafeshops.com/IoLanguage (what else do you need in a language?).
Io’s objects are generated by cloning existing objects, rather than instantiating classes (so it has some similarity to Self). So I could create a Dog object using something like
Dog = Object clone
Dog sound = "woof"
Dog bark = block( write(self sound, "\n") )
Dog bark
The first line creates a new object based on Object, assigning it to a slot called Dog. The second creates a slot in Dog called sound and arranges for it to reference the string “woof”. The third lines creates an anonymous block (which writes “woof”) and assigns that block to the bark slot in Dog. Finally we call it.
We can now create some objects based on a Dog: note that the mechanism is the same:
rover = Dog clone
fido = Dog clone
fido bark #=> woof
fido sound = "bow wow"
fido bark #=> bow wow
rover bark #=> woof
Io has differential prototyping: the only slots created in sub objects are those specialized in those objects.
Io has lots of interesting features. It keeps its code lying around in a message tree structure, allowing you to inspect and alter it at runtime (yup, alter. You can write self-modifying Io programs, so I guess adding aspects would be fairly straightforward).
Because it’s becoming a tradition, here’s 99 bottles of beer in Io (taken from the distribution).
bottle = block(i,
if(i==0, return "no more bottles of beer")
if(i==1, return "1 bottle of beer")
return i asString("%i") .. " bottles of beer"
)
for(i, 99, 1,
write(bottle(i), " on the wall, ", bottle(i), ",\n")
write("take one down, pass it around,\n")
write(bottle(i - 1), " on the wall.\n\n")
)
I’m not sure if Io is a keeper for me. It is certainly interesting, but it has a slightly pedantic feel to it (especially compared with Ruby). But it’s fun to play with.
- NickName, E-Mail, and Website are optional. If you supply an e-mail, we'll notify you of activity on this thread.
- You can use Markdown in your comment (and preview it using the magnifying glass icon in the bottom toolbar).