"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.
What's better about Ruby than Python? - comp.lang.python
61–70 of 129 posts
Re: What's better about Ruby than Python? - comp.lang.python
#62Re: What's better about Ruby than Python? - comp.lang.python
#63The 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…
But seriously, at his Q&A session on EuRuKo 2010 Matz mentioned that monkey patching issues are going to be addressed in Ruby 2.0. http://nuclearsquid.com/writings/euruko-day2.html
Re: What's better about Ruby than Python? - comp.lang.python
#64Earlier quoted context omitted.
In what situation is it actually a good idea to employ a large number of bad programmers, rather than a small number of good ones? We shouldn't be making trade-offs for the sake of bad ideas ;)
...and all it takes is one rogue or bad programmer to mess up the code base.
Re: What's better about Ruby than Python? - comp.lang.python
#65The only things that are really "different" between Python and Ruby are topical features of the grammars of each, that mostly disappear once the code has been AST-transformed. These could likely be expressed more succinctly in terms of a simple common base grammar, and two small, modular sets of reader macros.
Re: What's better about Ruby than Python? - comp.lang.python
#66Earlier quoted context omitted.
Then why bother with OOP to begin with?
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).
Re: What's better about Ruby than Python? - comp.lang.python
#67+ 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. Besides, skimming the comments has given me enough of the flavor that I don't really think I'm missing much that I didn't get from the comments themselves.
Score another one for the HN community. Thank you.
Re: What's better about Ruby than Python? - comp.lang.python
#68My biggest beef when I've done a little Python has been inconsistency, such as that over functions versus methods. Ruby has a simpler mental model to me. I hear this has improved in Python 3.0, but it felt bleurgh to use functions like len(str) some of the time and methods at other times (though str.__len__() is a poor workaround here). That said, the reasons have been discussed and defended numerous times, so it's d…
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 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).
Re: What's better about Ruby than Python? - comp.lang.python
#69Earlier 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
BTW the ruby equivalent for the above convention would be (maybe inspired by scheme?)
a.inverse!() -> mutate a
a.inverse() -> return the inverse
Which one is more consistent?Re: What's better about Ruby than Python? - comp.lang.python
#70 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)
This syntax difference may seem trivial, but it allows you to do some very interesting things to classes. For instance: class Foo
def self.property(name)
define_method(name) do
instance_variable_get(name)
end
end
end
class Bar
Now the class Bar has a method called "x", without us needing to explicitly define it.Ruby's instance_eval method extends this further, allowing you to execute a block of code in the context of any object you wish.