Ask HN: Rails or Django?
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:
* Adoption - Are a lot of people using this framework and does it look like it is still gaining followers?
* Community - Is there a strong support community around it? Are there good resources for learning?
* Jobs - What are the job prospects like for this language + framework?
* Scalability - Does the framework scale well? I imagine this is determine by application design too, but lets assume that it's designed well.
* 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?
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.
59 comments
[ 5.4 ms ] story [ 133 ms ] threadI'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.
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.
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.
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.
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.
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.
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.
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.
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/..., if you'd like to get started with it.
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.
In Rails, I believe the database backend can be either. Look at Twitter - their using Cassandra.
Also, the Django ORM is pretty flexibile, and the architecture just got improvements for NoSQL in 1.2.
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"?
Cursebird (http://cursebird.com/) is powered by Mongo via MongoEngine (http://mongoengine.org/) and Redis via redis-py (http://github.com/andymccurdy/redis-py). None of the Django apps have a models module.
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.
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.
I'd even say consider Flask for larger projects if you have patience, a good head for package/module layouts, and are after a really "no fluff" framework.
Tie it up to Nginx using Gunicorn: http://gunicorn.org/
(Here's the instructions in the Flask docs: http://flask.pocoo.org/docs/deploying/others/#gunicorn)
You will get some killer, low memory performance (many times smaller memory footprint than Django) out of that setup.
@OP: Personally I think Python has a lot of syntax fluff, whereas Ruby couldn't get simpler in that regard; even forgetting about the LOC and focusing on the respective DSLs:
Python:
Ruby: Don't get me wrong, I sometimes use Python, it's a great language, especially for non-web things, but I always jump at the chance to use Ruby. It's not the fastest language (though compared to Python nowadays, it doesn't lag behind that bad), but it's the nicest by far I've ever had the chance to work with.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.
* 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.
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.
In what way? I was a heavy Python user for a number of years and then moved to Rails/Ruby. I use Ruby for a lot of non-web projects, and I've never found it to be lacking.
* 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
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.
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.
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.
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.
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/).