Live data from Hacker News

Why do programmers prefer Python over Ruby?

news.ycombinator.com

11–20 of 31 posts

Re: Why do programmers prefer Python over Ruby?

#11
post #7

Disclaimer: This is very subjective and from a Python guy 1. While Python and Ruby are roughly of the same age, Ruby was only popular in Asia before Rails. At that point Python already had a solid base of non-web stuff. 2. Ruby feels more wild and crazy to me. Is monkey-patching still considered cool in the Ruby community? As a Pythonista I try to avoid such confusing stunts. Due to both of those reasons I believe Py…

> As a language enthusiast I envy Ruby for the blocks. As a Python programmer I never felt the need for them.

I think one of the reason why Python isn't hurt by the lack of blocks is the difference in namespacing rules. Since defining a top level function doesn't pollute the global namespace, there's much less of a need for blocks and mulit-line lambdas. If I feel that I've got too many functions sitting around in one of my project's files, I can simply open up a new file, utils.py, and all my utility functions will be in their own namespace.

So, I agree, blocks are cool, but when it comes to re-reading code, I like that I've been forced to spend the extra few seconds to give my functions names.

Re: Why do programmers prefer Python over Ruby?

#12
One word: Cython.

Having a fast way to interface C code, and speed up your bottlenecks is a godsend for anything that isn't a strict web app.

I'm sure Ruby has an FFI, and most likely even has a SWIG interface but Cython is far beyond that--its a typed version of Python that compiles directly down to C/C++, so you can port code between Python and Cython instanteously.

Doing just that usually makes it 2x faster. Annotate it with types to make it more than 10x faster. Change the algo to something you can only do efficiently in C, and it's 100-1000x faster. Seeing something go from taking 10 minutes to taking 600ms in less than a days work is fantastic.

----

Also personally, I find I like white-space scoping. Python is like psuedocodethat actually runs.

Re: Why do programmers prefer Python over Ruby?

#13
I think it has nothing to do with the languages themselves, and more to do with a sort of tipping point around tools, libraries and adoption. Through random chance, I prefer Python simply because people I know use Python so I started to use Python.

At the end of the day, there really isn't much inherent that makes Python better than Ruby. Which is exactly why the world would benefit from the eventual dominance of one over the other. Even if it is a randomly driven tipping point process.

On the other hand: Ruby vs Java vs C++, each has clear advantages in certain situations. These languages seem less likely to compete with each other.

Re: Why do programmers prefer Python over Ruby?

#15

One word: Cython. Having a fast way to interface C code, and speed up your bottlenecks is a godsend for anything that isn't a strict web app. I'm sure Ruby has an FFI, and most likely even has a SWIG interface but Cython is far beyond that--its a typed version of Python that compiles directly down to C/C++, so you can port code between Python and Cython instanteously. Doing just that usually makes it 2x faster. Annot…

Hmm... Could you recommend some resources for this? I need to wrap a couple libraries and make them accessible in both Python and Ruby.

Re: Why do programmers prefer Python over Ruby?

#16
post #6

I'm going through Ruby koans right now but am a Python programmer. The #1 thing I like about Python is the community and has nothing to do with the language. I find the python community doesn't actively champion the language as the end all be all (for better or worse). Rather it is accepting of when Python sucks for a specific task. I also find Ruby to be really web focused. Python tends to have lots of libraries tha…

I have that same feeling about the ruby comunity and its the main reason why I try to stay away from it, it gets on my nerves. About the python comunity, no complaints so far with one or two exceptions. I also feel the same about ruby being more web focused, it may be wrong but that's how I see it too, one "problem" of python is that there is too many modules and with some variations so its rather hard to know it. And maybe its just me but the python docs sometimes are rather confusing, with few examples (I like to read examples, its a lot easier IMHO)

Re: Why do programmers prefer Python over Ruby?

#17
I am not sure that this poll was representative of the whole programming community. We are a Berlin based startup and we're looking for a Python developers and they are a lot harder to find than Rails devs. Not to talk about PHP, C# and Java developers.

Also there are tons of existing libraries and you don't have to implement anything but your actual business logic.

Re: Why do programmers prefer Python over Ruby?

#18
post #15

One word: Cython. Having a fast way to interface C code, and speed up your bottlenecks is a godsend for anything that isn't a strict web app. I'm sure Ruby has an FFI, and most likely even has a SWIG interface but Cython is far beyond that--its a typed version of Python that compiles directly down to C/C++, so you can port code between Python and Cython instanteously. Doing just that usually makes it 2x faster. Annot…

Hmm... Could you recommend some resources for this? I need to wrap a couple libraries and make them accessible in both Python and Ruby.

The best thing to do is to take a look at the Cython docs (http://cython.org/) and check out some of the whitepapers they have posted. There is also a bunch of cython code on github. If you search "cdef extern" you should find examples where other people have wrapped external c libraries.

Re: Why do programmers prefer Python over Ruby?

#19
I like Perl, I like SmallTalk, and given that, I actually do like Ruby the language. My main peeve is the infrastructure. No, not even the community, you'll find nice people and bumwads on both sides. But I just can't stand the penchant for overly cutesy DSLs that seems to pervade the Ruby world. It's basically Lisp macro abuse all over again.

Re: Why do programmers prefer Python over Ruby?

#20
post #7

Disclaimer: This is very subjective and from a Python guy 1. While Python and Ruby are roughly of the same age, Ruby was only popular in Asia before Rails. At that point Python already had a solid base of non-web stuff. 2. Ruby feels more wild and crazy to me. Is monkey-patching still considered cool in the Ruby community? As a Pythonista I try to avoid such confusing stunts. Due to both of those reasons I believe Py…

>Is monkey-patching still considered cool in the Ruby community?

It can be useful in your particular project to overcome library incompatibilities, but it probably shouldn't be used in library/framework code.

Post reply on HN