Monthly Archives: September 2006

Django and Ruby on Rails

Over the last few weeks I’ve been taking a bit of a holiday (well as near as I ever get, which means I just work a few hours less than usual each day). One of the things I’ve been meaning to do over the last year or so is investigate the newer web frameworks, with a view to moving over to which ever one I prefer, as a replacement for PHP.

Reading around, I decided to install and play around with two of the most popular new frameworks – Django and Ruby on Rails. There’s already lots of comparisons between these two frameworks, but below are my thoughts having installed them and worked through their tutorials.

Django and Ruby on Rails compared to PHP:

  • Both push you into separating content from presentation, whereas PHP doesn’t try to help you impose any structure on your code. For larger projects, I’m sure this going to be a good thing
  • They both try to take you away from writing SQL. Instead you access the database through objects
  • Scaffolding in Rails and the Django admin interface help you get up and running very quickly
  • Implicit naming conventions are used in many places to transparently get data from one place to another. This avoids lots of tedious coding and potential mistakes

Good things about Django compare to Rails:

  • The free admin interface is very very slick. Much more powerful and elegant than Rail’s scaffolding. It’s something that you could give to end users with very little customisation
  • It’s supposed to scale better than Rails. A lot of the difference is probably because Python interpreter uses compiled bytecode, whereas Ruby does not have this facility in its current stable release
  • It’s written in Python, which seems to have better library support than Ruby at the moment
  • It seems to be biased towards content management systems, which is most what my websites are
  • Using Django would improve my Python, and Python seems to be used across a far wider set of domains than Ruby at the moment

Good things about Rails compared to Django:

  • Much easier to install. Making Django work on Mac OS X took me most of an afternoon, whereas Locomotive took only five minutes. I also found Rails installation instructions for Redhat Enterprise Linux 4, which will be very useful if I’m going to deploy a Rails application on my main webserver. I couldn’t find a similar document for Django
  • Rails works very well with my favourite text editor – TextMate
  • There are more tutorials and books available for Rails
  • Rails and Ruby just seemed more beautiful to me. I’ve written Python several times before, and while I admire it as a language, I just can’t get away with errors because of mixed spaces and tabs, and all the “self”ing and double underscores. Not the most rational of reasons, but if I’m going to spend many hours with a technology, it helps if significant aspects don’t irritate you
  • Rails seems to have more momentum than Django. If I’m going to switch to a new platform, I want to to have a good longterm future. That said, I think Django has a very positive future ahead of it too
  • Rails just seems to be about a year ahead of Django in terms of the slickness of the experience. Everything worked the way it should have done, where as Django felt like more of a work in progress

In summary, while I loved Django’s admin interface, its probable performance advantage, and the better availability of Python libraries, I’ve fallen for Ruby on Rails. This is mainly because of its elegance, and absence of any significant problems while installing and using it.