views:

11682

answers:

31

I'm interested in learning a web framework. The two big ones, as I gather, are Rails and Django. Which one is better/faster? Is one better designed or more logically consistent than the other? Is there another framework I should look into? How easy is it to set up and administer a Rails or Django server, and how easy is it to find a shared hosting plan?

To give a little background, the websites I'm currently used to making are in straight PHP (no framework) and I'd like to be able to manage some of the complexity that comes from feature creep. Outputting HTML with echo becomes a lot less fun the more you have to customize it. In addition, I don't know either Ruby or Python so I'm free to go either way.

note: I'm not interested in ASP. I'd like to develop on a Mac and deploy to Linux/FreeBSD and I don't think that ASP fits the bill.


To everyone that's replied so far: thank you! Choosing a web framework can be a difficult thing, so I'll try to narrow down what I would like to do.

First, I would like to build small, custom sites (hard to call them "apps") that serve data from a database, and optionally an administrative interface to manage everything behind the scenes. As an example, I have a website for my grandmother to showcase her artwork built in PHP. I've spent more time on the backend than the front end to enable her to reorder, relabel, and reprice her artwork as well as upload an image, tag it, and have it scaled and appear on her site.

I notice both frameworks generate "scaffolding" that can be used as a rudimentary admin interface; how would they handle non-textual data (like images)?

Also, when watching a Rails screencast, there was a casual mention that the framework does some singular/plural translation. This strikes me as quite odd - is this what is referred to as "magic" in Rails? If so, does Django (or any other framework) have a more sensible naming strategy?

+41  A: 

The eternal question.

The answer: try both and see which one fits best for you.

Hyposaurus
Try other as well!
Jrgns
You can't get a sense of what these complex frameworks are about with just a few hours of dabbling. You'll just get an incorrect impression that way. Choose ONE and take the time to learn it. Otherwise, you're just messing around and wasting your time.
Ethan
About "The answer: try both and see which one fits best for you.": That attitude is the opposite to stackoverflow objective. If there are outside more experienced developers, why not ask them? If a I have to try ever possible technology outside, I will die before take a decision.
Nisanio
+2  A: 

I'm a PHP developer as well and I really like Django; I have no experience with Ruby on Rails though;

You can also use a PHP Framework offcourse, a good candidate is Symfony

D4V360
+17  A: 

I think it depends if you like to code in Python (Django) or in Ruby (Rails). The Frameworks are both very well designed and working well. I would prefer Rails because i like ruby :)

DeeCee
Rails has a pretty huge DSL which means for real rubyists it doesn't feel much like Ruby. Frameworks like Ramaze or Iowa fit this category much better.
Fabian Buch
@Fabian that is true but you have to remember that a large chunk of "Ruby programmers" have *only* used Ruby for Rails.
TM
I pick Rails for the same reason. Ruby is beautiful!
ohho
+1  A: 

@Hyposaurus

That is always an option. However, there are aspects I'm curious about that I wouldn't be able to determine for myself without extensive testing, such as scalability. I'm hoping that there are some people here that have tried both and have some observations they can share.

@DubCee

Why do you prefer coding in Ruby? Do you prefer the syntax, or are there more powerful features that make writing web apps easier or more fun?

Kyle Cronin
yes,both.i like the sytntax ), ruby has only one listtyp (Array) but you can use it in many different ways (queue,stack,list,set). very usefull for iterating...just 4 example
DeeCee
+12  A: 

Ultimately it depends on what language you'd rather work in. If you are comfortable with PHP already, then you may want to look at http://codeigniter.com/ which is a framework similar to Rails, Django, Pylons, Spring etc, but in PHP which you are already familiar with.

The other factor to consider is the server. With passenger (mod__rails) shared hosting now has a much better way to offer Rails hosting. mod_python should help you with Pylons or Django (python based frameworks)

How much customization are you looking to do? Would a content management system like Joomla or Drupal work for you?

Rails and Django are really easy to work with on your local computer since they have test servers that can be run right from scripts in their installation.

