Live data from Hacker News

Ask HN: Why Python over Ruby?

news.ycombinator.com

181–190 of 198 posts

Re: Ask HN: Why Python over Ruby?

#181
post #89
post #76

1. Get latest OpenSolaris. 2. Install latest SunStudio 3. download latest source of Python (3.1) and Ruby (1.9.1). 4. Try to build them with CC=/opt/SUNWspro/bin/cc" CFLAGS="-m64" 5. See the results. Run make test for ruby.

So Ruby compiles cleaner on failed Unix OSs?

No. Its standard modules were coded more portable way.

btw, Solaris will stay on its niche like FreeBSD.

Re: Ask HN: Why Python over Ruby?

#182
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…

[deleted]

Re: Ask HN: Why Python over Ruby?

#183

Earlier quoted context omitted.

So I just saw 3 ways to print from 3 to 6... are those all used in the wild? Zen of Python: "There should be one-- and preferably only one --obvious way to do it." Sure, there are other ways to do it in Python, but it'd be frowned upon to use something like 3.upto(6) rather than a standard range() that everyone is used to. Readability matters.

I'm sorry, did you say there's only one way to deal with each integer in a set of numbers? Admittedly I don't know very much about python, but it seems that at the very least you could do this recursively.

Neither Python nor Ruby AFAIK have tail-call optimization.

Re: Ask HN: Why Python over Ruby?

#184

Earlier quoted context omitted.

That's how I feel about Django at this point. A quick glance at reddit reveals how out of hand it's getting; the answer to every web programming question is "Django!" regardless of whether it's relevant or not. And every popular comment or blog post by Django developers discussing Rails contains a bunch of inaccuracies. At least with Rails there's enough of a push back that even the the annoying minority is better be…

Hmmmm. Is it 'really hard' to develop web apps with python and avoid django? No. It isn't.

Well... You can use Zope and Plone. I have done so for a very long time (in fact, I started using Python because of Zope).

Zope 3.x (Plone runs on top of Zope 2.x) is a very nice application server. I wonder if it would be possible to make it work seamlessly with things like Hadoop instead of ZODB.

Re: Ask HN: Why Python over Ruby?

#185
post #88

I have been using Python for about year for Google App Engine projects. I have been using Ruby for about two years for various personal open-source projects. I like both languages, but I prefer Ruby over Python. I hate Python's neglect (by Zed Shaw): http://www.zedshaw.com/blog/2009-05-29.html Ruby seems to be so much more "symmetric", Python feels like a hack on top of dictionary to me.

What I will blame Python for is the lack of even the most basic time conversion features that even C has. If all they did was give me the exact same POSIX C API I’d be happy. Instead, I got some half-assed library and some half-assed rationale about why this is a better way to do it.

Ermm, datetime.strptime and datetime.strftime?

Re: Ask HN: Why Python over Ruby?

#186

Earlier quoted context omitted.

Humor me for a moment, because I've been asking this question of many people for a long time and have never yet gotten a straight answer. Why is len() always the thing people pick on? Why is it always "Python uses len(obj) instead of obj.len()", and never "Python uses str(obj) instead of obj.str()", or any of the various polymorphic built-ins like sum()? I've seen this so many times now that I'm honestly quite curiou…

Even without going to the trouble of importing types, every Python callable has an __call__ method. Including the __call__ method: >>> def f(): ... print("Helllo __call__") ... >>> f.__call__.__call__.__call__.__call__() Helllo __call__ Don't use this in real life though, there's a performance penalty.

Of course, there's also the singleton that always returns itself:

  >>> recursive = lambda: recursive

Re: Ask HN: Why Python over Ruby?

#187
post #9

Ruby is slightly newer and wasn't particularly popular in the United States until it was popularized by Rails. Python became popular with Linux and open source developers before Ruby did, and has had slightly more time to develop a nice set of libraries to do just about anything.

May I also add that Python works very nicely on a Windows box. Ruby/Rails works on Windows, but when I used it, it hobbled around on one leg. Going to PyCon this past year, I was stunned at how many Windows laptops there were. Python itself and the Python community are really quite OS agnostic. The online Python documentation tends to be pretty good. When I picked up Ruby a year and a half ago, and I tried to find th…

I used to do all my Rails development on XP, with no hobbling.

Nowadays I work on Kubuntu, and maybe things have changed, but I've no bad experiences with Ruby on Windows.

Re: Ask HN: Why Python over Ruby?

#188
post #78
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…

Python's C implementation is so clean.. just try to compile it on OpenSolaris with Sun compiler. hint: Perl or Ruby were passed 100% tests.

That's portability. Portable and clean code are 2 different things.

Re: Ask HN: Why Python over Ruby?

#189
post #181
post #89

Earlier quoted context omitted.

So Ruby compiles cleaner on failed Unix OSs?

No. Its standard modules were coded more portable way. btw, Solaris will stay on its niche like FreeBSD.

10 years ago Solaris' niche was being the standard OS at financial services companies. These days, that standard is Linux, generally Red Hat - nobody's buying SPARC anymore and Solaris on Intel runs very few apps. The largest hedge fund, the top tier investment banks, and the top retail banks have all abandoned Solaris. The only new purchases from Sun are support contracts on ancient kit that's still waiting to be replaced.

Re: Ask HN: Why Python over Ruby?

#190

When you say "win", are you meaning in the sense of "there can only be one"? Why limit the discussion to Python and Ruby? Why not include PHP, say? Why have Python and Ruby "lost" to PHP? What about C++, Java and C#? Heck, VB is still more "popular" than either: http://www.tiobe.com/index.php/content/paperinfo/tpci/index....

I wanted to understand the factors that led to a particular outcome: Python becoming the de-facto winner for scripting applications.

I compared to Ruby, because that's the language I would choose for scripting, based on the ability to create nice internal DSLs.

Post reply on HN