Epicserve

Python and Django, Ruby on Rails, and PHP

February 22, 2006 | 10:42pm CST
Djang, Rails, PHP

I've been a PHP / MySQL developer for almost a decade now and I like it a lot. I think I could probably do just about anything you can imagine or have seen on the web in PHP / Mysql. I haven't been looking for a change, but part of being good at anything in life means keeping an open mind and thinking critically. In trying to keep an open mind, I read and keep up with the latest news in web development. Unless you've been living in a cave you've probably heard at least something about Ruby on Rails. Ruby on Rails has been making a ton of news lately in the web development community. And in case you don't know, Ruby on Rails is a programming framework for the programming language Ruby.

Also another programming framework that is making some buzz in the community is Django. Django is a programming framework for Python that I first heard about when I read the news on Simon Willison's blog that Django was going to be released as an open source framework.

So trying to be the open minded critical thinker that I am, I thought I would give both of them a try. I tried Ruby on Rails first by working through a tutorial they had which walked you through making a simple to-do application. I admit that I'm no guru after working through one tutorial but I do have some initial impressions which might be of interest to people thinking about Rails or Django.

First of all the installation process was a little tricky since in order to get Rails to work with Apache 2 you have to install FastCGI. After the install the tutorial was pretty straight forward and Rails did a lot of the tedious reparative tasks for you, which I liked. However, after finishing the tutorial I felt like the overall application was sluggish. I'm sure a lot of this has to do with the fact that Rails uses FastCGI instead of a module for Apache like mod_python and php4_module. I've heard but haven't experienced it first hand that Rails is a lot faster when you use LightHttpd instead of Apache 2. But for me that wasn't an option because I already had a lot of applications on my server that were dependent on Apache and I didn't want to run another web daemon on a different port on the same server.

A Django site.

Just recently I've been trying Django. I just finished part one through part four of "Writing your first Django app". I have to say that so far I'm really impressed with Django. It seems a lot more logical and seems to mesh more with my programming philosophy. The programming workflow and Django's stack just seem to make more sense. Not only does Django seem to make more sense, it's a lot faster than Rails when used with Apache 2. I don't have any benchmarks to prove it but you can just tell by the feel that Django's tutorial poll application is faster than Rails's tutorial to-do application.

Another main difference between Django and Rails is that Django uses Python and Rails uses Ruby. So what does that mean? Well if you like Ruby you're going to want to use Rails and if you like Python you're probably going to want to use Django. But what if you don't know either Python or Ruby, what then? You'll need to do some research or just take my word for it that Python is better! Python is stricter in the way that it does things, like being whitespace sensitive for example. Being whitespace sensitive means that it delimits blocks of code by line breaks, other programs like Java, C++ and PHP use curly braces to delimit code blocks. In the online book Dive Into Python, Mark Pilgrim puts it this way, "After some initial protests and several snide analogies to Fortran, you will make peace with this and start seeing its benefits. One major benefit is that all Python programs look similar, since indentation is a language requirement and not a matter of style. This makes it easier to read and understand other people's Python code."

One of the other features and main differences between Rails and Django is that Django has an "Automatic admin interface" which you can either take it or leave it. But if you want the automatic admin interface it's there to use, and guess what? It's not crap! It's actually pretty detailed and even styled. Having an automatic admin interface can cut down on building web applications like content management systems and blog applications. And what I found really cool about the admin interface that comes with Django is that it doesn't look like something your PhD math professor designed. It's actually has a nice detailed clean graphically designed interface.

If you can't already tell my preference is defiantly swaying toward Django. The final catalyst that made the pendulum sway towards Django was listening to a three hour Snakes and Rubies presentation where Adrian Holovaty (one of the creators of Django) and David Heinemeier Hansson (the creator of Rails) both present their frameworks and then answer questions from the audience. In my opinion Adrian's presentation was far superior to David's it wasn't even funny. Adrian's presentation was very logical in that he explained the Django stack so that you could follow Django's workflow for creating applications. David's presentation on the other hand seemed to be in no particular order and very unorganized. Not to mention that David's over all demeanor was very cocky and arrogant which was a major turn off. After hearing both presentations and the questions that followed it felt very clear to me that Django is definitely the framework for me. Its overall philosophy goes with mine, it uses Python which I like more than Ruby and Django's workflow and stack seem a lot more simple and logical than Rails.

