Programming with Ruby

Posted by Stormy on October 4th, 2007 in Open Source

It's been a long time since I wrote much real code, so when I started getting a lot of pointers in that direction, I decided to go for it.  What I discovered is that's it's just as addictive as it used to be!

I decided to learn Ruby for a number of reasons:

  1. I've heard lots of Ruby on Rails hype.
  2. Our engineering team decided to use Ruby for the new project they are starting.
  3. A couple of people at work were recommending Learn to Program as a good book to get your kids started programming and it uses Ruby.  I'm always interested in how to get kids (especially girls) into computers.  (Plus, if I'd forgotten how to program, a book on how to program might be handy.  I originally learned how to program using a book and no computer.  Then I talked my parents into the computer.)

So I checked Learn to Program out of the library and decided to do a couple of examples and then to tackle my favorite pet project.  It took me about an afternoon to go through the book, try out a few examples and write a couple of programs from scratch on my own.  (I won't tell you exactly how long it took me to write a sort program as it's a little embarrassing.)  Ruby turned out to be a pretty easy fun language.  It can pretty much do anything you want it to do and I spent quite a bit of time combing the documentation looking for pre-existing methods to do whatever I needed.  For all that open source software projects get a bad rap for documentation, I found the Ruby documentation to be really good.  You can never have enough examples, but I found most everything I needed in the docs and better yet, all online.  

So my favorite pet project.  I wanted a program that would search all of the science fiction books on Amazon and come up with a list of ones that are worth something used.  (This all started when I discovered that a book I bought at Borders for $6.99 was worth $13 less than a year later!  Since I spend a lot of time in used book stores, I thought I should keep an eye out for bargains.  While I can type all the ISBNs into Amazon on my mobile phone to get their value, that's a bit tedious.)  So I started with Ruby, ended up with the Ruby/Amazon project written by Ian Caliban, and came up with a nifty little program that gets the top 200 (or however many you want) science fiction paperbacks from Amazon and returns a list of all of those that are worth more than x amount (say $4) used and are in the top in terms of sales rank (you decide what number – most people say the top 500,000 at the most if you want to sell it in the next few months.)  

All that in a week using Ruby, open source software, a book and the web!  (Now I just need to release it as open source on the web … once I fix those few ugly spots that is. :)

As a side note, for some strange reason, programming in Ruby reminds me of programming in Scheme.  I'm still trying to figure out why that is … but I like Scheme so it's a good thing. 

Bookmark: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Reddit
[Trackback URI]

Comments

Subscribe to comments with RSS

  1. Rubinator said, on November 2nd, 2007 at 9:03 pm

    Did you use watir or some web automation tool to extract the data or did you use Ruby’s HTTP libraries. I am just curious as to how you accomplished the pet project, and hopefully compare it to how i would have done it

  2. Rubinator said, on November 2nd, 2007 at 9:05 pm

    nevermind, i see you used REST