ooc - osdc 2010 - amos wenger
DESCRIPTION
TRANSCRIPT
oocThe Quest for the Holy Grail
OSDC.fr 2010 ooc-lang.org Amos Wenger
Roadmap
I. The origins
II. The best of both worlds
III. Syntactic sweets
IV. Rocking out
V. The legacy
VI. Agora
OSDC.fr 2010 ooc-lang.org Amos Wenger
The Original Sin
● After years of self-teaching➔ The Games Factory/MultiMedia Fusion➔ C++/OpenGL/SDL➔ Java/Xith3D/JOODE
● Back to the real world➔ A C school project➔ Deadline: 6 months➔ No object-orientation in sight
ooc-lang.orgI. The origins
The fool who challenged the gods
● A dead-end idea➔ Java-derived syntax➔ No structure➔ ...instead of working on the actual project
● MOD (Miracle-Oriented Development)➔ Naive « translator »➔ No error checking➔ Bug-ridden
ooc-lang.orgI. The origins
The first-born
● ooc 0.1➔ Written in Java, 11K SLOC➔ Generates C code➔ Handed in along with the real project➔ « Real » project developed in a few days➔ Success!
« Version 1.0 sucks, but ship it anyway »Jeff Atwood (CodingHorror)
ooc-lang.orgI. The origins
A curious alchemy
ooc-lang.orgI. The origins
The test of time
● 4 rewrites later➔ Syntax evolved➔ Still written in Java➔ Type inference➔ Generics (horribly implemented)
● Meanwhile, on #ooc-lang/Freenode➔ A self-hosting effort is started
ooc-lang.orgI. The origins
A dream come true
● In just a few weeks➔ rock = ooc port of the j/ooc compiler➔ first real community effort➔ serious cleanups
● A few more weeks, and➔ rock compiled itself!➔ again...➔ and again...➔ (with a spoon)
ooc-lang.orgI. The origins
C vs Java
● Low-level● « Simple »● « Lightweight »● Fuckload of libraries
● « Object-oriented »● « Safe »● « Modular »● Garbage-collected
Can't wehave both?
ooc-lang.orgII. The best of both worlds
ooc in a nutshell
● Modularity➔ import = Modules➔ use = Libraries
● Types➔ cover = base types from C➔ class = simple inheritance, interface, enum
● Functions➔ name: func (…) -> Type { … }➔ first-class, overload, defaults, varargs
ooc-lang.orgII. The best of both worlds
ooc in a coconut shell
● Generics➔ identity: func <T> (t: T) T { t }→
● try, catch = Exceptions➔ Exception new("You dun goofed!") println()
● version = Platform-specific blocks➔ version(trial) { Time sleepSec(5) }
● operator = Operator overload➔ operator + (a, b: Int) { a - b } // huhu.
ooc-lang.orgII. The best of both worlds
Sweet #1
● Before
Person: class { firstname, lastname: String init: func (firstname, lastname: String) { this firstname = firstname this lastname = lastname }}
● After
init: func (=firstname, =lastname) {}
ooc-lang.orgIII. Syntactic sweets
Sweet #2
● Before
import structs/ArrayListimport structs/HashMapimport structs/Stack
● After
import structs/[ArrayList, HashMap, Stack]
ooc-lang.orgIII. Syntactic sweets
Sweet #3
● Before
set := Set new()set add(a)set add(b)set add(c)
● After
set := Set new(). add(a). add(b). add(c)
ooc-lang.orgIII. Syntactic sweets
Sweet #4
● Before
if(o instanceOf?(LeftBound)) { e as LeftBound left} else if(i instanceOf?(RightBound)) { e as RightBound right}
● Aftermatch o { case lb: LeftBound => lf left case rb: RightBound => rb right}
ooc-lang.orgIII. Syntactic sweets
Sweet #5
● Before
f: func (key: String, value: UInt) { …}map each(f)
● After
list each(|key, value| …)
ooc-lang.orgIII. Syntactic sweets
covers
● Most C apis are OO➔ include someaudiolib➔ SomeType: cover from some_sound { ... }➔ new: static extern(some_sound_load) func➔ play: extern(some_sound_play) func
● We're only revealing their true nature➔ Sound new("ka-ching.ogg") play()
ooc-lang.orgIII. Syntactic sweets
compound covers
● C structs on steroids➔ Point: cover { x, y, z: Float }
● Stack vs Heap allocation➔ p := (3.0, 6.0, 7.0) as Point➔ init: func@ (=x, =y, =z) {}
● By-value semantics● Per-method by-ref semantics with func@
➔ norm: func -> Float { Math sqrt(x*x + y*y + z*z) }➔ set: func@ (=x, =y, =z) {}
ooc-lang.orgIII. Syntactic sweets
apropos allocation
● So far, every object is heap-allocated➔ Boehm GC - conservative & fast (si si.)➔ -gc=off
● But since new is a method like any other...➔ pool := static Pool<This> new()➔ new: static func -> This { pool acquire() }➔ destroy: func { pool release(this) }➔ v := Vector3 new() // sha-zam.
ooc-lang.orgIII. Syntactic sweets
extend
● User-side addition of methods to any type
extend SSizeT { times: func (f: Func(SSizeT)) { f(this) (this - 1) times(f) }}
3 times(|| knock())
ooc-lang.orgIII. Syntactic sweets
rock
➔ ooc compiler in ooc➔ 22K SLOC➔ 132 modules➔ 1900 commits
– Amos Wenger– Friedrich Weber– Rofl0r– Yannic Ahrens– Joshua Rösslein– Scott Olson– Michael Tremel
– Anthony Roja Buck– Noel Cower– Mark Fayngersh– Peter Lichard– Patrice Ferlet– Nick Markwell– Daniel Danopia– Michael Kedzierski– Tim Howard– Mickael9– Viraptor– ...
ooc-lang.orgIV. Rocking out
The plan
ooc-lang.orgIV. Rocking out
Parsing
ResolvingError
reporting
C backend
Generating C
C compilation
Other backends
Drivers
● combine➔ All at the same time➔ Legacy
● sequence (default)➔ One by one, lib cache➔ Partial recompilation
● make➔ Generates a Makefile with the C code➔ Ideal for distribution
ooc-lang.orgIV. Rocking out
Dependencies
● import text/json/Parser➔ Not transitive (unlike include)➔ Cyclic deps are handled
● use antigravity, sdl➔ Name, Description, Version, Requirements➔ Includes, Linker and compiler flags
– pkg-config➔ SourcePath, Imports
● Bye-bye auto-tools!
ooc-lang.orgIV. Rocking out
The SDK
● Mainline SDK➔ is comfortable (net, text, structs, io, math, os...)➔ ...but a bit large for some
● There's no such thing as « The SDK »➔ -sdk=, $OOC_SDK➔ Bare minimum
– Object– Class– a few base types
ooc-lang.orgIV. Rocking out
The legacy
● oosooc operating system, runs on x86 real hw,custom sdk, bits of asm but 0% C
● ooc-tisdk for tigcc, compiles+runs stuff on TI89!
● pyoocuse ooc code from python, json backendzero-configuration
● ruby-inline-oocload+evaluate ruby code inside ooc
ooc-lang.orgV. The legacy
ooc-ti
ooc-lang.orgV. The legacy
The legacy II
● reincarnatepackage manager, in ooc, for ooc. deps based on usefiles, python server backend (nirvana)
● stakoa stack-based language inspired by factor
● langsniffanalyzes a text and find which language it's in
● yajitsimple just-in-time assembler - used in rock for flattening closures
ooc-lang.orgV. The legacy
teeworlds-ai
ooc-lang.orgV. The legacy
The legacy III
● spryIRC bot framework in ooc
● proofsmall testing framework for ooc
● ooc-webooc web applicaton framework
● mustangtemplating engine based onthe infamous mustache
ooc-lang.orgV. The legacy
inception-engine
● game engine, OpenGL+SDL, ingame console
ooc-lang.orgV. The legacy
The legacy IV
<your project here>
http://github.com/languages/ooc
ooc-lang.orgV. The legacy
Questions
➔ Languages– What about Go/Vala?– What about
Scala/Clojure?– What about C++?– What about C#?
➔ Development– Can I contribute?– Do you want money?– What's next for rock?– Where else can I help?
➔ Performance– Is it fast?
➔ Bindings– Does lib X have
bindings yet?– Isn't it tedious to do
bindings?➔ Interoperability
– Let's do rbooc!– Let's do Perl::ooc!– Let's do Y!
ooc-lang.orgVI. Agora
Thanks for listening!
Web http://ooc-lang.org
IRC #ooc-lang on Freenode
Twitter @ooc_lang
Mail [email protected]
OSDC.fr 2010 ooc-lang.org Amos Wenger