What I'm Doing...

Posting tweet...

Powered by Twitter Tools



Every now and then I see an article about an alternative implementation of some aspect of Ruby on Rails in another language. The latest is about Propel, an ORM layer in PHP. Let’s compare and contrast:
Propel:

$dish=new Dish();
$dish->setName(“Beans on Toast);
$dish->setDescription(“Yummy”);
$dish->save();

Ruby on Rails:

dish=Dish.create(:name=>”Beans on Toast”,
:description=>”Yummy”)

Propel:

$c = new Criteria();
$c->add(AuthorPeer::FIRST_NAME, “Leo”);
$results = AuthorPeer::doSelect($c);
foreach($results as $author) {
print “Author: ” . $author->getLastName() . “,
” . $author->getFirstName() . “\n”;
}

Ruby on Rails:

Author.find_by_first_name(“Leo”).each do |author|
puts “Author: ” + author.lastname +”,” + author.firstname
end

In the last example, Ruby on Rails would of course delegate the outputting of author details to a view – I put the “puts….” line in to illustrate how much more intuitive the ActiveRecord syntax is. No disrespect to Propel – it is clearly a major piece of work, has features that are not present in ActiveRecord and could make a huge difference to those obliged to code in PHP. But I know which I’d rather be using! The problem is that PHP is just plain ugly compared to Ruby. I used to use PHP, but I can’t really understand why so many people are still using it. Inertia I guess. Tell me if I’m wrong!

Stumble it!



0 Responses to “Ruby on Rails ORM wannabes never quite cut it do they?”

  1. No Comments

Leave a Reply


I like comments! Anonymous comments are fine, but I prefer to know who I'm talking to.
Avoid personal attacks and offensive stuff.


XHTML: You can use these tags <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> :





Subscribe to Email Feed

Enter your Email


Preview | Powered by FeedBlitz

My Photos

www.flickr.com
This is a Flickr badge showing public photos from Robert M Jones. Make your own badge here.
3K2 theme by Hakan Aydin