

Ask HN: Rails or Django? - vital101

For the past 5 years I've been a PHP developer.  For the past 2 I've been using frameworks to make my life a lot easier.  The thing is, I'm a bit bored with PHP.  I'd like to expand my horizons and learn a new language + framework.<p>Currently I'm looking at Ruby + Rails and Python + Django.  I already know a bit of Python (I write back-end scripts with it), but not enough to have it influence my decision.  The criteria I'm looking at are:<p>* Adoption - Are a lot of people using this framework and does it look like it is still gaining followers?<p>* Community - Is there a strong support community around it?  Are there good resources for learning?<p>* Jobs - What are the job prospects like for this language + framework?<p>* Scalability - Does the framework scale well?  I imagine this is determine by application design too, but lets assume that it's designed well.<p>* Fun - Is it a fun language to code in?  Does the framework make writing web applications enjoyable?  CakePHP made PHP fun for me again.  Does Django or Rails do the same thing for their respective languages?<p>I'm also open to other suggestions as well, but these two languages and frameworks are the ones I see floating around HN the most.
======
larrykubin
Jobs, Adoption, and Community - plenty of adoption of both, but I've seen more
Rails opportunities than Django

Scalability - you'll be fine with either

Fun - Rails

After completing a bunch of PHP projects, I recently completed a project for a
client where I spent about 6 months with Django. It was fine and I'm glad I
did it, but I can't say I would call it "fun". There were a few points that I
found painful. The django admin is customizable and for certain types of apps,
it works well. But I wanted my clients to use it to manage data in a legacy
database. The inspectdb command was cool and generated models for me along
with some data management forms. However, getting the forms to work in ways
that matched the workflow of my clients was difficult. I found myself wanting
to do things like a "reverse" inline -- there were several things that I
couldn't figure out and StackOverflow searches didn't reveal good solutions.
On my next django project, I decided not to use the admin because it took me
longer to figure out how to customize it then it did to just use ModelForms
outside of the admin. I haven't found many of the contrib apps to be all that
useful or flexible.

And for reporting, some of the more complicated queries just didn't work well
with the ORM, and I found myself doing ugly things to avoid writing SQL (I
know Django doesn't prevent you from writing raw SQL).

I just didn't get the same "fun" feeling I did when I first developed a Rails
app, first grabbed a Vimeo API or flickr gem off of Github, and first pushed
it up to Heroku and saw it magically work. And I didn't feel like I was any
more productive than I was with PHP -- the main benefits were that 1) my code
was more readable and 2) it led me to another opportunity in a completely
different area that involves writing python -- but rather than Django, I get
to work with Twisted, and this has expanded my horizons greatly.

~~~
Herald_MJ
Django admin isn't designed to handle any kind of workflow - it's just for
adding data. That's all, plain and simple.

If you're expecting to need any kind of workflow, it's actually prefererable
to start your page from scratch, and use some of the other django page
creation tools than use the admin module.

------
ibejoeb
I do both; they're both worthy of your time to investigate. I've had more
success with Django. They both offer roughly the same thing, but when it comes
to taking something live and handling significant traffic, I find it's easier
to go out of the box with Django. That is, when the plain vanilla is no longer
sufficient, Rails, as a matter of course, fights you. I appreciate the "we
know better" paradigm that it operates under because it can teach and enforce
some pretty good practices. Although I speak only for myself, I've had many
conversations with some very experienced folks, and I've felt like we were on
the same page.

Also: if you're already comfortable with Cake, the jump to Rails is probably
quite short. I'll bet you become very productive on it very quickly.

The Python job market in New York is hot, and Django is very popular. I don't
see too much other than Rails opportunities for those that bring Ruby
knowledge, but there is certainly enough Rails work to keep you busy. The
upside is that there are lots of CMS and infrastructure stuff that is Ruby
based, but they tend to be products in their own right rather than tools to
hack on. In my opinion, Rails carries Ruby in the market. Without Rails, Ruby
would probably fade back into relative obscurity.

------
rufugee
I just returned to Rails after a brief stint with Django. I was working on a
stackoverflow-ish site and wanted to make use of an existing OS project if
possible. Django has OSQA, and Rails has Shapado. Shapado would've naturally
been the better choice for me, but they use MongoDB and at the time I started
the project, I questioned the wisdom of that decision. Learning Django (since
I already know python) and using OSQA seemed like the better option, as it
would allow me to use my beloved PostgreSQL.

Bias warning...I've used Rails for far too long now, so it's very familiar to
me and I'm comfortable with it. That said, here's the heavily opinionated and
subjective reasons why I'm back:

