Bruce Tate discovers Ruby on Rails

Bruce Tate is the author of Bitter Java and Bitter EJB, so if you were just judging by the titles of those books, you may not be too surprised that Tate is at least interested in an alternative. There’s a long way to get a conversion out of it, but Tate at least haves Rails on the radar and are seeing some of the possibilities:

Which brings me back to Ruby on Rails. It’s got that magic. I’ll just give you a little taste. When you’re mapping a Java class to a schema, you must often type the name of a property five times. FIVE TIMES Count them. Three in the bean: the getter, the setter, the instance variable. One in the schema: the field. Two in the mapping: the property, and the column. In Ruby, you type it once. Reflection and inspection of the database handle the rest. You use intelligent defaults and naming conventions to handle the rest. You can always override differences, but you don’t have to.

Keeping DRY is a big part of what makes Ruby on Rails special compared to the Java world. Getting rid of the bane of compilation in the development cycle is another big one.

Rails 0.10.0 loves lighttpd

With the release of Rails 0.10.0, the reign of Apache has finally ended and equal opportunity for all web servers has been introduced. The most important beneficial of this is lighttpd. The server describes itself as “…a secure, fast, compliant and very flexible web-server which has been optimized for high-performance environments” and is catching the attention of a lot of people lately.

Personally, I’ve been most interested in its FastCGI implementation that includes a load balancer component. But whether you need that or not, you owe it to yourself to check out lighttpd. Here’s a sample minimal configuration file needed to setup lighttpd to run a Rails application under FastCGI:


server.port = 8080
server.bind = "127.0.0.1"
# Needed on OS X: server.event-handler = "freebsd-kqueue"
 
server.modules = ( "mod_rewrite", "mod_fastcgi" )
 
url.rewrite = ( "^/$" =>"index.html", "^([^.]+)$" =>"$1.html" )
server.error-handler-404 = "/dispatch.fcgi"
 
server.document-root = "/path/application/public"
server.errorlog      = "/path/application/log/server.log"
 
fastcgi.server = ( ".fcgi" => ( "localhost" => (
 "min-procs" => 1,  "max-procs" => 5,
 "socket"   =>"/tmp/application.fcgi.socket",
 "bin-path" =>"/path/application/public/dispatch.fcgi",
 "bin-environment" => ( "RAILS_ENV" =>"development" )
) ) )

This configuration is also to be found in the README file of new Rails installations.

Rails for Strut-ters: Dealing with the view

Brian McCallister is doing an excellent job showing Strut-ters how Rails work by comparing it to their own environment. In this round, he’s taking a look at the oh-horror that is unleashing a real programming language on view logic. He finds that perhaps it’s not so bad at all comparing:

<% for invite in @invitations %>
  ...
<% end %>

…from Rails to the JSP approach of tag libraries with:

<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
...
<logic:iterate name="invite" property="invitation">
  ...
</logic:iterate>

Indeed they do look similar. For more on that discussion, read my views on template languages and why the scriplet approach works in Rails.

As a sidenote, I’d like to suggest a few improvements to the tag/value mix that Brian has in his examples. For example, we could convert:

&lt;form action="<%= url_for :action => 'register', :controller => 'rsvp' %>">  
...
   &lt;input type="text" 
          name="invite_names[&lt;%= slot %>]" 
          length="30"&lt;%= "value='#{@invite.split_names[slot]}'" %>/>
...

To use a few more succinct FormTagHelper helper methods:

&lt;%= form_tag :action => 'register', :controller => 'rsvp' %>
...
&lt;%= text_field_tag "invite_names[#{slot}]", @invite.split_names[slot] %>

But that’s nitpicking. Brian is doing a fabulous job expressing the unknown in familiar terms. If you’re in need for something more visual on the Helpers, see this video demonstrating how to create a helper method in Rails.

What if I could just use Ruby on Rails...

Jaikoo wonders what the world would look like if he could just develop purely in a dynamic environment:

One of the things I’m currently working on is this massively complex J2EE application running on JBoss. The thing I still can’t get used to is bouncing Apache (thats running a full blown Rails app). I mean it starts from cold in like 3 seconds on my live server. That can’t be right? After all JBoss 3.2.3 takes around 5 minutes to startup on the equivilent server. Yes, I know I’m comparing apples with oranges, but sometimes I just wonder how much more productive I’d be if I developed purely in dymanic languages such as Ruby or Python.

Of course, during development you don’t even have to restart anything to see your changes instantly reflected. It’s change’n’reload, baby.

Odeo is launching on Rails

Evan Williams (of Blogger fame) and friends have unveiled their latest venture: Odeo. It’s going to make “…it easy for you to discover, create, and subscribe to fresh, independent audio content for your iPod”. In short, Portal for Podcasting. That hook got the interest of The New York Times, but to get the full story, you’ll be well advised to read Evan’s blog posting about it and the Odeo blog in general.

I had a sneak peak at the application a few days ago and it looks mighty cool. I’m a big fan of podcasting myself (especially from the ever excellent ITConversations), so the prospect of Odeo makes me pretty excited.

What also makes me excited is Odeo running Ruby on Rails. Remember that posting Evhead advertises for a Rails developer back in the beginning of December? That resulted in the hiring of Rabble as the lead developer on Odeo. He talks about the Odeo launch and how they “…built it with the wonderful Ruby on Rails framework” in his blog.

So congratulations, guys! It’s great to see another high-profile site launch on Rails and loving it. Keep ’em coming.

Rails 0.10.0 is a Ruby 1.8.2 framework

