pegarus & poison - o'reilly mediaassets.en.oreilly.com/1/event/45/pegarus and poison_...
TRANSCRIPT
We spend most of our time talking about “How”
dynamic vs staticfunctional vs object-oriented
threads vs eventsRails vs Django
Ruby vs Python vs Perl vs PHPC++ vs Java
SQL vs NoSQL
Thursday, July 29, 2010
We spend a lot less talking about “What”
should we build Facebook?Twitter?Google?
Windows?
Thursday, July 29, 2010
We spend the least time on the most important question...
Why am I doing this?
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
In ~3.5 years...
virtual machinegarbage collectorbytecode compilerRuby core libraryprimitives systemJIT compilerRubySpecs
Thursday, July 29, 2010
In ~3.5 years...
virtual machinesgarbage collectorsbytecode compilersRuby core libraryprimitives systemsJIT compilersof RubySpecs
21.75
3122
tons
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
A Text Pattern-Matching Tool based on Parsing Expression Grammars
www.inf.puc-rio.br/~roberto/docs/peg.pdfwww.inf.puc-rio.br/~roberto/lpeg/lpeg.html
Thursday, July 29, 2010
disadvantages of regexes
ad hoc extensionsno formal semanticsunpredictable complexitydifficult optimizations
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
exceptionsmethod aritiesvariadic methodsexpression groupingsingleton methodsclass methods
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 totalLocals: 1: aStack size: 2Lines to IP: 1: 0-5
0000: meta_push_1 0001: set_local 0 # a0003: 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 totalLocals: 0Stack size: 5Lines to IP: 1: 0-23
0000: push_rubinius 0001: push_literal :foo0003: push_literal #<Rubinius::CompiledMethod foo file=(snippet)>0005: push_scope 0006: push_variables 0007: send_stack :method_visibility, 00010: send_stack :add_defn_method, 40013: pop 0014: push_self 0015: push_int 50017: allow_private 0018: send_stack :foo, 10021: pop 0022: push_true 0023: ret ----------------------------------------
================= :foo =================Arguments: 1 required, 1 totalLocals: 1: aStack size: 3Lines to IP: 1: 0-5
0000: push_local 0 # a0002: 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 totalLocals: 1: aStack size: 3Lines to IP: 1: 0-5
0000: push_local 0 # a0002: meta_push_1 0003: meta_send_op_plus :+0005: ret ----------------------------------------
Thursday, July 29, 2010
[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
Image Credits
Thursday, July 29, 2010