* urls.py - the python regular expression syntax makes your route definitions very ugly as they grow. I find Rails' route DSL much more intuitive.

* Lack of model-level validation - OSQA uses Form objects to validate models rather than letting the models validate themselves (as Rails does). In OSQA, the Form objects are rather heavily bound to the UI interaction, so if you need to create models outside of the web app itself (I did) it gets painful. I kept having to hack these form objects to get them to validate properly. I've been told that Django now provides model-level validation, but OSQA doesn't use them (for now).

* ORM - I find ActiveRecord to be a much cleaner and intuitive ORM.

* Django's template language - I don't work with designers, so I don't need to be hobbled by a template language that is limited by design. I know you can use other template engines, but I was working with what OSQA provided, so I was stuck.

* Community - the Rails community in general is more active.

* Language preference - at the end of the day, Ruby just feels more natural and clean to me. You could attribute this to familiarity, but I actually knew python long before I knew ruby. I do like python, but tend to "think" in ruby.

I re-assessed my progress after a month and realized I was just not reaching
the same level of productivity I was used to. I decided to switch course and
learn MongoDB, which was probably the decision I should've made to begin with,
and my productivity instantly improved. I was able to move the features I'd
created in Django over within a few nights of focused effort, and I couldn't
be happier with Shapado (and, surprisingly, mongodb).

This is simply my experience. If it were a completely new project, my
experience might've been different. YMMV.

~~~
mzl
With regards to urls.py, I would greatly recommend using surlex. It makes it
much nicer and much more readable.

------
risotto
I've done a lot of Django, Rails and PHP. The choice always depends on what
your app looks like.

If your app has a lot of non-user facing CRUD (i.e. a CMS or publishing app),
Django offers some incredible shortcuts with the built-in admin app.

I also think Python is a better systems programming language (i.e. calling out
to unix during web stuff), due to it's scientific background.

Otherwise RoR and Django are roughly the same MVC frameworks -- opinionated
conventions about models with a database abstraction layer, and views and
controllers (templates and views in Django terms).

Likewise, Ruby and Python are roughly the same -- object oriented scripting
languages.

But for your specific questions, I'd say Rails wins by a long shot. There are
a lot more Rails companies/jobs in the Bay area (though more Python than Ruby
jobs, again because of science). Rails 3 shows the community is still going
strong.

Sinatra is the most fun for simple web services and it integrates with Rails
no problem.

And most importantly, you can use Heroku for Ruby deployment, which is an
incredible short cut for launching a site and its impossible to go back to
being a sys-admin once you realize it's not necessary.

