I first began exploring Ruby on Rails in 2007 at the urging of Tim Rosenblatt. He and I went out to a meeting of the Orlando Java Users Group to see a presentation about this new framework called Rails in a language called Ruby. At the time, I was very interested. However, after I got my position at Bonnier, I wasn’t able to spend the time fully learning RoR. That changed when I switched jobs to Orange Lake.
I’ve been coding in Ruby using Rails for the past four months for Orange Lake Resorts. I wanted to share some of my experiences developing Ruby software in hopes of enlightening people who are unaware of some of the aspects of Ruby on Rails I like best.
- Ruby is easy to learn, but difficult to masterIt’s not so easy in a literal sense, the language is complex and powerful, but it follows a principle of least astonishment. This means that you can make some educated guesses about how the software should behave. The language syntax in incredibly unobtrusive. It’s designed to be Object Oriented from the ground up. It has dynamic type casting, garbage collection, and other features that make it easy to focus on your code. When you add Rails in to the mix, you have an incredibly rapid platform for development.When you get past the basics, you can really start to see the power Ruby on Rails has to offer. One feature that really sines is dynamic class modification. This lets you, the developer, modify the behavior of a class without changing it’s main source and without making a subclass. It lets you dynamically add, modify, and delete methods and class/instance variables. This may not seem like much until you are sitting there cursing your favorite plugin because it doesn’t support custom site feature x. Now it can!
Combined with the “acts_as” design pattern, you can add encapsulated pieces functionality to any existing class. For instance, I can write a global logger plugin that can be attached to any class, giving it a single interface globally across an application. I can add that logger to any class I want on an as-needed basis. Check out this tutorial on building plugins for Rails.
- Ruby on Windows sucksI hate to say this, but does. Bitnami only does so much. Eventually, you need a native extension. This gets in to cygwin and a compiler stack on Windows. I tried really hard to use the Windows computer provided by Orange Lake, but I couldn’t. Windows was getting in the way. I’m not sure what can really be done to fix the problems for Windows users; some things just don’t work. When it does work, it’s slow. Really slow. Now, I use my personal Mac to do my ruby development. Textmate + MacPorts + Gem is a much more manageable installation profile compared to anything I could find for Windows.
- Mongrel and Passenger (mod_rails) are two different beasts entirelyMongrel is the development server a lot of people use. It comes included with Rails and is fairly robust. It’s what fires when you run script/server . Passenger is something you’re more likely to see in a production environment. Passenger is an Apache module (mod_rails). One thing I’ve learned is that Apache is much more strict about errors, and it provides a lot less information about them.Mongrel has the wonderful ruby debugger (ruby-debug). It’s not only for Mongrel, but it’s much easier to use with Mongrel. It’s a command line debugger, but that’s ok with me. It works just like any other debugger and is a great tool for any Ruby developer. This lets you quickly track down the source of any errors, including backtrace and application state information. Some pages fail to load, but instead of returning an error 500, it returns an error message useful to the developer.
Maybe this is just the configuration I’m working with, but Passenger is not so generous. We only get some very specific output that is explicitly coded. It’s hard to get output. We have to go out of our way to get output you take for granted using Mongrel’s console. When there is an error, it tends to go directly to the 500 error document. This might be due to configuration of our particular server instances however.
Overall, I love working with Ruby on Rails. It’s a powerful language. By following the principle of least astonishment, it assures rapid development. Powerful languages features let you extend core classes. Just know that if you are a Windows user, you’re going to have some issues. Also, if you use Mongrel for development and Passenger for Apache in production, you’re going to have some problems.