Recently I've been experimenting with
Ruby and
Ruby on Rails.
Many years ago, when I was at university, I was introduced
to Scheme. There were a lot of libraries of interesting code
doing crazy things behind my back, because the professors wanted
us to focus on the high-level concepts of the problems, not the
nuts and bolts of how to do shuffle these bits around. Still,
with those libraries available, many concepts became quite easy
to express in a very compact, readable way. Code flowed. It
didn't always start from the beginning, proceed until it reached
the end, and then stop. The projects I did write in scheme
grew almost organically from conception to completion. I may
have started coding over here, but if the next step was over
there, it frequently seemed natural to go over there.
When I was at university, I was also exposed to post-fix
languages for the first time: Forth, RPN, whatever language
/bin/dc uses, and Postscript. Postscript had
glimpses of that organic feeling, as long as I kept things in
the realm of the functional and procedural. It was (and still
is) a good tool for solving 2-D graphical problems. (Why did
we have to draw the corridor of rooms with flapping doors in
OpenGL/C instead of some as-yet undeveloped animated Postscript?
C was not meant for post-fix expression of ideas!) And then I
attempted string handling in that language, and decided that I
didn't need to visit that hard labor prison. (It makes C string
handling look good.) I do still like Postscript, but I have a
much better sense of when not to use it. I also think that a
calculator without RPN is not a calculator.
Some of you know that Perl
is my best computer language. It is the Swiss Army Chainsaw
of TMTOWTDI. It is my tool of choice for slicing and dicing
text, simple CGI programs, automated web scrapers, IRC clients,
and talking ASCII-art cows. But for all its utility, it does
lack certain aesthetic qualities. Perl is steampunk; it can
accomplish a great many things, but it is not always elegant
in accomplishing them. And while the flow is often logical,
it is not necessarily organic. Sometimes it gets downright
dirty -- dirty man-made dirt, not clean nature-made dirt. And
that dirtiness is sometimes praised as a virtue. Not that I
have a problem with dirt; I like writing cryptic pattern matches
as much as the next Perl programmer, and those who never get
exposed to dirt never learn to adapt to it. (24/7 technical
operations for a web site that makes money is seldom a clean
affair.) But sometimes when I get home from work I don't want
my (virtual) overalls to be stained with grease, grime, curry
lunch, and industrial chemicals.
For my latest web toy at work -- a basic data-browsing
scaffold, minus any ability to modify the data -- I initially
looked at a framework in Perl for getting the concept in code
quickly. Catalyst
is one such framework. The initial going didn't go so well,
partially because I had to install half of CPAN, and partially
because I was just not familiar enough with ORM yet. Jifty is another one, but after
attempting to install three-fourths of CPAN (finally failing
on HTML::Mason) I decided that neither of these
were the right tool for this job -- at least not right now,
since this involved paid work, and not hobby programming.
I had experimented a bit with
Ruby last year, to see if
its framework Ruby on
Rails was worth investigating. After a reasonably easy
time installing it and generating half of a scaffold for an
LDAP-based model, I thought it was worth another look.
Once I remembered how to install Ruby's relevant gems, and
I had my database schema set up, it didn't take very long to
get the scaffold to a basic CRUD state. I noticed that when I
went to modify the code for the basic views, some concepts just
seemed right. I was even able to guess a few things correctly,
and it seemed natural to do certain things certain ways.
(Honestly, I don't remember when I learned about single-line
versus multi-line blocks, but I was writing them anyway!)
Something was clicking between me, Ruby, and Rails.
Ruby has some of the natural quality that I had found in
Scheme. I hesitate to call it zen because the person
who designed Ruby is Japanese. But I get the distinct impression
that he knew how he wanted Ruby to look and act when it had
grown up. I guess Ruby decided not to be a rebellious teenager.
Yesterday, I got my pick-axe, er, Ruby book, and it looks
like it will be well-used. I do not expect to throw out my
chainsaw -- it will always have its uses -- but I will be making
space in my tool shed for it.