Io (programming language)

Io is a compact prototype -based, object-oriented programming language. The inventor and principal developer of the Americans Steve Dekorte, lays in the development of great importance to minimalism, both in terms of code size and complexity of the syntax and memory consumption. This is also reflected in the motto of the language Io - less is more resist. In Io stronger than in other programming languages ​​is: " Everything is an object ". The language was mainly of Smalltalk (all values ​​are objects ), Self, NewtonScript, Act1 ( prototype - based inheritance, Actors and access ), Lisp ( code at runtime considered and modifiable ) and Lua (compact, embeddable ) inspired.


The interesting thing about Io is primarily the prototype-based approach to object-oriented programming in which no classes are used. Instead, objects are assigned so-called prototypes. Non-existing methods or fields will be searched automatically in the prototype. Thus, an object is defined by the properties of its prototype and its specific differences in state and behavior towards the prototype. This kind of object-oriented programming similar to that of JavaScript.

Another interesting property of Io is the use of so-called Actors to achieve concurrency. An actor is equally a "living" object; it represents a lightweight thread that stores asynchronous method calls in a queue and then executes a after another. Synchronization problems can thus be elegantly circumvented. Such an asynchronous method call returns the result back a transparent futures. Future This blocks access until there is an actual value, and is then the result.

Io is, like other scripting languages ​​also translates into an abstract syntax tree (AST ). The parser is written in C, a Io version is in development ( November 2005). As a special feature of this AST exclusively of Message objects: Each of these objects represents one of the usual in OO languages ​​operations of sending a message to a recipient. This tree of news broadcasts can be inspected at runtime and possibly manipulated. This makes it possible to write Lisp -like macros.

The message tree is interpreted by a simple virtual machine, which only consists of about ten thousand lines of ISO - C code. The virtual machine provides incremental garbage collection (English garbage collection) with support weak references ( weak references ). In addition to this minimum -VM are using add-ons for the most important applications of advanced VMs, including regular expressions, an XML parser, Blowfish encryption and a OpenGL, an audio port and a FreeType Binding. Supported platforms are currently Mac OS X, Linux, BSD systems, IRIX, Windows, Symbian OS and L4.

Io is under the BSD license.

Sample Code

/ / Comments in C style can be used # And Shell comments / * And comments in the style of C * /   "Hello world " print / / Hello World   for (i, 1, 10, i print ) / / prints the numbers from 1 through 10   x: = Object clone / / syntax as in Smalltalk: ': = ​​' creates new slots x = Map clone / / '=' is used to override pretty print x: = method ( / / Create a method with no arguments      foreach ( key, value write ( key, ":", value, "\ n" )) / / loop over 'map ' ) x atPut ( "hi ", 1) / / key - value pair in 'map ' Write x atPut ("hello ", 2) x pretty print / * Output:       hi: 1       hello: 2 * / Web Links

  • Homepage
  • Object-oriented programming language
  • Scripting language