Currently I'm now planning to finish reading Dive Into Python and the Django documentation and then move on to rewriting this blog using Django which is currently using PHP and my own PHP framework that I wrote.

If you're bored with PHP and need a change, give Django a try! What's the worst that can happen, you broaden your knowledge base and become a better PHP programmer (or whatever you use) because of it?

Comments

1.   At 12:24am CST on February 23, 2006, Jeff Croft wrote:
Rewrite my blog in Django too, while you’re at it. :)

Nice post, Brent!
2.   At 10:04am CST on February 23, 2006, Wilson Miner wrote:
And what I found really cool about the admin interface that comes with Django is that it doesn’t look like something your PhD math professor designed.

I nearly spit my coffee on my screen when I read that. Thanks - and welcome to the Django community!
3.   At 10:00pm CDT on May 12, 2006, John Nunemaker wrote:
Brent,
I haven’t looked into Django much mainly because I attached myself to Ruby. Ruby feels like I am speaking English instead of programming, which I find very attractive. I have chosen Ruby and Rails, but that is not to say that I am not going to also look into Python and Django. I’m addicted to indention so in that respect, Python is intriguing.
4.   At 6:24am CDT on May 18, 2006, Sebastian wrote:
Would you recommend reading “Dive into Python” or are there better python books for experienced PHP programmers like us?

cu
Sebastian
5.   At 8:06am CDT on May 18, 2006, Brent O'Connor wrote:
I haven’t finished Dive into Python yet, but from what I have read so far I’m very impressed and happy with it.
6.   At 9:00am CDT on May 18, 2006, Sebastian wrote:
Thank you for the quick answer!

Btw, very nice comparison, the best i’ve read so far!

cu
Sebastian
7.   At 5:06pm CDT on April 02, 2007, Matthew Nuzum wrote:
I too have been programming PHP for many years. The more I experiment with other languages, the more I dislike PHP. I’ve tried both Python/Django and Ruby on Rails (and Python/TurboGears) and like Python/Django the best. I especially like the way the URLs work.

However, the buzz around RoR is so big, I sometimes feel I’ll be left behind if I don’t jump on the RoR bandwagon. I’ll be honest, the Ruby syntax is different enough from other languages that it puts me off a bit. I’m going to give it a few more tries, maybe it will grow on me.
8.   At 2:51pm CST on November 13, 2007, hey yeah wrote:
“Not to mention that David’s over all demeanor was very cocky and arrogant which was a major turn off”

and also not too mention rails fanatics are mocking other frameworks (especially in PHP) in any occations.
9.   At 4:51am CDT on April 22, 2008, Piyush wrote:
Good post, thanks.

FYI, here is a performance benchmark comparison of the three frameworks/platforms:

http://wiki.rubyonrails.org/rails/pages/Framework+Performance

I was contemplating learning a server-side platform, and I think I will go with Django/Python.
10.   At 12:05pm CDT on May 25, 2008, Dave wrote:
I’ve posted a poll at: http://www.railsordjango.com

Post Your Comment

(Optional & Not Displayed)

(Optional)


(allowed tags - strong, em, cite, & code)

remember me

Post Guidelines

Please be considerate of others. Keep comments relevant. Content deemed inappropriate or offensive may be edited and/or deleted. Email addresses are never displayed.

Line breaks and paragraphs are automatically converted — no need to use p or br/. Quotes, apostrophes, and double-dashes are automatically converted to smart punctuation. Be careful when copying and pasting portions of entries or other comments.

Links can be created using the standard <a href="http://url">urlName</a>. The following inline HTML elements may also be used: strong, em, cite, & code. The title attribute is allowed within any element. All other code will get removed before posting.

Latest Photos

Good Reading

A bunch of presentations on scaling websites: twitter, Flickr, Bloglines, Vox and more.
Good links and presentations I'm going through about scaling websites.
Upside-Down-Ternet
Now that's a good April fools joke!
Animator vs. Animation by Alan Becker
Pretty cool flash animation that a friend showed me.
30+ Useful Websites You Probably Didn't Know About
Looks like some good websites that could come in handy. The GetHuman website definitely sounds useful!

view past links