views:

565

answers:

12
+4  Q: 

Rails or Django?

Possible Duplicates:
Rails or Django? (or something else?)
Django or Rails?

I come from a PHP background and was planning to try out a new framework. I have never done Ruby or Python before.

Knowing PHP, what language would be easier to learn?

A: 

Rails. Because the community is generating faster than Django. Rails has won the framework game, no matter what people say.

Pylons is the complement of Rails (in Python), but still..it is lagging behind the community of Rails 3 (coming out stable very soon)

TIMEX
Rails has won the internet folks. Time for everyone else to pack up and go home.
Paul D. Waite
"Rails has won the framework game, no matter what people say." - makes me wonder by what rules is this 'framework game' played, if 'what people say' doesn't matter.
cji
Let's see, how about : no? There is room for more than one language, and more than one framework. Try telling people using ASP.NET MVC that it's time to throw it out the window and turn to Ruby, and you will have them look at you like you are a total idiot.
Cole
Django is used for shitting out stuff for contractor work. Any 'real' work should be done in Rails/Pylons--and Rails has got Pylons nailed. I personally use Django myself, for contractor work--since it's so fast and simple.
TIMEX
@Cole — “There is room for more than one language, and more than one framework.” Ah, but there’s only room for one winner, and Rails has won, because it is best for real work (i.e. work not done for someone who’s contracted you to do it).
Paul D. Waite
@Paul that's obviously just an opinion. There is no 'winner'. Django and Symfony will not cease to exist because you guys like Rails. If that's how you think, hope you like using Windows because I guess Mac and Linux don't exist, Baltimore and Boston are useless because NYC is bigger, etc.
Cole
@Cole: ah, sorry, I was parodying the answer. *A little too closely.*
Paul D. Waite
@Paul OH.. ha ha, I see now... why, yes. Contracted work is 'fake' work, and I'm not part of Real America for that matter.
Cole
@Cole: you're certainly not as much a part of Real America as I am, old chap.
Paul D. Waite
+4  A: 

This question is likely to generate some terribly subjective answers. My advice to you is to go through the tutorials and introductory material of both python/ruby and figure out what language suites you better. After that decide on and worry about web frameworks (there are a myriad of others for python, at least).

whaley
+19  A: 

I've just started learning Django, after reading the python tutorial in a few evenings. Things I've noticed:

  • In a sunday afternoon, I've managed to create two fully functional list/add pages.
  • My code was already pretty short, and could even get more shorter in a few revisions.
  • The views API, template language and ORM really allows you to speed up.
  • It felt like flying! There is a truth in this one: http://xkcd.com/353/ :D

My take on Django vs Rails, based on what I've read so far:

  • In Python, things are more explicit. Using just notepad, you can still tell where a function is imported from.
  • Rails will magically create methods on demand when you try to invoke them (e.g. find_by_... methods). Avoiding useless method programming, while requiring some more knowledge.

  • Django additionally increases productivity by offering generic views (think them as base classes).
  • Rails additionally increases productivity by offering scaffolding (generating code).

  • Django requires to you specify your model explicity.
  • Rails can extract your model at runtime from your database schema.

  • Django had performance in mind from day 1.
  • In Rails programmer productivity is seen as more important.

This is where IMHO the difference between Rails and Django imho really boils down to: Rails does things "by convention". Django requires you be a little more explicit, which in return allows the framework to perform better. Which one you'll like, depends pretty much on what kind of programmer you are. I'm obviously a Python/Django guy ;)


Both allow you to start a development server directly (like VS offers for .NET). Both allow FastCGI for hosting (like IIS app pools), can be run on the JVM (JRuby, Jython) and both have a specialized solutions for running an app pool (mod_wsgi in case of Django, mod_rails in case of Rails).

Some other worth full readings are:-

http://www.ctctlabs.com/index.php/blog/detail/rails_vs_django/

http://mackstar.com/blog/2010/04/23/django-vs-rails

http://superjared.com/entry/rails-versus-django/

http://docs.google.com/View?docid=dcn8282p_1hg4sr9

http://www.magpiebrain.com/2005/08/14/a-comparison-of-django-with-rails/

