The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Ruby is so cool

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jared Richardson

Posts: 1031
Nickname: jaredr
Registered: Jun, 2005

Jared Richardson is an author, speaker, and consultant who enjoys working with Ruby and Rails.
Ruby is so cool Posted: Feb 23, 2006 7:45 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by Jared Richardson.
Original Post: Ruby is so cool
Feed Title: Jared's Weblog
Feed URL: http://www.jaredrichardson.net/blog/index.rss
Feed Description: Jared's weblog. The web site was created after the launch of the book "Ship It!" and discusses issues from Continuous Integration to web hosting providers.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Jared Richardson
Latest Posts From Jared's Weblog

Advertisement

I'm going through Dave and David's Rails book and parts of it just amaze me. How much code would it take in your language of choice to do the following:

  1. Pull all the data from a database table
  2. Filter out the data by some value on a single column
  3. Sort the data

Granted, this isn't rocket science. Any beginner programmer should be able to do this. But in the Rails book, it's four lines of code... and it could be one. It's written on four lines to be readable.

This is a routine that returns all the items that can be sold now. Can you read it?

def self.salable_items
   find (:all,
         :conditions  => "date_available <= now()",
         :order       => "date_available desc")
end	
I know, some of the magic is ActiveRecord, the Ruby OR layer... but in my mind I'm running through all the JDBC driver trappings, the selects, the sorting. Maybe if I'd tinkered with Hibernate, I'd know a four line way to do this in Java. Maybe....

Jared

Read: Ruby is so cool

Topic: Stupidity on Parade Previous Topic   Next Topic Topic: Even a thief takes ten years to learn his trade

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use