Ruby on Rails, and the Rails Beta Book

I’ve been reading Agile Web Development with Rails, and it’s a great book, as well as a great structure, the “Beta Book” program from the Pragmatic Programmers, for providing early access to books. Rails (for the most part) feels like the future of Web application development, and the Beta Book feels like the future of book publishing.

Some engineering shops have what is known as a “tools developer” — the person who goes around finding the repetitive tasks endemic to software development, and who develops code to automate those tasks. It can be a good job, but often the tools developer either becomes the department janitor, cleaning up other people’s messes, or they get sucked into some “high priority” project and lose the purity of the original role. But when a tools developer excels, you see common tasks factored out of your day. You do something three times, and suddenly some new code appears so you don’t have to do it anymore.

Rails feels a bit like the best tools developer in the world automated all the stuff you haven’t even had to hit once yet. As you reach to do it the first time, you’ll find the framework steering you to do it the easy way. I love that. The “convention over configuration” idiom is very worthwhile, and I’d love to see more frameworks use it.

I’d learned Ruby a while ago, back when the first PickAxe book came out, and I was impressed with it. A detour into Groovy made me appreciate Ruby still more. My friend Nelson, a Python fan, was joking with me about the funny characters Ruby puts at the front of each line — @, @@, and so on. “Python does, too!” I replied, “but its funny character is a tab!” Don’t shy away from Rails because of Ruby; it’s a worthwhile language to know, and I find it far more usable and consistent than Python.

The one area of Rails that grates, for me, is the inclusion of code directly in the HTML templates. Of course, Rails is not alone in this at all, and many successful frameworks do just the same thing. I’ve written at length about my complaints with this approach (yes, I am the number one hit if you type ‘jsp sucks‘ into Google — thank you, thank you), so after reading many pages of beautifully-short code examples, hitting the HTML template on page 61 of the Rails book felt like slipping on a banana peel. What happened to the elegence?

David (the author of Rails) has written about this at length in the past. What he says in the book — that MVC frameworks used business logic active code in the view from the beginning — isn’t very compelling; his blog post is much more persuasive, but still I am unconvinced. Nonetheless, I’m going to try to drink his kool-aid dry, and see if another try, and a try using Ruby instead of the languages I’ve used in the past, changes my mind. David did too many other things right for me to question this decision without a good, up-to-date run at the way he suggests doing it. In the back of my mind is a method for adopting “convention over configuration” into HTML templates — hopefully a better proposal than the one in my “JSP sucks” article — and if I still hate .rhtml a few weeks in, I may clamor for it.

If you haven’t already, check out Rails, and definitely check out the Beta Book program from the PragProg guys. That’s the way you’ll get technical books in the future, I suspect, and you might as well start writing web apps from the future now, too.

UPDATE: Several people have pointed out that there are a few splinter groups trying to take “convention over configuation” to the template. If you’re interested, check out:

None of these are quite what I had in mind, but they’re all close, and I wonder if one of them would make a good option for Rails.

I’m still planning to go the default Rails way for now and see if I’ve just talked myself into my ideas on this topic, rather than actually being right!

UPDATE 2: Please see my comment about HTML developers in response to Andrew’s comment, below. I think people assume I’m saying “Photoshoppers can’t grok code, we must save them,” and, well, that’s not my point at all.