Live data from Hacker News

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

groups.google.com

111–120 of 129 posts

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

#111
post #30

Earlier quoted context omitted.

We run probably one of the largest Ruby production systems that has ever been made and the dynamism and "monkey patching" are used daily to skillfully make the language better and better over time for the tasks that we solve. It's absolutely crucial to teams that internalize it's power and pitfalls.

It's an extension of the critique leveled at dynamically typed languages by Java/C/C++ devs. How can you possibly work in a world where function foo can return/expect any type? The more dynamic (powerful?) the language the more leverage good, experienced developers have. They can achieve results in 10 lines of code that are hard/impossible in more static languages (closures, meta-classes etc.). The other edge of the…

I can believe that such power can be achieved and scale within a single department-size group of "smart people".

The problem appears if or when you want to share the code between departments or give it to the world. Give "clever code" to someone who simply doesn't understand the whole process and they turn into a "dud developer" no matter how otherwise intelligent they are.

(And what's with down-voting the parent? It's a fair point even if I'm not in agreement)

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

#112
There are many small-to-medium differences between Python and Ruby, but in my experiences, no one actually chooses one language over the other because of these differences. When you ask someone, "Why do you prefer Ruby over Python?" or vice-versa, everyone has their favorite differences to talk about, but often, the choice is actually made before enough familiarity with both languages is established to be aware of those differences. Most people choose between the two based on je ne sais quoi, rather than an objective comparison of the differences.

More succinctly: "Ugh! Python? I hate the idea of syntactic whitespace," and "Ugh! Ruby? I have the idea of using @ for instance variables," are both cursory judgments that mask deeper preferential foundations therein.

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

#113
post #69

Earlier quoted context omitted.

In python the convention tends to be: a.inverse() -> mutates 'a' to its inverse MatrixMath.inverse(a) -> returns the inverse of 'a', leaving 'a' unchanged

1 isn't a matrix. Integers/floating point numbers are in many languages treated differently than other types for reasons of performance and memory management etc. Ruby isn't different in this respect (IIRC they call it immediate objects). A matrix is a "normal" object in ruby. BTW the ruby equivalent for the above convention would be (maybe inspired by scheme?) a.inverse!() -> mutate a a.inverse() -> return the inver…

I am a python user, but I _really_ like that .inverse!() notation indicating that the object itself is being mutated. It's concise and consistent. Sometimes punctuation in names is exactly what you need. Same with ? for predicates. I'll take even? over evenp any day of the week.

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

#114
post #24

Earlier quoted context omitted.

You certainly could solve that with a symbol, I suppose, but that's a bit like doing a word-for-word translation of 'it's raining cats and dogs' into a foreign language. Better to translate to the local idiom than to try to blindly write Fortran in any language, as the saying goes. So, for instance, you might solve it with: result = case when baz>10 then foo else bar end This is synthetic, of course. If the goal is t…

Or a slightly more direct translation is: result = if baz > 10 foo else bar end

  result = case
    when baz>10 then foo
    else bar
  end
is a translation of

  if baz>10:
    result = self.foo()
  else:
    result = self.bar()
while

  result = if baz > 10
    foo
  else
    bar
  end
is a translation of

  result = self.foo() if baz>10 else self.bar()
It's true that some things have to be changed when translating, but you can't ignore the deliberate structure of the original. Let's say I want to look at how inter-sentence objects work in two languages. I give you the phrase: "Raining cats and dogs. This is what the weather is like." You can't translate it as if it said "It's raining cats and dogs" without losing the basis of comparison entirely.

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

#115
post #30

Earlier quoted context omitted.

We run probably one of the largest Ruby production systems that has ever been made and the dynamism and "monkey patching" are used daily to skillfully make the language better and better over time for the tasks that we solve. It's absolutely crucial to teams that internalize it's power and pitfalls.

"one of the largest Ruby production systems that has ever been made" As an aside, I worked on a very large Ruby app (built by about a dozen developers over the course of years) and then later worked on another very large Ruby app of similar size. One of the employees there remarked that it was the largest Rails app built. I think the people who write very large Ruby apps tend to be very quiet about it (no blogs, no o…

I can fully agree about the quietness of developers working on large ruby app considering I work on such an app but were not big on advertising it yet.

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

#116
post #36

Earlier quoted context omitted.

Having a global len() function is very, very linked to polymorphism. You can call it on anything that has a __len__() function defined (i.e., any class that implements something like a "HasLength" interface in Java terms).

If you have __len__() implemented on the object, why not call it directly? If you are dealing with object X, that is of classes A,B,C or D (that all implement __len__), I don't see the fundamental difference between len(X) and X.__len__().

Tomato, tomahto.

Why use x.__len__() rather than len(x)?

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

#118
post #21

Earlier quoted context omitted.

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?

In python the convention tends to be: a.inverse() -> mutates 'a' to its inverse MatrixMath.inverse(a) -> returns the inverse of 'a', leaving 'a' unchanged

This confuses me, because python strings use str.lower() to return a lowercase copy of str, leaving str unchanged. I prefer the Ruby idiom of naming the mutating versions with a !.

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

#120
post #96
post #71

Earlier quoted context omitted.

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' ;)

yup, republican and java are in the same camp ;) On a serious note, I've been doing ruby as my job for about 5 years and I work at a giant corporation with a few hundred programmers. In those 5 years I've never been bitten by someone changing a core class that breaks my code. Maybe 3 times I've been bitten by someone changing a non core class, and it usually takes me about an hour or two to resolve it. So that's mayb…

That sounds like an interesting big Ruby gig that would be a good story to tell the anti-dynamic languages FUD brigade.

You should blog :)

Post reply on HN