<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>def euler(x); cos(x) + i*sin(x); end - Home</title>
  <id>tag:blog.brightredglow.com,2009:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.7.2">Mephisto Noh-Varr</generator>
  <link href="http://blog.brightredglow.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.brightredglow.com/" rel="alternate" type="text/html"/>
  <updated>2009-03-18T00:10:45Z</updated>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-03-18:5331</id>
    <published>2009-03-18T00:05:00Z</published>
    <updated>2009-03-18T00:10:45Z</updated>
    <link href="http://blog.brightredglow.com/2009/3/18/a-vm-by-any-other-name" rel="alternate" type="text/html"/>
    <title>A VM by any other name</title>
<content type="html">
            &lt;p&gt;With the recent switch away from the spaghetti stack execution model, &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt; has also acquired native threads. A big part of understanding something is syncing up our mental model with reality. If you&#8217;ve ever tried to explain what an OS is to your mom, you know that can be a challenge. So let&#8217;s peel back a few layers and see where these native thread critters fit into Rubinius.&lt;/p&gt;


	&lt;p&gt;Rubinius is an implementation of the Ruby programming language. One of the bigger components is the virtual machine. But what is that? Unfortunately, &lt;em&gt;virtual machine&lt;/em&gt; is a label for a category of software (and maybe hardware) that, well, does a bunch of different things. Virtual machines are often thought of as virtual computers or virtual CPUs. The problem with trying to equate two things is that you look at the one you know about and try to understand the one you do not by looking for analogous structures. Therein lie the seeds of misunderstanding. Since Rubinius has this &lt;code&gt;vm/&lt;/code&gt; directory, we&#8217;ve got to try to nail some of this gelatin to the wall.&lt;/p&gt;


	&lt;p&gt;Thinking about threads running inside a physical computer, you might visualize the relationship something like the following Ruby-ish pseudo code. As the program starts up, it creates a virtual machine.&lt;/p&gt;


&lt;pre&gt;&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='fu'&gt;main&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  vm = &lt;span class='co'&gt;VM&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='c'&gt;# do some setup&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  vm.run&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/pre&gt;

	&lt;p&gt;Sometime later in the program, you add a new thread, which might be implemented something like this.&lt;/p&gt;


&lt;pre&gt;&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='co'&gt;Thread&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;  thr = &lt;span class='co'&gt;VM&lt;/span&gt;.threads.create&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='c'&gt;# ...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;return&lt;/span&gt; thr&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/pre&gt;

	&lt;p&gt;You might imagine the &lt;code&gt;VM&lt;/code&gt; instance having a &lt;code&gt;Scheduler&lt;/code&gt; component that would supervise the threads and arrange for running them on one or more processors or cores. In this model, the VM is really like a virtual computer in which all execution is occurring. In other words, the VM is composed of multiple threads of execution.&lt;/p&gt;


	&lt;p&gt;The point of this mental exercise is to expose the tacit assumptions we might have about our mapping between a real computer and the virtual machine. Now let&#8217;s delve into Rubinius.&lt;/p&gt;


	&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; function is located in &lt;code&gt;vm/drivers/cli.cpp&lt;/code&gt;. The first thing it does is create an instance of &lt;code&gt;Environment&lt;/code&gt;, which is composed of an instance of &lt;code&gt;VMManager&lt;/code&gt;, &lt;code&gt;SharedState&lt;/code&gt;, and &lt;code&gt;VM&lt;/code&gt;. In the &lt;code&gt;Environment&lt;/code&gt; constructor, the command line is parsed for configuration options. Then the manager creates a new shared state. The shared state creates a vm. And finally the vm is initialized. During initialization, the &lt;code&gt;ObjectMemory&lt;/code&gt; is created. The object memory in turn is composed of garbage collected heaps for the young and mature generations.&lt;/p&gt;


	&lt;p&gt;Back in &lt;code&gt;main&lt;/code&gt;, a platform-specific configuration file is loaded, the &#8220;vm&#8221; is booted, the command line is loaded into &lt;code&gt;ARGV&lt;/code&gt;, the kernel is loaded (i.e. the compiled versions of the files located in the &lt;code&gt;kernel/&lt;/code&gt; directory), the preemption and signal threads are started, and finally the compiled version of &lt;code&gt;kernel/loader.rb&lt;/code&gt; is run, which will process the command line arguments, run scripts, start &lt;span class='caps'&gt;IRB&lt;/span&gt;, etc. When your script, &lt;span class='caps'&gt;IRB&lt;/span&gt;, &lt;code&gt;-e&lt;/code&gt; command, etc. finish running, &lt;code&gt;loader.rb&lt;/code&gt; finishes, &lt;code&gt;main&lt;/code&gt; finishes, resources are cleaned up, and finally the process exits.&lt;/p&gt;


	&lt;p&gt;Whew. The point of this whirlwind tour is to illustrate that &lt;em&gt;VM&lt;/em&gt; is a rather fuzzy concept, even though we have a class named &lt;code&gt;VM&lt;/code&gt;. Now let&#8217;s take a look at how threads fit in.&lt;/p&gt;


	&lt;p&gt;Rubinius has a 1:1 native thread model. In other words, each time you do &lt;code&gt;Thread.new&lt;/code&gt; in your Ruby code, the instance returned maps to a single native thread. In fact, let&#8217;s look at the code for &lt;code&gt;Thread.new&lt;/code&gt; in &lt;code&gt;kernel/common/thread.rb&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;&lt;span class='r'&gt;class&lt;/span&gt; &lt;span class='cl'&gt;Thread&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;def&lt;/span&gt; &lt;span class='pc'&gt;self&lt;/span&gt;.new(*args, &amp;amp;block)&lt;tt&gt;
&lt;/tt&gt;    thr = allocate&lt;tt&gt;
&lt;/tt&gt;    thr.initialize *args, &amp;amp;block&lt;tt&gt;
&lt;/tt&gt;    thr.fork&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;return&lt;/span&gt; thr&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/pre&gt;

	&lt;p&gt;The calls to &lt;code&gt;allocate&lt;/code&gt; and &lt;code&gt;fork&lt;/code&gt; are implemented as primitives in C++ code. They are short, so we&#8217;ll take a look at them, too.&lt;/p&gt;


