I haven’t talked much geek talk around here lately, so here’s a little tidbit for ya. If you are totally not into Web design or programming, just skip this post. Also, if you aren’t interested in Ruby on Rails, just skip…wait a minute! If you aren’t interested in Ruby on Rails, you better go get your brain examined!
Anyway, I was thinking about how to implement lightweight feeds of latest comments, users, discussions, etc. for the home page of the super-secret Web project I’ve been working on, and after deciding an asynchronous job running some kind of message queue system was way overkill for the present time, I went ahead with implementing a simple stats cache using memcache. I already have a way to cache actual ActiveRecord-based models easily using the cached_model gem, but I didn’t want to use something that heavy for this. All I need are a few bundles of read-only attributes I can display in a pretty fashion on the home page, and an update every ten minutes or so is perfectly adequate.
What blew me away is once I’d started to write some simple test code, in a very short time my simple test code/prototype became the actual, usable product. What’s even more amazing is that I started to write some pseudo-code in a TODO comment to remind myself at a later date how to implement the actual database queries and hand the data off to a stats object, only to realize that I could simply type away for a couple more minutes and have real, working code! Now my job is pretty much over with, all done in about three hours max. Can’t beat that with a stick.
In Rails by way of the Ruby language, the dividing line between conceptual planning, prototyping, testing, and final robust implementation is virtually nonexistent a lot of the time, and that’s pretty darn cool. I could have done all of this stuff in my former love PHP, to be sure, but it would have taken longer and looked uglier. Ruby on Rails reminds me of another system that sports a serene, productive, and elegant design — one that starts with an M and ends with a c and is made by a fruit company.
BTW, some time soon I’ll have to tell you about my experiencing setting up an Apache/MySQL/Rails/Passenger (aka mod_rails)/Subversion stack on a virtual machine slice running Ubuntu Linux. Now that’s a party.