My experience with day one of exploring Io through Seven Languages in Seven Weeks.
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
Some Io example problems
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