It’s time to upgrade to Ruby 1.8.2, folks. Rails 0.10.0 includes various bits that require this version of Ruby, so if you want to run the latest Rails, you’ll have to get on the latest Ruby too. You’ll be glad you updated anyway. Ruby 1.8.2 contains a year’s worth of fixes, additions, and goodies from the Ruby masters. It’s an insult to them if don’t get jiggy with the goods (and Rails developers have other things to worry about that testing across old Ruby versions). Oh, when you upgrade, be sure to patch test/unit.

Joyent seeks 4 developers with Rails experience

David Young from the San Francisco start-up Joyent are looking for 4 developers with Rails experience:

We’re looking for four exceptional people, they should have deep experience writing good GUI applications and/or understand the integration of various open-source server products including mail, calendar, directory, samba, and rails. Some experience with Mozilla’s XUL is a big plus (it’s a bigger plus if they understand why XUL isn’t a complete solution). We will provide relocation (and visa, etc. sponsorship) assistance, but relocation is not necessary for the first phase. If desired, relocation would happen in the September, 2005 timeframe.

If you’re interested, get in touch with david at joyent dot com.

Rails 0.10.0: Routing, Web Services, Components, Oracle

We’re plowing through the road map at lightning speed with the release of Rails 0.10.0. There’s so much good stuff in here this time it’s really hard to pick just a few bits to focus on for the overview, but still I have. With Rails 0.10.0, you’ll get:

  • Routing: Pretty URLs of all flavors and fashions can now be specified using an easy to understand Routing syntax made in Ruby. This means no more wrestling with mod_rewrite in Apache to get custom URL schemes. It means you’re not bound to the traditional /controller/action/id form (the controller and action names don’t even have to be part of the URL!). It also means that the URL parsing and generation is handled by the same configuration, which removes all the labor previously involved in getting your Ruby code to sync with your rewrite rules. That makes it possible to share the same URL configuration across all the web servers supported by Rails. You can seemlessly develop your application on WEBrick and without changes move it to Apache or lighttpd. Read more in the Routing book, see a bunch of routes explained, or dig into the ActionController::Base#url_for API documentation.
  • Web Services: Action Web Service is a whole new add-on framework for Action Pack that enables SOAP with WSDL and XML-RPC web services to be made with Rails ease. You can either describe an existing controller with an API, and let the clients interact with the same methods used to do the HTTP interface, or you can create dedicated service classes that can be bound to a controller. In addition to the support for building web services, we’ve also added convenient wrappers for calling other web services from your application. For getting started, there’s a whole book on Action Web Service that explains how to define, implement, and interact with the web serivce APIs. We also got examples using the GoogleSearch API and the metaWeblogApi.
  • Components: With components it’s possible to call other actions and controllers for their rendered response while executing another action. You can either delegate the entire response rendering or you can mix a partial response in with your other content. This makes it possible to package functionality in reusable parts and to keep more DRY on application elements that integrate from many sources (like a dashboard). To learn more about components, we have another book, a video showing how to make and call components, and the API docs.
  • Oracle: In addition to the existing adapters for MySQL, PostgreSQL, SQLite, SQL Server, and DB2, we now also support Oracle as a database option for Active Record. The adapter that made it in is built on top of OCI8 and has been confirmed to work great with Oracle 8i and 9i. Our sixth database adapter is documented in the API.

But there’s a world of additional new and fixed stuff in 0.10.0. See the other whole new package Active Support and check the changelogs for Rails, Active Record, Action Pack, and Action Mailer.

Honoring Nicholas Seckar and Leon Breedt

The two most important features in this release has been contributed to two relative newcomers to the Rails scene. Nicholas Seckar tried at least three attempts at Routing before we found the one that felt like the best Rails fit. He put an enormous amount of energy into sorting out all the complications and have since helped to improve all parts of Rails. You’ve done a superb job, Nicholas. May potential employeers looking for talent see your name.

Equal thanks goes to Leon Breedt that popped out of nowhere with a whole new framework that followed our established conventions and approach to the dot. The quality of the code and documentation has made a big impression on the existing team of core contributors. And the work has contributed to make us all the much closer to 1.0. Thanks for the excellent work, Leon!

So how far away is Rails 1.0?

Rails 1.0 moved much closer today as we knocked off well over half of the previously announced road map. What we primarily lack now is Packaging and Performance alongside the aim to bring the number of uninvestigated and/or fixed fault tickets down to zero. The current tentative date is end of March/start of April.

Upgrading from Rails 0.9.5 to 0.10.0

If you don’t have any custom URLs defined in your existing application, then it’s a fairly straight forward process to upgrade. If you do have custom URLs, it’s a bit more work, but definitely manageable. Basecamp used a lot of custom URL tricks and it took me under an hour and resulted in 100 lines of code being stripped from the application. In any case, we’ve created a book to guide the upgrade process.

'They won't ever fit together like Rails'

Matt Grayson is another Python programmer that despite his love for Python “…haven’t done much Python lately”. He blames Rails, which he declares “…is worth the hype.”. On the prospect of seeing Python on Rails, he offers:

The closest thing I’d found to Rails in Python is a combination of CherryPy, SQLObject and Cheetah. But as much as I like each one of those pieces individually, they won’t ever fit together like Rails – which is why I don’t have a lot of optimism for things like Subway. I’ve got nothing against Subway. Could they pull it off and put together a really good Python web framework? Sure. But, given the track record of past attempts at web frameworks within the Python community, I won’t hold my breath.

And Jake from Maui is yet another Python programmer that has been getting into Ruby through Rails:

Every time my work took extra time, it’s because I was expecting a level of complexity that wasn’t there. Wow. It’s not often that one of the tools I use humbles me, but finally I’ve found something that allows me to write code as fast as I think.