The best languages are deceptively simple. Io has an incredibly brief grammar, so it’s easy to think you’ve learned everything with one short perusal. And the manual is quite short, too, isn’t it? Nothing to it, right?
Io is just an incredibly hushed secret. (Perhaps because it is impossible to Google stuff about it.) Did you know that Io’s introspection and meta tricks put Ruby to serious shame? Where Ruby once schooled Java, Io has now pogoed.
Here, let’s start with a simple block:
Io> plus := block(a, b, a + b) ==> method(a, b, a + b ) Io> plus call(2, 3) ==> 5
Okay, so the block works. The
plus block added two numbers.
Now let’s do some introspection on this little fellow.
Io> plus argumentNames ==> list("a", "b") Io> plus code ==> block(a, b, a +(b)) Io> plus message name ==> a Io> plus message next ==> +(b) Io> plus message next name ==> +
Hot holy cold mold. Not only can you get the names of the block params. And not only can you get a string of the block’s complete source code. You can sneak into the code and traverse the messages inside. And most amazing of all: it’s awfully easy and natural. True to Io’s quest. Ruby’s mirror can’t see any of that.
But, whoa whoa, hey now, don’t touch that dial.
Io> plus message next setName("-") ==> -(b) Io> plus ==> method(a, b, a - b ) Io> plus call(2, 3) ==> -1
Gunpowder and treason! Now THAT is a monkeypatch to the viscera. Subtraction is in effect.
See, I first had Io pegged as a Python. Simple rules, very strict, few sigils, very little sugar, both adhering strongly to their own manifestos. No way, though. Python keeps trying to shed its functional skin, only to reveal its acid wash jeans underneath. Ironed and starched and pegged.
Io pays obeisance to minimalism, but somehow cracks the door open on a wild and uncouth gymnasium of meta magic. And it goes so much deeper than these examples. I don’t know if Io is trying to be rebellious, but its malleability goes far beyond Ruby. And, I’d say it goes beyond Smalltalk and Self and Lisp, since it makes this kind of ripping and tearing completely effortless.