TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Rails or Django?

48 点作者 vital101超过 14 年前
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.

31 条评论

ibejoeb超过 14 年前
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.<p>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.<p>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.
larrykubin超过 14 年前
Jobs, Adoption, and Community - plenty of adoption of both, but I've seen more Rails opportunities than Django<p>Scalability - you'll be fine with either<p>Fun - Rails<p>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.<p>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).<p>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.
评论 #1833654 未加载
risotto超过 14 年前
I've done a lot of Django, Rails and PHP. The choice always depends on what your app looks like.<p>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.<p>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.<p>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).<p>Likewise, Ruby and Python are roughly the same -- object oriented scripting languages.<p>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.<p>Sinatra is the most fun for simple web services and it integrates with Rails no problem.<p>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.
评论 #1830925 未加载
评论 #1833045 未加载
runjake超过 14 年前
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.<p>There is no right answer, and you can't go wrong with either. Try both, run through _many_ tutorials for each, and decide.<p>Remember that <i>everything</i> sucks. Find the one that sucks less for you.<p>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.<p>Downsides?<p>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.<p>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.<p>They're both great, overall, though. Find the one that matches you, because nobody else can decide that for you.
mikeryan超过 14 年前
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.<p>In general however I prefer Python as a language and Rails as a framework.<p>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超过 14 年前
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.<i>
flacon超过 14 年前
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.<p>* Adoption - Rails is being heavily adopted, especially with the startup community, but also state agencies, hospitals etc.<p>* Community - Rails has a strong community of core devs, plugins devs, conferences, books etc.<p>* 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: <a href="http://jobs.37signals.com/" rel="nofollow">http://jobs.37signals.com/</a><p>* Scalability - Yes, Rails can scale. Check out: <a href="http://rails100.pbworks.com/Alexa+Rankings" rel="nofollow">http://rails100.pbworks.com/Alexa+Rankings</a> Ever heard of Hulu, JustinTV or Big Cartell?<p>* Fun - Ruby was designed for programmer happiness
rufugee超过 14 年前
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.<p>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:<p>* urls.py - the python regular expression syntax makes your route definitions very ugly as they grow. I find Rails' route DSL much more intuitive.<p>* 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).<p>* ORM - I find ActiveRecord to be a much cleaner and intuitive ORM.<p>* 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.<p>* Community - the Rails community in general is more active.<p>* 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.<p>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).<p>This is simply my experience. If it were a completely new project, my experience might've been different. YMMV.
评论 #1832997 未加载
poink超过 14 年前
Adoption: Rails is bigger. Both are healthy, and neither is going anywhere.<p>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.<p>Jobs: It's easier to find a Rails job.<p>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).<p>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.<p>Full disclosure: I do Rails for a living.
ubernostrum超过 14 年前
Meh.<p>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超过 14 年前
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.<p>Check out what's generated for you when initially starting a rails app: <a href="http://twitpic.com/30sz41" rel="nofollow">http://twitpic.com/30sz41</a> vs. a Django app: <a href="http://twitpic.com/30szgk" rel="nofollow">http://twitpic.com/30szgk</a><p>I think Django is a little less overwhelming for beginners.
_b8r0超过 14 年前
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.
kenneth_reitz超过 14 年前
I think this is more of a decision between languages rather than Frameworks.<p>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.<p>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.<p>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.<p>I highly recommend you read the Zen of Python to see if the language is a good fit for you: <a href="http://www.python.org/dev/peps/pep-0020/" rel="nofollow">http://www.python.org/dev/peps/pep-0020/</a><p>Something to keep in mind.
评论 #1830707 未加载
hoop超过 14 年前
There are plenty of reasons why you should use Django or Rails over the other, but I rather discuss why maybe you <i>shouldn't</i> use Django. I haven't used Rails, so I will not be discussing that side of the coin.<p>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.<p>Where Django seems to break down is:<p>1. When you upgrade Django, or 2. When you start customizing Django<p>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.<p>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: <a href="http://blog.brandonbloom.name/2009/08/dropping-django.html" rel="nofollow">http://blog.brandonbloom.name/2009/08/dropping-django.html</a><p>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.<p>(Also, FWIW, Django doesn't natively support schema migrations, although their are tools such as "South" that implement this functionality.)<p>I think that if you're interested in using a Python-based like framework, you should also consider Pylons and Tornado.
评论 #1831157 未加载
carterac超过 14 年前
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.<p>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超过 14 年前
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.<p>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 (<a href="http://gearman.org/" rel="nofollow">http://gearman.org/</a>).
roder超过 14 年前
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.
评论 #1830153 未加载
danieldon超过 14 年前
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.<p>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.
评论 #1831165 未加载
评论 #1831068 未加载
评论 #1832305 未加载
keokilee超过 14 年前
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.<p>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超过 14 年前
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.<p>Ruby is a nice language though. I do all my non-web stuff in that.<p>I highly recommend Peter Cooper's Book: Beginning Ruby, Link:<a href="http://www.amazon.com/Beginning-Ruby-Novice-Professional/dp/1590597664" rel="nofollow">http://www.amazon.com/Beginning-Ruby-Novice-Professional/dp/...</a>, if you'd like to get started with it.
评论 #1832554 未加载
carbon8超过 14 年前
Regarding jobs for each framework, there are far more Rails jobs than Django jobs: <a href="http://news.ycombinator.com/x?fnid=JBPFd8i2nk" rel="nofollow">http://news.ycombinator.com/x?fnid=JBPFd8i2nk</a>.<p>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.
评论 #1830988 未加载
AdamN超过 14 年前
I picked Django because:<p>* 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<p>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.<p>As for jobs, both Rails and Django have tons of open positions available and hot startups using them.
评论 #1830943 未加载
评论 #1831056 未加载
zimro超过 14 年前
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.<p>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超过 14 年前
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.<p>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超过 14 年前
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.<p>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超过 14 年前
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超过 14 年前
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.<p>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超过 14 年前
Yes.
robwgibbons超过 14 年前
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.<p>This is not to say RoR is not awesome, it's mostly a preference of language.
honza超过 14 年前
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.<p>In Rails, I believe the database backend can be either. Look at Twitter - their using Cassandra.
评论 #1830880 未加载
评论 #1830835 未加载
thdn超过 14 年前
go Django you wont regret