piemesons
The Django admin replaces some need for back-end programming too, like scaffolding but a lot better.
Cole
you can run a djanogo app on the jvm?
Blankman
@Blankman http://docs.djangoproject.com/en/1.2/howto/jython/
Cole
Copying this from http://stackoverflow.com/questions/3042259/django-or-rails/3043518#3043518 looks a bit lame to me. Linking would have been possible too ;)
vdboor
@vdboor check revisions of my answers.. Initially i specified this link..
piemesons
+3  A: 

I don’t think either Ruby or Python are easier to learn coming from a PHP background.

You’ll definitely want to learn one of these languages a bit before using one of their web frameworks. But it might be worth having a look at the Rails and Django tutorials first to see which one sounds more appealing, then learn the requisite language.

Or just pick based on whether you prefer red or green. (You have to write Python in green and Ruby in red, otherwise you’ll get silent but problematic errors.)

Paul D. Waite
What if I like blue best?
Wayne Werner
@Wayne Stick with PHP. ;)
Stuart Branham
@Wayne doesn't IBM have an MVC framework you can use?
Cole
I thought PHP was a lovely shade of purple??? Now I'm soo confused! ;)
Wayne Werner
+3  A: 

I feel Python to be an easier language to learn than Ruby. From a C and C# background, it just feels more "familiar" for some unqualified reason, probably syntax and patterns.

Both frameworks are excellent. The Rails community seems larger. Django has well-renowned documentation. Django provides an excellent automatic admin interface, generic controllers (views), and other really nifty features to help you reduce the amount of code you need to write. Rails has built-in support for database migrations, and seems to be smoother to manage.

Keep in mind that Django was originally built for a newspaper site. It's absolutely excellent for those kinds of interactive, public-facing web sites. I imagine that Django's advantages have less impact when writing a full-on web application, and that Rails is more useful in this field.

I've used both, but my personal preference is Django. Regardless, I'd pick up Rails for a project it suits in a heartbeat.

Stuart Branham
+2  A: 

Number of questions in Stack Overflow with the two tags:

ruby-on-rails: 16915
       django: 8965

Number of books on Amazon in the "Computers & Internet" section:

 rails: 222
django: 34

This doesn't mean that Ruby on Rails is better, but it has a bigger community.

gdelfino
Or is just less self-explanatory... ;)
cji
I get my answers on the #django irc channel when I really need help. Very helpful community there.
joel3000
Or has the hype. (That’s not a criticism; I mean hype in the sense of lots of people being interested in it, which can be helpful in itself.)
Paul D. Waite
Rails caught so much publicity early on, which has helped with the momentum. Judging by the SO vs. book numbers, sounds like there are room for more Django books. Or, the Rails book market is over-crowded because of all the hype.
Cole
Django is known for its documentation as well. There's the official docs and the open-source Django Book — between them they've pretty much got it covered.
Paul D. Waite
A: 

If you are going with python, my vote is for cherrypy.

buckbova
cherrypy is more like an application server.
Cole
It does have the best name out of the Python frameworks though. I always imagine Dale Cooper saying it with a smile.
Paul D. Waite
+2  A: 

I had to look at both for my project, coming from no prior knowledge of python or ruby.

I went with RoR first but then eventually got frustrated with it because of its 'programming by convention' design. Instead of just building what I wanted, I had to figure out the magic words to get RoR to do it for me. For me that's hard.

I switched to Django and have been much happier with it. Django has the phrase "No magic" as one of its central design philosophies. Everything is explicit, nothing happens unless you make it happen. Django maintains its programmer efficiency by providing a solid set of well designed tools. I also like the fact that Django was designed to scale from the outset. The fact that Google has chosen Django as their web application framework for App Engine, and python as their preferred scripting language reassured me that Django was quality software.

I'm not knocking RoR, it works great for some people. This is just my experience.

joel3000
+1  A: 

