Posts Tagged ‘Io’

It is day 3 with Io and the subjects that we are tackling are DSLs (domain specific languages) with a help from metaprogramming and concurrency in Io.

As you can expect Io lends itself very naturally to defining DSLs due to its proverbial flexibility – after all the ability to change practically everything what it does, allows you to change the nature of Io to your specific problem domain.

In book this is explained through a simple example of defining a DSL in 13 lines of code that allows map definition in JSON like syntax. Homework 2 sets a similar but simpler goal of defining a syntax based on brackets that allows definition of lists. So here it is:

HW2: Create a list syntax that uses brackets

squareBrackets := method(
    call message arguments map(value,
        self doMessage(value)
    )
)

aList := [1, 2, 30, "forty"]
aList println
aList at(3) println

Read on »

“Day 2″ with Io on my more and more misnamed quest. In this chapter Bruce explains basics of conditionals, looping, operator definition and reflection. He also spends a bit more time to explain message passing in Io.

In conditionals and looping section we get overview of some typical looping and branching structures. Such as a simple infinite loop that will keep evaluating until a break:


loop("you spin me right round..." println)

This can come in handy when implementing things such as servers etc. We also get to meet our good old friends (often seen in most languages) for and while loop:

i := 1
while(i <= 10, i println; i = i + 1)

for(i, 1, 10, i println)

for(i, 10, 1, -1, i println)

First two lines are an example of a while loop. It will print numbers from 1 to 10. While loop takes a condition as a first parameter and it will keep evaluating statements passed in second parameter while the condition holds. Lines 4 and 6 are examples of a for loop. First one prints numbers from 1 to 10 and second one counts back from 10 to 1. This is due to the fact that second for loop utilises the optional step parameter. The parameters of a for loop method are: the name of the counter, the first value, the last value, optional step, and a message with sender. As we can see from example step parameter can be negative. Read on »

My quest to learn seven languages in seven weeks continues. Next language that I am tackling is Io. By this time I am now very well aware, that due to the fact that I don’t have much time for private life lately, I will probably end up spending seven months for the task as mentioned in my previous post. In order to make some visible progress, I decided to blog about my endeavours on a day by day rather than language by language basis.

So let me sum up my thought after day one with Io. You might not heard about this language before as it is not as popular or well known as others mentioned in the book. Io is an object oriented prototype language. This means that it doesn’t have the notion of a class as an object template meaning that there is no distinction between classes and instances – all object are merely clones of other objects. The language is very simple and syntax is minimal. Objects are created by cloning like this:

Food := Object clone

Read on »

Book Cover: Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages by Bruce A. TateLately I have a feeling that Java ecosystem is getting a bit stale. To add to that grass seemed greener on the other side of the fence. Several of my friends that I started my coding career with in J2EE trenches have deserted and moved on to Ruby. None of them ever mentioned regretting the move.

Then new languages that run on JVM started gaining traction and I had a little play with Groovy couple of years ago. I liked the language very much and I grokked why my friends were so happy with Ruby path they’ve chosen. Sheer expressiveness and productivity provided were impressive. I tried to push for Groovy to be used at work but it never got beyond utilities and scripts. I once read that someone said that the problem Groovy has, is that it is not called Business Logic Expression Language. It seems that sentiment rings quite true.

Anyway as I mentioned earlier Java no longer feels quite like a nice new comfy shirt. I am feeling that it’s constraining me and due to my brushes with alternative, there is always that little question in the back of my head: “Am I using the proverbial golden hammer?”

Recently I started looking over the fence again and I am seeing that there seems to be more choice than ever. One of the languages that sparked my interest was Scala. I checked out some of the websites devoted to it and found that community seems quite vibrant and that the language itself is very interesting indeed. Also the fact that it allows and encourages functional programming sparked my interest even further. I am quite familiar with object orientation and have merely brushed with functional programming at uni. The prospect of getting my head around something new and the promises that functional programming paradigm brings (especially regarding concurrency) got me quite excited.

As I almost decided to devote more time to Scala I have attended Agile Testing & BDD eXchange. In one of the presentations Erik Stenman talked about Erlang amongst other things and caught my attention. Read on »