Rails, Cake and Django

I've been having a close look at web frameworks recently. As my programming has matured, I've gone from spaghetti and hacking right through to well-structured, modular programs and I'm now religiously keeping my logic separate from my design. I see web frameworks as the next step in this evolution. Frameworks allow you to take advantage of other people's work (and that has to be a good thing!). If you work within the framework's parameters you can program your application with very little code. You will end up with a well-structured program that is simple, and easy for someone else to work out what you have done.
<!-- break -->
Here's some more detail on what I've found so far.

Things web frameworks have in common

  • Create a directory structure for you
  • Abstract database access so that you hardly ever have to write sql
  • Use the Model-View-Controller pattern. A well known design pattern for creating applications that separate logic, design and input.
  • Scaffolding - which creates data access methods for you to test your structure (this is a really neat feature - check out any of the frameworks to learn more).
  • AJAX / Web2.0 support

Rails

The framework that's in everyone's face at the moment is Rails (or Ruby on Rails). Its a framework written in the Ruby language. Yes, that's Ruby - not your everyday language for most web programmers. A nice language yes, but the fact that it is not one of the mainstream languages makes me nervous right away. I know at some stage my code is going to be handed over to someone else who probably knows PHP, Java and heck might even know some Python, but they are probably not going to know Ruby. Not a problem (the Ruby people cry) - its easy and can be easily understood. Yes, I'm sure that's true, but it still worries me.

There are some great demos and video tutorial available on the Ruby on Rails website. As much as anything, they are an advertisement for frameworks rather than any particular one. As the supporters of the other frameworks point out, there is nothing inherent in Ruby that makes for a good framework. A framework can be written in Java, PHP, Python, Perl or whatever. If you hunt around, every framework has a tutorial that shows you how to build a (blog|poll|guestbook) in only (40-70) lines of code. Its true that a good framework is built around Object Oriented programming and that's true of Rails as well as the next two frameworks.

CakePHP

CakePHP is a framework written in (you guessed it) PHP. It does many of the things Rails does, but it is written in a language more familiar to the average web programmer. Most people will find this easier to install and get your head around than Rails. I ran through the tutorial and was impressed with how easy it was to get an application running.

CakePHP is not the only PHP web framework. In fact there are over 40 PHP frameworks modelled on the MVC pattern. Its a harsh world out there and it will be interesting to see which ones survive.

Cake seems to me to be one of the more mature implementations of a web framework and its real strength is that it has a strong community with contributed modules and that is is written in PHP. Some people see that as a weakness - PHP has a reputation in some circles for being insecure, but that is more about how the program is written rather than than the language itself. Using a framework goes a long way to helping make a program secure.

I also like the name - it lends itself to lots of references to baking.

Django

I've saved the best until last :) Django is a framework written in Python. For many people, this is just as big a turn-off as using Ruby, but let me tell you, Python is gaining in popularity and is more often than not installed by default on your typical webserver (i.e. a linux server running apache). I can't really tell much of a difference between Python and Ruby. They are both really well thought out languages that are easy to read and make maintenance a breeze.

Django comes from the world of on-line publishing an newspapers where new web apps need to be written very quickly and be able to take sometimes massive loads. Django has been proven to work well in this environment. Django is not entirely simple to install - you'll probably need root access to your server, but once installed it flies. It has its own test server written in python built in, which makes prototyping application very simple.

Another drawcard of Django is that it can create an entire (very nice looking) admin interface with only a couple of lines of code. This is something that would normally take a long time to write and is used by just about every application. Not having to write it yourself makes for rapid development (which is what its all about).

Finally, I like the name Django. Its from Django Reinhardt one the great Jazz guitarists of all time. While the name lends itself to other references, it can get you into trouble - from the Django weblog:

We've changed the default session cookie name. Instead of "hotclub", it's now "sessionid". Intended as a reference to the Hot Club of France (one of Django Reinhardt's bands), "hotclub" had been misinterpreted by some people as having some sort of porn-site meaning.
Oh, well. Wit and obscure references only go so far.

Final Comments

A good review of Django v. Rails can be found here.

All these frameworks are relatively new and will no doubt develop further (at the time of writing all of the above were only just at, or nearly at 1.0 releases). They are getting attention for a good reason, they allow programmers to create quality applications with fewer lines of code and no-one can argue that's not a good thing.

Also worth a look

There's some good info around out there. This article about drupal as an MVC framework is interesting. Also turbogears is another framework for builing web apps in python (have not checked it out, but looks like it is worth a look).

Edit: A lightweight php framework that I have started using in some projects is codeigniter. It has almost no learning curve and excellent documentation (how often do you see that!) Its real strength is that is pragmatic - it is simple but powerful. As a relative newcomer it has a smaller community, but I expect to see this grow. Definitely one to have a look at.

Links: CakePHP | Rails | Django

Comments

Cost of medigap insurance

Good evening! My name is Reese!.
I am from Venezuela and , too, and now am writing in English, give true I wrote the following sentence: "More employees pay to more investment, and the water remains further. "

Thank you so much for your future answers ;-). Reese.

Hm...GWT...never considered that yet...

And I guess if I love Java that much, that is one toolkit that I should really look into. Considering that I have already explored CakePHP, Rails, Django, and even writing our own customized frameworks, plus customizing Mambo, Drupal, PMWiki among other small ones...maybe I should stick to pure Java like GWT?

Advise anyone?

About time for a review?

Yes, GWT is certainly getting a lot of coverage recently and looks very interesting too. Although I still get nervous about compiling into something that's going to look ugly (perhaps this is a hangup from all those bad html editors that used to be around that created awful markup).

This article might be showing its age in terms of some frameworks that have been left out although the basics probably still apply to what I wrote. I've certainly used more of codeigniter in the last year (highly recommened) and also plain old java servlets.

reply

The (probably) best webframwork ever? Does it exist? Since I tried Google's new webtoolkit I am convinced that GWT is the way to go. That's probably the big winner. Even Ruby on Rails looks outdated if you ask me.

Nice writing.

I really appreciated the contrast between the frameworks, many thanks!

I hope you don't mind a couple of suggestions for easier reading:

s/than than/than
and
s/publishing an/publishing and

Best regards,

Chris

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.