Nick Sieger: RubyConf: Sydney and Rubiniustag:blog.nicksieger.com,2005:TypoTypo2007-08-31T17:47:20+00:00dasdurn:uuid:680b2a69-c52c-444f-8d5b-734a4fdf8e5a2006-12-20T01:44:27+00:002007-08-31T17:47:20+00:00Comment on RubyConf: Sydney and Rubinius by dasd<p><a href='http://www.goolde.com' rel="nofollow"></p>SonOfLiliturn:uuid:0d73991c-c70d-458f-a248-ceace5eacdeb2006-10-25T07:51:46+00:002007-08-31T17:47:13+00:00Comment on RubyConf: Sydney and Rubinius by SonOfLilit<p>_why’s redhanded.hobix.com has a link.</p>Pat Eylerurn:uuid:4da133d1-a189-42fa-b593-9b44d7cd71f02006-10-21T12:08:24+00:002007-08-31T17:47:13+00:00Comment on RubyConf: Sydney and Rubinius by Pat Eyler<p>Evan said that, yes he’s used valgrind with rubinius already.</p>Nickurn:uuid:ba6e75cd-25a3-4d9e-9131-4cc9586c5fd52006-10-21T02:48:42+00:002007-08-31T17:47:12+00:00Comment on RubyConf: Sydney and Rubinius by Nick<p>Evan said the code is in a public SVN repo, but he hasn’t published the URL yet. He’ll probably be transitioning it to Rubyforge soon. When I find out I’ll update here with info.</p>Anonymous Cowardurn:uuid:c64b8c4b-c186-472f-90b7-64331f6615272006-10-20T22:57:52+00:002007-08-31T17:47:12+00:00Comment on RubyConf: Sydney and Rubinius by Anonymous Coward<p>Any URL for this project yet?</p>Nick Siegerurn:uuid:9785ffcc-1680-492c-8b42-6e9111cc85aa2006-10-20T19:07:00+00:002007-08-31T16:50:37+00:00RubyConf: Sydney and Rubinius<p><em>Update: Evan has posted code and has <a href="http://blog.fallingsnow.net/rubinius/">a page set up for the project</a>.</em> </p>
<p>Evan Phoenix (nee Webb), of Seattle.rb, is presenting on Sydney and Rubinius, an experiment in improving the ruby interpreter. Sydney has died, and Rubinius has risen from its ashes, appropriately.</p>
<h2>Why</h2>
<ul>
<li>Why would you write a new Ruby interpreter? It’s fun, it’s a good challenge.</li>
<li>What’s wrong with the existing interpreter – are you hating on Matz? Of course not.</li>
</ul>
<p>Today’s Ruby interpreter is like a big dump truck – sometimes a little slow, but it works for us. YARV is like the red, shiny fire truck.
Both big and complex. Rubinius, by comparison, is like a dune buggy. Fast, light, but you’re going to get sand in your eyes if you drive
it a lot.</p>
<p>The project, admittedly, is naive.</p>
<ul>
<li>Simple architecture and implementation.</li>
<li>As little background magic as possible</li>
<li>No opaque C backend</li>
<li>Leverage axiom of simple == powerful</li>
<li>Less magic means more introspection
<ul>
<li>More control for the developer</li>
<li>Richer introspection: Backtrace, MethodTable objects</li>
</ul></li>
</ul>
<h2>What was Sydney?</h2>
<ul>
<li>Giant patch to 1.8.2 that included reentrancy and thread-safety</li>
<li>Turned out to be a major PITA</li>
<li>CRuby uses a large number of C globals, references to which had to be tracked and fixed</li>
</ul>
<h2>Transition to Rubinius</h2>
<ul>
<li>Ruby borrowed a lot from Smalltalk, so why not try an implementation based on the same concepts?</li>
<li>Prototype A ported the blue-book implementation to Ruby</li>
<li>It worked and validated the basic concept and approach</li>
<li>Prototype B took ideas from A but implemented a bytecode interpreter and compiler. Used RubyInline to access raw memory operations.</li>
<li>At this time the goal emerged to have a translator which could take a prototype and bootstrap itself into C code.</li>
<li>Prototype S was a manual translation of Prototype B into C code to make the implementation quicker.</li>
<li>Prototype W was created to translate parts of Prototype B so that there is a maintainable core in Ruby code itself.</li>
</ul>
<h2>Questions</h2>
<p><em>Q. Since you were starting over, could you use a platform-independent library to ease the process, such as APR?</em> Yes – currently using String and PointerArray from glib.</p>
<p><em>Q. How is performance?</em> Too early to tell – I hope to know by the end of the conference. Prototype S became runnable and usable on the plane here.</p>
<p><em>Q. Can you clarify the goal?</em> To create a Ruby interpreter in Ruby that can translate itself out into a C interpreter.</p>
<p><em>Q. Have you figured out how to link in external libraries in a platform independent way?</em> No. My hope is that the decision will be made to write a common framework for translating to system calls, e.g., SWT.</p>
<p><em>Q. Have you looked at PyPy? (similar project for Python)</em> Yes, and it’s f-in complicated. It worries me actually.</p>
<p><em>Q. Could you have it generate backend code in another language/platform (Java bytecode, CLR)?</em> Yes, I certainly hope so, otherwise I’m wasting my time.</p>
<p><em>Q. How will you add native thread support in a cross-platform way?</em> I hope I won’t have to, by leveraging external tools.</p>
<p><em>Q. If you’re building a Ruby-to-C translator, why write a Ruby interpreter at all?</em> If I didn’t, what would I translate? You still need some core engine to translate. <em>Would it be a subset of Ruby?</em> Yes.</p>
<p><em>Q. Looks very similar to Squeak, have you looked at Squeak code and talked to Squeak people?</em> Looked at code a lot, I’ve really stolen all of their ideas. I haven’t talked to the folks yet because I’m afraid they might laugh at me.</p>
<h2>Resulting Works</h2>
<ul>
<li>SydneyParser: Used parser from Sydney and stole ParseTree’s algorithm for generating a sexp that represents the Ruby code.</li>
<li>SegfaultProtection: detects a segfault in an extension, saves the Ruby interpreter, and raises a memory fault exception instead.</li>
</ul>
<h2>The Nitty Gritty (Red Pill)</h2>
<ul>
<li>All components separated by APIs for swappability</li>
<li>Garbage collector: baker two-space copy collector, and a train GC</li>
<li>Bytecode interpreter: small set of instructions driven by tests and need, so there are no extraneous operations</li>
<li>Compiler: written completely in Ruby, using ParseTree and SexpProcessor. Intended to compile itself to be used as a base compiler for Prototype S.</li>
</ul>
<h2>Future</h2>
<ul>
<li>Other backends – Java, Smalltalk</li>
</ul>
<h2>More questions</h2>
<p><em>Q. Worried about fragmentation?</em> Yes, but I really want to make it as compatible as possible with the current interpreter.</p>
<p><em>Q. Rubinius bytecode compatibile with YARV?</em> No, but I hope to be able to write a bridge to YARV in Rubinius.</p>
<p><em>Q. Have you looked at Valgrind for the C code?</em> Yes, I have. Good possibility for future direction.</p>
<p><em>Q. Can you demo some code?</em> They’re incredibly boring. “Look I got a MethodTable object, I asked for one.”</p>