4 ms·
I'm interested in the answers to these questions: 1. What does Rails do that Django doesn't? (Feel free to substitute any other Web framework for Django if yo
by csense 13y ago
I'm interested in the answers to these questions:
1. What does Rails do that Django doesn't? (Feel free to substitute any other Web framework for Django if you think it'll help your answer be more illustrative.)
2. Why hasn't the Python community seen whatever Ruby's doing and copied whatever makes Ruby popular? Are there any Python/Ruby experts reading this who are willing to port or reimplement the good parts of Ruby in Python?
3. Are there any other reasons to prefer Ruby over Python besides Rails? For example, do Gems do things that are impossible with Pip?
- spoiler 13y agoI don't know about the first question, but: 2) Because Python would become Ruby, or at least Pubython, then. What attracts most people to Ruby is its humanist syntax, not sure what Pythons guiding philosophy behind the syntax is, but I tried both and ruby was just a lot better. 3) There is loads of little things that are just personal preference for me, but the choice of language always boils down to personal preference one way or the other! Never really tried Pip, so I can't answer.
- csense 13y ago> Pythons guiding philosophy behind the syntax Python's syntax philosophy in a nutshell: The more your program looks like line noise, the harder it is to read. Operators should be simple and minimal, operations like list comprehension should match existing usage in English, mathematics, or C. > ruby was just a lot better Here's a Ruby snippet. I don't want to pick on this particular project [1], rather, I've found that this is typical of Ruby code: state_machine :state, initial: :active do after_transition any => :blocked do |user, transition| # Remove user from all projects and user.users_projects.find_each do |membership| return false unless membership.destroy end end Wow. There are colons, absolute value bars, implications, and who-knows-what-else flying everywhere! It gets worse, elsewhere in the same file there are messy lines like this one with single-arrow implications, question marks and ampersands [2]: scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : scoped } Simple, intuitive syntax? From where I sit, the syntax of Ruby is worse than C++, and approaches Perl levels of awfulness. In most languages, I can at least sort-of grok what's going on from the context when I see unfamiliar operators, but not so in Ruby. [1] https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d11b409efa5701dd74614d2a/app/models/user.rb#L118 https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d1... [2] https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d11b409efa5701dd74614d2a/app/models/user.rb#L143 https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d1...
- haney 13y agoFor #1 everything I've seen points to rails and Django having a nearly 1 to 1 correspondence. It's just preference for the most part.
- squidsoup 13y agoIt really doesn't - Rails comes with a lot of things that Django does not by default. Off the top of my head, Django does not come with database migrations, environment based configuration or an asset pipeline. You can add those things to Django, but you need to either use a 3rd party library or roll it yourself. I believe Django database migrations are coming, based on South, but if they'll land in 1.6 I don't know.
- chc 13y ago> 1. What does Rails do that Django doesn't? The answer is, basically, "Have a larger ecosystem without being Java." There are a few things each has by default that the other doesn't, but by and large I don't think people pick Rails because it has 8 million features and Django only has 7.95 million. > 2. Why hasn't the Python community seen whatever Ruby's doing and copied whatever makes Ruby popular? Are there any Python/Ruby experts reading this who are willing to port or reimplement the good parts of Ruby in Python? Just about anything worthwhile already has an equivalent. The reason Ruby is popular is not really about features. Ruby is popular because Ruby managed to capture people's imagination. When the new generation of webdev was first coming around in the mid-2000s, Ruby had a huge burst of enthusiasm. Everybody was enamored with Ruby on Rails, and Ruby itself had lots of fanatical evangelists like Why who were eager to teach people. Python, ironically, was hampered by the fact that it was more mature and thus it was harder to get people excited about it. Additionally, Rails was the killer app for Ruby, while Python took a relatively long time to put out a comparable product. I don't remember if Django existed, but there certainly wasn't the situation you have today where Django is basically the "Python Rails" and they're seen as being on roughly equal footing. Instead, Pythonistas were all talking about how you should take Twisted and twelve other libraries and you just write all this glue code and then it's sort of like Rails if you squint really hard — and nobody really found that exciting either. This isn't to say that Ruby doesn't have actual benefits to recommend it. Rails is a very nice, mature environment for web development, and Ruby as a whole has a very nice ecosystem these days. But the reason it got where it is is because Ruby won people over eight years ago, and it's gotten where it is today from that momentum. It isn't that Ruby is miles ahead and Python is simply inferior, but that Ruby just got a head start in that field and inertia matters a lot. > 3. Are there any other reasons to prefer Ruby over Python besides Rails? For example, do Gems do things that are impossible with Pip? The culture of the two languages is sort of different. Python invariably loves explicitness. Ruby isn't as crazy infatuated with "magic" as it used to be, but it's still much more acceptable over there to do weird tricks that let you write code the way you want to (e.g. "this magically executes in a context with functions that aren't available elsewhere") instead of the old-fashioned way. A lot of people prefer the latter, so they like Ruby. A lot of other people hate that kind of code, and they will be much happier using Python.
- 13y ago