Live data from Hacker News

What's better about Ruby than Python? - comp.lang.python

groups.google.com

71–80 of 129 posts

Re: What's better about Ruby than Python? - comp.lang.python

#71
post #43
post #20

Earlier quoted context omitted.

That extreme is also terrible. Python is somewhere in between.

if ruby is an extreme to the left, and java an extreme to the right, then python is also extreme to the left. The difference between python and ruby in dynamicity is really small. Python is not in the middle of ruby and java. Python is virtually on top of ruby.

A fair point. Maybe 'optimum' would be a more useful concept here than 'centre'... I see Python's position on the dynamicity (ugh) spectrum is in line with it's philosophy on readability.

(On a side note - your definition of 'extreme' rather depends on what outliers you have. I do love it when the US media refers to the Democrats as 'left of center' ;)

Re: What's better about Ruby than Python? - comp.lang.python

#72

I just get a login screen. + Newspapers require me to register and login - I go somewhere else. + Commercial sites require me to register and login - I go somewhere else. + Google requires me to register and login, guess what happens. I can't be bothered. I've got stuff to write, products to ship, and a life to live. It's just another article. I've saved time by not reading it, and the chances it was useful are small…

It's actually a Usenet post on comp.lang.python. You sound old-skool enough to still have access to a NNTP server ;-)

Re: What's better about Ruby than Python? - comp.lang.python

#73
post #61
post #31

"Other syntax differences such as '@foo' versus 'self.foo', or the higher significance of case in Ruby vs Python" ...suddenly wonders if there's a language where both case and indentation are significant.

I think he was talking about the "case" control structure. Or maybe I should just go to sleep... In any case, "case" returns a value, doesn't need breaks and doesn't need to be the same type. That's awesome.

Given that the switch-case construct doesn't exist at all in Python, I'm pretty sure he was talking about character case.

Re: What's better about Ruby than Python? - comp.lang.python

#74
post #19

Earlier quoted context omitted.

That may accomplish the same thing, but the direct translation would be: if baz > 10 func = method(:foo) else func = method(:bar) end result = func.call Here, we actually deal with the Method objects, rather than just sending a dynamic message. Although the send() approach would be closer to idiomatic Ruby, I wanted to emphasize that dealing with methods as first class objects in Ruby is indeed possible.

This discussion really makes me appreciate clojure.

Why is that?

Re: What's better about Ruby than Python? - comp.lang.python

#75
post #25

The biggest difference between Python and Ruby is in the mindset of the developers that choose them. I think of Ruby and Python as two languages standing back-to-back in the same spot, mostly unaware of each other, greeting developers who come from different directions.

I know it's early yet, so take this with all appropriate grains of salt, but that is easily the most insightful comment I've read today, and really drives home a point I've been trying to make for awhile (and probably failed to).

I started out with Ruby, because of Rails, and just never seemed to quite make it jive with me mentally. When I found Python (because of Django), everything clicked more. I'm not even sure it was the language differences that clicked more for me, or whether it was the documentation, or the code samples, or some other intangible that made it all work.

Re: What's better about Ruby than Python? - comp.lang.python

#76
post #68
post #7

Earlier quoted context omitted.

The main reason why I like having functions instead of methods is that it removes the possibility for inconsistency. In some languages, you have some objects with methods named size, some with length, etc. With python, you just have one global len method to remember.

"In some languages, you have some objects with methods named size, some with length, etc." In ruby you dont. It's #size and ruby is quite consistent in this respect. So it's remembering a method name vs remembering a function name (in a supposedly OO language).

Actually in Ruby you can often use both #size and #length.

It's part of the Ruby's philosophies to have synonyms like that.

Re: What's better about Ruby than Python? - comp.lang.python

#77
post #21
post #7

Earlier quoted context omitted.

The main reason why I like having functions instead of methods is that it removes the possibility for inconsistency. In some languages, you have some objects with methods named size, some with length, etc. With python, you just have one global len method to remember.

I am often frustrated by this as well, but I'm not sure it's specific to Python or Ruby. Why is it Math.log(1) rather than 1.log()? And given whatever reason it's Math.log, why is it a.inverse() when a is a Matrix not MatrixMath.inverse(a)? Is there a good guideline for static method vs. instance method distinction?

I agree with you, and I was equally frustrated. I think the problem is that most people don't use the Math module that much. Hence they try to keep the Numeric classes smaller rather than filling them with all possible Math functions.

However, it doesn't take much to "fix" it the way you like it. You need to patch Numeric. Whenever you call a method that doesn't exist, it calls the method "method_missing". Hence you can monkey patch Numeric#method_missing to call the equivalent Math function.

Re: What's better about Ruby than Python? - comp.lang.python

#78

make sure to use the zoom button on that... (not only the page itself but the differences too)

Try Readability (http://lab.arc90.com/experiments/readability) - it will fix the monospace and excess whitepace (as well as the size) in a single click.

Re: What's better about Ruby than Python? - comp.lang.python

#79

There are two things that Ruby has that Python doesn't have a good syntax for. One is blocks; in Ruby, I can write: foo { |x| puts x } Whilst in Python, I need to write: def tmp(x): print x foo(tmp) It's not really very nice. The other thing is that Python has no concept of context. In Ruby, I can type: foo(x) And it will execute foo(x) for the containing object. In Python, the closest equivalent would be: self.foo(x…

> The other thing is that Python has no concept of context

Rather, I'd say that part of the zen of python is: implicit is better than explicit, and I prefer python's behavior in this instance.

Re: What's better about Ruby than Python? - comp.lang.python

#80

The title made me nervous that this would be run-of-the-mill fanboy garbage. But I trust the author (Alex Martelli), so I read it, and I'm glad I did. It's reasonable and sane. My two big take-away points: 1) It's very nearly a wash. Ruby and Python are so close together (beneath any superficial differences) that distinguishing is almost an exercise in futility. 2) The key thing about Ruby he doesn't like is its "TOT…

My impression of the Ruby community, especially the OSS part of it, was that they were explicitly more about tinkering than enterprise. Certainly characters like _why were in that camp.

In regards to monkey-patching, while I'm not a Ruby programmer by any means, I sorely feel its absence in other languages. It's in JavaScript (expando objects as well as being able to override and overwrite built-in methods of existing types), and to some extent available in C# (extension methods are a sort-of expando object, but there is very little ability to overwrite a method). Like operator overloading, sure, don't build a project completely off of it (I'm looking at you, C++'s iostream), but when you need it, damn you need it. I'm still delving into Python (late to the party, whatever), but I definitely use Python in much more of a tinkering fashion, so monkey-patching is something I would desire in the language.

Post reply on HN