Better is a subjective term, and faster depends on what you are doing with it. If you don't want to learn another language, go with code igniter. If you want to learn ruby or python, then play around with both rails and pylons or django, and then look at what your hosting options are.

I don't know much about SQLAlchemy but it is supposedly a great ORM package that is only an option when using python. So if you need a very flexible ORM, then maybe python is the way to go.

danivovich
There are some hacks to get SQLAlchemy to work with Django, but in general you'll need to use a framework like Pylons or TurboGears if you want to use SQLAlchemy as your ORM.
gbc
Just a note, nowadays `mod_wsgi` is the "preferred" way to host a Django app, rather than `mod_python`.
TM
I'll second drupal, although I have not used it for years. I know we (Thoughtworks) have been using it more as another suggested solution alternative to rails or django. Especially if you are already familiar with PHP, there will be a much less learning curve.
Xian
Last I checked, CodeIgniter lacked some (what I consider to be) crucial features, most notably url generation that conforms to defined routes.
Brian Warshaw
+2  A: 

Since you're using PHP, I'd recommend CodeIgniter. It's well-documented and has a nice set of functionality without being too complex or bloated. I'm using it all the time!

Christian Davén
codeigniter is no match for frameworks like symfony, ror and django. but for smaller, mid-sized applications, it shines. and the other frameworks aren't bloated =)
never_had_a_name
+9  A: 

I'd like to develop on a Mac

Then Rails may be a better fit. Apple seems committed to having a good out of the box Ruby/Rails development experience. (Pre-installed ruby and rails gems + other dependencies)

Although, to be honest the Python/Django experience is just as good, just maybe not baked in and fully supported by Apple.

Its a little dated now, but this comparison of both has some good info on both. Try them both out and see which suits your needs.

rnicholson
+2  A: 

I know for a fact there is a great community behind Ruby on Rails (mailing list, irc channel, and at least two forums) and probably an equally greater one behind Django. I agree with Hyposaurus, try both and work out for yourself which one you like.

A Rails server is easy enough to set up, it's just a matter of installing Ruby (which comes with Mac OS X), Rubygems, Rails and optionally the gem called Mongrel, which is a HTTP web server.

Deploying a Rails application is easy enough, with Capistrano or Vlad the Deployer to help you out there and there's plenty of documentation for both programs to help you along the way. Setting up on servers is now easy thanks to Phusion Passenger which has epic documentation also.

I personally prefer coding in Ruby because the language is written to be read by humans primarily, not machines.

Best of luck.

Ryan Bigg
The same great community as this one? http://www.zedshaw.com/rants/rails_is_a_ghetto.html :-P
Chris Jester-Young
+1  A: 

You may want to consider if you'll ever want/need to run on the JVM and see what options are available for either framework.

Ed.T
+4  A: 

You may want to take a day or two and try out CakePHP—not as an end in itself, but as an introduction to the concepts behind Rails. Last time I checked, Cake was the closest to a port of Rails of any framework. If you like it, you're more likely to enjoy Rails (and conversely, if not, not)

Ben Scofield
+6  A: 

Besides the obvious issues(whether you like python or ruby) you may want to look into the deployment issues with both frameworks. If you choose Django, you'll be able to use Google Apps. If you choose Rails, there's no Google Apps. But there're many other good options such as Amazon EC2/S3. Deployment used to be a hairy issue with Rails, but with mod_rails, I guess its no longer an issue.

Another issue could be the local community. If there's a vibrant community of Python coders in your city, it'd be better to join them. It always feels better to have other geeks around who can help you.

liangzan
+1  A: 

A lot of PHP developers migrated to Rails successfully (have a look at Rails for PHP Developers).

Luca
+1  A: 

As mentioned, they're both quite similar. I would suggest finding more about the community for each framework to help you decide.

Is the documentation good? Are great books available? If you post to a forum, are others helpful or condescending?

From my experience, the community and availability of good resources makes all the difference.

My personal preference is Ruby on Rails, but my reason for choosing it over Python and Django was strictly personal. I've heard nothing but nice things about both Rails and Django.

