Live data from Hacker News

Ask HN: Why Python over Ruby?

news.ycombinator.com

131–140 of 198 posts

Re: Ask HN: Why Python over Ruby?

#131
post #41
post #38

Earlier quoted context omitted.

The "XML library" that comes with Ruby is REXML, which uses only regular expressions to 'parse' XML into the tree structure that it exposes via its API. It is a stinking pile of shit.

Sure is! Actually, I can't even remember if it has the functionality nailer's talking about. As far as I know all rubyists permanently abandon REXML approximately 20 minutes into their first coding session involving anything to do with XML. Gets to the point where other libraries are so common that they may as well be in core, though. I wonder if there's any rubygems installation anywhere that doesn't have hpricot.

"As far as I know all rubyists permanently abandon REXML approximately 20 minutes into their first coding session involving anything to do with XML."

No, not really.

Some do, I'm sure. I've had great success with it when I needed it.

Re: Ask HN: Why Python over Ruby?

#132
post #6

One major problem with Ruby has been that the performance as been much slower than Python. This is no longer true with Ruby 1.9. I happen to have done a benchmark using a recursive Fibonacci algorithm yesterday, results: http://pastie.org/528717 source: http://pastie.org/528720 I wouldn't say Ruby has lost just yet.

I don't think performance is holding ruby back I think that libraries especially mature and massive libraries, or lack thereof, is holding ruby back. Not to say people aren't working on it give ruby some time it will probably catch up especially with rails but just not right away.

" think that libraries especially mature and massive libraries, or lack thereof, is holding ruby back."

JRuby FTW.

Yes, there are downsides to sitting on the JVM, but for anything other than one-off scripts, or where start-up speed is really important, JRuby gives the best of both worlds[0]: Ruby syntax with JVM libraries.

[0] Clearly if you do not care for Ruby syntax then this is not a win. I believe, though, that JRuby is more advanced and stable than Jython. But the Jython folks are quite capable for continuing to kick ass, so that will improve.

Re: Ask HN: Why Python over Ruby?

#133
post #50

For me it's very simple ! I can READ other people's Python code with greater ease than Ruby, Java, C#, C++ or even C. At the end of the day, the quicker I can assimilate library code the quicker I can use it well and the quicker the module gets completed and fully tested. Of course, with Google and Eric Raymond raving about it, the confidence factor increased further.

This is a cultural issue. In the Ruby (or Perl) community, if you use obscure language features to do a common task in a single line of code, you will be worshipped as a god. In the Python (or Tcl) community, you will be viewed with suspicion. Not that Python doesn't have one-liners (e.g. comprehensions) - just that everyone agrees which ones and when and how to use them.

You'll get that in a Perl Golf competition but the trend these days it towards much more readable and maintainable code. Which is why we have things like Moose (a better way to do objects).

Re: Ask HN: Why Python over Ruby?

#134
Any popularity in Python over Ruby stems largely from the fact that Python came first.

I've heard Python developer's working on a Ruby on Rails application that the problem with Ruby is that approximately equivalent to Python in terms of productivity. They wanted to use Python, but pragmatically you can't make the case to management to switch from one language to the other if the other language is more or less the same. But most of the time this effect works the other way around, where Python was established before Ruby.

I was doing Perl in 1999, and looked at switching to Ruby or Python. Python was still quite small back then, but you had web frameworks (Zope, Twisted), albeit the incarnations back then are clunky by today's standards, but Python was establishing itself as a clean, readable, dynamic language. Ruby on the other hand had no web frameworks, and almost no documentation in English - the only reason I was considering it was because I was working with a Japanese localization team and they thought Ruby was quite hot.

The debate over which dynamic or scripting language to use was always between Perl and Python back then. Perl was the incumbent and Python the challenger, Ruby rarely factored into the picture. It wasn't until Rails started to become useable and gain attention in 2004 and 2005 that Ruby interest started to really blossom. And so Python was well established for many uses: scientific computing, ad-hoc data processing, network programming. If you're a development manager of an application that you want to make scriptable, you would have made the decision to already go with Python, there just isn't any compelling reason to switch to Ruby beyond the sake of switching.

