Io (lenguaje de programación)

De Wikipedia, la enciclopedia libre
(Redirigido desde «Io (Lenguaje de programación)»)
Saltar a: navegación, búsqueda
Io
Desarrollador(es)
Steve Dekorte, Jonathan Wright, Jeremy Tregunna
[1]
Información general
Paradigma POO, basada en prototipos
Apareció en 2002
Diseñado por Steve Dekorte
Tipo de dato Tipado duro o fuerte, Estático y dinámico
Implementaciones Io Io.NET Acute
Dialectos Europa Metis
Influido por Smalltalk, NewtonScript, Self, Lua, Lisp
Ha influido a Ioke, Restricted Io, Fancy, Luna
Licencia BSD

Io es un lenguaje de programacion del tipo orientada a objetos inspirado en Smalltalk, Self, Lua, Lisp, Act1, y NewtonScript.[1]

Io usa un paradigma de objetos basada en prototipos tal como lenguajes como Self y NewtonScript, eliminando las diferencias entre clases e instancias.

Tal como Smalltalk, absolutamente todo es un objeto y como en el caso de Lisp, los programas son alboles de datos. Io también usa actores para la concurrencia.

También es destacable que Io corre sobre una ligera y portable Máquina virtual.

Historia[editar]

Este lenguaje fue creado por Steve Dekorte el 7 de Marzo del 2002, después de intentar ayudar a un amigo, Dru Nelson, con en lenguaje Cel. Él se encontró con que sabia mucho de como funcionaban los lenguajes y decicio escribir un pequeño lenguaje para entender mejor los problemas.

Filosofía[editar]

Io intenta explorar la unificación conceptual y el dinamismo del lenguaje, priorizando la simplicidad y flexibilidad sobre el rendimiento.

Características[editar]

Sintaxis[editar]

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.

Methods and blocks[editar]

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

Both method and block are higher-order functions.

Examples[editar]

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
:    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.

Referencias[editar]

  1. Io Programming Guide

Enlaces externos[editar]