+1  A: 

It's actually not about learning a particular framework - both is equally good (or bad depending on your point of view). If you have time, do both, and if you dont have time, pick one whose language you are unfamiliar with (so that you learn a new language..hit two birds with one stone as they say).

Chii
+61  A: 

From my experiences, rails seemed to be more of a black box than django. You issue some command and some stuff happened and you got a basic CRUD application. You run this particular function and something happened and you got something else as an output, not knowing what the middle bits were. While this is fine for easy things, the lack of online documentation (in my experience) was a huge hindrance.

Django, on the other hand, seems to be more logical and transparent about what's going on behind the scenes. There's no "magic". Django is also one of the best documented open source projects out there.

Just came back and saw your additions:

If you want something with an extensible admin, pick Django. This is a test in which Django shines. Its clean looking and is extensible. In my experience, the Rails scaffolding is typically thrown away as you add more functionality. Its meant to get you up and going, but not necessarily something you'll see in production. That being said, lists for grandma aren't exactly production :) Reordering field and such is fairly easy, especially given the many community contributions to the admin.

When people talk about "magic" in Rails (or any other framework for that matter), they're really talking about things happening without it being immediately obvious why or how. A key example of this is Rails' find_by_* function. Its autocompleted function that you don't explicitly define, but its just "magically" there. You can find a lot more information at http://www.stephenbartholomew.co.uk/2007/6/4/is-rails-magic Purely antecdotal, but I've found that Python (and Django) itself is much more explicit where as Ruby (and Rails) rely a lot more on convention ("That's just the way its done.")

