Epicserve

Python and Django, Ruby on Rails, and PHP

February 22, 2006 | 10:42 p.m. 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

Jeff Croft
1.   At 12:24 a.m. CST on Feb. 23, 2006, Jeff Croft wrote:

Rewrite my blog in Django too, while you're at it. :)

Nice post, Brent!

Wilson Miner
2.   At 10:04 a.m. CST on Feb. 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!

John Nunemaker
3.   At 10:00 p.m. 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.

Sebastian
4.   At 6:24 a.m. 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

Brent O'Connor
5.   At 8:06 a.m. 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.

Sebastian
6.   At 9:00 a.m. 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

Matthew Nuzum
7.   At 5:06 p.m. CDT on April 2, 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.

hey yeah
8.   At 2:51 p.m. CST on Nov. 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.

Piyush
9.   At 4:51 a.m. 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.

Dave
10.   At 12:05 p.m. CDT on May 25, 2008, Dave wrote:

I've posted a poll at: http://www.railsordjango.com

christoph Blaul
11.   At 6:13 p.m. CDT on July 20, 2008, christoph Blaul wrote:

great words, will give django a dry

Johan Bichel Lindegaard
12.   At 7:18 p.m. CDT on Sept. 30, 2008, Johan Bichel Lindegaard wrote:

Thanks for the good comparison. Coming from php/mysql, I too have been working through the tutorials.

Do you know about what significant references ROR and Django has, how do they compare in terms of what developers have actually accomplished?

Do you have an impression on how large and active the communities are?

Brent O'Connor
13.   At 8:48 a.m. CDT on Oct. 1, 2008, Brent O'Connor wrote:

I personally don't have a list of what has been accomplished. I do know on the Django side that pownce.com uses Django for it's server side solution. I think both Django and ROR have big websites that use their frameworks.

I've personally been working on converting all of ciy.com's websites over to using Django. I really like it so far. It's hard getting used to the Django way of doing things, but you are going to have that probablem anytime you move to a new language or framework.

I created a small irc channel for web geeks in my area called #joplin-web-geeks on freenode.net. It has 2 people on it that are Django users. I also know that #django on freenode.net is very active.

Thomas Gruner
14.   At 11:09 a.m. CDT on April 11, 2009, Thomas Gruner wrote:

Django is great!

I had built a framework in php over the past five years, that powers lots of high traffic multilingual sites, but after two weeks with Django, I´ve not only decided to learn Django, but also to stop any other development on my own solution. Django rocks!

I recommend this book for 1.0: http://www.packtpub.com/django-1-0-website-development-2n...>

It teaches you first the nitty gritty stuff to create your own forms, and then goes into how to make the automatic admin.

Drazen
15.   At 10:05 p.m. CDT on May 10, 2009, Drazen wrote:

I have been evaluating RoR and Django recently (as well as Pinax/Django) and its been very difficult deciding between the two. They are both excellent frameworks.

I have no exposure to Ruby other than experimenting with RoR, while I have written a few apps with Python and also the python-based Scrapy framework. So I have been leaning strongly to Django.

I had also heard rumours of DHH being a YAP (Young Arrogant Programmer) and finally decided to watch the Snakes and Rubies video.

I'll be honest, I did not find DHH cocky or arrogant. He came across as very opinionated and having strong beliefs. However, his opinions and beliefs seemed to clearly line up with the vision and principles he was espousing. Some of these opinions are not politically correct, but advance the end goal. In the context of web application development, I do agree with most of the decisions RoR makes. In fact, I find it refreshing that they had the balls to make some of these decisions. ie. AJAX support (screw the 7%), allowing code in the template, etc...

Its as if all the mundane (who cares type) decisions and the obvious good for the 90% use case decisions have been made. Good riddance. If I didn't have a framework to being with, I'd have wasted my time basically making the same decisions and having to implement them all.

After watching the video, I committed myself to doing a full app in RoR and so far... the experience is pleasantly surprising me at many turns.

Cheers

Brent O'Connor
16.   At 8:48 a.m. CDT on May 11, 2009, Brent O'Connor wrote:

Hey Drazen, This article was written over three years ago, so things have changed since this article was written for me, in that I have probably about a years worth of experience using Django full-time at my full-time job. Have a look at http://www.ciy.com/, which is the parent organization for about eight different websites and organizations. The MOVE website is one of my favorite that I developed (http://www.ciy.com/move/).>

The two factors that made me choose Django over Rails are that Django has a very powerful and mature admin website built into the framework that you can use if you want. It saves a ton of time and is very customizable and was way better than anything Rails had when I was doing comparisons, so things might have changed since then.

The other major factor that made me choose Django, was for Python. Python's syntax and way of doing things is so much cleaner and elegant in my opinion that ruby. I honestly get a headache when looking at ruby code. So ultimately it wouldn't have made good sense to choose something that gave me a headache and required extra time because it came without an admin website built in.

And after working with Django for over a year, I am very happy with it and have started using Django's design patterns in my PHP framework that I have keep up over the years. Django is a little hard to get used to at first and I needed help from friends at times but ultimately I'm glad I made the investment.

AD
17.   At 1:38 p.m. CST on Feb. 5, 2010, AD wrote:

As a person wanting to move from LAMP to django, the most common things I am unclear about are:

  1. What is the best deployment strategy? What do I need to tell my host to install?

In DjangoBook it says its outside of its scope, indeed everywhere talks about it being installable on Apache but never really detail it; or if it has any hic-ups or even what the host is meant to have installed if I wanted to deploy a django thingee.

  1. Where do my django/python files go? It says not to put them in /www/ folder, so they go outside right? So what goes in /www/?

  2. Installing and using MySQL -- Django comes with mysqllite but I am unclear of the best way to install it, or whether it works well with it or not.

  3. Can I really use the in-built admin interface with public facing websites; I mean it'll be a security risk if I can't.

Thanks

Brent O'Connor
18.   At 8:12 a.m. CST on Feb. 15, 2010, Brent O'Connor wrote:
  1. You basically just need python and whatever database you're using installed locally for development. Just run the included django dev server. I use Git to keep revisions of my code and when I'm ready to deploy I commit the changes to my remote repository and then I update the code that the live site is hosted on from the master repository. I run all my stuff on a Linode.com VM and so I have complete control on what is installed. I install, Apache, MySQL and mod_wsgi.

  2. Put them wherever you want. I put mine in /home/code/www.example.com/.

  3. Django works well with MySQL, but most Django coders will tell you that they prefer PostgreSQL.

  4. You can use the built-in admin site however you like. Django developers are always thinking about security and as far as I know it's very secure.

AD
19.   At 9:12 a.m. CST on Feb. 17, 2010, AD wrote:

Thanks

Post Your Comment

(Optional & Not Displayed)

(Optional)


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

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.