Saturday, January 2, 2010

My intro to Ruby

I started poking around with Ruby a month or so ago.  Prior to this I had seen a little bit of ruby code but had a lot of trouble following it.  I had modified a single line of Ruby in a documenting tool I was using for my Actionscript 2 code, but that was just changing a false to a true and doesn't really count.

My first real involvement with Ruby was to join my friend and coworker Matt at the December meeting of the Pittsburgh Ruby Users Group.  I was worried that everything would go over my head, but the guys and gals there were quite helpful.  I ended up learning about a couple ruby projects that helped get me into writing Ruby code very quickly.

The first, Ruby Version Manager, is apparently a fairly new project that lets you install multiple versions of ruby at a time and very easily swap between which ones you use.  I've used it to swap between ruby 1.8, 1.9, jruby, and macruby (though sadly I've yet to get macruby to run properly).  So far I haven't had any real need to play with different versions, but I can see it being quite useful for people who need to worry about version compatibility.

While the guys in the user group were talking about some Rails stuff that was over my head, I started playing with Ruby Warrior.  It's basically a simple rogue-like game written in ruby, but instead of the user playing the game he has to write the AI for a player.  It starts very simple, but requires more sophisticated logic for the later levels.  I haven't gotten very far in it yet as I started poking around with other projects, but I'll probably go back to it at some point.

The one other thing I started to pick up at that meeting was just how awesome github (and, by extension, git) is.  I had used github previously to save some of my shared configuration files "in the cloud", but that was pretty much it.  I started to realize just how nice it was when I started looking at ruby warrior.  I opened up a terminal, did a `git clone`, and was up and running.  When I realized I could commit, branch, and revert locally I got even more excited.

The best praise I can give to both ruby and git is that it's gotten me writing code in my spare time again.  For the last few years I've had trouble getting motivated to write code after I get home from work.  A couple times I tried starting something but always stopped after a day or so.  Since starting to play with ruby that's completely changed, and even git has been fun to learn.  Here's hoping it sticks for a lot longer.

Starting to learn ruby and git. rvm makes getting started in ruby easy, and ruby-warrior is an interesting project idea.

1 comment:

  1. Interesting thoughts (and thanks for making me aware of the existence of a local RUG; I'll have to look into that in detail!).

    I had a similar experience in learning Ruby on Rails recently. Ruby is a quirky language relative to the others I've used, but in a good way; I'm a big fan of the notion they've hit upon that functions tend to be dynamic upon at most one other function, so they've built special-case syntax for that. It's hard to describe precisely, but it makes parameterizing by function feel more like the "right" way to solve problems than in other languages.

    Git exists at an interesting intersection between convenience and power. I'm going to be recommending it to FIRST Robotics teams this year.