First Adventures in Ruby and the Rails

After learning Python and playing with Django, I really didn’t see any need to explore other languages, and certainly not RoR. I’d played with RoR around 2004 when it was in it’s infancy, and I was not impressed. I’d tried at that time to learn both Python and Ruby – looking for a graduation from Perl, but both were very complex. In the end, around that same time I was starting to do a lot of my own personal PHP development, playing around with WordPress, etc.

Ruby on Rails came up again in 2006 when I was freelancing for an online survey business, and they brought in a lead developer/manager who was in love with REST and RoR. I remember seeing the book “Agile Web Development with Rails” on his desk. He’d tried then to explain to me what was so great about REST and Rails, and I didn’t really pay much attention, as what I was doing at that time was developing comprehensive application specifications, and wasn’t really concerning myself with code.

Back in August/September 2009, in the middle of developing a new application, after exploring multiple other options, and delving deep into CouchDB and schema-less databases I found myself finally revisiting Rails for the purpose it was always intended – quickly prototype an application, so you can focus on building it properly once funded.

That’s of course quite a ridiculous assumption, as everyone who built on rails stayed on rails, despite the overhead, and tremendous resource inefficiencies. It seems once you drink the cool aid…

So I picked up a book and started reading. Interestingly enough, my favorite online e-book destination ( Safari Books Online ) did not carry the definitive text on Rails – and nor did Amazon (for Kindle anyway). Not surprising I suppose, as Rails has a somewhat elitist perspective. Needless to say, there are other books, and I found a great one from my favorite publisher ( O’Reilly ).

They mentioned Heroku, which is a cloud-based rails deployment and hosting service, however it seems the book was a bit out of date, as the interface has changed drastically. Digging a bit deeper however I found that Heroku supports a number of Ruby frameworks, and so I did a bit of research.

Frameworks if you aren’t already familiar are somewhat essential tools today for the modern web developer. In most cases, you choose one, or the most popular – but if you are like me, you often want to learn as much as you can.

During the time I was waiting for the “gem” installation, I decided to review Rails.  As a language, Ruby was quite compelling, similar to Python, and thus somewhat familiar.  That said, there’s quite a lot of difference, and you can’t just “read” ruby code without understanding the syntax fully first. Special characters like “@” and “?” would be otherwise very misleading.

Below was my experience in September 2009.  As a result, I have not yet revisited Rails development, though I think once Rails3 is released, I will reconsider.  Stay tuned for a proper review of 3 when it arrives.

RAILS

The pinacle of all web-development frameworks.  First things I noticed:

NOT easy to install on Linux.  Rails is pre-installed in Leopard, and there are Windows installers for it, but installing on Linux takes a few extra manual steps – something that doesn’t quite figure for me, because I can’t imagine developing on anything but Linux (the LAMP developer in me).

You need to modify your PATH manually, but be careful because if you don’t have access to the /usr/lib path, it will install in a .gem path instead (somewhat like how CPAN works for Perl), but instead of just using this as a build directory, everything will be placed there, including binaries, which makes finding them in the first place a pain.

Also, installing anything from gem – is SLOOOOW.  I’ve never used a package manager that provided such little information during it’s discovery of packages, and subsequent installation.  It seems at first that it’s simply not working.  Canceling it will only leave you with a mess of corrupted files/directories.  This is pretty frustrating – seems to be typical of what I’d already experienced with Rails in my past… great when it works (like if you have it pre-installed on OSX or you use apt-get to install it), sucks when it won’t.  Oh yes, and be prepared for a MESS of documentation to be generated… which takes forever.

So far I haven’t written a single piece of code and two hours have passed since I started this project!

Lots more issues with gems, and missing dependencies/libraries.  Bottom line – Ubuntu and Rails do not like each other.

During scaffolding, there is no way to generate anything but primary datatypes.  Fine for simple mindless apps, but for one that requires several joins, scaffolding isn’t much use.  Let’s go and edit the code.

If your application is a single table such as a blog, Rails is a great tool to get you started with little or no effort.  But if you want to create complex relationships between tables, you end up doing just as much work to create schemas for these services as you do anything else.

In the end, I abandoned Rails, and thus I never really completed this article.  Since that time, a lot has changed, I’m not running development for a PHP/Java/Flash team on a B2B web-based software product.  Working in PHP has been VERY limiting however, and I find myself missing the flexibility and robustness of languages like Python and even Ruby.  So, I figured I’d dredge up some old posts, and start re-exploring the different languages available.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.