a small programming language

36
Io a small programming language

Transcript of a small programming language

Page 1: a small programming language

Ioa small programming language

Page 2: a small programming language

Purpose

briefly show Io’s Lua roots

present overview of Io

get your feedback

working together

Page 3: a small programming language

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

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

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

Lua

faster

smaller

more mature

larger community

Page 7: a small programming language

Io

pure OO

no globals

code is data

lazily evaluated arguments

simpler, more consistent syntax and semantics

Page 8: a small programming language

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

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

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

Operators

expression compiles to

a * 2 * b a *(2) *(b)

Page 12: a small programming language

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

Loops

while(x < 10, ...)

for(i, 1, 10, ...)

loop(...)

10 repeatTimes(...)

Page 14: a small programming language

Conditions

a := if(b == 1, c, d) // conditions are expressions

if(a == b) then(

...

) elseif(...) then(

...

)

Page 15: a small programming language

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

Blocks and Methods

foo := method(a, a + b) // object scoped

foo := block(a, a + b) // lexically scoped

Page 17: a small programming language

Scoping

no globals

variables are local by default

Page 18: a small programming language

Expressions

a := people select(person, person age < 30)

names := people map(i, person, person name)

Page 19: a small programming language

“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

Account := Object clone do(

balance := 0

deposit := method(amount,

balance = balance + amount

)

)

Objects

Page 21: a small programming language

account := Account clone

account deposit(10.00)

writeln(“balance:”, account balance)

Example

Page 22: a small programming language

Number double := method(self * 2)

100 double

==> 200

Everything is an Object

Page 23: a small programming language

Number double := method(self * 2)

Number getSlot(“double”) code

==> “method(self *(2))”

Introspection

Page 24: a small programming language

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

IoVM

Date (high precision, supports dates < 1970)

Duration

List

ImmutableSequence (Strings/Symbols)

Sequence (Buffers)

Map

WeakLink

Page 26: a small programming language

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

IoDesktop

OpenGL, GLU, GLUT

Audio (PortAudio)

Font (FreeType, caches in texture)

Movie (ffmpeg)

Ion user interface toolkit

Page 28: a small programming language

Ion example

Page 29: a small programming language
Page 30: a small programming language

Implementation

Page 31: a small programming language

Garbage Collector

non-moving, tri-color, write-barrier, generational

Page 32: a small programming language

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

Platforms

Unix OSX, Linux, *BSD, Irix

Windows Cygwin, Mingw, MSVC

Other Symbian, Syllable, Zeta

Page 34: a small programming language

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

Working Together

bindings

Vector, Image, Movie, Font...

Page 36: a small programming language

I’m interested to hear your thoughts and suggestions

[email protected]

more info at

iolanguage.com