Pegarus & Poison Rubinius VM as a Multilanguage Platform Thursday, July 29, 2010
Brian Ford brixen on {twitter IRC gmail} Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
discussion rant tutorial Q&A interaction Thursday, July 29, 2010
fundamentally, we solve problems Thursday, July 29, 2010
Thursday, July 29, 2010
how? Thursday, July 29, 2010
We spend most of our time talking about “How” dynamic vs static functional vs object-oriented threads vs events Rails vs Django Ruby vs Python vs Perl vs PHP C++ vs Java SQL vs NoSQL Thursday, July 29, 2010
what? Thursday, July 29, 2010
We spend a lot less talking about “What” should we build Facebook? Twitter? Google? Windows? Thursday, July 29, 2010
why? Thursday, July 29, 2010
We spend the least time on the most important question... Why am I doing this? Thursday, July 29, 2010
because Thursday, July 29, 2010
do as I say, not as I do Thursday, July 29, 2010
values morals emotions attachments Thursday, July 29, 2010
right vs wrong Thursday, July 29, 2010
context Thursday, July 29, 2010
$ ruby bt.rb bt.rb:7:in `bar': boo (RuntimeError) from bt.rb:2:in `foo' from bt.rb:7:in `bar' from bt.rb:10 Thursday, July 29, 2010
$ rbx bt.rb An exception occurred running bt.rb boo (RuntimeError) Backtrace: Object#bar {} at bt.rb:7 Object#foo at bt.rb:2 Object#bar at bt.rb:7 main.__script__ at bt.rb:10 Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:67 Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:91 Rubinius::Loader#script at kernel/loader.rb:429 Rubinius::Loader#main at kernel/loader.rb:521 Rubinius::Loader.main at kernel/loader.rb:558 Object#__script__ at kernel/loader.rb:570 Thursday, July 29, 2010
cargo culting is a failure to understand “why?” Thursday, July 29, 2010
we are hard-wired for mimicry Thursday, July 29, 2010
mirror neurons Thursday, July 29, 2010
there is no place in our programming languages for rationale Thursday, July 29, 2010
so, you want to implement a programming language Thursday, July 29, 2010
handful of VMs to choose from... Thursday, July 29, 2010
handful of VMs to choose from... and, they all suck Thursday, July 29, 2010
primary language primary data types Thursday, July 29, 2010
Rubinius An implementation of Ruby github.com/evanphx/rubinius Thursday, July 29, 2010
In ~3.5 years... virtual machine garbage collector bytecode compiler Ruby core library primitives system JIT compiler RubySpecs Thursday, July 29, 2010
In ~3.5 years... 2 virtual machines 1.75 garbage collectors 3 bytecode compilers 1 Ruby core library 2 primitives systems 2 JIT compilers tons of RubySpecs Thursday, July 29, 2010
rewrite lazily Thursday, July 29, 2010
rewrite lazily... but, for everyone’s sake, rewrite! Thursday, July 29, 2010
• C++ virtual machine • generational garbage collector • Ruby bytecode compiler • Ruby core library • native threads (GIL) • Fibers (experimental) • LLVM-base JIT compiler Thursday, July 29, 2010
Pegarus An implementation of LPEG github.com/brixen/pegarus Thursday, July 29, 2010
A Text Pattern-Matching Tool based on Parsing Expression Grammars www.inf.puc-rio.br/~roberto/docs/peg.pdf www.inf.puc-rio.br/~roberto/lpeg/lpeg.html Thursday, July 29, 2010
disadvantages of regexes ad hoc extensions no formal semantics unpredictable complexity difficult optimizations Thursday, July 29, 2010
advantages of a parsing machine fairly simple formal semantics optimizations Thursday, July 29, 2010
Thursday, July 29, 2010
/./ Thursday, July 29, 2010
/a/ Thursday, July 29, 2010
/.a/ Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Thursday, July 29, 2010
Poison An interpretation of Potion github.com/brixen/poison Thursday, July 29, 2010
Potion syntax* * examples from _why’s docs Thursday, July 29, 2010
Potion syntax* * examples from _why’s docs Thursday, July 29, 2010
Potion syntax* * examples from _why’s docs Thursday, July 29, 2010
Potion syntax* * examples from _why’s docs Thursday, July 29, 2010
Potion syntax* * examples from _why’s docs Thursday, July 29, 2010
Potion syntax* * examples from _why’s docs Thursday, July 29, 2010
$ cat test.pn "hello" print Thursday, July 29, 2010
$ bin/poison test.pn Script @statements: \ Statements @statements: \ Expression @expression: \ Value @value: \ String @value: "hello" Message @name: "print" Thursday, July 29, 2010
Some missing parts exceptions method arities variadic methods expression grouping singleton methods class methods Thursday, July 29, 2010
Rubinius rbx compile --help Thursday, July 29, 2010
$ rbx compile -S -e 'a = 1' [:script, [:lasgn, :a, [:lit, 1]]] Thursday, July 29, 2010
$ rbx compile -A -e 'a = 1' Script @name: __script__ @file: "(snippet)" @body: \ LocalVariableAssignment @line: 1 @name: a @variable: nil @value: \ FixnumLiteral @line: 1 @value: 1 Thursday, July 29, 2010
$ rbx compile -B -e 'a = 1' ============= :__script__ ============== Arguments: 0 required, 0 total Locals: 1: a Stack size: 2 Lines to IP: 1: 0-5 0000: meta_push_1 0001: set_local 0 # a 0003: pop 0004: push_true 0005: ret ---------------------------------------- Thursday, July 29, 2010
$ rbx compile -B -e 'def foo(a) a + 1 end; foo 5' ============= :__script__ ============== Arguments: 0 required, 0 total Locals: 0 Stack size: 5 Lines to IP: 1: 0-23 0000: push_rubinius 0001: push_literal :foo 0003: push_literal #<Rubinius::CompiledMethod foo file=(snippet)> 0005: push_scope 0006: push_variables 0007: send_stack :method_visibility, 0 0010: send_stack :add_defn_method, 4 0013: pop 0014: push_self 0015: push_int 5 0017: allow_private 0018: send_stack :foo, 1 0021: pop 0022: push_true 0023: ret ---------------------------------------- ================= :foo ================= Arguments: 1 required, 1 total Locals: 1: a Stack size: 3 Lines to IP: 1: 0-5 0000: push_local 0 # a 0002: meta_push_1 0003: meta_send_op_plus :+ 0005: ret ---------------------------------------- Thursday, July 29, 2010
$ rbx compile -B -N foo -e 'def foo(a) a + 1 end; foo 5' ================= :foo ================= Arguments: 1 required, 1 total Locals: 1: a Stack size: 3 Lines to IP: 1: 0-5 0000: push_local 0 # a 0002: meta_push_1 0003: meta_send_op_plus :+ 0005: ret ---------------------------------------- Thursday, July 29, 2010
Thank you Thursday, July 29, 2010
Image Credits [3] lwn.net/images/conf/ks-jls-09/matz2.jpg [7] www.thadguy.com/wp-content/uploads/2007/07/modal-logic-can-solve-all-problems.png [9] blog.tmcnet.com/blog/tom-keating/images/chow-hound-what-no-gravy.jpg [10] www.toothpastefordinner.com/030910/what-did-you-have-for-breakfast.gif [11] spamusement.com/gfx/17.gif [16] pyeuler.wdfiles.com/local--files/start/functional-programming-joke.png [21] student.biology.arizona.edu/honors2007/group11/monkeysee.jpg Thursday, July 29, 2010
Recommend
More recommend