Io (programming language)
This article needs additional citations for verification. (August 2014) |
Developer Steve Dekorte, Jonathan Wright, Jeremy Tregunna | | |
First appeared | 2002 | |
---|---|---|
Stable release | 20170906
/ August 11, 2017[1] | |
strong | ||
Website | iolanguage | |
Major implementations | ||
Io Io.NET | ||
Influenced by | ||
Smalltalk, NewtonScript, Self, Lua, Lisp, Python, Act1 | ||
Influenced | ||
Ioke, Potion |
Io is a pure
Remarkable features of Io are its minimal size and openness to using external code resources. [3] Io is executed by a small, portable virtual machine.
History
The language was created by Steve Dekorte in 2002, after trying to help a friend, Dru Nelson, with his language, Cel. He found out that he really didn't know much about how languages worked, and set out to write a tiny language to understand the problems better.[4]
Philosophy
Io's goal is to explore conceptual unification and dynamic languages, so the tradeoffs tend to favor simplicity and flexibility over performance.
Features
- Pure object-oriented based on prototypes
- Code-as-data / homoiconic
- Lazy evaluation of function parameters
- Higher-order functions
- reflection and metaprogramming
- Actor-based concurrency
- Coroutines
- Exception handling
- Incremental garbage collecting supporting weak links
- Highly portable
- shared librarydynamic loading on most platforms
- Small virtual machine
Syntax
In its simplest form, it is composed of a single identifier:[5]
doStuff
Assuming the above doStuff is a
If doStuff had arguments, it would look like this:
doStuff(42)
Io is a message passing language, and since everything in Io is a message (excluding comments), each message is sent to a receiver. The above example demonstrates this well, but not fully. To describe this point better, let's look at the next example:
System version
The above example demonstrates message passing in Io; the "version" message is sent to the "System" object.
1 + 5 * 8 + 1
translates to:
1 +(5 *(8)) +(1)
All operators in Io are methods; the fact that they do not require explicit parentheses is a convenience. As you can see, there is also a little bit of
Methods and blocks
In Io there are two ways of creating
Both method and block are higher-order functions.
Examples
The ubiquitous
"Hello, world!" println
New objects are created by cloning objects. In Io specifically, a new, empty object is created and only the differences between it and its parent are stored within the new object; this behavior is known as differential inheritance. An example of this behavior is shown:
A := Object clone // creates a new, empty object named "A"
A simple non-recursive factorial function, in Io:
factorial := method(n,
if(n == 0, return 1)
res := 1
Range 1 to(n) foreach(i, res = res * i)
)
Because assignment of res * i
to res
is the last action taken, the function implicitly returns the result and so an explicit return expression is not needed. The above demonstrates the usage of ranges, and doesn't use a for()
loop, which would be faster.
References
- ^ "Io Releases". GitHub. Retrieved 2020-02-06.
- ^ Io Programming Guide
- ^ "Io Programming/Writing Addons - Wikibooks, open books for an open world". en.wikibooks.org. Retrieved 2023-06-22.
- ISBN 978-1934356593.
- ^ "io guide". iolanguage.org. Retrieved 2023-06-22.
External links
- Io home page
- Io at Synrc Research Center
- Io at Curlie
- Jasmine.Io BDD Testing Framework for Io