insertmorecoins

power.wisdom.courage

Ruby on Rails

February 20th, 2005

One of my 2005 new year’s resolutions was to tinker around more with open source software. Well, already 2 months on into the year and I’m glad to say that I’ve gotten over my procrastinating ways to start to come good with my promise. Over the past few weeks I’ve installed Apache, MySql, PHP and WordPress to get my blog up and running.

I original tried using Moveable Type as my blogging engine, but got frustrated and gave up (after 5 hours) when I couldn’t get Perl and PostgreSQL 8.0 to play nicely. You can of course use a variety of data providers for Moveable type, but I stubbornly wanted to use the first Win32 native release of Postgre. It was all or nothing.

Next stop on my open source voyage is Linux Town. I’ve had flirtations with Linux in the past, but my encounters were brief because I couldn’t motivate myself to do anything on it that would keep my attention. Also I’ve been spoiled for several years now by .NET, which I consider to be the total package in terms of application development, and has kept me tied mainly to Windows.

So how is this next Linux encounter going to be any different? Firstly I’m going to be using Fedora core 3 running within MS Virtual PC. This removes the hassles associated with running multiple OS’s like dual booting and such, and allows me to switch back and forth with ease while going about my usual XP duties. Next, to force a dependency of sorts and to prevent my Linux usage from going astray, I’ll be using it to host my blog.

I have no intention to abandon windows as a result of all this open source experimentation. It’s served me well since W2K and through sensible usage - things just work, with little fuss. I consider myself a pragmatic computer user who doesn’t get fanatical enough to take any sort of allegiances but rather prefer to value software on its merits.

I think the open source movement is driven by a lot of smart, innovative and devoted developers who want to make a difference and keep the big players on their toes. I want to get acquainted with the various established and developing projects in the open source world as recognition of all the good that’s going on in this area and to be able to respect myself more as geek.

Another driving force that has compelled me to venture into open source territory has been the buzz surrounding the Ruby programming language and the associated Rails web development framework. I haven’t even begun to scratch the surface on this stuff yet, but I have started to play a little.

I followed this good tutorial as my first foray into Ruby. It provides instructions on setting up Ruby, the Rails framework, MySQL and code for a simple recipe management web app. There’s plenty of good documentation out there to help you setup Ruby on Rails on various platforms. The process itself is relatively smooth and trouble free.

Ruby on Rails - First Impressions

I think Rails will have the same affect on open source web developers (who predominatantly code in PHP) as .net had on asp developers. When asp.net came around classic asp developers were liberated from writing spaghetti code through an object oriented framework that promoted the separation of logic and UI. Also at their disposal were a rich set of web controls and data binding mechanisms to free them of mundane coding duties to focus on the bigger picture. But to take advantage of these new features required a major change in programming mindset which was more challenging for developers not experienced in OO programming.

Rails offers an object oriented framework that enforces tiered design and good programming practices. There’s an air of elegance about it from the organised application directory structure to keeping url querystrings look tidy.
You create a Rails application by first running a utility script in the location you want the application to reside. The script creates a directory structure containing levels for the various application tiers, configuration setting, log files and a bunch of others which I don’t know the exact nature of yet.

A striking feature of Rails which I got to see in action from the tutorial is the ability to interface with a database using minimal code. With as little 10 lines I had all the code necessary to display web pages for add, edit, delete and list functionality on a table of recipes. This was firstly achieved by running another utility script that created all the scaffolding needed for CRUD operations on the specified database table.

The tutorial goes on further to facilitate table relationships (e.g. categories of recipes), and customising the display of the pages. The speed and simplicity of development gained by trivialising mundane tasks such as db CRUD operations is a big selling point for Rails. Of course, you could trivialise these tasks somewhat in other environments like .net for example by using tools that generate CRUD and strongly typed collection templates based on the database entity you want to create a data layer for. I use CodeSmith exactly for this purpose. In .net I initially had to manually create these templates, which required me to have an understanding of the internals of the process and allowed me to have complete control over the implementation. Rails goes one step further by freeing you of this process, although I think you can modify the scaffolding as needed. This is yet another thing I have to investigate.