Another example is IronPython versus IronRuby: work started on IronPython in 2003, work started on IronRuby in 2007. IronPython is at version 2.0, while IronRuby is at version 0.5, and this is reflected in the polish of these language implementations. A .Net developer might decide that they prefer the idiosyncracies of Ruby over Python's idiosyncracies, but if they had to start a large project in today, they'd most likely choose IronPython since there is much less risk of the project bumping up against the rough edges of IronPython versus IronRuby.

Re: Ask HN: Why Python over Ruby?

#135
post #55

Ruby has clever syntax. Python has pure syntax. Ruby has method aliases. Python does not allow a string to capitalize itself. Ruby uses Ruby methods within Ruby classes to extend Ruby. Python has decorators so you can write functions that return functions that return functions to create a new function. Ruby has strict object-oriented encapsulation. Python is laid-back about objects, because you probably know what's g…

Ruby has method aliases. Python does not allow a string to capitalize itself.

    >>> "hello".capitalize()
    "Hello"
Python has decorators so you can write functions that return functions that return functions to create a new function.

Or functions that return classes, or classes that use other objects, or any possible other use for the pattern "wrap this with that and save the result"

Python will let you mix tabs and spaces for indentation, but passive-aggressively mess up your scoping as punishment.

    $ ./mixed.py
      File "mixed.py", line 3
        print "b"
                ^
    TabError: inconsistent use of tabs and spaces in indentation

Re: Ask HN: Why Python over Ruby?

#136
post #100

What's clear to me reading the comments in this thread, is that there are a lot of people who like Python, and don't understand what people appreciate in Ruby. None of these are reasons why people choose Python over Ruby. Or why Python has become more popular. It is worth noting that Python was also mentioned a lot as a teaching tool when its popularity began ramping up, and some universities have replaced Java and S…

To claim that Ruby is a tangled soup of options and syntactic sugar is to miss the point really. What is the point? I sincerely wish to learn, for my own intellectual curiosity. Because I have read Ruby code and I have done Ruby tutorials and talked to people who use Ruby and for the life of me, no matter how hard I meditate on the issue, I cannot understand why anyone would use Ruby over Python. I don't feel Python…

Python presented me with one insurmountable cognitive hurdle, and that's what drove me to Ruby: whitespace scoping. That single misfeature in Python is enough to keep me from ever using it in my own projects.

The compiler/interpreter should work for me, not force me to work for the compiler/interpreter. (And no, there's not always preferably one way to do things, which is an attitude I can't stand.)

Re: Ask HN: Why Python over Ruby?

#137
I think it's mostly about maturity, of the runtime, of the language, and of the community.

For example, Ruby has backward incompatibility issues in minor releases that would never be permitted in Python. They had to jump to Python 3 for even fairly small things that wouldn't be accepted in the 2.x line. Even subtle incompatibilities between Python versions are taken seriously, and there's a documented process for deprecation that involves multiple releases and means when a feature is deprecated it'll probably still be available for years. There's cruft in the language as a result, but for people using Python seriously this is more than worth it.

I think the Python-Dev community is also more mature. Changes get serious review. Though there's not a formal "core", strong objections from certain people are enough to bring a new feature back to zero and require a restart (not because those people have special weight, but because they are respected and everyone kind of understands there's a benefit to listening to crotchedy naysayers if they are smart crotchedy naysayers).

