comfort zones are for sleeping

Thursday, August 30, 2007

Bourne Again

Trust me, this list really is about RoR, and my experiences with learning it. But from time to time I stop staring at this screen, and I stare at other screens. I recently went to see the Bourne Ultimatum. Here's my review. First, a plot summary:

SPOILER ALERT
If you don't want to know what happens in the movie, stop reading now.

Ok, have you stopped reading now? Here's the summary:

Jason Bourne gets mad
There's an implausible car chase
Some people get hurt

My review:
Pretty good.

Next up in the Bourne series:
The Bourne Proctoscopy
(Matt Damon ain't getting any younger, you know)

Sunday, August 26, 2007

What to do?

Everything I'm discussing in this post is available at http://www.rubyonrails.org/, but I'll post links to everything in case you're too lazy to click over there yourself. Good goober, it's just one click, you fat load!

What have I done so far to get started on RoR? Nothing. Nada. Zip, zero, zilch. I mean it, not a dern thing. I took like a three-hour nap today, read a chapter of Taran Wanderer by Lloyd Alexander, watched a rerun of America's Funniest Home Videos, and chased after my in-laws' two dogs who are staying with us for the weekend. I love my in-laws dearly, but for some reason our seagrass floor coverings tend to make their dogs incontinent. Oh yeah, and I also ate a piece of cake.

The RoR site makes it seem like you just install a couple of things and, badda-bing badda-boom, you're on the road to fame and fortune. I wonder if getting started with RoR is really as easy as advertised. Now that RoR has been around for a while, I feel like I'm coming in a bit late on the conversation. But all the cool kids are doing it, so off to the RoR download page.

How do I know I've installed RoR correctly?
In order to call myself successful in getting a RoR development environment up and running on my box (a Dell Dimension E512 running Vista Premium), I want to see a functioning editor and compiler for Ruby, and an executing Hello World sample app. To get there, I assume I have to install a few things:

1) Ruby - the language itself.
2) RubyGems - a Ruby 'package manager'.
3) Rails - a Ruby implementation of several really nice patterns, including ActiveRecord.
4) Brick - a Ruby-based webserver. RoR won't run on IIS or Cassini (as far as I know), so you have to install a different webserver.
5) MySql - I don't really have to install this. RoR will indeed work with MS Sql Server. But the lion's share of the most readily available documentation centers on MySql, and it will be much easier later to find a web host for RoR and MySql rather than RoR and MS Sql Server. And since this little adventure is about charting new territory and claiming it for myself: Excelsior!!

There are a few options for getting all this stuff up and running, so I'll follow my typical MO and take the path of least resistance.

Ruby and RubyGems
First I'm gonna use the One-Click Ruby Installer for Windows. I used Version 1.8.5 because they told me to on the download page (they came up with this stuff, I figure they must know what they're talking about), the .exe download. Took all the defaults for installation. It took a few minutes to install, and it installed to c:\Ruby. This took care of items 1) and 2) on my list above.

Rails
And now, I've run into my first problem. To install Rails, the download page says I need to run the following command:

gem install rails --include-dependencies

But where do you run it? Do you just open up a cmd window and type that in? As it turns out: yes, you sure do. But then RubyGems starts asking a number of rather personal questions:

Install required dependency rake? [Yn]
Install required dependency activesupport? [Yn]
Install required dependency activerecord? [Yn]
Install required dependency actionpack? [Yn]
Install required dependency actionmailer? [Yn]
Install required dependency actionwebservice? [Yn]

I answered 'y' to all of these, but it seems a bit odd. I mean, I said 'include-dependencies' in the initial command, and RubyGems is telling me these dependencies are required. Why doesn't it just go ahead and install them without asking permission again? Anyway...after a couple of minutes everything seems to be installed. Or, at least, I'm back to a command prompt. An eerie calm as fallen over my computer.

Next: the Application or the DBMS?
The next step the RoR download page tells me to do is to create the application skeleton. That doesn't seem right - I'm pretty sure the stuff I have just installed didn't include the development webserver, and I'm very sure I haven't installed MySql yet. So let's get MySql installed first. I'll download it from http://dev.mysql.com/.

OK, I pulled this guy: mysql-essential-5.0.45-win32.msi down from dev.mysql.com and installed it. Vista didn't really want to let me, but after some arm twisting MySql is up and running on my box - pretty easy, just run the msi and take the defaults.

Now the Sample Application
So now I'm back to creating a sample app. rubyonrails.org/down tells me to do this:

rails path/to/your/new/application
cd path/to/your/new/application
ruby script/server

I've got no clue here, so I'm switching over to a book by David Heinemeier Hansson (his mother calls him "Hiney"). Hiney says rails is a command-line tool that you use to construct each Rails app you write. According to Hiney, I need to pick out a directory on my machine and use rails to create an app called demo. So I'll make a new directory called c:\rubysandbox and navigate to it in a command shell.

All I have to do to create the app is type rails demo. rails thought about it for a couple of seconds, but then it spit out a bunch of create statements and dumped me back out onto a command prompt. Now when I list the contents of the c:\sandbox\demo there are 14 new directories, plus a Rakefile and a README.

Hiney says there's a directory in there called script, and it contains a ruby script called server. The server script allegedly starts WEBrick - so I guess we did install the web server after all. Here's how you run it: c:\rubysandbox\demo>ruby script/server . Once I run that, I can point Firefox to http://localhost:3000/. When I do, I get a nicely formatted message saying: "Welcome aboard You're riding the Rails!"

Yay me! It worked!!

At this point I expected balloons and confetti to fall from the ceiling, and maybe a buxom spokesmodel would present me with one of those oversized grand prize checks. I'm kind of glad that didn't happen though. I think my wife would be mad. But let's accentuate the positive: I have successfully installed Ruby on Rails, with MySql as the DBMS. And I have proven to myself that my installation is successful, because I've seen the sample app come up in a browser. Very cool! I still have to get the development tools up and running and create a Hello, World! app, but I'll do that tomorrow.

I'm pooped.

Get Started, Start a Fire

I'm a .Net programmer. Some programmers say that with embarrassment or downright shame these days, but not me. Now, I'm sure good ol' uncle Bill and crew have engaged in some rather nefarious business practices over the years, but what major U.S. corporation doesn't have a few skeletons in the closet? Hey, programming the Microsoft way has fed my family for years. Frankly, I'm far too self-centered to spend my time developing political opinions about gay skeletons. So I have neither a war to wage nor an axe to grind against Microsoft. I'm fairly satisfied with the .Net programming opportunities available to me in the marketplace (that's in Austin, TX, by the way). I'm comfortable creating applications based on the .Net framework, and I will continue doing that professionally.

So why bother with Ruby on Rails? The simplest answer is: I want to be a better programmer. Like I said, I'm comfortable with .Net. But I readily admit that Microsoft's marketing plan does not necessarily lead programmers to create software using the highest degree of craftsmanship. It's time to be uncomfortable again. Even if I never use RoR professionally, I want to broaden my understanding of my chosen profession.

I will use every resource available to me to further my education and progress. This includes easily available stuff like http://www.rubyonrails.org/, RoR books, tons of online samples and tutorials, etc., as well as local resources like the Austin on Rails developer community. Hopefully, I'll be successful enough with my experiments to post some of them online, so that the world might gratefully acknowledge my genius by mailing me hundreds of cards and letters containing their good wishes, offers of moral support and prayers for my progress along this pilgrimage, and small honorariums (cashier's checks only please, no personal checks).

So here we go.