Mountain West RubyConf 2008

Monday, March 31 2008 @ 05:09 PM EDT

Contributed by: Admin

I attended the Mountain West RubyConf 2008 in Salt Lake City, UT.



It promised to be enlightening, and was. Some of the best sessions were unexpected gems (no pun intended). Following is my take on the sessions that provided some unique insights. Videos of all presentations are available on the Mountain West site.

First Impressions

The trip to Salt Lake City was uneventful and I got to my hotel without incident. The walk from the hotel to the Library where the conference was about a mile. It's not really a long distance, but with the temperature slightly above the freezing point of water and a some wind gusts, it made for an unpleasant trek. Fortunately, the presentation room was top notch and there was plenty of power for all the laptop toting Ruby fans.

Nearly every attendee had a laptop fired up and I was a little shocked to see that Macs outnumbered PC notebooks 4-1. I heard the telltale boot up drum roll of Ubuntu a few times and saw one XO laptop (OLPC) in use. I wonder if the Apple appeal is limited to the Ruby glitterati or if it represents a wider trend.

Opening Keynote -- Rubinius

Two speakers were scheduled for the opening keynote presentation.

The first one was given by Evan Phoenix, the founder of the Rubinius project. I have to admit that I didn't know anything about Rubinius before the conference. It turns out it is a project to rewrite most of the Ruby interpreter in Ruby itself (though small parts of it remain in C). The current interpreter is written in C and I heard it referred to as MRI version, though I don't know what MRI means. The two other main implementations are JRuby, written in 100% java, and IronRuby, written in 100% C# for the Microsoft .Net VM.

Evan said Rubinius can now run the interactive Ruby shell (IRB), and Ruby gems, but he still considers it alpha software and has a ways to go before the 1.0 release.

He talked a lot about community, about his philosophy of accepting any contribution, no matter how small the size, and what the last year was like working on Rubinius. Evan mentioned that it is his personal goal, but not the project goal, to eventually be the standard Ruby interpreter.

From my perspective, it seems like an interesting project, but I'm not sure I see the need. I'm also skeptical about the performance impact, given that performance is already an issue for Ruby. However, I am keeping an open mind.

Opening Keynote -- Merb

The second keynote was given by Ezra Zygmuntowicz on the Merb web framework.

Ezra introduced Merb, originally an acronym for Mongrel and Erb (embedded Ruby), but he said the project has transcended the original meaning. Merb is a full MVC web framework similar to Ruby on Rails. The project tagline is "All you need, none you don't". While he appreciates Rails, he said he wanted a leaner framework to build applications with less cruft.

Ezra said Merb was feature complete and may approach a 1.0 release later this year. He said it was refactored to be more more modular, and supports more options for back end data storage, not just relational databases.

Merb prefers simplicity over magic as much as possible, with no need for monuments to personal cleverness. Merb claims to execute faster than other frameworks. He mentioned a line I heard in several other presentations: People come for the rails, but stay for the ruby.

Here are some other Merb factoids:

Domain Specific Languages: Molding Ruby

Joe O'Brien presented a fascinating way to address problems in specific business areas by extending Ruby to create a meta-language, or mini-language, useful only within that domain. He talked about targeting the domain specific language (DSL) at primarily non-technical users, while a traditional API would be used for programmers.

He discussed the evolution of computer languages from machine-centric to programmer-centric to user-centric. For example, he showed this general progression of languages:

Enough stats so Zed won't yell at you

Devlin Daley covered the use of httperf and how to approach performance measurement using statistics. He talked about how hard it can be to draw meaningful conclusions from raw data. He demonstrated the open source R statistical package running on X11.

He discussed how the mean/average is not enough and showed how standard deviation was an important consideration when looking t a data set. He talked about how samples must be representative of the population.

He talked about a z-test to test how well a result compares to random guessing, and also the t-test to see if two samples are from the same population.

Zed quote (as relayed by Devlin) - "Programmers need to learn statistics or I will kill them"

CouchDB

Jan Lehnardt introduced CouchDB, a non-RDBMS document based database. Instead of tables and records, it stores documents (objects) in JSON format. JSON is a text format similar XML, but easier to read/write. Similar documents don't need to have an identical schema. The read/write cycle works something like this:

Ruby object -> JSON -> CouchDB -> JSON -> Ruby object

CouchDB is written in Erlang, a language created by telco giant Ericsson. It features non-locking MVCC and ACID compliance. It doesn't support two-phase commits, just transactions on a single document read/write/update/delete.

Here is a sample document as stored by CouchDB:

{
"_id":"BCCD12CBB",
"_rev":"AB764C",
"type":"person",
"age":63,
"dark_side":"true"
}
The _rev field stores the revision of the record, used to implement the MVCC.

Communication with CouchDB is done using HTTP REST, so no database abstraction layer is needed. You can use standard HTTP web server solutions to tune CouchDB like analyzers, load balancers, etc.

Here are some other CouchDB factoids:

Ruby Internals

Patrick Farley, from ThoughtWorks, gave what I thought was the most compelling presentation of the conference on the inner workings of the Ruby interpreter.

He began with snippets of C code from the interpreter showing how Ruby objects and classes are constructed and how method dispatch works. Methods are implemented by passing messages to an object. Ruby objects don't have methods attached to them, only their class and superclass. All method tables are attached to classes, so when you execute a method, Ruby looks at the object's class table to find it. It if doesn't find it in there, it looks at the method table of the superclass, then the superclass of the superclass and on up the chain.

When a singleton method is created, a unique method for one object, Ruby creates a unique class for that object in the background, references the original class as the superclass, and attaches the method to the unique class. Ruby doesn't tell you it created a unique class and if you ask it, it will return the original class of the object. Patrick explained several situations where this was desirable, but parts of the session went by too fast for me to grasp it.

Here are the core C snippets:

All objects are built with two structs:
struct RObject {
  RBasic basic
  st_table *iv_tbl --> instance var table, properties
};

struct RBasic {
  unsigned long flags;  frozen, tainted, etc.
  VALUE klass;  --> class type
};

No place for methods to be stored in an object.  All methods stored in a class:
struct RClass {
  struct RBasic basic;
  st_table *iv_tbl --> properties
  st_table *m_tbl --> methods
  VALUE super;
};

Patrick went on to show how JRuby, IronRuby, and Rubiniuis each implement objects, classes, and method dispatch. Toward the end of the presentation, my head exploded.

BDD and Shoulda

Tammer Saleh introduced Shoulda, a testing framework for Rails that extends Unit::Test. The goal of Shoulda is to allow you write simpler and fewer tests for your Rails applications. If you can write it in one line of code, you should be able to test it in one line of code.

One of the most powerful features of Shoulda is the "should_be_restful" test which can generate up to 50 Unit::Test lines internally. Tammer was not sure if that feature would remain in Shoulda for various reasons.

Wrap Up

The conference went off without a hitch. Several companies were actively hiring, pointing to a bright future for Ruby. According to the organizers, the size of the conference more than doubled compared to 2007, and they believe it will require a larger venue for 2009.

Comments (0)


CommandLineMac
http://www.commandlinemac.com/article.php/20080324170957972