A Small Programming Language
A Small Programming Language
Purpose
briefly show Ios Lua roots present overview of Io get your feedback
working together
Some history
interested in dynamic OO languages since 1990 did NeXTstep/ObjC and Python development found Lua - a great language
A new language
liked Luas size and speed but...
Lua and Io
small simple highly dynamic multi-platform multi-state BSD/MIT licensed designed for embedding incremental garbage collection syntax that script writers can deal with
Lua
faster smaller more mature larger community
Io
pure OO no globals code is data lazily evaluated arguments simpler, more consistent syntax and semantics
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
The language
no keywords no statements (only expressions) expressions are composed only of messages supports lexically scoped blocks objects can have multiple parents
Message Syntax
Lua a:b() a:b(c) a:b(c, d) Io ab a b(c) a b(c, d)
Operators
expression a*2*b
Assignment
expression a := 2 a=2 compiles to setSlot(a, 2) updateSlot(a, 2)
Loops
while(x < 10, ...) for(i, 1, 10, ...) loop(...)
10 repeatTimes(...)
Conditions
a := if(b == 1, c, d) // conditions are expressions
Enumeration
someList := list(a, 2.3, foo) someList foreach(i, v, writeln(i, : , v) )
Scoping
no globals variables are local by default
Expressions
Macro Example
glChunk := method( glPushMatrix sender doMessage(thisMessage argAt(0)) glPopMatrix )
glChunk(glTranslated(1,2,3); glRectd(0,0,100,100))
Objects
Account := Object clone do( balance := 0 deposit := method(amount, balance = balance + amount ) )
Example
account := Account clone account deposit(10.00) writeln(balance:, account balance)
Everything is an Object
Number double := method(self * 2) 100 double ==> 200
Introspection
Number double := method(self * 2) Number getSlot(double) code ==> method(self *(2))
Concurrency
url := URL with(http://www.google.com)
IoVM
Date (high precision, supports dates < 1970) Duration List ImmutableSequence (Strings/Symbols) Sequence (Buffers) Map WeakLink
IoServer
SGMLParser (supports XML and HTML) Socket (async, libevent, supports async DNS) Transparent Distributed Objects Vector (supports SIMD/altivec) Regex SQLite3 MD5 Blowfish CGI, URL
IoDesktop
OpenGL, GLU, GLUT Audio (PortAudio) Font (FreeType, caches in texture) Movie (ffmpeg) Ion user interface toolkit
Ion example
Implementation
Garbage Collector
Tricks
objects use perfect hashes lookups done by symbol objects create hashes on demand objects are recycled block contexts are recycled immediately
Platforms
Unix Windows Other OSX, Linux, *BSD, Irix Cygwin, Mingw, MSVC Symbian, Syllable, Zeta
Whats next?
Io 1.0 by end of 2005 incremental orthogonal persistence packages docs for Ion bug tracker revision control official wiki
Working Together