jueves, 25 de diciembre de 2008

Io language, a consistent scripting language

Some days ago I discovered a new language called Io (that's capital 'i' and 'o'). It's inspired by smalltalk, but with few features of other languages like self, lisp or lua. FYI, I discovered it among other cool languages. There are even more esoteric languages here.

First thing to say about Io is it's minimalist. Really minimalist. Only look at it's site to see it. As a minimalist language, its doc is also minimalist, so you have to understand the little doc fully, and I mean *really* understand. Io is a Prototype-based language with a syntax similar to smalltalk, but more minimal (assignation is a message too). Its introspection is astonishing aswell, and it introduces a concept of context which I'm still not very confortable with.

Anyway, I've already written my first program (a typical guessing number game) for Io. Here's the code.

guesser := Object clone
guesser toGuess := Random value(100) ceil
file := File standardInput
guess := file readLine asNumber
while(guess != guesser toGuess,
   if(guess < guesser toGuess,
     "higher" println,
     "lower" println)
   guess = file readLine asNumber
)
"ok, el numero es " print
guesser toGuess println


Ah! comunity is very friendly and willing to help (you can find them at #io @freenode

1 comentario:

Randal L. Schwartz dijo...

It’s too bad Io has an implicit non-overridable “asBoolean” method in the Object base class. That’s a mistake… the same one Ruby and Perl made. Only Smalltalk gets that right.

it’d be ok if I could at least override “asBoolean” for my classes as far as ifTrue: and ifFalse: are concerned, but no. Io has its own idea, and that’s that. And I can’t even get it to throw a “must be boolean” error instead. Sigh. So close, and yet so far away.