~~~
clyfe
You should check active scaffold plugin for rails. (fork
<http://github.com/vhochstein/active_scaffold> for rails 3)

------
runjake
This isn't a complaint, because although some may be tired of this question
being asked, I personally enjoy the subject being brought up a lot, because of
the new perspectives and quick pace of development for each project, but
you'll find a lot of additional insight by back searching for "Rails vs
Django", too.

There is no right answer, and you can't go wrong with either. Try both, run
through _many_ tutorials for each, and decide.

Remember that _everything_ sucks. Find the one that sucks less for you.

I'm still more productive and knowledgeable in Python/Django, but find
Ruby/Rails/Sinatra more fun, and I enjoy the new ways of thinking it causes in
this old Perl programmer.

Downsides?

I'm still trying to grasp many of the concepts in Ruby, and the rapid pace of
development and prevalence of trends is daunting. Many things in the Ruby
world are hackish and/or poorly documented. I question DHH's wisdom.

For Python, the indenting thing still bugs the bejeebus out of me. I'm not a
trendy kind of guy, but it is a bit too untrendy to me.

They're both great, overall, though. Find the one that matches you, because
nobody else can decide that for you.

------
mikeryan
I like both languages and frameworks and honestly I don't think either has a
huge edge of the other on any of the criteria you're looking at.

In general however I prefer Python as a language and Rails as a framework.

I think Rails is hands down the best architected and easy to use framework out
there. I think Python is one of the most well curated and thought out
languages. I should say this, I doubt I would have every learned Ruby if not
for Rails (though its my "go to" language now for simple scripts, having
replaced Perl), I'm pretty sure I'd have learnt Python at some point
regardless of Django.

------
LeBlanc
If you go searching around for comparisons between the two, keep in mind that
Rails just released v3 which is significantly different and improved over
versions 2. _

------
flacon
As a professional Rails developer, I will try to answer all your points from a
pro rails point of view. Granted, I have dabbled with Django and found it
satisfying also.

* Adoption - Rails is being heavily adopted, especially with the startup community, but also state agencies, hospitals etc.

* Community - Rails has a strong community of core devs, plugins devs, conferences, books etc.

* Jobs - Tons of Jobs in my experience. We have a hard time finding good Rails/Ruby devs. I have checked the market, seems like there are plenty of Rails jobs across the country. Check out: <http://jobs.37signals.com/>

* Scalability - Yes, Rails can scale. Check out: <http://rails100.pbworks.com/Alexa+Rankings> Ever heard of Hulu, JustinTV or Big Cartell?

* Fun - Ruby was designed for programmer happiness

------
hoop
There are plenty of reasons why you should use Django or Rails over the other,
but I rather discuss why maybe you _shouldn't_ use Django. I haven't used
Rails, so I will not be discussing that side of the coin.

Django is a wonderful framework as long as you work inside the box. There's a
large enough of a community for support, plenty of documentation, and alot of
the pieces for a website are already written for you and work just fine.

Where Django seems to break down is:

1\. When you upgrade Django, or 2\. When you start customizing Django

With just about every release of Django, something breaks. Thankfully, these
changes are usually outlined in the release notes, but this often results
(from what I've seen) in projects running on fairly old versions of Django
because nobody wants to break a working website or app by upgrading their
framework. Where I come from (sysadmin turned web dev,) you don't want to run
outdated software and you don't want things to break. With Django, you're
constantly stuck between a rock and a hard place.

Theoretically, you can write all the middleware, decorators, backend
authentication modules, etc you want and plug it into Django and have it work
flawlessly; however, this isn't always the case in practice. This blog post
from one person explains their gripes with extending ,and eventually
replacing, Django: <http://blog.brandonbloom.name/2009/08/dropping-
django.html>

It's important to keep in mind that Django was ultimately developed for news
websites. This makes it a great framework for building CMSes, blogs, etc but
causes it to break down when you start moving outside of that use case.

(Also, FWIW, Django doesn't natively support schema migrations, although their
are tools such as "South" that implement this functionality.)

I think that if you're interested in using a Python-based like framework, you
should also consider Pylons and Tornado.

~~~
stevenwei
Pylons or Tornado probably implies SQLAlchemy...and I have to say south is a
much better tool than sqlalchemy-migrate. (Not that the migration tool itself
should heavily influence anyone's decision to use a web framework. I actually
prefer SQLAlchemy itself to Django's ORM)

------
poink
Adoption: Rails is bigger. Both are healthy, and neither is going anywhere.

Community: These are roughly equivalent. The Rails community is probably
significantly larger, but there's more than enough activity and information
coming from both to keep you plenty satisfied.

Jobs: It's easier to find a Rails job.

Scalability: You can scale both. Both frameworks are pretty heavyweight, but
they're also both designed with scaling in mind (e.g. decent caching is built
in).

Fun: If you like CakePHP, then assuming you don't just irrationally hate
Python or Ruby you should feel right at home with either one.

Full disclosure: I do Rails for a living.

------
ubernostrum
Meh.

Do a tutorial in each language, it'll take you a day at most. Then pick a
framework that matches the language you liked better.

------
jordanmessina
As everyone else said, both is best. If you're looking for which one to get
started with first, I've always felt that Django has a less steep learning
curve.

Check out what's generated for you when initially starting a rails app:
<http://twitpic.com/30sz41> vs. a Django app: <http://twitpic.com/30szgk>

I think Django is a little less overwhelming for beginners.

------
kenneth_reitz
I think this is more of a decision between languages rather than Frameworks.

I'm a passionate Pythonist with a deep respect for Ruby. I personally find
Python to be extremely elegant in both syntax and paradigm, but Ruby is the
next thing I'd use if Python were to disappear today.

In my experience, Python generally has more backend libraries and tools, while
Ruby has more frontend. Of course, there are hundreds of exceptions to this,
but the premise of what I'm saying is this: Python developers tend to come
from other unixy backgrounds, and Ruby devs often are web-centric.

As far as the frameworks themselves are concerned, Rails has a bit more magic
"convention over configuration", while in Python "explicit is better than
implicit", so Django is a little more engineer-friendly.

I highly recommend you read the Zen of Python to see if the language is a good
fit for you: <http://www.python.org/dev/peps/pep-0020/>

Something to keep in mind.

~~~
kenneth_reitz
On another note, I have reason to believe that Ruby + Rails will be the next
go-to "language of the web", as PHP (is) was two years ago.

On yet another note, Pythonists are in HIGH demand. Good Python devs (who
aren't actually Java devs who've dabbled with Python once or twice) are hard
to come by. Excellent job opportunities because of it.

------
iuguy
You already have some python experience, I'd say give Django a try. It's not
hard to get a simple app up and running, and if you already understand the
underlying language basics you'll find it even easier.

------
carterac
The one factor I haven't seen mentioned so far is that Python has more math
and science libraries. So if those kind of problems interest you, that is
worth considering.

On a semi-related note, at Art.sy we use Zend, a PHP framework, for our web
app (all our AI is in a separate Java service). We've found Zend to be great
and I've noticed that large companies like AppNexus, NextJump, and (initially)
Facebook use Zend too. Yet I've never seen it mentioned on HN. Curious if
anyone can explain this.

------
jbarham
The problem domain you're working in is also important. For example, if you're
doing heavy duty number crunching for finance or image processing, Python has
NumPy, for which AFAIK there is no equivalent for Ruby.

Then again at very large scale you don't want to restrict yourself to one
language in which case you can lash together various components using a
distributed job scheduler like Gearman (<http://gearman.org/>).

------
roder
You should just learn both (and more). You shouldn't isolate yourself to 1
language, you should learn as many as you can, because the diversity and
understanding will make you a better programmer. It's not like that Python or
Ruby are that different from each other anyhow.

~~~
vital101
I completely agree, but learning them in parallel won't yield good results for
me. I'm interested in both, I'm just looking for which one I should learn
first.

~~~
strait
Yes, don't feel pressured by all these comments saying "Why not learn both?
They're not that different anyway." You're probably better off semi-mastering
one before you focus on the other. There's a lot more to a language with its
idiosyncrasies in general use than what simple examples reveal, and it's going
to take significant experience to really be proficient.

I'd say pick the language that you can develop the most passion to learn.
Spend some time doing a little research. Are you a specialist in another
technology? How well does either Python or Ruby integrate in whatever way with
what you already know. If you're really at a loss, go with Python and Django.

------
danieldon
Honestly, I think these "Ask HN: X vs X?" posts should be strongly discouraged
here. The Rails vs Django threads get posted at least once a month, often more
frequently, and it's beyond tiresome. They already get flagged and killed half
the time, but people still post in them as if it's totally normal to have the
same question posted week after week.

Edit: Instead of downvoting, explain why you think this same discussion needs
to be rehashed month after month, sometimes week after week. When it comes to
other topics we have no problem reminding people to search HN rather than ask
the same questions repeatedly.

~~~
stevenwei
Have to say I disagree here....both frameworks are evolving over time and it's
good to get a _current_ comparison, as answers from 6-12 months ago may not be
relevant anymore.

------
keokilee
As someone who has a passing knowledge of both, I also find that I like Python
more than Ruby but I like Rails more than Django. The main reason is that the
Rails community is larger and more active than the Django community.

That said, it depends on your needs. Rails has a slightly steeper learning
curve than Django (mostly because there are a ton of helpers and options in
the API). If you want something that will get you started quickly, I'd go with
Django. Later on, you'll have to do a lot of Django hacking to get some things
that come for free in Rails.

------
taphangum
I would stick with PHP and try codeigniter. Going down the 'Rails' or 'Django'
path. Ultimately just gives you a new toy. I wouldn't say it was worth it. But
that depends on what your goals are.

Ruby is a nice language though. I do all my non-web stuff in that.

I highly recommend Peter Cooper's Book: Beginning Ruby,
Link:[http://www.amazon.com/Beginning-Ruby-Novice-
Professional/dp/...](http://www.amazon.com/Beginning-Ruby-Novice-
Professional/dp/1590597664), if you'd like to get started with it.

~~~
askar
I second that...CodeIgniter is really nice with no fuss...Rails is nice too
unless you get familiar with it...in the mean time CodeIgniter is your rescue.
Simple framework that's quite flexible.

------
AdamN
I picked Django because:

* The documentation was better than Rails * Python is more useful outside of Django than Ruby is outside of Rails * The Python syntax seemed easier to read

Since then, I've become a big fan of Django and Python. With that said, plenty
of smart people are using Rails. I agree with some of the other commenters
that you should do the tutorial for each framework before deciding.

As for jobs, both Rails and Django have tons of open positions available and
hot startups using them.

~~~
clyfe
Arguable, but I think Rails haw way more docs than django:
<http://railstutorial.org/book> , <http://guides.rubyonrails.org/> ,
<http://railscasts.com/> to name a few

~~~
AdamN
"was" being the operative verb. This was two years ago.

Nonetheless, I just looked at those three links and IMHO, the Django docs are
more concise and well-organized:

<http://docs.djangoproject.com/en/1.2/>

For me at least, it's all about maintainability and parsimony, two things that
Django/Python has in spades and for which excellent central documentation is a
necessary requirement.

------
carbon8
Regarding jobs for each framework, there are far more Rails jobs than Django
jobs: <http://news.ycombinator.com/x?fnid=JBPFd8i2nk>.

For me, I periodically use Django for content-centric sites with standard CRUD
operations primarily performed by a small number of privileged users, but I
prefer Rails and Sinatra for most projects. I prefer the Ruby web development
ecosystem, with libraries like Haml, Sass and Compass.

~~~
bobf
Although that's true, I would guess there is possibly far more competition for
those jobs from a larger quantity of Rails programmers than Django
programmers.

~~~
carbon8
I'm in Chicago, but also do work for Asian firms. In my admittedly completely
anecdotal experience as a contractor over the past few years, I encounter PHP
(which I don't work with) and Rails applications, but have never been
approached for Django in my freelance work, despite telling people that I can
work with both Rails and Django. I do almost no self promotion and I still
have Rails contract jobs handed to me. I've been approached by non-technical
people to work on Rails sites they didn't know were built on Rails and without
them knowing what my exact skills were. When I meet startup people (which I do
fairly regularly despite not going to meetups), they are almost always running
their startups on Rails. YMMV, but this is what my experience has been.

------
zimro
I tried (and still working) with both languages that power the respective
frameworks, and from my own opinion they are the same. I've been in your
situation too and the best way to find what framework suits you is to go and
try them, build something.

I wont respond to your question as I've a little more inclination to
Ruby/Rails than Pyhton and I don't want to influence your decision, you should
really try them both and find by yourself.

------
mattculbreth
The correct answer of course is "both". There are many similarities between
the languages and the frameworks, and there are good job opportunities for
each.

Go do a side project with one of them and release it. Then go do another side
project with the other and release that. Then go get a job or contract with
one or the other. You'll be able to say you've used each, you'll be able to
give pros and cons to each, etc.

------
ig1
I'm just learning Rails now, and while I still prefer Python over Ruby, Rails
is more fun and I'm feeling I'm getting more done with less effort.

On the other hand I think Django is simpler to understand in-depth, with Rails
I feel like a lot of it is magic and it'll take a lot more work to understand
how it works (but it isn't stopping me being productive with it).

------
acconrad
I'm surprised this got upvoted so high, since this has been discussed ad
nauseum on HN. But I will say that I had the same question and I ultimately
chose Ruby simply because it intrigued me more. Since they are THAT similar,
if you just go with your instincts, you can't go wrong.

------
codyguy
Gaining followers might not be the right metric to follow. A stable framework
might not gain followers at the same rate as a hyped up shiny-new-thing.

Since you say you are "bored", why not try both out for a day or two and see
what's more "fun" to you?

------
shabda
Yes.

------
robwgibbons
After considering all of the angles, we chose Django over Rails. At the end of
the day, the biggest difference between the two is the languages they're each
based on. And at the end of the day, we prefer Python over Ruby. This is for a
number of reasons, including massive community and commercial support,
libraries, etc.

This is not to say RoR is not awesome, it's mostly a preference of language.

------
honza
I'm not familiar with Rails, but in Django you are 100% tied to SQL databases.
There are some efforts to make talk to NoSQL databases (like App Engine).
Google actually gave up those efforts.

In Rails, I believe the database backend can be either. Look at Twitter -
their using Cassandra.

~~~
bad_user

         Google actually gave up those efforts.
    

Was there ever a Django-related effort from Google to update the ORM?

Also, the Django ORM is pretty flexibile, and the architecture just got
improvements for NoSQL in 1.2.

~~~
bron
I think he was trying to refer to was Google's Big table integration which app
engine uses instead of NoSQL.

~~~
bad_user
Dude, what are you guys talking about? What Big table integration? What NoSQL?

There was a Django patch somewhere that used a thin layer to make the API
"look" like the Django ORM, but IMHO it is broken in a lot of ways and you're
better off using the raw App Engine API (which is in no way related to
Django).

But it is a half-ass attempt, looking like some patch somebody did in an
afternoon to get something working: and that was the "Google effort"?

------
thdn
go Django you wont regret

