Ruby on Rails

Clarifying my position on ASP.net

Oliver Brown
— This upcoming video may not be available to view yet.

One of my most read (and most commented on) posts was the one claiming “ASP.NET sucks”, which only goes to show being a little offensive goes disappointingly far on the internet. Since it has now been five years since I posted that, I thought a quick follow-up was in order.

I stand by most of what I said my initial post, but with a little specificity. It’s not ASP.net that’s the problem but Webforms. Unfortunately at the time Webforms was all you ever saw. There are alternatives around today (and may have been back then but none were especially high profile and none were by Microsoft). These days of course Webforms are very much out of fashion. Following on from the success of Rails Microsoft realised that Webforms weren’t an idea that could keep up with modern web development. A quick glance at the ASP.net home page today shows four out of five articles talking solely about ASP.net MVC and one article talking about both MVC and Webforms (of course that will vary by day I but I doubt the result will be very different).

So taking into account a minor title change (ASP.net Webforms suck!) I’d say my original point stands.

Nokia 770

Oliver Brown
— This upcoming video may not be available to view yet.

My recently ordered Nokia 770 has arrived :o)

For those that don’t know, it isn’t a phone - Nokia market it as an “Internet Tablet”. Basically it’s a PDA running Linux with WLAN, Bluetooth and an 800x480 touchscreen display.

There’s too much about it that’s cool for me to go into right now, so I’ll leave you with the picture :)

Apparently the term “UMPC” is being used by a few people to describe the 770 (and similar devices) - “Ultra Mobile PC”.

Zend Framework

Oliver Brown
— This upcoming video may not be available to view yet.

Zend, the commercial endeavour of the people who brought you PHP have a produced a framework, cleverly called the “Zend Framework”.

It’s basically a lightweight MVC framework for PHP. Lightweight in this case is good. It doesn’t do as much as Rails does for Ruby (although it is significantly younger) - the most notable hole is a object-relational-mapping system. But it does provide URL rewriting for Rails-esque view/controller access. I started writing my clever language thingy in it.

The biggest problem I had was getting it to work with IIS. Which I couldn’t. I decided since I had IIS installed I’d give it a go. Unfortunately you require mod_rewrite which IIS doesn’t have. So I installed ISAPI_rewrite, a version for IIS. After an hour of trying to get it to work I went and downloaded Apache 2.2. Which was my second mistake You see it seems PHP doesn’t work with Apache 2.2. Not sure why but I found a vague mention of it on a forum after trying for another hour to get it to work. So I got Apache 2.0 and everything worked. Of course there are reasons not to use PHP 5 with Apache 2, but meh.

There is one little problem with the Zend Framework, I think. It seems to be printing a space somewhere before any other output. It wouldn’t be a problem except I need it to output XML and a space at the beginning makes Firefox (and probably Internet Explorer) explode.

BackBase really pushing AJAX

Oliver Brown
— This upcoming video may not be available to view yet.

BackBase is another AJAX toolkit. This one is different though. It’s not really an AJAX toolkit, more a toolkit powered by JavaScript taking advantage of AJAX.

The clue is the price. Yes it has a price - $2000 to be exact. There is a “community edition” that is free for personal use though. Anyway, I don’t have time to run down all the features but basically it defines a whole new bunch of tags allowing you to create complicated content in a declarative HTML style way. These tags are then translated into proper XHTML on the fly by the back end JavaScript engine. Since the clever work is actually handled by the browser, you’re free to use whatever you like on the server (PHP, Ruby) including static HTML pages - outputting BXML is no different to outputting HTML. In fact BXML has a very ASP.NET feel to it and embedding BXML into an XHTML page along with ASP content could have the ultimate cleanness about it (syntax isn’t one of my complaints about ASP.NET).

It should be noted that Microsoft are working on Atlas which could be something very similar but I haven’t looked into it… It all seems very clever.

AJAXy Scriptaculous goodness

Oliver Brown
— This upcoming video may not be available to view yet.

Scriptaculous is a Javascript library used for doing AJAX stuff and certain visual effects.

It’s very well written, has excellent cross browser support and best of all there are cool functions in Ruby on Rails for using it. One of the coolest features is drag and drop. I’ve already implemented it in Galaxia Ruby for adding ships to fleets :)

Tree structures in Ruby on Rails

Oliver Brown
— This upcoming video may not be available to view yet.

This is becoming a trend - another built-in feature of Rails that will seriously help Galaxia development.

You can use acts_as_tree in a model to make it, well, act as a tree.

What this means is you add an extra field to the database called parent_id that tracks object’s parents. Rails automatically manages this for you and adds extra methods for dealing with trees (things for accessing parent, ancestors, children etc.). Just like the post on type, this is something I was already doing with Galaxia but managing myself.

Using “type” in Ruby on Rails

Oliver Brown
— This upcoming video may not be available to view yet.

By default Rails applies special meaning to certain fields in a database table. One of these fields is “type”.

The type fields is used by Rails to create a “single table inheritance model”. This sounds fairly complicated and is best explained with an example:

Imagine a forum system. A forum will have threads and replies. Threads and replies are different and have different functionality, but certainly share a lot of characteristics. So you might create a class message with two sub classes: replies and threads. In Rails you can store all these in one messages table with a type field set to either reply" or thread. When you load a message it will actually create either a reply or thread object (in stead of a message object). When you create a new object it stores it in the messages table with the correct type.

This is ideal for Galaxia. In fact it’s the model I used all along - I just had to write the functionality myself.

Galaxia Ruby

Oliver Brown
— This upcoming video may not be available to view yet.

Okay, Galaxia on Rails would my be a more apt name for a version of Galaxia in Ruby on Rails. But Galaxia Ruby sounds better to non-programmers.

This follows the tradition I’ve been recently following of learning new languages by writing bits of Galaxia in them. There is a real possibility I might get a version out this time :P

This version may even have AJAXy goodness and things. But don’t hold your breath…

Ruby on Rails may rock

Oliver Brown
— This upcoming video may not be available to view yet.

I’ve been vaguely aware of Ruby for a while but never really gave it more than a cursory glance. If you didn’t know Ruby is a language that has been around for a while that got far more interesting when Rails, a framework for it was released.

After reading around I don’t think I’m really a fan of Ruby syntax per se (I’m definitely a fan of the punctuation heavy C-style syntax as opposed to the keyword heavy Basic-style syntax) but Rails seems to be an amazing framework.

Since I might be starting a job soon (and if not soon at least eventually) that will focus on PHP, starting to learn something new might not be ideal. But if it really as good as it’s fans say then things might be fine.

I suggest anyone involved in web development who hasn’t checked it out yet do so. There is a good introductory article on ONLamp.com.