Hacker News new | ask | show | jobs
by csense 4772 days 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?

3 comments

> 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.

> 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 is the most informative part of your comment. I came to Python around version 2.6, and Django was already pretty near its modern form. I also first started hearing about Rails at that time, so my perception was "Python has always had Django, and Rails is a new thing." If Rails is older than Django, that explains much.

> Python invariably loves explicitness

Before I used Python, Java and C were my main languages. I was amazed at how short programs became in Python. For this reason, saying "Python loves explicitness" strikes me as strange, since it gets rid of braces, semicolons, variable declarations, the 'new' operator...

> A lot of other people hate that kind of code, and they will be much happier using Python.

This is totally me. I've ranted elsewhere in this thread about Ruby's syntax. Maybe some clever person will write a Python-to-Ruby translator someday so you can use Rails without having to deal with Ruby syntax.

> inertia matters a lot

I'm just a little surprised the momentum isn't swinging back to Python. Since IMHO Ruby's syntax makes the language...very undesirable, and if I was forced to use it to take advantage of tools that only exist in Ruby-land, I'd be looking to switch back to Python as soon as the tools were ported -- and even devote effort to helping with ports.

Everybody was excited about Perl in the beginning, but very few people still code in Perl these days. I think Ruby suffers from similar problems and will eventually be eaten by Python.

> Before I used Python, Java and C were my main languages. I was amazed at how short programs became in Python. For this reason, saying "Python loves explicitness" strikes me as strange, since it gets rid of braces, semicolons, variable declarations, the 'new' operator...

I think you have confused "explicitness" with "verbosity." Indentation is no less explicit than braces.

> I'm just a little surprised the momentum isn't swinging back to Python. Since IMHO Ruby's syntax makes the language...very undesirable

That is very much a YMMV sort of thing. A lot of people actually like the Ruby syntax because they find the greater flexibility and ability to define pseudo-DSLs to be pleasant.

> very few people still code in Perl these days

Please try to separate your beliefs from facts.

http://www.indeed.com/jobtrends?q=perl%2C+python%2C+ruby%2C+...

I 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.

> 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/4caaea824cf51670d1...

[2] https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d1...

"Implications"? Is that a weird word for a block or what?
He/she means that `=>` looks like a mathematical implication, just like `|...|` looks like absolute value bars.
For #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.
It 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.