a small programming language
TRANSCRIPT
![Page 1: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/1.jpg)
Ioa small programming language
![Page 2: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/2.jpg)
Purpose
briefly show Io’s Lua roots
present overview of Io
get your feedback
working together
![Page 3: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/3.jpg)
Some history
interested in dynamic OO languages since 1990
did NeXTstep/ObjC and Python development
found Lua - a great language
used Lua on Yindo project
![Page 4: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/4.jpg)
A new language
liked Lua’s size and speed but...
willing to trade off for greater simplicity
wanted a pure OO language
![Page 5: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/5.jpg)
Lua and Iosmall
simple
highly dynamic
multi-platform
multi-state
BSD/MIT licensed
designed for embedding
incremental garbage collection
syntax that script writers can deal with
![Page 6: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/6.jpg)
Lua
faster
smaller
more mature
larger community
![Page 7: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/7.jpg)
Io
pure OO
no globals
code is data
lazily evaluated arguments
simpler, more consistent syntax and semantics
![Page 8: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/8.jpg)
Io overview
simple prototype-based object model
all actions are messages
simple and consistent syntax
dynamic all messages are dynamic
code is data and runtime modifiable
concurrent all objects can be actors
actors use coroutines
futures supported
and... bundled with extensive official bindings
![Page 9: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/9.jpg)
The language
no keywords
no statements (only expressions)
expressions are composed only of messages
supports lexically scoped blocks
objects can have multiple parents
![Page 10: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/10.jpg)
Message Syntax
Lua Io
a:b() a b
a:b(c) a b(c)
a:b(c, d) a b(c, d)
![Page 11: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/11.jpg)
Operators
expression compiles to
a * 2 * b a *(2) *(b)
![Page 12: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/12.jpg)
Assignment
This separation allows self to be implicit
expression compiles to
a := 2 setSlot(“a”, 2)
a = 2 updateSlot(“a”, 2)
![Page 13: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/13.jpg)
Loops
while(x < 10, ...)
for(i, 1, 10, ...)
loop(...)
10 repeatTimes(...)
![Page 14: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/14.jpg)
Conditions
a := if(b == 1, c, d) // conditions are expressions
if(a == b) then(
...
) elseif(...) then(
...
)
![Page 15: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/15.jpg)
Enumeration
someList := list(“a”, 2.3, “foo”)
someList foreach(i, v,
writeln(i, “ : ”, v)
)
// foreach also works on Maps, Strings, Buffers, etc
![Page 16: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/16.jpg)
Blocks and Methods
foo := method(a, a + b) // object scoped
foo := block(a, a + b) // lexically scoped
![Page 17: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/17.jpg)
Scoping
no globals
variables are local by default
![Page 18: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/18.jpg)
Expressions
a := people select(person, person age < 30)
names := people map(i, person, person name)
![Page 19: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/19.jpg)
“Macro” ExampleglChunk := method(
glPushMatrix
sender doMessage(thisMessage argAt(0))
glPopMatrix
)
glChunk(glTranslated(1,2,3); glRectd(0,0,100,100))
![Page 20: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/20.jpg)
Account := Object clone do(
balance := 0
deposit := method(amount,
balance = balance + amount
)
)
Objects
![Page 21: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/21.jpg)
account := Account clone
account deposit(10.00)
writeln(“balance:”, account balance)
Example
![Page 22: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/22.jpg)
Number double := method(self * 2)
100 double
==> 200
Everything is an Object
![Page 23: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/23.jpg)
Number double := method(self * 2)
Number getSlot(“double”) code
==> “method(self *(2))”
Introspection
![Page 24: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/24.jpg)
Concurrency
url fetch // sync message
f := url @fetch // future message
url @@fetch // async message
url := URL with(“http://www.google.com”)
Futures auto-detect deadlocks
![Page 25: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/25.jpg)
IoVM
Date (high precision, supports dates < 1970)
Duration
List
ImmutableSequence (Strings/Symbols)
Sequence (Buffers)
Map
WeakLink
![Page 26: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/26.jpg)
IoServerSGMLParser (supports XML and HTML)
Socket (async, libevent, supports async DNS)
Transparent Distributed Objects
Vector (supports SIMD/altivec)
Regex
SQLite3
MD5
Blowfish
CGI, URL
![Page 27: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/27.jpg)
IoDesktop
OpenGL, GLU, GLUT
Audio (PortAudio)
Font (FreeType, caches in texture)
Movie (ffmpeg)
Ion user interface toolkit
![Page 28: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/28.jpg)
Ion example
![Page 29: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/29.jpg)
![Page 30: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/30.jpg)
Implementation
![Page 31: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/31.jpg)
Garbage Collector
non-moving, tri-color, write-barrier, generational
![Page 32: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/32.jpg)
Tricks
objects use perfect hashes
lookups done by symbol
objects create hashes on demand
objects are recycled
block contexts are recycled immediately
![Page 33: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/33.jpg)
Platforms
Unix OSX, Linux, *BSD, Irix
Windows Cygwin, Mingw, MSVC
Other Symbian, Syllable, Zeta
![Page 34: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/34.jpg)
What’s next?
Io 1.0 by end of 2005
incremental orthogonal persistence
packages
docs for Ion
bug tracker
revision control
official wiki
![Page 35: a small programming language](https://reader031.vdocuments.site/reader031/viewer/2022012410/616a614211a7b741a351dc31/html5/thumbnails/35.jpg)
Working Together
bindings
Vector, Image, Movie, Font...