I started playing with both (my brother wanted me to learn Ruby on Rails. He says it's the way forward). However I hit a point where I just didn't understand Ruby on Rails. Django just has a nice feel, and I plan on learning Python which looks amazing. When playing my aim was to create a relational object application, which Python won (lines in the model then add the admin application). EASY.

Dean
A: 

Don't forget there are plenty of good PHP frameworks. I looked at Rails and Django but have been enjoying learning and using symfony for the last few years.

One thing I think is especially suitable is PHP in the template/view layer. It seems silly to see each framework re-invent its own weird/awkward/limited template sublanguage for including data and display logic in HTML, when PHP was originally made for that?

For the Model and Controller layers, PHP isn't as "pure" as Ruby or Python but it's still possible to write well-designed code.

Learning other languages is fun too though, and I think all the frameworks have been cross-pollinating each other to some extent. Have fun!

Nathan
“It seems silly to see each framework re-invent its own weird/awkward/limited template sublanguage for including data and display logic in HTML, when PHP was originally made for that?” — quite possibly, although e.g. Django’s template language was specifically designed to avoid allowing Python to be used for templating. See http://www.djangobook.com/en/beta/chapter04/#cn210. I’m not saying they were right, but it was a conscious choice to avoid PHP’s approach of having templates be written in a full programming language.
Paul D. Waite
Django can support full python in its templates via the mako lib. Usually I wouldn't want to though. Dumb templates keep your code manageable. I like that I that in a given app most of my codes is either in views.py or models.py, I don't want it spreading into the template files.
joel3000
It's still Yet Another Syntax to keep straight, and all templating languages start simple but end up supporting conditional statements and comments and loops and helper/filter functions and so on and so on.
Nathan
+1  A: 

I'm of the opinion that all programmers in the world will fall into one of two camps, Python guys and Ruby guys.

Python is all about doing things the simplest, most straight forward way. In Python, there should only be one way to do something, and that way should be clear.

Ruby is all about pushing the language in innovative ways to create amazing APIs specifically for the task at hand. In Ruby, there is more than one way to do it, and you should always strive to choose the most elegant way.

Back when I decided I didn't want to do C# anymore I was pretty much in the same boat, what tipped the scale for me at that point to Ruby was that Ruby embraces functional programming ideas in ways Python doesn't. The creator of Ruby loves Lisp, and borrowed a lot of ideas and philosphy from it. The creator of Python has said explicitly several times that he finds functional programming in imperative languages ugly.

IMO you should choose your framework based on what language you want to go with. The differences in the frameworks are pretty much the same as the differences between the philosophies in the languages. One thing that may give Ruby on Rails an edge is that it is further along in building out a good deployment story, and sharing code/infrastructure with other frameworks on the platform, but that will all come in time with Django.

If I were you, I would pick up The Well-Grounded Rubyist, read through it, find a great Python book and read through that, and then make your own decision. Depending what parts of the Internet you frequent, you will find either rabid Rubyists or rabid Pythonistas trying to convince you the other side is crap.

Matt Briggs
‘Dive into Python’ by Mark Pilgrim (it’s on the Internet and it’s free) is quite a good head-first Python intro. And I really like ‘Learning Python’ by Mark Lutz for a comprehensive view. Python tries to take a small collection of core concepts, and do a lot with them. Lutz’s book does a great job of teaching the language along those lines. Oh and Ruby is crap :)
Paul D. Waite
(Note: I’m kidding about Ruby, I’ve never even written Hello World in Ruby.)
Paul D. Waite
@Matt: have you ready _why’s Poignant Guide to Ruby? What did you think?
Paul D. Waite
So _whys poignant guide is hilarious and creative, but I don't know how effective it is as a programmer language guide. I know of dive into python, but not all of it has been good. I know Zed Shaw started this http://learnpythonthehardway.org/index after getting into an argument with mark on twitter
Matt Briggs
A: 

I think it's more a matter of taste. That's why I'll tell you why I personally prefer Ruby.

Ruby is an equally strong language as Python and I think it is the easiest language you can learn. That's why the productivity matter is number one. The main mantra is to like what you do and to have pleasure when you see the code, it's plain English.

I like its syntax very much (no indentation like in Python which personally bothers me to get these kind of errors), method chaining which I found is very easy to understand even if you don't know Ruby and with the philosophy of "there is more than one right way to do something" which makes me feel more free.

Ruby, I think, is also the strongest metaprogramming language and that's why there are many great tools around Ruby on Rails that can't exist in other languages.

I also love the TDD and BDD philosophy of Ruby on Rails which you will eventually do if you want to be a successful web developer and Ruby on Rails has great tools like RSpec, Cucumber and much more, which I don't know if there are so good tools in any other language (and have that tools due to strong metaprogramming abilities of Ruby).

JohnDel