Io (programming language): Difference between revisions
No edit summary |
Jerryobject (talk | contribs) Small WP:COPYEDITs WP:EoS: WP:TERSE, clarify. Avoidable WP:SLASH > comma+space. |
||
(40 intermediate revisions by 28 users not shown) | |||
Line 1: | Line 1: | ||
{{Short description|Prototype-based programming language}} |
|||
{{morerefs|date=August 2014}} |
|||
{{ |
{{More citations needed|date=August 2014}} |
||
{{Primary sources|date=August 2014}} |
|||
{{Infobox programming language |
{{Infobox programming language |
||
|name = Io |
|name = Io |
||
|logo = |
|logo = Io-logo.svg |
||
|logo size = 64px |
|||
|paradigm = [[Object-oriented programming|object-oriented]] [[prototype-based programming|prototype-based]] |
|||
|paradigms = [[Object-oriented programming|object-oriented]] [[Prototype-based programming|prototype-based]] |
|||
|year = {{Start date and age|2002}} |
|||
|designer = Steve Dekorte |
|designer = Steve Dekorte |
||
| |
|developers = Steve Dekorte, Jonathan Wright, Jeremy Tregunna |
||
|released = {{Start date and age|2002}} |
|||
|typing = [[Type system|dynamic]], [[Strongly-typed programming language|strong]] |
|||
|latest release version = 20170906 |
|||
|implementations = [http://www.iolanguage.com/ Io] [http://synrc.com/io/index.htm Io.NET] [https://github.com/acutelanguage/acute Acute] |
|||
|latest release date = {{Start date and age|2017|09|06}}<ref name="Releases">{{cite web |url=https://github.com/IoLanguage/io/releases |title=Io Releases |website=[[GitHub]] |access-date=2020-02-06}}</ref> |
|||
|influenced_by = [[Smalltalk]], [[NewtonScript]], [[Self (programming language)|Self]], [[Lua (programming language)|Lua]], [[Lisp (programming language)|Lisp]], [[Python (programming language)|Python]], [[Actor_model_middle_history#Actor_programming_languages|Act1]] |
|||
|latest preview version = 2019.05.22-alpha |
|||
|influenced = [[Ioke (programming language)|Ioke]], [[Restricted Io (programming language)|Restricted Io]], [[Fancy (programming language)|Fancy]], [[Luna (programming language)|Luna]], [[Potion (programming language)|Potion]] |
|||
|latest preview date = {{Start date and age|2019|05|22}} |
|||
|typing = [[Type system|dynamic]], [[Strong and weak typing|strong]] |
|||
| platform = [[IA-32]], [[x86-64]]; [[ARM architecture family|ARM]], [[Apple M1|M1]]–[[Apple M4|M4]]; [[.NET]] [[Common Language Runtime|CLR]] |
|||
| operating system = [[Microsoft Windows|Windows]], [[macOS]] |
|||
| license = [[BSD licenses|BSD 3-clause]] |
|||
|implementations = [http://iolanguage.org/ Io] [https://web.archive.org/web/20110716175739/http://synrc.com/io/index.htm Io.NET] |
|||
|influenced by = [[Smalltalk]], [[NewtonScript]], [[Self (programming language)|Self]], [[Lua (programming language)|Lua]], [[Lisp (programming language)|Lisp]], [[Python (programming language)|Python]], [[Actor model middle history#Actor programming languages|Act1]] |
|||
|influenced = Ioke, Potion |
|||
}} |
}} |
||
'''Io''' is a pure [[ |
'''Io''' is a pure [[object-oriented programming]] [[Programming language|language]] inspired by [[Smalltalk]], [[Self (programming language)|Self]], [[Lua (programming language)|Lua]], [[Lisp (programming language)|Lisp]], [[Actor model middle history#Actor programming languages|Act1]], and [[NewtonScript]].<ref>[http://iolanguage.org/guide/guide.html#Introduction-Overview Io Programming Guide]</ref> Io has a [[Prototype-based programming|prototype-based]] object model similar to those in Self and NewtonScript, eliminating the distinction between [[Object (computer science)|instance]] and [[Class (computer programming)|class]]. Like Smalltalk, everything is an object and it uses [[Type system|dynamic typing]]. Like Lisp, programs are just data trees. Io uses [[actor model|actor]]s for concurrency. |
||
Remarkable features of Io are its minimal size and openness to using external code resources. |
Remarkable features of Io are its minimal size and openness to using external code resources.<ref>{{Cite web |title=Io Programming: Writing Addons |url=https://en.wikibooks.org/wiki/Io_Programming/Writing_Addons |access-date=2023-06-22 |website=Wikibooks.org: open books for an open world |language=en}}</ref> Io is executed by a small, portable [[virtual machine]]. |
||
== History == |
== History == |
||
The language was created by Steve Dekorte in 2002, after trying to help a friend, Dru Nelson, with his language, Cel. He learned that he really didn't know much about how languages worked, and set out to write a tiny language to understand the problems better.<ref name="Tate_2010"/> |
|||
The language was created by Steve Dekorte around March 7, 2002, after trying to help |
|||
a friend, Dru Nelson, with his language, [[Cel (programming 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. |
|||
== Philosophy == |
== Philosophy == |
||
Io's goal is to explore conceptual unification and [[Dynamic programming language|dynamic languages]], so the tradeoffs tend to favor simplicity and flexibility over performance. |
Io's goal is to explore conceptual unification and [[Dynamic programming language|dynamic languages]], so the tradeoffs tend to favor simplicity and flexibility over performance. |
||
== Features == |
== Features == |
||
* Pure [[Object-oriented programming|object-oriented]] based on [[Prototype-based programming|prototypes]] |
|||
* Code-as-data, [[Homoiconicity|homoiconic]] |
|||
* pure [[object-oriented programming|object-oriented]] based on [[Prototype-based programming|prototypes]] |
|||
* [[Lazy evaluation]] of function parameters |
|||
* code-as-data / [[Homoiconicity|homoiconic]] |
|||
* [[Higher-order function]]s |
|||
* [[lazy evaluation]] of function parameters |
|||
* [[Type introspection|Introspection]], [[Reflective programming|reflection]] and [[metaprogramming]] |
|||
* [[higher-order functions]] |
|||
* introspection, [[reflection (computer science)|reflection]] and [[metaprogramming]] |
|||
* [[Actor model|Actor-based]] [[Concurrency (computer science)|concurrency]] |
* [[Actor model|Actor-based]] [[Concurrency (computer science)|concurrency]] |
||
* [[Coroutine]]s |
* [[Coroutine]]s |
||
* [[ |
* [[Exception handling]] |
||
* |
* Incremental [[Garbage collection (computer science)|garbage collecting]] supporting [[Weak reference|weak links]] |
||
* |
* Highly [[Porting|portable]] |
||
* |
* Shared [[Library (computer science)|library]], [[dynamic-link library]] (DLL), dynamic loading on most platforms |
||
* |
* Small [[virtual machine]] |
||
== Syntax == |
== Syntax == |
||
{{ |
{{Unreferenced section|date=June 2013}} |
||
In its simplest form, |
In its simplest form, Io [[Syntax (programming languages)|syntax]] is composed of one identifier:<ref>{{Cite web |title=io guide |url=https://iolanguage.org/guide/guide.html#Syntax |access-date=2023-06-22 |website=iolanguage.org}}</ref> |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
doStuff |
doStuff |
||
</syntaxhighlight> |
|||
</source> |
|||
Assuming the above doStuff is a [[Method (programming)|method]], it is being called with zero arguments and as a result, explicit parentheses are not required. |
|||
Assuming the above doStuff is a [[Method (computer programming)|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: |
If doStuff had arguments, it would look like this: |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
doStuff(42) |
doStuff(42) |
||
</syntaxhighlight> |
|||
</source> |
|||
Io is a [[message passing]] language, and since everything in Io is a message (excluding [[Comment (computer programming)|comment]]s), 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: |
Io is a [[message passing]] language, and since everything in Io is a message (excluding [[Comment (computer programming)|comment]]s), 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: |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
System version |
System version |
||
</syntaxhighlight> |
|||
</source> |
|||
The above example demonstrates message passing in Io; the "version" message is sent to the "System" object. |
The above example demonstrates message passing in Io; the "version" message is sent to the "System" object. |
||
[[Operator (programming)|Operators]] are a special case where the syntax is not as cut-and-dried as the above examples. The Io [[Syntax analysis|parser]] intercepts a set of operators defined by the interpreter, and translates them to method calls. For example, the following: |
[[Operator (computer programming)|Operators]] are a special case where the syntax is not as cut-and-dried as the above examples. The Io [[Syntax analysis|parser]] intercepts a set of operators defined by the interpreter, and translates them to method calls. For example, the following: |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
1 + 5 * 8 + 1 |
1 + 5 * 8 + 1 |
||
</syntaxhighlight> |
|||
</source> |
|||
translates to: |
translates to: |
||
<source lang="io"> |
|||
1 + (5 *(8)) +(1) |
|||
</source> |
|||
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 [[Operator precedence in C|C precedence levels]]. |
|||
<syntaxhighlight lang="io"> |
|||
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. |
|||
1 +(5 *(8)) +(1) |
|||
</syntaxhighlight> |
|||
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 [[operator precedence]] happening here, and the precedence levels are the same as with the [[Operator precedence in C|C precedence levels]]. |
|||
=== Methods and blocks === |
=== Methods and blocks === |
||
In Io there are two ways of creating [[anonymous function]]s: methods and blocks. Between them, they are almost identical except for [[Scope (programming)|scope]]. While blocks have [[lexical scope]], methods have [[dynamic scope]]. |
|||
Both ''method'' and ''block'' are [[higher-order function]]s. |
|||
In Io there are two ways of creating anonymous functions: methods and blocks. Between them, they are almost identical except for [[Scope (programming)|scope]]. While blocks have [[lexical scope]], methods have [[dynamic scope]]. |
|||
Both ''method'' and ''block'' are [[higher-order functions]]. |
|||
=== Examples === |
=== Examples === |
||
The ubiquitous [[Hello world program]]: |
The ubiquitous [[Hello world program]]: |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
"Hello, world!" println |
"Hello, world!" println |
||
</syntaxhighlight> |
|||
</source> |
|||
New objects are created by [[Cloning (programming)|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: |
New objects are created by [[Cloning (programming)|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: |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
A := Object clone // creates a new, empty object named "A" |
A := Object clone // creates a new, empty object named "A" |
||
</syntaxhighlight> |
|||
</source> |
|||
A simple non-recursive factorial function, in Io: |
A simple non-recursive factorial function, in Io: |
||
<source lang="io"> |
|||
<syntaxhighlight lang="io"> |
|||
factorial := method(n, |
factorial := method(n, |
||
if(n == 0, return 1) |
if(n == 0, return 1) |
||
Line 96: | Line 111: | ||
Range 1 to(n) foreach(i, res = res * i) |
Range 1 to(n) foreach(i, res = res * i) |
||
) |
) |
||
</syntaxhighlight> |
|||
</source> |
|||
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 [[Range (programming)|ranges]], and doesn't use a for() loop, which would be faster. |
|||
Because assignment of <code>res * i</code> to <code>res</code> 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 [[Range (computer programming)|ranges]], and doesn't use a <code>for()</code> loop, which would be faster. |
|||
== See also == |
|||
* [[Ioke (programming language)]] |
|||
== |
== References == |
||
{{Reflist |
{{Reflist|refs= |
||
<ref name="Tate_2010">{{cite book |last=Tate |first=Bruce |year=2010 |title=Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages |location=Raleigh, North Carolina |chapter=Chapter 3: Io |publisher=[[Pragmatic Bookshelf]] |page=[https://archive.org/details/sevenlanguagesin00tate/page/60 60, 72] |isbn=978-1934356593 |edition=1st |chapter-url-access=registration |chapter-url=https://archive.org/details/sevenlanguagesin00tate/page/60}}</ref> |
|||
}} |
|||
== External links == |
== External links == |
||
* |
* {{Official website|iolanguage.org}} |
||
* {{GitHub|IoLanguage|Io}} |
|||
* [http://synrc.com/research/io/index.htm Io at Synrc Research Center] |
|||
* {{ |
* {{Curlie|Computers/Programming/Languages/Io|Io}} |
||
* [https://web.archive.org/web/20121012010044/http://synrc.com/research/io/index.htm Io at Synrc Research Center] |
|||
* [https://github.com/bekkopen/jasmineio Jasmine.Io] BDD Testing Framework for Io |
|||
* {{GitHub|bekkopen/jasmineio|Jasmine.Io}}, Behavior Driven Development (BDD) testing framework for Io |
|||
* [http://pragprog.com/book/btlang/seven-languages-in-seven-weeks Seven Languages in Seven Weeks] book which features Io |
|||
{{DEFAULTSORT:Io (Programming Language)}} |
{{DEFAULTSORT:Io (Programming Language)}} |
||
[[Category:Programming languages]] |
|||
[[Category:Dynamic programming languages]] |
|||
[[Category:Dynamically typed programming languages]] |
[[Category:Dynamically typed programming languages]] |
||
[[Category:Prototype-based programming languages]] |
[[Category:Prototype-based programming languages]] |
||
[[Category:Object-oriented programming languages]] |
|||
[[Category:Programming languages created in 2002]] |
|||
[[Category:Scripting languages]] |
|||
[[Category:2002 software]] |
|||
[[Category:Homoiconic programming languages]] |
Latest revision as of 22:30, 23 June 2024
This article needs additional citations for verification. (August 2014) |
Paradigms | object-oriented prototype-based |
---|---|
Designed by | Steve Dekorte |
Developers | Steve Dekorte, Jonathan Wright, Jeremy Tregunna |
First appeared | 2002 |
Stable release | 20170906
/ September 6, 2017[1] |
Preview release | 2019.05.22-alpha
/ May 22, 2019 |
Typing discipline | dynamic, strong |
Platform | IA-32, x86-64; ARM, M1–M4; .NET CLR |
OS | Windows, macOS |
License | BSD 3-clause |
Website | iolanguage |
Major implementations | |
Io Io.NET | |
Influenced by | |
Smalltalk, NewtonScript, Self, Lua, Lisp, Python, Act1 | |
Influenced | |
Ioke, Potion |
Io is a pure object-oriented programming language inspired by Smalltalk, Self, Lua, Lisp, Act1, and NewtonScript.[2] Io has a prototype-based object model similar to those in Self and NewtonScript, eliminating the distinction between instance and class. Like Smalltalk, everything is an object and it uses dynamic typing. Like Lisp, programs are just data trees. Io uses actors for concurrency.
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
[edit]The language was created by Steve Dekorte in 2002, after trying to help a friend, Dru Nelson, with his language, Cel. He learned 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
[edit]Io's goal is to explore conceptual unification and dynamic languages, so the tradeoffs tend to favor simplicity and flexibility over performance.
Features
[edit]- Pure object-oriented based on prototypes
- Code-as-data, homoiconic
- Lazy evaluation of function parameters
- Higher-order functions
- Introspection, reflection and metaprogramming
- Actor-based concurrency
- Coroutines
- Exception handling
- Incremental garbage collecting supporting weak links
- Highly portable
- Shared library, dynamic-link library (DLL), dynamic loading on most platforms
- Small virtual machine
Syntax
[edit]In its simplest form, Io syntax is composed of one identifier:[5]
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)
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 operator precedence happening here, and the precedence levels are the same as with the C precedence levels.
Methods and blocks
[edit]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
[edit]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.
References
[edit]- ^ "Io Releases". GitHub. Retrieved 2020-02-06.
- ^ Io Programming Guide
- ^ "Io Programming: Writing Addons". Wikibooks.org: open books for an open world. Retrieved 2023-06-22.
- ^ Tate, Bruce (2010). "Chapter 3: Io". Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (1st ed.). Raleigh, North Carolina: Pragmatic Bookshelf. p. 60, 72. ISBN 978-1934356593.
- ^ "io guide". iolanguage.org. Retrieved 2023-06-22.
External links
[edit]- Official website
- Io on GitHub
- Io at Curlie
- Io at Synrc Research Center
- Jasmine.Io on GitHub, Behavior Driven Development (BDD) testing framework for Io