Ask YC: Django vs Ruby on Rails
I have recently finished the design work for a project I am going to be working on this summer and I was having a hard time deciding which framework to implement the project in. A lot of the articles written out there seem to either be dated (so some of the qualms may have been changed in newer versions) or biased. I have no experience in Python or Ruby, so I am completely open to either, I just want to make sure the investment in the time spent learning is worth it not just for this project but also for future ones (and for potential jobs). I also am curious as to which hosting service you all use and how easy it is to implement that framework with it. I had bought my domain name with GoDaddy.com along time ago, but I am open to switching to something reliable (and cheap I am still a student). Thanks for any input!
EDIT (To elaborate a little on my project, without giving details):
The project is relatively simple and provides a service to an area for a small fee. For now, the area would be specific to one geographic location. As the site grows and progresses, the site will need to scale by adding more locations (organized similar to how craiglist is specific to each location).
114 comments
[ 263 ms ] story [ 3762 ms ] threadReally answering this question comes down to what your application needs are and what you and others working on this application is most comfortable in. I prefer RoR, I can develop quickly in it - I've got experience with that technology but it doesn't mean it will be the best solution for you.
I'd take a look at slicehost for hosting, I think for something like this having full control of a (virtual) server is a benefit and a great learning experience.
I will be using a hosting service so the ease of use in implementation is also a big issue, not just the framework itself.
Personally, I chose django, but only because I was a python programmer before ror and django took off. If I were to do it again, I might look seriously at Pylons, as I consistently read good things about it.
I deployed a smallish rails app on Dreamhost in about 5 minutes last night. My previous attempt to deploy on a stock SuSE/apache2 server took a few days of fairly dedicated prodding.
I learned more from launching a demo application in both (I used a blog and a poll as an example) than I could have by asking other people. I found what suited my tastes.
It depends on what your experience you have. If you know Python, use Django. If you know Ruby, use Rails. I know Python, so I use Django. Since you have no experience with either, this one is moot.
It depends on what you're building. A lot of people on the net seem to take the position of "Django is good for content publishing sites, and Rails is good for web apps", but that has more to do with the applications the two frameworks were derived from than the frameworks capabilities. Realistically, anything you can build in Rails you can build in Django, and vice-versa.
Personally, I love Django. It lets me develop quickly and I know how to deploy it properly. I tried setting up Rails no more then three days ago (on Ubuntu), and it wasn't as much fun. I had issues installing the correct version of Ruby, and then Gems didn't want to work.
As for you, I'd recommend spending a few days with each framework. Get them both installed and just tinker around. Build a quick CRUD app. After that, you'll have a pretty good idea of which one suits you (and your needs) better
Or maybe I'll setup a new debian slice to toy around with.
I tried Rails first as Ruby is a lot closer to lisp than Python. Personally I find Python a bit restrictive, but fairly easy to read.
If you don't have a lot of experience with Rails/Ruby, Django is the clear choice. It's very well documented and it just works.
I was able to get Django in the first 10 minutes of using it and after that over the next day most of the concepts became clearer.
I found with Rails, the lack of familiarity with some of the advanced Ruby features made it very difficult for me to read the code. So I was coding blind a bit.
Someone's done this already:
http://www.vaporbase.com/postings/Evaluating_Web_Development...(part_1/15)
Thanks that is a great resource and will definitely read it to help with my decision, but after skimming he only speaks of installing on his iMac, and one of my main concerns is usage with a hosting service.
The main reason I asked this question is because I have more trust in hearing as many diverse opinions from this community as possible rather than a reliance on what a few individuals wrote on the topic. This community helped me so much on my last question and I hoped I could get a definitive result again.
I like Python because it forces people to write code that is relatively easy to follow. Hell is other people's code. Python will help get rid of some bad habits you may have picked up from PHP (though Ruby might do this as well). As far as jobs go, I've seen far more Ruby web development jobs than Python ones, especially among startups, so it's definitely a language I'll be learning soon, but I think I'll still prefer Python.
Another plus for Python is that Django's documentation is excellent and free. From what I've heard, you have to pay for all the good Ruby books, and printed documentation ages poorly. Django's documentation is religiously updated to reflect new changes.
I host my sites on a Linode VPS. They did obliterate my VPS when my credit card expired which would normally make me never use them again, but I didn't actually lose any data and they're cheap. You get what you pay for. For DNS, which you'll need if you host off of GoDaddy, I use ZoneEdit, which is free for your first five domains. I've used up my five free ones, and when I removed one domain so I could add a new one, they told me that technically, only the first five domains are free, but they let it slide anyway. I'll definitely be sticking with them.
If your first impression with Python was good then why force yourself to something else? In my opinion Ruby on Rails is better, completely object-oriented, fast, and there are lots of documentation out there as well.
I should say that I have more concern over the framework itself rather than the language. It would probably be expected that Python would give off a good first impression because of its syntax.
Steve Yegge has made a good write-up on languages: http://steve.yegge.googlepages.com/tour-de-babel. Steve is a top notch programmer with brains and eloquence. He was one of the first hackers at Amazon. Now he works at Google, and Google has chosen Python and JavaScript as company languages. Which has pissed off Steve quite a bit, because he has firmly decided that Ruby is more powerful and rewarding than Python. But he's not allowed to program in Ruby at work.
So, Steve has engineered a kind of 'JavaScript on Rails' in order to fit into Google. All to avoid programming in Python. JavaScript is more powerful and elegant than Python, as he sees it.
This gives you two clues. One about Ruby and second about the Rails. To be brutally honest, Lisp is the most powerful and beautiful language to approach a programming problem. But List is not the most practical choice because of lack of libraries and dialect balkanisation. Ruby is considered to be an 'acceptable Lisp'. Almost as powerful and much more practical. And very very elegant. You may hear a lot about Ruby being slow. That is true, but that is also changing fast. Make your own research. You'll hear some interesting thoughts about what 'programmers' time' is worth vs. 'processor time' etc.
Finally, the frameworks. Rails has been mercilessly hyped, but the fact remains -- it is a framework for programmers. It has digested lots of 'theorizing' from Java and Smalltalk space. It tried to answer the question: "What an ideal MVC framework would be?" The answer turned out to be surprisingly good.
Django is a clever framework, but it has arisen from a particular website (Lawrence Journal-World) and it still has roots in website page design. Nothing wrong with that, but programmers talk less about Django (just check IBM tech articles), there is less programming 'meat' in there. There are also much lesser number of plugins and hacks for Django. You do not have the same amount of books and general enthusiasm about Django platform, comparing to Rails. Not by any objective measure.
Now let Python fanboys kill me, but I went through the same analysis a couple of years ago and I came firmly in favour of Ruby and later in favour of Rails. And I have not been disappointed a bit ever since.
If only it were true.
Steve wrote Rhino on Rails while working on a project that requires the JVM. At Google this infers a choice of Java, Python (Jython) or Javascript (Rhino).
Steve chose Rhino over Jython for reasons you can read about here: http://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html
http://youtube.com/watch?v=1QD9XQm_Jd4
But I somehow feel I'm not far from the truth, knowing his history of gentle Python bashing. After all, he chose not to make 'Django on Rhino'.
I'd say you're far from the truth.
>Well, they're just like the Smalltalk folks, who waited forever to replace C++, and then Java came along and screwed them royally, and permanently. Oops. Ruby's doing exactly that to Python, right now, today. Practically overnight.
He just points out at some major architectural flaws in Python (like the scoping issues leading to selfSelfself and unreadable code, and then the whitespace...) and argues that Ruby has superseded both Perl and Python in many ways. That does not mean he does not LIKE Python. His is just an engineer's analysis, not an emotional judgement.
offtopic:
I -- on the other hand -- am emotionally scarred by Python having tried to take it into my system over a couple of years and having failed to love it. Then Ruby came along... ;)
http://steve.yegge.googlepages.com/tour-de-babel
And I have felt the same way, seeing "self" everywhere.
The result? Ruby has the syntactical consistency and beauty of Perl, and the blazing speed and low overhead of Lisp. There are roughly six dozen different ways of doing everything (including really simple things, like delimiting blocks), and bizarre inconsistencies in basic use cases (e.g. most String functions return copies, whereas nearly everything else works by reference), and plenty of long-term code maintainability nightmares lurking in the corners.
It can be fun to code in Ruby, and it's certainly a language you should check out someday, but I'm still not sure it's the language you want to choose for a project involving a team of programmers or long-term project maintenance. My advice, if you know neither Ruby nor Python, is to learn Python, unless you've got some particular reason (i.e. a job) to learn Ruby first. Rails is an okay framework, but Django is okay too, and Python is the more elegant language.
(Now...if you'll excuse me, I'm going to go put on my asbestos underwear....)
How did you conclude this?
I'm not sure your argument about Python/Django being better for long-term use really holds muster. There are a lot of very passionate Rails hackers, and I can see Rails taking over the web application development sphere over the next few years. This isn't because it's necessarily better, mind you, but because Rails has a hell of a lot of mindshare.
So, you should be as worried about finding competent Rails hackers as you should be about finding competent Python/Django hackers. Or should you?
Rails is the web development framework for Ruby. There are probably others, but nobody has ever heard of them, so they don't matter. Python has Django, and Pylons, and TurboGears, and so on. Your hypothetical future Python web developer, then, has a lower chance of being an expert in The Best Web Framework than does the Ruby hacker, because with Ruby, you only have one choice.
It's not finding the coders that's hard (any smart coder can pick up Ruby quickly); it's the quality of the code that any new person will inherit. My experience is that the syntactical looseness of Ruby leads to write-only code. Lots of people complain about the readability of Perl, but Ruby is really only nominally better. In Python, readable code is the rule, not the exception.
True, but can they pick up ruby quickly, and rails (rails is non trivial these days), and rspec, and rake, etc. I'm guessing it would take at least 6 months to become merely comfortable with all of these. This is far different than having a proficient coder walk in the door.
You'll have much better luck getting a proficient rails coder than a proficient django coder. On the flip side I'm starting to get a lot of rails candidates that aren't really interested in rails, but used it at their previous job. For while if someone had rails on their resume it meant they took the time to learn it on their own (which is a good sign). Those days are gone.
If Blub is an order of magnitude more difficult to maintain/read/understand than Foo, then even if it's far more difficult to find a Foo coder today, it makes more sense for me to use Foo for my new project.
Try to explore (save alone, maintain) a complex Python application like Plone with its multiple inheritance. And then read the code of a modern MVC Rails application. You'll see what I mean.
And your statement that Ruby is only marginally more readable than Perl is very surprising. Ruby is a vast improvement in terms of clarity over Perl and is on par with Python there.
In my opinion ruby's syntax is simpler from a users point of view and equally as powerful. This may be my bias, but a fair assessment is that they are fairly equal
2 Weeks for Ruby & Rails. 1 to 2 weeks for Rspec & rake... especially if you're learning using Peepcode videos and a real project. Those numbers are from personal experience. Your learning curve may vary.
So, 'readability' in this case isn't a very valid argument, because anyone who codes in language X is going to find X to be highly readable.
Well, yeah. That's why I said it was my experience.
I think the point is, I code in Ruby and in Perl, and my opinion is that neither language is particularly readable or maintainable. Meanwhile, I have less experience with Python than either Perl or Ruby, yet I find it to be a consistently readable language.
Those are all opinions, but they're informed opinions (and I'm not simply advocating for the language with which I am most familiar).
Simply untrue. You, and your opinion, are grossly misinformed.
Rails burst onto the scene, brought everyone on board with a 1.0, published books, and already decided enough design elements needed to change to warrant a 2.0 release. Django, despite having the BDFL's semi-official endorsement, has crept along, nitpicking at its own API, cranking out beautiful versioned documentation and tutorials, and writing and editing the official Django Book in a wiki. And only now are they feeling confident enough to consider the 1.0 label and even publish their precious gem of a book.
Same timeframe, completely different personalities. This played out somewhat similarly with Python and Perl a decade ago, which leads me to believe that Django's time in the spotlight is still ahead of it.
I disagree vehemently. I myself have started using Ramaze, and like it better than Rails. In any case, it's more important to me to know Ruby well than a particular framework.
Actually, there are some Lisp implementations that leave Ruby in the dust. (Not saying much, I'll grant you that.) There are some Lisp implementations that let you compile code to machine language.
sigh yet another clueless spreader of programming urban legend and old prejudice!
In all honesty, I think both are perfectly fine web languages, and it doesn't really matter which you choose. Pick one and get good at it. Either will be light-years better than, say, Java or PHP.
Sorry to add an option.
I personally prefer Python's syntax and style, Python has many more libraries and it's been around longer than Ruby, and I've noticed that among "top" tier coders they tend to prefer it over Ruby. (Not all, but most.) But Ruby has many strengths, and can do a few tricks that Python can't, to it's credit. Python apps tend to execute faster than Ruby apps. It appears to be easier to scale up Django/Python apps than Ruby/Rails apps, though a lot of the same techniques can be used for both since they're language/framework agnostic (using a clustered architecture with a scalable number of server nodes, caching aggressively, choosing good algorithms, etc.)
I was at the same decision point over a year ago, did both tutorials, and decided I needed to focus more on the languages to help break what might otherwise have been a tie. With either framework you'll be a lot better off than the typical "web COBOL" stack: Java + Servlet/JSP + XML.
That said, I've been doing all of my work in RoR and I'm very satisfied. The end-to-end toolset for Rails is pretty hard to beat.
Ruby and Rails does seem to be better targeted for web development, both because (as some here have said) Rails is more meaty than Django and because there seem to be many more web development jobs out there requiring RoR.
Python on the other hand seems like a much better general purpose programming language, with a far richer set of libraries (ScyPy and NumPy on which Sage Math is based, bindings for wxWidgets and other toolkits etc)
I have a huge problem with the lack of focus on testing in the Django community though, so I'm somewhat biased.
Again, as many here have mentioned, we need to know more about your problem in order to offer an appropriate solution.
It is very reliable, a great simple admin for adding dns entries, setting up backups for your VPS, etc.
Just another good quality option. Similar price I believe.
I must say that I am pretty new to web development, so it is somewhat hard for me to determine both the feasibility and what will be needed to perform certain tasks, but people have asked if I could elaborate on what issues I will need to tackle, but please excuse me if these are unrealistic demands.
These are some of the things that I need to accomplish:
-Manage a numerous amount of small credit card transactions
-Create an algorithm that would self manage the database for certain areas based on date (delete data past a certain date or data that has expired)
-Allow the uploading of images, but also create thumbnails for those images
With regards to size, the application would focus on the area specific to where I live (so that I could market it easily with normal advertising methods), but scale simply by adding a new location (simply by cloning the first site and changing the location) similar to craigslist like I said previously.
Sorry if anything I had said does not make much sense or is unrealistic. I am new to web development and am trying to approach this in a very logical manner without wasting too much time.
background tasks are easy, you can use activerecord outside of rails in your data warehouse scripts.
image upload with thumbnails is trivial with attachment_fu plugin for rails.
http://www.python.org/community/jobs/
Rather than spending time on both though as some have stated, I think you're much better off just flipping a coin and digging in head first, fully commited, and concentrating on the more important thing... your app design.
One of the great things about full-stack frameworks like Rails and Django is that you don't have to agonize over all of the components, so why agonize over the framework itself?
Just do it. Switch for your next webapp if you feel like it.
its also worth mentioning that django has a development (wsgi) server thats simple to run and great for working locally, deploying globally:
http://www.djangoproject.com/documentation/django-admin/#run...
Django seems easiest for me to learn in terms of general theory (the Model, View, Template makes more sense than Model, View, Controller in my head for some reason).
Both have a good number of resources, both are being updated very quickly. A lot of the issues I had with Ruby on Rails a year ago (hard to deploy) are disappearing now that it has matured a bit.
Catalyst is a framework that does what you want instead of telling you what you want. This means a steep learning curve, but more productivity in the end.
Regardless, it's a shame to ignore Perl.
Like I said, Perl is far from a perfect programming language, but the community and CPAN make it all worthwhile.
One reason to choose Rails is that there are many excellent libraries. Want to have tags on your models? Just install acts_as_taggable_on_steroids... Though there's something to be said about the rails plugin & gem landscape being in very rapid development. (acts_as_taggable doesn't do proper caching so you have to dig around to find the better version etc.etc.) On the whole I think that there are really kick ass plugins for rails available.
If you already know Python - maybe Django would be better.
Also, Django has geo-django, if you think you might be geo-coding things - this is great, and built right in.
I expect that ruby has something similar??
Instead of asking here, I suggest that you pick a subset of your project that can be put together as one program and try to write it in both Ruby on Rails and Django. When you've seen what's required for either, you'll then be able to go back and build the rest of the system in your framework of choice.