&lt;pre&gt;&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;Thread* Thread::allocate(STATE) {&lt;tt&gt;
&lt;/tt&gt;  VM* vm = state-&amp;gt;shared.new_vm();&lt;tt&gt;
&lt;/tt&gt;  Thread* thread = Thread::create(state, vm);&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  return thread;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;Object* Thread::fork(STATE) {&lt;tt&gt;
&lt;/tt&gt;  state-&amp;gt;interrupts.enable_preempt = true;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  native_thread_ = new NativeThread(vm);&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  // Let it run.&lt;tt&gt;
&lt;/tt&gt;  native_thread_-&amp;gt;run();&lt;tt&gt;
&lt;/tt&gt;  return Qnil;&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/pre&gt;

	&lt;p&gt;The call to &lt;code&gt;allocate&lt;/code&gt; creates a new instance of &lt;code&gt;VM&lt;/code&gt; as thread local data. The call to &lt;code&gt;fork&lt;/code&gt; creates the new native thread. The call to &lt;code&gt;native_thread_-&amp;gt;run()&lt;/code&gt; will eventually call the &lt;code&gt;__run__&lt;/code&gt; method in &lt;code&gt;kernel/common/thread.rb&lt;/code&gt;. Something to note about this snippet of C++ code is the nice consistency between the primitives and the Ruby code that calls them.&lt;/p&gt;


	&lt;p&gt;We&#8217;ve encountered the &lt;code&gt;VM&lt;/code&gt; class in two contexts: 1) when starting up the Rubinius process, and 2) when creating a new &lt;code&gt;Thread&lt;/code&gt;. We can consider the &lt;code&gt;VM&lt;/code&gt; instance to be an abstraction of the state of a single thread of execution, and in fact, &lt;code&gt;state&lt;/code&gt; is the name most often given to an instance of &lt;code&gt;VM&lt;/code&gt; in the Rubinius source.&lt;/p&gt;


	&lt;p&gt;As we&#8217;ve seen, Rubinius as a running process is composed of various abstractions, including the &lt;code&gt;Environment&lt;/code&gt;, &lt;code&gt;SharedState&lt;/code&gt;, &lt;code&gt;NativeThread&lt;/code&gt;, and &lt;code&gt;VM&lt;/code&gt; to name a few. While it is accurate to call Rubinius a virtual machine, it is apparent that concept can cover a fair bit of complexity. But breaking it into parts makes it fairly easy to understand. Let us know what things you&#8217;d like to understand better. We have the &lt;code&gt;doc/&lt;/code&gt; directory in the source that we&#8217;re (slowly) building out. If you&#8217;re interested in contributing, docs would be a great way to help everyone.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-03-06:5329</id>
    <published>2009-03-06T22:24:00Z</published>
    <updated>2009-03-06T22:25:54Z</updated>
    <link href="http://blog.brightredglow.com/2009/3/6/come-to-the-open-source-bridge-conference" rel="alternate" type="text/html"/>
    <title>Come to the Open Source Bridge conference</title>
<content type="html">
            &lt;p&gt;If you live in or would like to visit beautiful Portland, OR, consider &lt;a href='http://opensourcebridge.org/attend/'&gt;signing up&lt;/a&gt; for the &lt;a href='http://opensourcebridge.org/'&gt;Open Source Bridge&lt;/a&gt; conference. I will (probably) be giving a talk on &lt;a href='http://opensourcebridge.org/proposals/13'&gt;RubySpec&lt;/a&gt; and &lt;a href='http://opensourcebridge.org/proposals/12'&gt;Rubinius 1.0&lt;/a&gt;. There&#8217;s lots of interesting folks giving great &lt;a href='http://opensourcebridge.org/events/2009/proposals/'&gt;talks&lt;/a&gt;. This is an opportunity to hear how people are developing the open-source community.&lt;/p&gt;


	&lt;p&gt;Hope to see you there!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-03-03:5328</id>
    <published>2009-03-03T19:41:00Z</published>
    <updated>2009-03-03T19:50:17Z</updated>
    <link href="http://blog.brightredglow.com/2009/3/3/what-is-rubyspec" rel="alternate" type="text/html"/>
    <title>What is RubySpec?</title>
<content type="html">
            &lt;p&gt;According to the folks over at &lt;a href='http::rubyspec.org'&gt;http://rubyspec.org&lt;/a&gt;, &#8220;RubySpec is a project to write a complete, executable specification for the Ruby programming language.&#8221; As with any sufficiently concise summary, there&#8217;s some opportunity for misunderstanding here, so let&#8217;s explore a few aspects of this definition.&lt;/p&gt;


	&lt;p&gt;Since this post is a bit long, here&#8217;s a summary:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;There is one &lt;em&gt;standard&lt;/em&gt; definition of Ruby.&lt;/li&gt;
		&lt;li&gt;RubySpec benefits the whole Ruby ecosystem.&lt;/li&gt;
		&lt;li&gt;RubySpec does not guarantee that program A will run on implementation B.&lt;/li&gt;
		&lt;li&gt;RubySpec includes only specs for the correct behavior when bugs are discovered in &lt;span class='caps'&gt;MRI&lt;/span&gt;.&lt;/li&gt;
		&lt;li&gt;Help your favorite Ruby implementation by contributing to RubySpec.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;First, what does it mean to be &#8220;the Ruby programming language&#8221;? The answer to this question used to be a little simpler before Ruby 1.9. Originally, there was the single Ruby implementation that Matz and friends built, referred to as &lt;span class='caps'&gt;MRI&lt;/span&gt; (Matz&#8217;s Ruby Interpreter). Now there is also RubyVM or &lt;span class='caps'&gt;KRI&lt;/span&gt; (Koichi&#8217;s Ruby Implementation) or simply Ruby 1.9. Either way, &lt;span class='caps'&gt;MRI 1&lt;/span&gt;.8.x and [KM]RI 1.9.x are the &lt;em&gt;standard&lt;/em&gt; or &lt;em&gt;reference&lt;/em&gt; implementations for Ruby. Everyone else is making an alternative implementation that either complies with the standard or deviates from it.&lt;/p&gt;


	&lt;p&gt;This is the way RubySpec is written. I realize that it&#8217;s possible to consider &#8220;the Ruby programming language&#8221; to be an abstract thing and &lt;em&gt;all&lt;/em&gt; the Ruby projects as merely more or less equal attempts to implement the language. I won&#8217;t try to convince you that either way of viewing this is more or less correct. I just want to be clear about the way RubySpec views it.&lt;/p&gt;


	&lt;p&gt;At the time I began writing what eventually became RubySpec, the only Ruby implementation in wide-spread use was &lt;span class='caps'&gt;MRI&lt;/span&gt;. My biggest concern when getting involved with &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt; was that the project would be consistent with Ruby the way Matz defines it and not cause fragmentation of the language. My reason was quite selfish. I loved programming in Ruby and I wanted to see the language thrive.&lt;/p&gt;


	&lt;p&gt;So, RubySpec&#8217;s over-arching value proposition is a single, comprehensive definition of the Ruby programming language. To see if the value proposition is actually universal, let&#8217;s examine the three categories of people involved with Ruby: consumers, programmers, and implementers.&lt;/p&gt;


	&lt;p&gt;I define &lt;em&gt;consumers&lt;/em&gt; as anyone who depends on a product or service written in Ruby. Consumers may use these products and services directly, or they may own or work for companies that provide them, or they may use products and services that are themselves supported by software written in Ruby. Consumers are the biggest part of the Ruby ecosystem.&lt;/p&gt;


	&lt;p&gt;Interacting closely with the consumers are &lt;em&gt;programmers&lt;/em&gt;, the men and women who write software or frameworks in Ruby. In fact, the same folks may be both consumers and programmers.&lt;/p&gt;


	&lt;p&gt;The &lt;em&gt;implementers&lt;/em&gt; are the people writing Ruby implementations for the programmers and consumers. They want to experiment with ways to better support programmers without worrying that they are breaking their programs in unknown ways. Again, the implementers may be programmers or consumers themselves.&lt;/p&gt;


	&lt;p&gt;If you&#8217;ve ever used a proprietary implementation of a programming language or know what vendor lock-in means, then I am preaching to the choir. If not, then consider that system requirements change, hardware changes, services change, customers change, development teams change, everything changes.&lt;/p&gt;


	&lt;p&gt;Consumers want assurance that the products and services on which they depend will remain available and will grow with their needs. Programmers want assurance that they will be able to meet their customers&#8217; needs. Implementers want to provide programmers the ability to do so. A single, consistent Ruby language really is a win-win-win situation.&lt;/p&gt;


	&lt;p&gt;With everything seeming so sunny, one may be tempted to think: &#8220;If implementation A and B perform the same on RubySpec, then a program running on A now should run just fine on B.&#8221; Unfortunately, it is not quite that simple. Just as a program may not run on both &lt;span class='caps'&gt;OS X&lt;/span&gt; and Linux simply because &lt;span class='caps'&gt;MRI&lt;/span&gt; runs on both. Once in a while, RubySpec finds bugs in &lt;span class='caps'&gt;MRI&lt;/span&gt;, though not that often considering the tens of thousands of expectations. Since a lot of the code in &lt;span class='caps'&gt;MRI&lt;/span&gt; has been around for years, this illustrates that even running thousands of programs (RubySpec is just another program) is no guarantee that there are not bugs lurking around the corner.&lt;/p&gt;


	&lt;p&gt;What can tell you whether a program will (likely) run on both A and B is the program&#8217;s own test suite. In this regard, the program&#8217;s test suite and RubySpec are complementary. If the tests discover something that RubySpec did not, it is an opportunity to enhance RubySpec. If running on another implementation expose issues not uncovered by the program&#8217;s tests, it is an opportunity to enhance the tests.&lt;/p&gt;


	&lt;p&gt;Ruby versioning is complex affair and another area where possible misunderstandings exist about RubySpec. It seems pretty simple that Ruby 1.8 and Ruby 1.9 are different. But then there is 1.8.7, which is like 1.8.6 and 1.9. And there may be 1.8.8, which will likely be different than 1.8.6 and 1.8.7 and 1.9. It is dizzying. RubySpec handles the different versions by using the &lt;code&gt;ruby_version_is&lt;/code&gt; guard. (Read the &lt;a href='http://rubyspec.org/wiki/rubyspec/Guards'&gt;guard documentation&lt;/a&gt; for full details.)&lt;/p&gt;


	&lt;p&gt;Generally, the version guards work fine. Each implementation provides the &lt;code&gt;RUBY_VERSION&lt;/code&gt; constant and based on its value, the guards permit the correct specs to run. Some have assumed this means RubySpec will tell you that alternate implementation A is just like &lt;span class='caps'&gt;MRI&lt;/span&gt; version X.Y.Z &#8220;bugs and all&#8221; because A says it is version X.Y.Z.&lt;/p&gt;


	&lt;p&gt;The principles RubySpec strives for are correctness, clarity, and consistency. There is no way to provide &lt;em&gt;clear&lt;/em&gt; and &lt;em&gt;consistent&lt;/em&gt; results if RubySpec included specs for the &lt;em&gt;wrong&lt;/em&gt; behavior as well as specs for the correct behavior. Either clarity or consistency suffer, badly. Matz is the one who ultimately determines whether a behavior is a bug or not. RubySpec simply includes specs for only correct behaviors.&lt;/p&gt;


	&lt;p&gt;These are some of the factors that complicate this issue:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;There is no definition of what &lt;em&gt;is&lt;/em&gt; a bug. It may be a segfault, an incorrect value computed, a frozen state not set or respected, the wrong exception class raised. The list is endless and impossible to consistently categorize.&lt;/li&gt;
		&lt;li&gt;All implementations, including &lt;span class='caps'&gt;MRI&lt;/span&gt;, have their own release processes and schedules.&lt;/li&gt;
		&lt;li&gt;RubySpec is a social as well as technical project. An aspect of the value-added proposition for any given implementation is the quality that they provide. There is no way the alternative implementations will consistently agree to defer fixing bugs until &lt;span class='caps'&gt;MRI&lt;/span&gt; releases a fix. Rather than supporting cherry-picking which bugs to fix, RubySpec only includes correct specs.&lt;/li&gt;
		&lt;li&gt;Bugs discovered by RubySpec in &lt;span class='caps'&gt;MRI&lt;/span&gt; are quite rare.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Finally, contributing to RubySpec is one of the lowest barriers-to-entry means of supporting your favorite Ruby implementation and the Ruby ecosystem as a whole.&lt;/p&gt;


	&lt;p&gt;Consider what the view looks like from the outside: Ruby has a vibrant community of implementations meeting consumers&#8217; and programmers&#8217; needs on virtually every significant platform, including on Java, .NET, Mac (Obj-C), and semi-platform-agnostic implementations like &lt;span class='caps'&gt;MRI&lt;/span&gt; and Rubinius. Internally, it means that Ruby programmers can focus more on writing their programs using the best tools for the job, confident that if requirements change they can move to a different platform with ease and confidence.&lt;/p&gt;


	&lt;p&gt;Check out the &lt;a href='http://rubyspec.org/wiki/rubyspec'&gt;RubySpec docs&lt;/a&gt; if you are interested in helping out.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-03-03:5327</id>
    <published>2009-03-03T07:01:00Z</published>
    <updated>2009-03-03T07:01:33Z</updated>
    <link href="http://blog.brightredglow.com/2009/3/3/when-describe-ing-it-ain-t-enough" rel="alternate" type="text/html"/>
    <title>When describe'ing it ain't enough</title>
<content type="html">
            &lt;p&gt;One of the things I like about the &lt;a href='http://rspec.info'&gt;RSpec&lt;/a&gt; syntax is that it packs a lot of information into a few concise, consistent constructs. It&#8217;s relatively easy to read through a spec file and pick out what I am looking for. The use of blocks both enable flexible execution strategies and provide simple containment boundaries.&lt;/p&gt;


	&lt;p&gt;Perhaps the most valuable aspect, though, is the ability to extend the RSpec syntax constructs easily and consistently. No need to grow a third arm here. In &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt;, we recently encountered a situation needing some extra sauce when fixing our compiler specs.&lt;/p&gt;


	&lt;p&gt;A compiler can be thought of as something that chews up data in one form and spits it out in another, equivalent, form. Typically, these transformations from one form to another happen in a particular order. And there may be several of them from the very beginning to the very end of the compilation process.&lt;/p&gt;


	&lt;p&gt;To write specs for such a process, it would be nice to focus just on the forms of the data (that&#8217;s what we care about) with as little noise as possible about how they got there. Here&#8217;s what we have in Rubinius:&lt;/p&gt;


&lt;pre&gt;&lt;table class='CodeRay'&gt;&lt;tr&gt;
  &lt;td title='click to toggle' class='line_numbers'&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class='code'&gt;&lt;pre&gt;describe &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;An And node&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  relates &lt;span class='s'&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;span class='k'&gt;(a and b)&lt;/span&gt;&lt;span class='dl'&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    parse &lt;span class='r'&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      [&lt;span class='sy'&gt;:and&lt;/span&gt;, [&lt;span class='sy'&gt;:call&lt;/span&gt;, &lt;span class='pc'&gt;nil&lt;/span&gt;, &lt;span class='sy'&gt;:a&lt;/span&gt;, [&lt;span class='sy'&gt;:arglist&lt;/span&gt;]], [&lt;span class='sy'&gt;:call&lt;/span&gt;, &lt;span class='pc'&gt;nil&lt;/span&gt;, &lt;span class='sy'&gt;:b&lt;/span&gt;, [&lt;span class='sy'&gt;:arglist&lt;/span&gt;]]]&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    compile &lt;span class='r'&gt;do&lt;/span&gt; |g|&lt;tt&gt;
&lt;/tt&gt;      g.push &lt;span class='sy'&gt;:self&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      g.send &lt;span class='sy'&gt;:a&lt;/span&gt;, &lt;span class='i'&gt;0&lt;/span&gt;, &lt;span class='pc'&gt;true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      g.dup&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;      lhs_true = g.new_label&lt;tt&gt;
&lt;/tt&gt;      g.gif lhs_true&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;      g.pop&lt;tt&gt;
&lt;/tt&gt;      g.push &lt;span class='sy'&gt;:self&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      g.send &lt;span class='sy'&gt;:b&lt;/span&gt;, &lt;span class='i'&gt;0&lt;/span&gt;, &lt;span class='pc'&gt;true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;      lhs_true.set!&lt;tt&gt;
&lt;/tt&gt;    &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class='r'&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class='r'&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/pre&gt;

	&lt;p&gt;The &lt;code&gt;relates&lt;/code&gt; block introduces the Ruby source code and contains the blocks that show various intermediate forms. A single word like &lt;code&gt;parse&lt;/code&gt; and &lt;code&gt;compile&lt;/code&gt; encapsulates the process of generating that particular form, as well as concisely documenting the specs.&lt;/p&gt;


	&lt;p&gt;The format is sufficiently flexible to allow for other forms. For instance, &lt;code&gt;ast&lt;/code&gt; for generating an &lt;span class='caps'&gt;AST&lt;/span&gt; directly from the parse tree rather than using the sexp as an intermediate form. Or &lt;code&gt;llvm&lt;/code&gt; to emit &lt;a href='http://llvm.org'&gt;&lt;span class='caps'&gt;LLVM&lt;/span&gt;&lt;/a&gt; IR directly from our compiler.&lt;/p&gt;


	&lt;p&gt;Another interesting aspect of this, it was possible with only a few custom extensions to &lt;a href='http://github.com/rubyspec/mspec/commits/master'&gt;MSpec&lt;/a&gt;. Recently, I had added custom options to the MSpec runner scripts to enable such things as our &lt;code&gt;--gc-stats&lt;/code&gt;. I didn&#8217;t know how easy it would be to add something more extensive. Turns out it was pretty easy. You can check out the source in our &lt;a href='http://github.com/evanphx/rubinius/tree/master/spec/custom'&gt;spec/custom&lt;/a&gt; directory.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-03-03:5326</id>
    <published>2009-03-03T06:17:00Z</published>
    <updated>2009-03-03T06:19:52Z</updated>
    <link href="http://blog.brightredglow.com/2009/3/3/boxers-or-briefs-neither" rel="alternate" type="text/html"/>
    <title>Boxers or Briefs? -- Neither?!</title>
<content type="html">
            &lt;p&gt;The emperor is wearing clothes and everything looks hunky-dory and sane on the outside. Usually, that&#8217;s a good thing. For instance, when running &lt;a href='http://rubyspec.org'&gt;RubySpec&lt;/a&gt; on a released version of &lt;span class='caps'&gt;MRI&lt;/span&gt;, it&#8217;s good to know that things are behaving as expected and &lt;em&gt;all known issues&lt;/em&gt; are accounted for. In other words, you won&#8217;t see any failures unless a spec is broken or a new spec has uncovered a bug.&lt;/p&gt;


&lt;pre&gt;
$ mspec library/stringio/reopen_spec.rb 
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
........................

Finished in 0.021797 seconds

1 file, 24 examples, 59 expectations, 0 failures, 0 errors
&lt;/pre&gt;

	&lt;p&gt;While the above can be reassuring, it may not tell the whole story. RubySpec uses &lt;a href='http://rubyspec.org/wiki/rubyspec/Guards'&gt;guards&lt;/a&gt; to control which specs are run. This enables the specs to accommodate differences in behavior due to varying platforms, versions, implementations, and bugs.&lt;/p&gt;


	&lt;p&gt;I&#8217;ve added a couple features to &lt;a href='http://github.com/rubyspec/mspec/commits/master'&gt;MSpec&lt;/a&gt; to enable discrete and not-so-discrete peeks under the robes, as it were. The first of these is akin to just yanking down the trousers. By passing the &lt;code&gt;--no-ruby_bug&lt;/code&gt; option, all &lt;code&gt;ruby_bug&lt;/code&gt; guards are disabled and the guarded specs are run.&lt;/p&gt;


&lt;pre&gt;
$ mspec --no-ruby_bug library/stringio/reopen_spec.rb 
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
............FF.....FF.....FF......

1)
StringIO#reopen when passed [Object, Object] resets self's position to 0 FAILED
Expected 5
 to have same value and type as 0

./library/stringio/reopen_spec.rb:117
./library/stringio/reopen_spec.rb:110:in `all?'
./library/stringio/reopen_spec.rb:61

---- snip ----

Finished in 0.022210 seconds

1 file, 34 examples, 76 expectations, 6 failures, 0 errors
&lt;/pre&gt;

	&lt;p&gt;If you cringe a little when blasted by a bunch of failures, don&#8217;t worry, So do I. For a more subtle examination, there is also the ability to run the specs and note which specs &lt;em&gt;would have run&lt;/em&gt; but did not due to guards.&lt;/p&gt;


&lt;pre&gt;
$ mspec --report library/stringio/reopen_spec.rb 
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
........................

Finished in 0.009809 seconds

1 file, 24 examples, 59 expectations, 0 failures, 0 errors, 10 guards

4 specs omitted by guard: ruby_bug #, 1.8.6.114:

StringIO#reopen reopens a stream when given a String argument
StringIO#reopen reopens a stream in append mode when flagged as such
StringIO#reopen reopens and truncate when reopened in write mode
StringIO#reopen truncates the given string, not a copy

6 specs omitted by guard: ruby_bug #, 1.8.7:

StringIO#reopen when passed [Object, Object] resets self's position to 0
StringIO#reopen when passed [Object, Object] resets self's line number to 0
StringIO#reopen when passed [String] resets self's position to 0
StringIO#reopen when passed [String] resets self's line number to 0
StringIO#reopen when passed no arguments resets self's position to 0
StringIO#reopen when passed no arguments resets self's line number to 0
&lt;/pre&gt;

	&lt;p&gt;The guards are reported only if they have altered how the specs were run. Since the &lt;code&gt;ruby_bug&lt;/code&gt; guard can only prevent specs from running on the &lt;em&gt;standard implementation&lt;/em&gt;, &lt;span class='caps'&gt;MRI&lt;/span&gt;, those guards are not reported when running under JRuby, for instance.&lt;/p&gt;


&lt;pre&gt;
$ mspec -t jruby --report library/stringio/reopen_spec.rb 
jruby 1.2.0RC1 (ruby 1.8.6 patchlevel 287) (2009-02-26 rev 9326) [i386-java]
..................................

Finished in 0.257000 seconds

1 file, 34 examples, 76 expectations, 0 failures, 0 errors, 0 guards
&lt;/pre&gt;

	&lt;p&gt;So, if you are wondering what is going on with some specs for a particular library, you can get a quick peek using the &lt;code&gt;--report&lt;/code&gt; option before digging into the spec files. There is also a &lt;code&gt;--report-on GUARD&lt;/code&gt; option that allows you to narrow the focus of your peeking.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-02-26:5312</id>
    <published>2009-02-26T01:15:00Z</published>
    <updated>2009-02-26T07:23:27Z</updated>
    <link href="http://blog.brightredglow.com/2009/2/26/warning-includes-known-bugs" rel="alternate" type="text/html"/>
    <title>Warning: Includes Known Bugs</title>
<content type="html">
            &lt;p&gt;&lt;strong&gt;&lt;span class='caps'&gt;UPDATE&lt;/span&gt;:&lt;/strong&gt; In further discussions with Jim Deville of IronRuby it appears that there may be a legal issue preventing IronRuby devs from patching Ruby code themselves. However it may be possible for IronRuby to use a commonly maintained and patched version of the standard library.&lt;/p&gt;


	&lt;p&gt;Reviewing the logs and considering this was Shri&#8217;s first major discussion in the &lt;span class='caps'&gt;IRC&lt;/span&gt; channel, I unfortunately grouped him in with Charles&#8217; intolerable behavior and personal attacks which have occurred on a number of occasions in #rubyspec and #rubinius. My apologies to Shri. The struck out text below remains merely for historical accuracy.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class='caps'&gt;UPDATE&lt;/span&gt;:&lt;/strong&gt; Charles response to this post wasn&#8217;t exactly positive, but I think it&#8217;s fair to have this discussion in public: &lt;a href='http://pastie.org/400493'&gt;http://pastie.org/400493&lt;/a&gt; Also, please note that I&#8217;ve struck out Shri&#8217;s name below as I may have misunderstood him in the earlier discussion.&lt;/p&gt;


&lt;hr /&gt;


	&lt;p&gt;You, the trusting consumer, would probably like to receive such cautionary advertisement were you to use a product that did, in fact, ship to you code that includes known bugs. And not just known bugs, but known bugs that have fixes for them.&lt;/p&gt;


	&lt;p&gt;You would like to know this, right? I mean, I&#8217;m not just some hard-headed asshole that thinks there&#8217;s something a bit whack here, am I? Please, do tell me.&lt;/p&gt;


	&lt;p&gt;Well, as luck would have it, you can also tell this to &lt;a href='http://http://blog.headius.com/'&gt;Charles Oliver Nutter&lt;/a&gt; of &lt;a href='http://jruby.codehaus.org/'&gt;JRuby&lt;/a&gt; &lt;del&gt;and &lt;a href='http://blogs.msdn.com/shrib/'&gt;Shri Borde&lt;/a&gt; of &lt;a href='http://www.ironruby.net/'&gt;IronRuby&lt;/a&gt;&lt;/del&gt;.&lt;/p&gt;


	&lt;p&gt;Here&#8217;s the drama: There&#8217;s this project &lt;a href='http://rubyspec.org'&gt;RubySpec&lt;/a&gt;. You may have heard of it. It attempts to describe the behavior of the Ruby programming language. All the alternative Ruby implementations use the RubySpec project to attempt to show that they are &#8220;Ruby&#8221;.&lt;/p&gt;


	&lt;p&gt;All the alternative implementations also choose to ship some version or other of the Ruby standard library. At least the parts written in Ruby. Makes sense, since they all implement the Ruby programming language.&lt;/p&gt;


	&lt;p&gt;As is the case with all software, from time to time bugs are discovered in Ruby. Usually, these are fixed soon after they are discovered and the fix is committed to the trunk version of &lt;span class='caps'&gt;MRI&lt;/span&gt; (Matz&#8217;s Ruby Implementation). Eventually, trunk becomes another stable release with a particular patchlevel.&lt;/p&gt;


	&lt;p&gt;The RubySpecs deal with this situation with a &lt;code&gt;ruby_bug&lt;/code&gt; guard. You can read the details of &lt;a href='http://rubyspec.org/wiki/rubyspec/Guards'&gt;RubySpec guards&lt;/a&gt;. This particular guard has two functions:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;It prevents the guarded spec from executing on any version of &lt;span class='caps'&gt;MRI&lt;/span&gt; less than or equal to the version specified in the guard. This is because &lt;span class='caps'&gt;MRI&lt;/span&gt; cannot re-release a particular patchlevel &lt;em&gt;after&lt;/em&gt; it has been released. And the bugs are discovered &lt;em&gt;after&lt;/em&gt; a release.&lt;/li&gt;
		&lt;li&gt;It documents the spec, which shows what the correct behavior should be.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;A key feature of the &lt;code&gt;ruby_bug&lt;/code&gt; guard is that it &lt;em&gt;does not&lt;/em&gt; prevent the spec from running on any alternative implementation. That is because every alternative implementation is expected to have the &lt;em&gt;correct&lt;/em&gt; behavior. Additionally, these guards are only added after Matz or ruby-core has stated that the behavior at issue is a bug and the behavior of the spec is the correct behavior.&lt;/p&gt;


	&lt;p&gt;Now here is the rub, Charles does not want to manage patching the Ruby standard library that he ships with JRuby &lt;em&gt;with the patches that already exist for known bugs&lt;/em&gt;. He wants to ship whatever version &lt;span class='caps'&gt;MRI&lt;/span&gt; has most recently released. Further, when you run the RubySpecs with JRuby, he wants to &lt;em&gt;&lt;strong&gt;&lt;span class='caps'&gt;MASK&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt; those bugs because he doesn&#8217;t think it&#8217;s fair that JRuby fails a spec which shows a known bug in the Ruby standard library for which patches are available.&lt;/p&gt;


	&lt;p&gt;That&#8217;s Charles choice of strategies for managing JRuby packaging. I&#8217;m strongly of the opinion that you, the user, would like to know that. Charles apparently disagrees.&lt;/p&gt;


	&lt;p&gt;In fact, he disagrees so vehemently that he takes to calling me names in the #rubyspec &lt;span class='caps'&gt;IRC&lt;/span&gt; channel because I refuse to change the fact that the &lt;code&gt;ruby_bug&lt;/code&gt; guard will not silently mask spec failures on JRuby or any other alternative implementation. Aside from being immature, I think there is a real problem with this. Don&#8217;t you?&lt;/p&gt;


	&lt;p&gt;Charlie will argue that it is simply impossible to ship the trunk version of Ruby standard library because it is an unknown quantity? However, the best defense against bugs in the Ruby standard library is better specs. And we&#8217;re talking about specs here that &lt;em&gt;show the bugs&lt;/em&gt; and for which patches exist. Furthermore, there are actually relatively few bugs noted in the specs and most of those are in older versions of Ruby, not the current stable release.&lt;/p&gt;


	&lt;p&gt;So, here&#8217;s my question to you: Would you like to know that JRuby &lt;del&gt;and possibly IronRuby&lt;/del&gt; ship you code that contains know bugs for which patches exist? Would you also like to know that Charles wants you to run RubySpec on JRuby and not know there is a bug?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-02-20:5305</id>
    <published>2009-02-20T23:36:00Z</published>
    <updated>2009-02-20T23:39:44Z</updated>
    <link href="http://blog.brightredglow.com/2009/2/20/caveat-lector" rel="alternate" type="text/html"/>
    <title>Caveat Lector</title>
<content type="html">
            &lt;p&gt;I really did double-check this time and I won&#8217;t be making any wild claims here. Sorry to disappoint.&lt;/p&gt;


	&lt;p&gt;We&#8217;re going to be running &lt;a href='http://antoniocangiano.com/'&gt;Antonio&#8217;s&lt;/a&gt; &lt;a href='http://github.com/acangiano/ruby-benchmark-suite/tree/master'&gt;Ruby Benchmark Suite&lt;/a&gt; daily to track our progress on performance in &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt;. The current &lt;span class='caps'&gt;RBS&lt;/span&gt; is a bit of a beast so I imported the files into the Rubinius &lt;a href='http://github.com/evanphx/rubinius/commits/master'&gt;repository&lt;/a&gt; and did some refactoring. You can &lt;a href='http://groups.google.com/group/ruby-benchmark-suite/browse_frm/thread/34b7b7472fa5b80'&gt;read the details&lt;/a&gt; and up-vote that if you&#8217;d like to see this merged back.&lt;/p&gt;


	&lt;p&gt;Now, for some baseline &lt;span class='caps'&gt;RBS&lt;/span&gt; results. If you want to follow along at home, here&#8217;s what I did. I generated these by running the &lt;code&gt;rake bench&lt;/code&gt; task using the &lt;code&gt;VM&lt;/code&gt; option (see the benchmark/utils/README in the Rubinius repository) for Rubinius on the &lt;code&gt;stackfull&lt;/code&gt; and &lt;code&gt;master&lt;/code&gt; branch and for &lt;span class='caps'&gt;MRI&lt;/span&gt; using the version installed on Debian lenny, 1.8.7p22. The system is a dual Intel&#174; Xeon&#8482; &lt;span class='caps'&gt;CPU 2&lt;/span&gt;.40GHz. Then I ran the &lt;code&gt;rake bench:to_csv&lt;/code&gt; task, imported the &lt;span class='caps'&gt;CSV&lt;/span&gt; file into Google Docs, added the comparison columns and colors, and exported to &lt;span class='caps'&gt;PDF&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://blog.brightredglow.com/assets/2009/2/20/mini-rbx-shootout.jpg'&gt;Here&#8217;s what I got.&lt;/a&gt; The green is faster, the red is slower. The reported time is the minimum time recorded in five &#8220;iterations&#8221; of each benchmark per input. The maximum time allowed to run five iterations is 300 seconds, or an average of 60 seconds per iteration.&lt;/p&gt;


	&lt;p&gt;A few notes about these numbers:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;We&#8217;re still fixing the breakage on the stackfull branch, so it is not surprising, for instance, that all the thread benchmarks errored out. The new native thread support is not 100% done.&lt;/li&gt;
		&lt;li&gt;There are a couple speed regressions on the stackfull branch, most minor. We&#8217;ll fix those.&lt;/li&gt;
		&lt;li&gt;Most of the benches do run on the stackfull branch.&lt;/li&gt;
		&lt;li&gt;On most of the benches that run slower in stackfull than &lt;span class='caps'&gt;MRI&lt;/span&gt;, we&#8217;re 2x or less slower than &lt;span class='caps'&gt;MRI&lt;/span&gt;.&lt;/li&gt;
		&lt;li&gt;We are &lt;em&gt;a lot&lt;/em&gt; faster than &lt;span class='caps'&gt;MRI&lt;/span&gt; on quite a few benchmarks.&lt;/li&gt;
		&lt;li&gt;Rubinius on either branch does quite well relative to &lt;span class='caps'&gt;MRI&lt;/span&gt; on benches that &lt;span class='caps'&gt;MRI&lt;/span&gt; times-out on for certain inputs.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Perhaps the biggest point about the stackfull branch is that we haven&#8217;t done much optimization at all. Evan&#8217;s been coding in the basic new interpreter architecture, fixing the GC interaction, adding the native threading. We&#8217;re fixing breakage now so we can get this merged into the master branch. The &lt;span class='caps'&gt;JIT&lt;/span&gt; is not hooked up. The new GC work is not done. There is no inlining. In other words, there is lots of head room. And that is the key point. You can&#8217;t just &#8220;make it faster&#8221;. Architecture is crucial. Since RailsConf 2008, we&#8217;ve been working hard to lay the architectural foundations. With those (and the switch away from stackless), we can start focusing on the real dynamic language optimizations.&lt;/p&gt;


	&lt;p&gt;While the benchmarks tell part of the story, there&#8217;s another part that is even more interesting &lt;span class='caps'&gt;IMO&lt;/span&gt;. And this is the part that &lt;a href='http://blog.brightredglow.com/2009/2/12/all-shiny-and-new'&gt;got me so excited&lt;/a&gt; I, um, well I &lt;a href='http://blog.brightredglow.com/2009/2/12/this-is-not-cold-fusion'&gt;just got excited&lt;/a&gt;...&lt;/p&gt;


	&lt;p&gt;The two biggest pieces of Ruby software that we most often run are the Rubinius compiler and the &lt;a href='http://rubyspec.org'&gt;RubySpecs&lt;/a&gt;. The RubySpecs are much more &#8220;real-world&#8221; than these benchmarks. Here are the results of two complete CI runs on master and stackfull. Note that we are not quite running all the basic CI specs on stackfull, but we&#8217;ll figure in that difference in our calculations below.&lt;/p&gt;


	&lt;p&gt;First, on master:&lt;/p&gt;


&lt;pre&gt;
  $ bin/mspec ci --gc-stats
  rubinius 0.10.0 (ruby 1.8.6) (f4c5576c4 12/31/2009) [i686-apple-darwin9.6.0]

  Finished in 131.248169 seconds

  1430 files, 6927 examples, 23006 expectations, 0 failures, 0 errors

  Time spent in GC: 51.6s (39.3%)
&lt;/pre&gt;

	&lt;p&gt;And then on stackfull:&lt;/p&gt;


&lt;pre&gt;
  $ bin/mspec ci --gc-stats
  rubinius 0.11.0-dev (ruby 1.8.6) (e7b6a2d56 12/31/2009) [i686-apple-darwin9.6.0]

  Finished in 66.357996 seconds

  1349 files, 6298 examples, 21344 expectations, 0 failures, 0 errors

  Time spent in GC: 12.7s (19.1%)
&lt;/pre&gt;

	&lt;p&gt;Let&#8217;s calculate how we do in expectations per second:&lt;/p&gt;


&lt;pre&gt;
  $ irb
  &amp;gt;&amp;gt; master = 23006 / 131.248169
  =&amp;gt; 175.286254850534
  &amp;gt;&amp;gt; stackfull = 21344 / 66.357996
  =&amp;gt; 321.649255351232
  &amp;gt;&amp;gt; stackfull / master
  =&amp;gt; 1.83499416782851
&lt;/pre&gt;

	&lt;p&gt;So, compiling and running the specs is about 1.8 times faster on stackfull. This is upside down from the normal results. Normally, we do better on the micro benchmarks and see that invert on &#8220;macro&#8221; benchmarks. On the &lt;span class='caps'&gt;RBS&lt;/span&gt; benches, stackfull is not 1.8 times faster than master. If I average the &#8220;x Master&#8221; column, I get 1.39.&lt;/p&gt;


	&lt;p&gt;There was something else in those spec run numbers I wanted to talk about&#8230; oh yeah, GC stats. We have a very simple GC timer stat right now. I&#8217;m going to be adding a few more stats. But what we see here is that the overall percentage of time spent in GC drops by half in stackfull. Even so, 19% is too much time to spend in GC. We expect to drop that by half again. Basically, leaning more on structures &lt;code&gt;alloca'd&lt;/code&gt; on the C stack reduces a lot of pressure on the GC.&lt;/p&gt;


	&lt;p&gt;Some would toss out that it&#8217;s not hard to be faster than &lt;span class='caps'&gt;MRI&lt;/span&gt;. Perhaps. But it is an accomplishment to write a reasonably good VM, garbage collector, compiler, and Ruby standard library without importing anyone else&#8217;s code. And, lest we forget, that is two VM&#8217;s in about 27 months of a public project.&lt;/p&gt;


	&lt;p&gt;Some would also question the sanity of writing a VM and garbage collector when crazy smart people do things like that. Well, crazy smart people write papers that reasonably smart people can read and understand. From the benchmark result above, that is working pretty well.&lt;/p&gt;


	&lt;p&gt;Here&#8217;s the point: Don&#8217;t ever let anyone tell you that something is a bad idea. Make your own decisions. We probably wouldn&#8217;t have Ruby itself if Matz fretted over whether Larry Wall or Adele Goldberg were smarter than he. My most recent favorites in this space: &lt;a href='http://factorcode.org/'&gt;Factor&lt;/a&gt;, &lt;a href='http://clojure.org'&gt;Clojure&lt;/a&gt;, and yes, &lt;a href='http://code.macournoyer.com/tinyrb/'&gt;tinyrb&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;We&#8217;re working frantically to get the stackfull branch breakages fixed and the branch merged back into master. Feel free to poke around and ask questions.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-02-12:5294</id>
    <published>2009-02-12T19:39:00Z</published>
    <updated>2009-02-12T19:59:22Z</updated>
    <link href="http://blog.brightredglow.com/2009/2/12/this-is-not-cold-fusion" rel="alternate" type="text/html"/>
    <title>This is NOT cold fusion</title>
<content type="html">
            &lt;p&gt;Um, whoops. It was really late last night. Have I mentioned you&#8217;re wearing a great outfit today. Ok, already.&lt;/p&gt;


	&lt;p&gt;There&#8217;s this slight matter of &lt;code&gt;DEV=1 rake build&lt;/code&gt; in Rubinius. Yes, I was debugging something. Started running some stuff under the stackfull branch, was intrigued by what I was seeing, decided to make some comparisons, could swear I ran &lt;code&gt;rake clean; rake&lt;/code&gt; in the master branch, had a lot of green tea yesterday&#8230;&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;All right already&lt;/strong&gt;. It&#8217;s not 4x faster. Here&#8217;s some new numbers:&lt;/p&gt;


	&lt;p&gt;Master branch:&lt;/p&gt;


&lt;pre&gt;
$ bin/mspec ci core/string
rubinius 0.10.0 (ruby 1.8.6) (781eb14d3 12/31/2009) [i686-apple-darwin9.6.0]
.....................................................................

Finished in 10.576468 seconds

69 files, 763 examples, 5632 expectations, 0 failures, 0 errors

&lt;/pre&gt;

	&lt;p&gt;Stackfull:&lt;/p&gt;


&lt;pre&gt;
rubinius 0.10.0 (ruby 1.8.6) (325174a8e 12/31/2009) [i686-apple-darwin9.6.0]
..................E.....E...E...F............E..E.EE..E........F..F..

Finished in 6.124444 seconds

69 files, 763 examples, 5545 expectations, 6 failures, 19 errors
&lt;/pre&gt;

	&lt;p&gt;That&#8217;s about 58% as long, or 42% faster, or creeping up on 2x.&lt;/p&gt;


	&lt;p&gt;If you rushed out and bought Evan a Valentine&#8217;s bear, I do apologize. But send it anyway. All the rest in my &lt;a href='http://blog.brightredglow.com/2009/2/12/all-shiny-and-new'&gt;previous post&lt;/a&gt; about this being the beginning of a very good thing still holds. We&#8217;ll be getting more results soon and fixing the spec breakage on the stackfull branch. Stay tuned!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2009-02-12:5288</id>
    <published>2009-02-12T17:22:00Z</published>
    <updated>2009-03-02T20:34:43Z</updated>
    <link href="http://blog.brightredglow.com/2009/2/12/all-shiny-and-new" rel="alternate" type="text/html"/>
    <title>All shiny and new</title>
<content type="html">
            &lt;p&gt;&lt;strong&gt;&lt;span class='caps'&gt;UPDATE 2&lt;/span&gt;.0:&lt;/strong&gt; You really did see the update below, right? You&#8217;re getting &lt;a href='http://blog.headius.com/'&gt;Charlie&lt;/a&gt; all worried with your enthusiasm for Rubinius.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class='caps'&gt;UPDATE&lt;/span&gt;:&lt;/strong&gt; Ahem, you should probably also read: &lt;a href='http://blog.brightredglow.com/2009/2/12/this-is-not-cold-fusion'&gt;This is &lt;span class='caps'&gt;NOT&lt;/span&gt; cold fusion&lt;/a&gt;. No, it&#8217;s not April 1st. Sorry about that. Are you still excited? Read on!&lt;/p&gt;


	&lt;p&gt;It&#8217;s a pattern I&#8217;m fairly familiar with now. &lt;a href='http://blog.fallingsnow.net/'&gt;Evan&lt;/a&gt; will be pondering an issue with &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt;. I&#8217;ll catch wind of it when he starts asking some questions of smart people, reading academic CS papers, other implementation&#8217;s code, and tossing out some &#8220;what if&#8230;&#8221; questions. Next thing you know, he&#8217;s frenetically churning out code. Suddenly, Rubinius is much better, and in this case, &lt;em&gt;faster&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;Well, it&#8217;s happened again and the preliminary results are &lt;em&gt;outstanding&lt;/em&gt;. A couple weeks ago, Evan began coding some changes to the way the Rubinius bytecode interperter works. He changed the stackless execution architecture that implemented an optimized kind of &lt;a href='http://en.wikipedia.org/wiki/Spaghetti_stack'&gt;spaghetti stack&lt;/a&gt; to use the C stack more directly and naturally. This better enables the &lt;span class='caps'&gt;CPU&lt;/span&gt; optimizations of the past dozen years to work. It also significantly simplifies the code for our &lt;span class='caps'&gt;FFI&lt;/span&gt;, C-API for C extensions, &lt;span class='caps'&gt;JIT&lt;/span&gt;, and for potentially leveraging &lt;span class='caps'&gt;LLVM&lt;/span&gt; much more effectively. This change also brings native threads, and a much better GC for the mature generation is also in the works.&lt;/p&gt;


	&lt;p&gt;Now, for some details. Again, these results are preliminary. There is still a lot of breakage on the &lt;a href='http://github.com/evanphx/rubinius/commits/stackfull'&gt;stackfull&lt;/a&gt; branch but MSpec is already running and &lt;em&gt;many&lt;/em&gt; of the CI specs run. I&#8217;ll be getting a new CI set in place today and we&#8217;ll get the remaining breakage fixed quickly (don&#8217;t ya just love those specs).&lt;/p&gt;


	&lt;p&gt;Here&#8217;s some numbers for compiling and running the String specs.&lt;/p&gt;


	&lt;p&gt;First, on the Rubinius master branch:&lt;/p&gt;


&lt;pre&gt;
    Finished in 25.829773 seconds

    69 files, 763 examples, 5632 expectations, 0 failures, 0 errors
&lt;/pre&gt;

	&lt;p&gt;Now, on the Rubinius stackfull branch:&lt;/p&gt;


&lt;pre&gt;
    Finished in 5.834874 seconds

    69 files, 754 examples, 5563 expectations, 6 failures, 19 errors
&lt;/pre&gt;

	&lt;p&gt;Here&#8217;s the numbers for running after the specs have been compiled.&lt;/p&gt;


	&lt;p&gt;Again, on the master branch:&lt;/p&gt;


&lt;pre&gt;
    Finished in 5.101799 seconds

    69 files, 763 examples, 5632 expectations, 0 failures, 0 errors
&lt;/pre&gt;

	&lt;p&gt;And now the stackfull branch:&lt;/p&gt;


&lt;pre&gt;
    Finished in 1.564942 seconds

    69 files, 754 examples, 5563 expectations, 6 failures, 19 errors
&lt;/pre&gt;

	&lt;p&gt;I&#8217;ll let that sink in a bit&#8230;&lt;/p&gt;


	&lt;p&gt;The numbers for Hash with compilation are similar.&lt;/p&gt;


	&lt;p&gt;Master:&lt;/p&gt;


&lt;pre&gt;
    Finished in 5.379050 seconds

    48 files, 195 examples, 425 expectations, 0 failures, 0 errors
&lt;/pre&gt;

	&lt;p&gt;Stackfull:&lt;/p&gt;


&lt;pre&gt;
    Finished in 1.295544 seconds

    48 files, 193 examples, 421 expectations, 0 failures, 0 errors
&lt;/pre&gt;

	&lt;p&gt;That&#8217;s right, &lt;del&gt;between 4.1 and 4.4&lt;/del&gt; &lt;strong&gt;approaching 2&lt;/strong&gt; &lt;em&gt;times&lt;/em&gt; faster (see the &lt;span class='caps'&gt;UPDATE&lt;/span&gt; above). And we are just getting started. The significant GC changes are not in yet. We are not &lt;em&gt;yet&lt;/em&gt; doing any significant optimizations in the compiler, no profile-directed optimizations at runtime, and our nascent &lt;span class='caps'&gt;JIT&lt;/span&gt; is not hooked up by default. As I said at the outset, these optimizations are made easier by this architecture change.&lt;/p&gt;


	&lt;p&gt;While I&#8217;m breaking the news, Evan deserves the credit for the architecture decisions and generally being courageous enough to try and learn (some would say fail) and try again. Some have doubted that the lofty goals Rubinius has set are realistic. Doubters have a seat.&lt;/p&gt;


	&lt;p&gt;If you want to try this at home, clone the &lt;a href='http://github.com/evanphx/rubinius/tree/master'&gt;Rubinius Github&lt;/a&gt; repository and do the following:&lt;/p&gt;


&lt;pre&gt;
    $ git branch --track stackfull origin/stackfull
    $ rake build
    $ bin/mspec ci core/string
&lt;/pre&gt;

	&lt;p&gt;Thanks to &lt;a href='http://engineyard.com'&gt;Engine Yard&lt;/a&gt; for trusting in Evan&#8217;s excellent judgment and system architecture talents and in all our hard work even if it doesn&#8217;t look immediately relevant. The path is clear. The goods are in the truck and they will be delivered.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2008-11-23:5178</id>
    <published>2008-11-23T06:30:00Z</published>
    <updated>2008-11-23T06:37:33Z</updated>
    <link href="http://blog.brightredglow.com/2008/11/23/call-of-the-lemmings" rel="alternate" type="text/html"/>
    <title>Call of the lemming</title>
<content type="html">
            &lt;p&gt;It&#8217;s sometimes hard to gauge troll, tirade, or spirited challenge online. &lt;a href='http://kirindave.tumblr.com/post/60776407/the-opposite-of-momentum'&gt;The Opposite of Momentum&lt;/a&gt; strikes me as a mix, though in what percentages, I haven&#8217;t decided. KirinDave is a little late to the bag&#45;on&#45;Ruby party, and if it&#8217;s Javascript he wants, &lt;a href='http://steve-yegge.blogspot.com/'&gt;Yegge&lt;/a&gt; was there well over a year ago. Browse some of the mind-expanding comments by the bottom feeders at &lt;a href='http://www.reddit.com/r/programming/comments/7epu0/ruby_and_the_opposite_of_momentum/'&gt;Reddit&lt;/a&gt; chewing on KirinDave&#8217;s post. It&#8217;s a reassuring, if disappointing, commentary on the consistency of human behavior: it is always easier to complain than to fix.&lt;/p&gt;


	&lt;p&gt;But, anyway.&lt;/p&gt;


	&lt;p&gt;True, the reference implementation of Ruby has some problems. But, Rubinius has a precise, generational garbage collector. It is definitely not &#8220;technically stagnant&#8221;, nor is it &#8220;in implementation limbo&#8221;. It was only in May of this year, before RailsConf, that we first got Rails running on Rubinius. We are close to getting it running again on the new VM. If we do that by year&#8217;s end, we will surely have some kind of record. For all the thousands of lines of Ruby code he&#8217;s written, KirinDave hasn&#8217;t contributed any code to Rubinius. That&#8217;s too bad.&lt;/p&gt;


	&lt;p&gt;Ruby isn&#8217;t that extraordinary as a language. But it is a very good language. What is more, Ruby is a &lt;em&gt;humane&lt;/em&gt; language, in the spirit of &lt;a href='http://en.wikipedia.org/wiki/Jef_Raskin'&gt;Jef Raskin&#8217;s&lt;/a&gt; &lt;a href='http://www.amazon.com/Humane-Interface-Directions-Designing-Interactive/dp/0201379376/ref=pd_bbs_sr_1?ie=UTF8&#38;s=books&#38;qid=1227419893&#38;sr=8-1'&gt;The Humane Interface&lt;/a&gt;. Furthermore, now like never before is the age of the dynamic programming language. The technical hurdles are being explored all around us. In fact, before the year is over, you should spend a few quality hours with one or more of the following languages.&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://www.factorcode.org/'&gt;Factor&lt;/a&gt;. This fascinating &lt;a href='http://en.wikipedia.org/wiki/Concatenative_language'&gt;concatenative&lt;/a&gt; language will definitely get you thinking outside of the box. Rubinius is a stack-based VM. Writing some Factor code is a little like peeling back the syntax layer of Ruby and watching the muscles and tendons work. Check out the quotations and combinators and think about how you write functional code with Ruby. Don&#8217;t miss the Google &lt;a href='http://www.youtube.com/watch?v=f_0QlhYlS8g'&gt;tech talk&lt;/a&gt; by Factor&#8217;s creator, Slava Pestov.&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://clojure.org/'&gt;Clojure&lt;/a&gt;. This is another fascinating language by another wicked smart guy, Rich Hickey (check out &lt;a href='http://blip.tv/file/812787'&gt;the video&lt;/a&gt;). In fact, this is currently my favorite language to study. It&#8217;s the Ruby of Lisps, in my opinion. And it contains a wealth of ideas that could be useful for implementing Rubinius, not to mention, thinking about writing concurrent programs.&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://www.iolanguage.com/'&gt;Io&lt;/a&gt;. Like Javascript? You owe it to yourself to play with this language a bit. I&#8217;d be interested to see about an implementation of Io on &lt;a href='http://webkit.org/blog/214/introducing-squirrelfish-extreme/'&gt;SquirrelFish Extreme&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://haskell.org/'&gt;Haskell&lt;/a&gt;. Amaze your friends and improve your sex life. Jump stateful, side-effect tangled heaps of code with a single Monad. There is a cool new &lt;a href='http://book.realworldhaskell.org/'&gt;online book&lt;/a&gt; that will soon be released in print as well.&lt;/p&gt;


	&lt;p&gt;Seriously, if you are a Ruby programmer, you could hardly do poorly by adopting any one of these languages. If Javascript makes your curly braces tingle, who am I to ridicule you. But if Ruby continues to maintain its captivating hold on your attention, don&#8217;t be disappointed. There is some awesome sauce in there, and we&#8217;re working on the recipe that really makes the flavor pop. Just a little request, instead of bitchin&#8217;, &lt;a href='http://github.com/evanphx/rubinius/tree/master/doc/contributing.txt'&gt;pitch in&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2008-11-18:5177</id>
    <published>2008-11-18T22:03:00Z</published>
    <updated>2009-02-13T20:00:46Z</updated>
    <link href="http://blog.brightredglow.com/2008/11/18/rubinius-is-a-community-project" rel="alternate" type="text/html"/>
    <title>Rubinius is a community project</title>
<content type="html">
            &lt;p&gt;Yesterday was a tough day. You can read the &lt;a href='http://blog.engineyard.com/2008/11/17/rubinius-past-present-and-future'&gt;details&lt;/a&gt; and &lt;a href='http://blog.fallingsnow.net'&gt;Evan&#8217;s&lt;/a&gt; &lt;a href='http://blog.fallingsnow.net/2008/11/18/a-sad-day/'&gt;thoughts&lt;/a&gt; about it.&lt;/p&gt;


	&lt;p&gt;It was especially hard for me because &lt;a href='http://metaclass.org/'&gt;Wilson&lt;/a&gt; was a mentor of sorts and the first person I talked to when I dropped into the #rubinius channel nearly two years ago. He allayed any fear I had that Rubinius would fragment the Ruby community and helped me get started contributing.&lt;/p&gt;


	&lt;p&gt;And &lt;a href='http://journal.kittensoft.org/'&gt;Eero&lt;/a&gt;, among many other things, jumped on board right away and toiled for many hours on the early specs, putting up with my dead ends when the project that is now &lt;a href='http://rubyspec.org'&gt;RubySpec&lt;/a&gt; was merely an expedient to fast-track Rubinius development.&lt;/p&gt;


	&lt;p&gt;So, I want to express my thanks to my teammates and wish them the best in their next endeavors. And I want to emphasize something that is well known to those of us who have worked hard on Rubinius from long before &lt;a href='http://engineyard.com'&gt;Engine Yard&lt;/a&gt; began to support the project: &lt;strong&gt;Rubinius is a community project&lt;/strong&gt;.&lt;/p&gt;


	&lt;p&gt;Evan&#8217;s free-flowing commit bit, the early adoption of Git, and the emphasis on writing specs while developing are just a few aspects that have helped propel Rubinius very quickly in its couple year history. And there is still plenty of exciting and interesting work to be done. We are all very grateful for Engine Yard&#8217;s support of the project, and that support remains strong and dedicated.&lt;/p&gt;


	&lt;p&gt;But the key to Rubinius&#8217; success is the community. In the past year, I feel we have to some extent let you, the community, down. We need to make Rubinius even easier to try out, understand, and contribute to. And we need your feedback on ways we can do this. The recent VM rewrite has been a huge step forward in this regard. But have you opened up the code, poked around, asked us about stuff that doesn&#8217;t make sense? If you haven&#8217;t, let us know why not. Have you taken a look at a failing spec for the core library? There&#8217;s tons of beautiful Ruby code just begging for some love. Let us know what barriers prevent you from spending some free time in there.&lt;/p&gt;


	&lt;p&gt;If you&#8217;re worried that development on Rubinius will slow down, I would challenge you to not let that happen. Evan produces prodigious amounts of code and has a terrific mix of genius and pragmatism. I will certainly not be working any less hard than I have for the past two years. So if you, like me, believe that Rubinius can be a terrific platform for Ruby, jump in. No contribution is too small. And we&#8217;re building on a solid foundation of past success.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2008-09-03:5165</id>
    <published>2008-09-03T22:07:00Z</published>
    <updated>2008-09-03T23:41:15Z</updated>
    <link href="http://blog.brightredglow.com/2008/9/3/hash-is-all-ponies" rel="alternate" type="text/html"/>
    <title>Hash is all ponies</title>
<content type="html">
            &lt;p&gt;We&#8217;ve been hard at work replacing the C virtual machine in &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt; with one written in C++. Along the way, we decided to use a simpler data structure internally where we had been using a Hash before. This allowed us to rewrite Hash in pure Ruby. Since our goal is to write as much &lt;a href='http://blog.brightredglow.com/2008/4/28/ruby-in-ruby-seriously'&gt;Ruby in Ruby&lt;/a&gt;, I was happy to work on this rewrite.&lt;/p&gt;


	&lt;p&gt;You can check out the resulting code &lt;a href='http://github.com/evanphx/rubinius/tree/cpp/kernel/bootstrap/hash.rb'&gt;here&lt;/a&gt; and &lt;a href='http://github.com/evanphx/rubinius/tree/cpp/kernel/common/hash.rb'&gt;here&lt;/a&gt;. It hasn&#8217;t been polished much yet, but the idea was to use expressive and natural Ruby. I didn&#8217;t take any performance-conscious tacks. Hash should provide a great case study for looking at optimizations in our compiler and VM. For example, &lt;code&gt;Hash#keys&lt;/code&gt; can be succinctly written as:&lt;/p&gt;


&lt;pre&gt;
def keys
  inject([]) { |ary, entry| ary &amp;lt;&amp;lt; entry.first }
end
&lt;/pre&gt;

	&lt;p&gt;Since &lt;code&gt;#inject&lt;/code&gt; comes from the &lt;code&gt;Enumerable&lt;/code&gt; module, we know it&#8217;s using &lt;code&gt;#each&lt;/code&gt; internally. And for Hash, I implemented an external iterator of sorts to help hide the implementation details. That iterator is making a method call for each item. So we&#8217;ve piled on two block calls and a method call for each item. The point is, we want that expressive Ruby code in our applications and let the implementation optimize it. So far, we really haven&#8217;t had any Ruby implementation to give us that.&lt;/p&gt;


	&lt;p&gt;Another thing to check out is the structure of our &lt;a href='http://github.com/evanphx/rubinius/tree/7f8af1531125850bc75b8315269a7e0528e98c50/kernel'&gt;kernel directory&lt;/a&gt;. Talking to the folks working on &lt;a href='http://ruby.gemstone.com/'&gt;MagLev&lt;/a&gt;, we&#8217;ve restructured our runtime kernel (aka Ruby standard library) to better allow sharing with other implementations. The &lt;code&gt;bootstrap&lt;/code&gt; and &lt;code&gt;delta&lt;/code&gt; directories are implementation specific, while the &lt;code&gt;common&lt;/code&gt; directory is intended to be shared. The &lt;code&gt;bootstrap&lt;/code&gt; directory provides just enough functionality to load the &lt;code&gt;common&lt;/code&gt; directory. The &lt;code&gt;delta&lt;/code&gt; directory provides a location for implementation specialization where specific methods can be replaced with more performant or otherwise specialized versions.&lt;/p&gt;


	&lt;p&gt;As always, we love to hear from folks about what&#8217;s bugging them with Ruby. Drop by #rubinius on freenode.net or check out the &lt;a href='http://github.com/evanphx/rubinius/tree/master'&gt;Rubinius&lt;/a&gt; project on &lt;a href='http://github.com'&gt;Github&lt;/a&gt;. Even though we&#8217;re in the middle of this VM rewrite, there&#8217;s plenty still to be done on the Ruby standard library.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;a href='http://blog.fallingsnow.net'&gt;Evan&lt;/a&gt; points out that this is a better implementation of &lt;code&gt;#keys&lt;/code&gt;:&lt;/p&gt;


&lt;pre&gt;
def keys
  map { |key, value| key }
end
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2008-08-01:5154</id>
    <published>2008-08-01T18:51:00Z</published>
    <updated>2008-08-02T21:10:37Z</updated>
    <link href="http://blog.brightredglow.com/2008/8/1/as-del-icio-us-as-a-giant-steaming-turd" rel="alternate" type="text/html"/>
    <title>As del.icio.us as a giant, steaming turd</title>
<content type="html">
            &lt;p&gt;I often dislike the interfaces that I&#8217;m forced to use. Banking sites are about the highest on my list of horrid. The pain these things inflict.&lt;/p&gt;


	&lt;p&gt;However, today I got a new jolt. Clicked on my handy &lt;a href='http://del.icio.us'&gt;del.icio.us&lt;/a&gt; shortcut in Firefox and was greeted by a bizarre interface. Not to worry, I powered on, since of course, the reason I use &lt;a href='http://del.icio.us'&gt;del.icio.us&lt;/a&gt; in the first place is because it was super quick and easy to add a bookmark. Quick is no longer in the vocabulary for &lt;a href='http://del.icio.us'&gt;del.icio.us&lt;/a&gt;. Instead of simply typing a few characters, hitting &amp;lt;tab&amp;gt; and being done with it, I now have to arrow in this stupid drop-down? Amazed, I started taking a closer look at the unwelcome intruder in my nice browse + bookmark flow.&lt;/p&gt;


	&lt;p&gt;The lame new auto-complete behavior is a breaker for me. However, it&#8217;s hard to say if that&#8217;s the worst of the UI redesign. The 3-option choice for the main list display goes from bad to worse to horrid. Is the date, in washed out grey, &lt;em&gt;really&lt;/em&gt; the most important piece of info that I need to see in my normal scan from left-to-right? I can barely scan any of the options quickly for the information I need to help me select a link. And where did my nice big entry field go for typing in a tag? Oh, there it is, camouflaged in that bar at the top of the list. Don&#8217;t really want me to use that, huh?&lt;/p&gt;


	&lt;p&gt;I could go on, but what&#8217;s the use. The amazing thing to me is that someone, somewhere thought this was a good idea. Have these idiots never heard of Alan Cooper, IxD, the rich body of books describing why you don&#8217;t design interfaces like this? Harsh? Damn, right. Horrid.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2008-07-21:5152</id>
    <published>2008-07-21T22:49:00Z</published>
    <updated>2008-07-25T05:56:17Z</updated>
    <link href="http://blog.brightredglow.com/2008/7/21/oscon-2008" rel="alternate" type="text/html"/>
    <title>OSCON 2008</title>
<content type="html">
            &lt;p&gt;If you&#8217;re headed to &lt;a href='http://en.oreilly.com/oscon2008/public/content/home'&gt;&lt;span class='caps'&gt;OSCON 2008&lt;/span&gt;&lt;/a&gt;, I hope I&#8217;ll have a chance to meet you. I&#8217;ll be speaking on Thursday afternoon, something about Ruby performance. Come and heckle me if you wish. Here&#8217;s the talk details:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href='http://en.oreilly.com/oscon2008/public/schedule/detail/2333'&gt;Who Wants a Faster Ruby?&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;07/24/2008&lt;/li&gt;
		&lt;li&gt;2:35pm &#8211;  3:20pm &lt;span class='caps'&gt;PDT&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Room: &lt;span class='caps'&gt;F151&lt;/span&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Also, please do come check out &lt;a href='http://pdxfoscon.org/'&gt;&lt;span class='caps'&gt;FOSCON&lt;/span&gt;&lt;/a&gt;. This is the 4th year for &lt;span class='caps'&gt;FOSCON&lt;/span&gt;. w00t.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class='caps'&gt;UPDATE&lt;/span&gt;:&lt;/strong&gt; Thanks to all who attended my talk. I&#8217;ve uploaded the &lt;a href='http://blog.brightredglow.com/assets/2008/7/24/faster_ruby_oscon08.pdf'&gt;slides&lt;/a&gt;. If you attended, please take a moment to &lt;a href='http://en.oreilly.com/oscon2008/public/schedule/evaluate/2333'&gt;send feedback&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.brightredglow.com/">
    <author>
      <name>brian</name>
    </author>
    <id>tag:blog.brightredglow.com,2008-05-16:5140</id>
    <published>2008-05-16T19:02:00Z</published>
    <updated>2008-05-17T18:42:07Z</updated>
    <link href="http://blog.brightredglow.com/2008/5/16/implementers-unite" rel="alternate" type="text/html"/>
    <title>Implementers Unite!</title>
<content type="html">
            &lt;p&gt;There&#8217;s a lot of things that &lt;a href='http://rubini.us'&gt;Rubinius&lt;/a&gt;, &lt;a href='http://ruby-lang.org/en/about'&gt;MatzRuby&lt;/a&gt; (including &lt;a href='http://www.atdot.net/yarv/'&gt;&lt;span class='caps'&gt;YARV&lt;/span&gt;&lt;/a&gt;), &lt;a href='http://jruby.codehaus.org'&gt;JRuby&lt;/a&gt;, &lt;a href='http://www.ironruby.net/'&gt;IronRuby&lt;/a&gt;, &lt;a href='http://ruby.macosforge.org/trac/wiki/MacRuby'&gt;MacRuby&lt;/a&gt;, &lt;a href='http://rubyurl.com/XN99'&gt;Ruby.NET&lt;/a&gt;, &lt;a href='http://ruby.gemstone.com/'&gt;MagLev&lt;/a&gt; don&#8217;t agree on. But that&#8217;s ok, because above all, they seem to agree that &lt;a href='http://ruby-lang.org'&gt;Ruby&lt;/a&gt; is one awesome language. And lately, that apparent agreement has gotten a boost of sorts.&lt;/p&gt;


	&lt;p&gt;Earlier this week, Rubinius (an &lt;a href='http://engineyard.com'&gt;Engine Yard&lt;/a&gt; project) &lt;a href='http://groups.google.com/group/ruby-talk-google/browse_thread/thread/e20f76ca2b8afe78'&gt;announced&lt;/a&gt; the &lt;a href='http://rubyspec.org'&gt;RubySpec&lt;/a&gt; project at &lt;a href='http://rubyspec.org'&gt;rubyspec.org&lt;/a&gt;. The effort to write an executable specification using &lt;a href='http://rspec.info'&gt;RSpec-style&lt;/a&gt; specs started with the Rubinius project in late December 2006. Since then, many people all over the world have contributed to the effort, including core folks from JRuby. &lt;a href='http://engineyard.com'&gt;Engine Yard&lt;/a&gt; has been financially supporting significant development of the RubySpecs since hiring &lt;a href='http://blog.fallingsnow.net'&gt;Evan&lt;/a&gt; in June 2007 and other full-time developers (myself included) in Jan 2008. All this effort has been to ensure that the Ruby programming language continues to evolve and receive the recognition it deserves.&lt;/p&gt;


	&lt;p&gt;Another recent development has been a regular meeting of folks working on various Ruby implementations. These &lt;a href='http://ruby-design.pbwiki.com/'&gt;Ruby design meetings&lt;/a&gt; are bringing together folks to discuss tough issues with Matz and everyone else.&lt;/p&gt;


	&lt;p&gt;Well, after last night&#8217;s meeting, Tanaka Akira (sorry, I don&#8217;t have a link to his website; if you do, please let me know) checked in some &lt;a href='http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&#38;revision=16430'&gt;changes&lt;/a&gt; to the ruby-core Makefile to fetch and run the RubySpecs. This is a very proud moment for me.&lt;/p&gt;


	&lt;p&gt;If you love Ruby, it doesn&#8217;t matter what color shirt you wear, what language you play with, or what country you live in. You can play a valuable role in helping make Ruby a wonderful language for everyone. Please help us with the &lt;a href='http://rubyspec.org'&gt;RubySpecs&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I changed the link to the changeset for the Makefile. Thanks Michael.&lt;/p&gt;
          </content>  </entry>
</feed>
