Io (programming language)

From Wikipedia, the free encyclopedia

(Redirected from Io language)
Jump to: navigation, search
Io
Paradigm object-oriented prototype-based
Appeared in 2002
Designed by Steve Dekorte
Developer Steve Dekorte (and others)
Typing discipline dynamic, strong
Major implementations Io
Influenced by Smalltalk, NewtonScript, Self, Lua, Lisp, Act1

Io is a pure object-oriented programming language inspired by Smalltalk, Self, Lua, Lisp, Act1, and NewtonScript. Io has a prototype-based object model similar to the ones in Self and NewtonScript, eliminating the distinction between instance and class. Like Smalltalk, everything is an object and it uses dynamic typing. Like Lisp, there are no statements, flow control is achieved using functions, and programs are just data trees. Io uses actors for concurrency, a technique rarely used in modern programming languages.

Remarkable features of Io are its efficiency, minimal size and openness to using external code resources. Io is executed by a small, portable virtual machine.

Contents


The language was created by Steve Dekorte around March 7, 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.

Io's goal is to explore conceptual unification and dynamic languages, so the tradeoffs tend to favor simplicity and flexibility over performance.

The syntax of Io is almost non-existent. In its simplest form, it is composed of a single identifier:

doStuff

Assuming the above doStuff is a method, it is being called with zero arguments and as a result, explicit parentheses are not required.

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.

Operators are a special case where the syntax is not as cut-and-dried as the above examples. The Io parser intercepts a set of operators defined by the interpreter, and translates them to method calls. For example, the following:

1 + 5 * 8 + 1

translates to:

1 +(5 *(8)) +(1)

As you can see, there is also a little bit of operator precedence happening here, and the precedence levels are the same as with the C precedence levels.

Operators were also turned into method calls. In fact, all operators in Io are methods; the fact that they do not require explicit parentheses is a convenience.

In Io there are two ways of creating anonymous functions: methods and blocks. Between them, they are almost identical except for one thing: scope. While blocks have lexical scope, methods have dynamic scope.

Both methods and blocks are higher-order functions.

The ubiquitous Hello world program:

"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
  n to(1) foreach(i, res = res * i)
  res
)

The above demonstrates the usage of ranges, and doesn't use a for() loop which is faster.

Wikibooks
Wikibooks' Programming has more about this subject:
Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.