Thursday, November 11, 2010

More fun with Io

One of Io's distinguishing features is an ability to extend its own syntax. Suppose that for some reason (for example to improve the readability of your code) you need unless keyword, similar to the one used in Ruby. You can define it as follows:
Object unless := method(if(call evalArgAt(0) not, call evalArgAt(1), call evalArgAt(2)))
That's it. You can now use a new keyword in your scripts:
Io> x := 15; unless(x < 10, "passed", "failed")
==> passed
Io> x := 5; unless(x < 10, "passed", "failed")
==> failed
In Common Lisp a similar effect can be achieved by using a macro like this:
(defmacro unless (condition &rest body) `(if (not ,condition) ,@body))
but in contrast to Common Lisp, Io does not use separate constructs to extend the language - what you can do in Lisp using macros, you can do in Io using only its own introspective features.

Saturday, November 6, 2010

Language of the year 2011

Probably the biggest programming language hit of the last year was Go - it was also (according to Tiobe) the fastest growing language in 2009. Year 2008 belonged to Erlang: Amazon started their SimpleDB based on Erlang, and Facebook announced their Erlang powered chat application.
For some time I was wondering if the incoming year can bring another player entering the game, and I came to a conclusion that a good candidate is Io. It's a prototype-based programming language, which is amazing in many aspects: it combines very simple grammar with incredible power, provides an interactive shell and a rich set of libraries out of the box, it also allows hundreds of thousands of concurrent processes through actor based model. Io is surprisingly mature as for a language with so few Internet resources and is definitely worth trying - it has been recommended even by some renowned hackers like _why and Ruby's creator Matsumoto Yukihiro. You can find a few Io example routines here.
Give Io a try if you have a minute, I can guarantee that you won't be sorry.