ASP.NET is still my development framework of choice but Ruby on Rails has left a good enough impression to warrant further investigation, and then there’s the Ruby programming language itself which I hope to comment on more in future posts.

Posted in Uncategorized | Comments Off

Touching the Void

February 13th, 2005

I watched Touching the Void today. It’s a movie documentary about the survival of two insane climbers and their attempt to scale a notoriously difficult mountain in the Peruvian Andes. The central character of the story, Joe Simpson, exemplifies the power of the mind and shows how spirit, determination and the will to survive can transcend any situation, no matter how arduous.

But the mind can only be stretched so far before its rational faculties start breaking down and things start to get absurd. Tantalising close to base camp after 6 days on the mountain with a broken leg and geting his only sustenance from snow, Joe resigns himself to a ditch, which coincidently served as the camp latrine. After days crawling through miles of crevice infested glaciers and icy rubble, Joe ends up in a pool of human refuse feeling completely despondent and alone. He is ready to accept his fate, but not before his final and most punishing ordeal. A tune starts to surface in his mind. How fitting you might think, a nice tune to comfort him in his final moments. But what tune was it? A childhood lullaby? A grandiose orchestral piece? A redeeming church hymn? No. It was a bouncy, bubbly number from 70’s euro disco outfit Bony M–”Brown girl in the ring, la di da di da”–that played over, and over again in his head. After admitting it was a song he hated, this is when you feel the greatest sympathy for Joe.

Who knows, maybe it was a bad experience in some German discotheque with Boney M playing in the background that compelled Joe to scale that impossible mountain. But we all know what it’s like, you’re listening to the radio when on comes a catchy tune whose melody brings a smile to your face and a swagger in your step. It’s all head bopping, feet tapping fun at first but after a couple of hours, days, or perhaps even weeks of high rotation in your head it becomes akin to Chinese water torture. Fortunately the condition eventually subsides, however, the innocuous melody can lay dormant within the deep recesses of the mind only to resurface a few years later while flicking through radio stations, strolling in a super market aisle, or in its muzak guise while riding an elevator.

The condition is less severe these days with the proliferation of mp3 players and music on the go. If a melody starts to overstay its welcome you can easily suppress it by putting on a different tune. But what if you find yourself on the verge of death and all of the sudden you’re haunted by a repressed melody, like Joe was. Thinking there’s got to be a more humane way to go out I came up with an innovative idea: The iPod Kill Switch accessory. It would consist of 2 parts: a wrist band to monitor your heart rate and a base unit that connects to your iPod. The base unit would poll the wrist band intermittently, via Bluetooth, for heart rate data. Should heart rate patterns indicate impeding death, the base unit activates the pre-designated song to accompany you into the after life.

With the iPod kill switch you could be trapped in a mangled car wreck comforted by the heartfelt sounds of Wings Beneath My Wings or be suffocating from an attack by killer bees to Bridge Over Troubled Waters. Whatever mortal predicament you might find yourself in, you’ll be able to fade away with dignity.

Posted in Uncategorized | Comments Off

Hello World

February 10th, 2005

Welcome to my blog. Don’t expect to find answers to life’s great mysteries, lively personal anecdotes or intelligent insights into issues affecting the world. All you’ll find here are sporadic ramblings on topics as diverse as computer programming to the number of rock stars who have suffocated on their own vomit and anything else that captures my attention at the time. But you better sound the geek alarm now because I have a feeling it’ll mainly be a repository for my adventures in programming land.

If you’re wondering about the domain name, it’s simply a reflection of my penchant for retro arcade machines and somewhat cynical outlook on life, plus I thought it sounded catchy.

I’ve known about the blog scene for quite sometime, but I dismissed it as a passing fad just when it was becoming popular, instead preferring to keep a padlocked hello kitty journal. Well, I’ve since changed my outlook on blogs to now be able to inflict upon you, the unwary reader, entries riddled with bad speling and poor grammar which are bound to really suck, so be warned.

Posted in Uncategorized | Comments Off