The community is large enough that there's a lot of domain knowledge. Python is better at getting a canonical and complete solution to a domain problem than Ruby. WSGI discussions for instance involved some people with a very intimate knowledge of HTTP. People work hard to get 95% solutions instead of 80% solutions. In part because Python has been around a long time, and there's already at least an 80% solution for whatever problem you are looking at, and if you are going to throw your hat in the ring you ought to be ready to try harder. I think the more aesthetic tendencies of the Ruby community work against it here, as people are more likely to rewrite for aesthetic rather than functional reasons. (OTOH, when Python settled early on some 80% solutions, it's caused a lot of difficulties because it's been hard to overcome inertia to introduce a better solution, while it's hard to get really good adoption of the 80% solution; pydoc would be an example.)

Then there's simple maturity. The VM is more stable; it may not be a great VM, but it is predictable. There's lots of tools for writing extensions. There's code for dealing with large data sets, for dealing with images, for accessing system libraries, etc. For any one problem Ruby might work fine, but for the problems you don't yet know you'll have to solve it's less likely you'll hit a blocker with Python.

Re: Ask HN: Why Python over Ruby?

#138
post #70
post #34

Earlier quoted context omitted.

...strange ad-hoc combination of other languages. I call bullshit, sir. Ruby is objectively less strange and more consistent than Python. Some has to do with the fact that Python is older - hence has more baggage to carry. A lot of it, though, just has to do with poor/missing design choices. Specifics? - ruby 'block' passing convention is much cleaner and more powerful than python's 'for'/iterators. - python's global…

Quoting an article on the topic: Having ploughed through several tutorials, I did not find Ruby particularly "elegant", or its syntax particularly obvious. Much of it seemed ad hoc, thrown together, in particular when there were several different ways of doing something, and it seemed to be the philosophy of the language to provide all of them. I did not find its constructs as intuitive and natural as claimed, trying…

Huntbach's article was pure nonsense when it was written[1], and it remains pure nonsense now.

[1] As I wrote two years ago: http://www.halostatue.ca/2007/03/17/whats-wrong-with-bitwise...

Re: Ask HN: Why Python over Ruby?

#139
post #69

Earlier quoted context omitted.

Me too, but I don't think it's just a preference. I come from a C/C++ background (I'd say the majority of people do, or C# or Java), and Python looks much more familiar and obvious to me than Ruby. For example, this from Wikipedia: (3..6).each {|num| puts num } Has some funny brackets and pipes. In Python, it's much more familiar to C-ish folks like me: for i in range(3, 7): print i

Ruby's syntax is flexible: for i in 3..6 do puts i end

You're right, that's pretty C/Python-like. Nice. In fact, I've often thought that Python could make the syntax "n..m" expand to "range(n, m+1)" or equivalent.

However, Python's TOOWTDI comes to mind. Not that it's quite true, but probably closer than with Ruby. I guess one could debate whether TOOWTDI is a good thing -- but I reckon Perl is the argument as to why it is a good thing.

Re: Ask HN: Why Python over Ruby?

#140
post #55

Ruby has clever syntax. Python has pure syntax. Ruby has method aliases. Python does not allow a string to capitalize itself. Ruby uses Ruby methods within Ruby classes to extend Ruby. Python has decorators so you can write functions that return functions that return functions to create a new function. Ruby has strict object-oriented encapsulation. Python is laid-back about objects, because you probably know what's g…

Ruby has method aliases. Python does not allow a string to capitalize itself. >>> "hello".capitalize() "Hello" Python has decorators so you can write functions that return functions that return functions to create a new function. Or functions that return classes, or classes that use other objects, or any possible other use for the pattern "wrap this with that and save the result" Python will let you mix tabs and spac…

I should point out that capitalize(), of course, returns a new capitalized string, just as it does in Ruby. But in Ruby you also have String#capitalize!

And as for indentation, I think Guido should have followed through with making tabs a syntax error, because they are part of the syntax and are fiendish sources of error. Let's just say you have this code, properly indented with spaces:

    class X:
        def visible(self):
            pass
And you open it in a non-Python-aware editor, say for Windows, which has a four-space tab length and does not convert them to spaces. You add:

        def invisible(self):
            pass
at the end of the file using your tab key. Now you have a potentially crazy-hard-to-figure-out bug.
Post reply on HN