Justin Lilly
An interesting perspective on things but unless I'm very mistaken part of "explicitness" you find in Django is probably due to the fact that Python is compiled and not a dynamic language and thus incapable of the kind of thing that Rails uses in Ruby to support find_by_* (i.e. method_missing).What you perceive as a strength in the framework, I perceive as a lack of power in the language behind it. Perhaps others with more familiarity with both languages can correct my misunderstanding if I have one though.
John Munsch
Python is almost as dynamic a language as ruby. The big difference between Django and Rails is more in the philosophy of their design. Python people like libraries to be transparent and obvious how they work, while Ruby people tend to provide clean and pretty interfaces with "magic" behind the scenes. That said, both Rails and Django can be inflexible and problematic in different ways. I have yet to find a perfect way to make web apps. Hopefully Pylons will help.
Nick Retallack
@John: completely incorrect -- Python is not compiled. See the wikipedia entry on the language for more.
alberge
@John: Python is exactly as dynamic as Ruby is. There are implementations of both languages that compile them to various bytecode engines, but they do so to implement their dynamic features, not to remove them. A dynamic language simply adds a level of indirection to every call in its bytecode than would a static language like C# or Java.
Brandon Craig Rhodes
I don't know if this is a lack of proud or something like that but about 1 year ago I start question myself "Why do I think I can do it better than entire teams of smart open source programmers?" or "Why do I think whatever they do is factible to be wrong?", So I started to accept that "magic" and be happy with that. I trust these guys made a great work and, whatever is happening behind the scenes, is happening fast and right. +1 for Rails from me.
Erik Escobedo
It's not a lack of pride. What do you think you know more than a team of open source developers? Your domain. Knowing how to tune the great piece of software they made to your domain and your actual problem is the whole reason you're getting paid. Otherwise, people would just install rails and be done.
Justin Lilly
Regarding Rails "magic". See Clarke's third law: Any sufficiently advanced technology is indistinguishable from magic.
@Brandon: Python's String class is immutable, which feels a bit less dynamic IMO. But you were just saying it's not compiled, which is right (well, at least they're both not statically typed, we can all agree on that).
rogerdpack
Regarding Django's *lack* of "magic". See Niven's law: Any sufficiently advanced magic is indistinguishable from technology.
Joe D
+11  A: 

My take on it is that Rails is more popular, more trendy, more volatile, more complicated and more versatile.

Django, on the other hand is more organized, better documented and comes with authentication and administration built in.

So if you want a fast evolving slightly crazy and egotistical community and framework go for rails. If you want slow and sane go with Django. I choose the slightly crazy.

srboisvert
+1  A: 

An alternative to Rails that is less restrictive of your design decisions is Ruby framework called Merb.

Thanatos
+2  A: 

I have read somewhere : If you know Python then use Django, If you know Ruby then Rails

Slavus
+26  A: 

Both Ruby and Rails have more 'magic' involved. This makes development very fast when you understand the magic, but frustrating when you don't. The documentation is also scattered; some of the newer features of Rails are only mentioned in blogs, or passed along by word of mouth.

Django is extremely well documented, and Python is likewise a 'no-tricks' programming language. It's not quite as 'fun' as Ruby, but it sounds like it would probably suit your need better.

Will Sargent
Very good point, but I think fun is what you make of it.
simplyme
I've tried both and I would say Django is more "fun" because it's easier to learn and has less "magic".
Ryan Thames
@Ryan I agree... personally I like to understand what is happening. Learning is more fun to me than saying to myself "wow, something happened behind the scenes and then it worked!". Also, in my experience, you ALWAYS get to a point where you've got to figure out the magic.
TM
Um, there's nothing 'magic' about the Ruby language. There is, however, due to Ruby's metaprogramming abilities a greater potential FOR 'magic'.
banister
@Ryan I think he was saying that Ruby funner than Python, not that Rails is more fun than Django FWIW.
rogerdpack
+1  A: 

They're both excellent, but very different. Personally, I prefer Python, but find Django overly difficult, especially for mere mortals. There's not really any significant alternative to Django.

On the other hand, if you like Ruby and the rapidly growing toolsets around it, but don't like Rails itself all that well, it's worth looking at Merb, too (merbivore.com). I'm having a Ruby on Merb project written for me right now by contractors, and I can tell you I'm flat amazed at the productivity they're getting in this environment - and I'm not all that easily impressed...

I'd just like to give a thumbs up to Merb. If you're looking to build smaller sites, this is definitely one to have a close look at.
Charles Roper
Merb and Rails are merging soon, and will become Rails 3.0
guns
+4  A: 

Rails has a very good plugin called paperclip which allows you to attach images to records in your database. It stores them on the filesystem and a link to that file in the database. Paperclip will automatically scale your images as you upload them as well into any number of sizes you wish.

Scaffolding in Rails is generally only good for text-based interfaces. Once you get into file uploading, you'll want to look at a good tutorial (or the paperclip documentation) about that.

The singular/plural translation is when you have a table called "forums", the model that corresponds with this is called "Forum". This is so when you do something like Forum.find(:first) you're effectively telling rails to "find me the first forum" not "find me the first forum**s**". Tables and Controllers are always plural, models are always singular. You'll learn all about this in any good Rails tutorial or book (e.g. Agile Web Development with Rails 3rd Edition)

If so, does Django (or any other framework) have a more sensible naming strategy?

What's not sensible about that?

Ryan Bigg
Thanks for the paperclip tip! About naming - it strikes me as odd. It has complicated language-parsing abilities that might (I don't know) fail on edge cases - and without any tangible benefit. I could live with it if I had to, but I guess I don't understand the rationale behind it.
Kyle Cronin
I've never encountered a situation where the naming has given me grief. I don't know the rationale behind it.
Ryan Bigg
The rational behind the naming convention is communication. What's in your users table? Well, Users. It's more natural to communicate about groups of things in plurals. However, if it bothers you, you can always turn it off.
PJ Davis
Personally I prefer singular table names, but it's something I learned to live with in Rails. Forum.find(:all, :conditions ...) is more common than your example... am I telling rails to find all the forum? Fora? Forums? Not really sure... Singular table names make for cleaner SQL. SELECT forum.name vs. SELECT forums.name
Alex Neth
+4  A: 

There was a good article posted back in January (so it might be a bit out of date now, knowing the speed these frameworks move at) in Smashing Magazine:

Frameworks Round-Up: When To Use, How To Choose?

It may help in your research.

Charles Roper
+4  A: 

For the most part, I agree with others here. However, I'm fairly familiar with rails, and pretty familiar with django. I've found that knowing python gets you a lot farther with django than knowing ruby gets you with rails. That said, they are both very powerful, and will likely be able to do anything you would want.

Ckhrysze
Thanks for your insight. Can you please elaborate on what you mean by "knowing python gets you a lot farther with django than knowing ruby gets you with rails"?
Kyle Cronin
Rails is much closer to a language in its own right than django is. Django setup and use looks like python code, and knowing python makes reading examples pretty easy. There are a lot of quirks in rails that knowing ruby won't prepare you for.
Ckhrysze
+4  A: 

I enjoy rails. However, as some have said, Rails moves quickly. They seem to adopt and then drop 'standards' very often. Google searches return outdated and broken ways of doing things as the top or near top hit.

That all said, rails is very powerful and if you can get up to speed it works wonderfully.

Chris Tosswill
+20  A: 

I would like to quote to you from one of our blog post's comment:

One of the main reasons I jumped from RoR to Django was the documentation.

The community and the admin interface are both wonderful, but the documentation is what sold me.

If you are learning, documentation is really important. You don't want to google to find blogposts which talk about this feature in an earlier release, and broken now!

Lakshman Prasad
+6  A: 

Two cents from a Django user whose never used rails:

Django is most intuitive when you are writing custom public views and accepting the admin interface more or less as is. There is a lot of customization that you can do without much trouble, whether it's customizing style, specifying which fields will be editable, or specifying what type of html form elements should be used by selecting a widget. But if you have to make particularly powerful edits to the admin site, this will probably require the most detailed understanding of python syntax and idioms. Your first few python tutorials will likely skip all the details of new-style objects, decorators, Meta classes, and other syntax introduced in releases of python 2.x.

I'll say the same holds for more complicated SQL queries. (My guess is that every ORM framework is going to require more detailed knowledge for more intricate SQL queries.)

The good news? Even though Django itself is heavily powered by the newer python features, a few introductory python tutorials will be fine to let you do most of what you need to do in Django. And, once you read the four page Django tutorial, you'll feel like you can 50% build your site.

Oh, and as for non-textual data, I haven't actually used this, but I believe it is supported by default in the ORM. This probably won't mean too much to you right now, but others can comment on it:

http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield

Anyway, as far as I know, everything supported in the ORM has a default admin interface, so it should be doable out-of-the-box.

David Berger
+4  A: 

I've written a blog entry about Rails vs Django that replies to your question.

Since you will just need to display (or insert or something) data and have an admin interface, I'd go for Django since it gives you that out of the box. On everything else, I'd say it's a tie, but the post explains it in detail.

Alcides
+4  A: 

I've tried both Rails and Django.

Personally, I prefer python syntax over ruby, but I think Rails is one step over Django.

I like how rails plugin system let you build a complete webapp in a few hours and especially I like the way rails and ruby support TDD and BDD.

From the other side, Django has a great pluggable app system and this is probably the most "to have" feature on rails.

Cheers, Stefano

stefano
+5  A: 

For everyone that says about magic in ruby or rails: http://gilesbowkett.blogspot.com/2009/07/do-you-believe-in-magic.html

+3  A: 

One word : Cucumber.

I prefer Rails because it has more test tools. You can use tons of very inspiring test tools. I can barely thing about using rails without Rspec, factory girl among other tools, and the new cucumber gem is just incredible.

Pedro
+1  A: 

My perspective - "Don't try to reinvent the wheel."

Was in your boat about 6 months back. could've gone either ways language/framework wise. Did some research & found google promoting python/dJango big time.

I love clean looking code and also love the speed of development which python gave.

As an engineer you would want to try your hands on both and then pick one, but hey, how much time does that take !!

I decided dJango/python since I guess a lot of smart(er) people have spent time at google on this. 8-)

Sticking with it till I hit a wall. Maybe Rails will break the wall at that time 8-)

Best'O'Luck 8-)

PlanetUnknown