Io Day 1

My experience with day one of exploring Io through Seven Languages in Seven Weeks.

The next language up is Io a prototype language created by Steve Dekorte in 2002. He wrote it as an exercise to get an understanding of how programming languages work. I’ve used Lua and JavaScript which are also prototype languages. I’m ashamed to say in the past I’ve used these languages without really thinking about how they behave or are structured so I think the next few days will help me to take more of an interest in the theory behind them.

Io is used as an embeddable language with a tiny VM and rich concurrency support. It has a very simple low level syntax. This can make it harder to understand what is going on right away but on the plus side it means there aren’t special rules or exceptions to learn.

As it is a prototype language there is no concept of classes instead every object is a clone of an existing object. The clones are called protoypes.

Each Object has slots which you can refer to with a key. In the example below we’ve created a slot with the key “description” and value “Takes you from A to B”. You get a slots value by sending a message

Io provides a method to view the name of all the slots associated with an Object.

Every object supports type. If the object begins with an uppercase letter its type slot is set to its name. If it doesn’t any call for type will invoke its parents’ type slot i.e. it is not a type. This is in general how missing slots are handling if an Object doesn’t have a particular slot Io calls its parent.

It is very simple to define a method.

You can retrieve a slot using getSlot method passing in a key.

Io has collections which include lists and maps. List is an ordered collection of objects of any type. List has convenience methods to allow it to act as other data types e.g. to act as a stack and handle mathematical problems e.g. average, sum

Map holds key-value pairs.

To create a singleton you just need to override the clone method

Self Study


Some Io example problems

An Io community that will answer questions

A style guide with Io idioms
Io Style Guide


Evaluate 1 + 1 and then 1 + “one”. Is Io strongly typed or weakly typed? Support your answer with code

Is 0 true or false? What about the empty string? Is nil true or false? Support your answer with code.

How can you tell what slots a prototype supports?

What is the difference between = (equals), := (colon equals), and ::= (colon colon equals)? When would you use each one?


Run an Io program from a file.

Execute the code in a slot given its name.

Check out my code at github