Ruby on Rails
Ta-da List


July 10, 18:54

Active Record steals the Hibernate show!

Ryan Dlugosz just wrote me about how Active Record made Hibernate, a Java-based ORM alternative, look like all labour and no fun:

[A] coworker of mine was doing a talk on Hibernate Tuesday night (the OR Mapping tool for Java). About a week earlier, I showed him a bit of Active Record & asked him to throw it into the talk somewhere for perspective.

He showed the many XML configuration files, pile of required libs, a 30-property-long JavaBean supporting the "Client" table, and finally some Java usage of Hibernate to persist and restore it. Everyone agreed - it's great that you don't have to write any SQL and Hibernate does a good job of optimizing queries & managing the object cache. Cool stuff.

Then he pulls out Active Record. :) People were simply amazed that the same result was achieved using Ruby + AR without any of the configuration or dependencies required by Hibernate. Granted, AR can't do everything that Hibernate does, but as far as core functionality goes (the stuff you'll actually *use* in your job) it's beautiful.

Even now people are emailing me about how cool AR is now that they've been playing with it. Thanks for a great piece of software and I'm looking forward to seeing (and using) Rails!

This is my dream response to Active Record. Appreciating that the Active Record pattern is a worth-while competitor to the horde of data mappers and that a Ruby-implementation can remove all the tedious labour from the usage.

I'm even more excited to get Rails on the street now. Just about a week's worth left on vacation (in which I've sneaked in lots of neat Rails stuff on the train from Venice to Rome and will be doing the same on the way back). So late July is now the current target.

Thanks to all the continued encouragement and anticipation. It means the world.

Challenge by Tomas on July 11, 14:39

I find the AR pattern very interesting as well, do you know of any good representable articles which talk about it and preferably implements part of it? Are there any special language features that make AR easier or harder to implement?

Challenge by David Heinemeier Hansson on July 12, 10:34

Martin Fowler discusses the pattern in three pages in Patterns of Enterprise Application Architecture. That was my initial inspiration. He also discusses the trade-offs against transaction scripts and full data mappers.

And yes, AR makes heavy use of open classes (runtime extendability) and powerful introspection of Ruby. Additionally, I use static methods to simulate language extensions for such things as associations and aggregations.

Challenge by Gokhan on July 17, 21:37

Man we really need a notification list for rails. I have been checking your blog every day almost to see rails. I have my own framework in php but I love ruby and want to stay away from php for next decade. Hope your work is going smooth to release anything for us to dive in:) I have a project waiting but want to use it with rails to see how quick I can adapt.

Challenge by Morten Wittrock on July 17, 22:39

Gokhan, download yourself an RSS feed reader and subscribe to David's RSS feed. Saves you the trouble of visiting the site over and over.

Challenge by gabriele on July 18, 2:21

btw, it would be nie to see the hibernaterails practical comparison, say, a link if the author of the talk has some slides online..

Challenge by Rick O'Shay on September 22, 19:50

Hibernate is embarrasingly simple yet it addresses every important problem in ORM.

The jar file configuration is a one-time cost that you integrate in to your build system such as Ant or your favorite IDE. That can also be setup and delivered ready-go-go in an example. The "pile" exists because Hibernate leverages several open standards and they must be included. I find this criticism asinine.

The configuration files themselves are the OR mapping. That is one of its major strenghts; not a reason for complaint. That is how you control the mapping in ever detail. You can use one file to contain them all or one file per class. That choice is yours.

Moreover, the mapping can be and is automated with tools such as the open-source Middlegen product. No coding required and not a single line of configuration needed.

This is what happens when you do things correctly rather than some proprietary all-in-one abortion. You can connect things together easily and automate everything or automate nothing.