From: Joao Pedrosa Date: 2004-10-21T09:11:08+09:00 Subject: Re: Python vs. Ruby (Re: A concise description of Ruby?) Hi, > - @vars sux Used often with a nice syntax color. Can't be beaten by (self) self. > - $vars too Used for global variables, matches from regular expressions and 10 to 20 "Perl" variables. With a nice syntax color and after getting used to them, they become handy. > - why should I write 'end'?? Better to use "end" or "}" than to use spaces or tabs. Ruby is much more maleable because of these. And you can see that in ERuby, ERB or RHTML. :-) (code generation) > - functions should be objects and __call__ is cool (the function > aplication operator, () ) AnyClass() is not as meaninful as AnyClass.new. This remindes me of capitalization issues. Ruby is clearer: - methods and variables names start with a lower case character - classes and modules start with an upper case character. With Ruby we call the methods directly from the objects, which make () kind of irrelevant, and Ruby allows us to not use them. anObject.method1.method2 This chaining of methods isn't recommended (train wreckage), but they aren't forbidden as well. Actually, we get addicted to them. It looks pretty. > - multiple inheritance is a good thing Mixin is an awesome solution for most problems. It has an ugly name, but it's an included module. A Ruby module is module Easy end > - __nonzero__ is sometimes useful (#to_bool for rubyists ) Not sure about this, but if anObject end is boolean enough most of the time. if anObject is not nil, then the following block is executed. > - blocks are useless Wow. They make up for the shortest solutions for many problems. Closures and blocks are awesome and addicting. > - python's metaclasses are great Maybe. But Ruby is very extendable. And when it comes to modules, classes and objects, hard to beat. > - list comprehensions are far better than map() and the likes Maybe. But closures and maps allow for some neat solutions. List comprehension is too alien for me. > - hey, writing self is good, you can name it cls or ignore it when non > writing instance methods Many Python programs may not use OO for the "self" reason. :-) OO can be as complicated and as easy as one wants. With Ruby, OO is piece of cake. > - having separated concepts for statements and expressions is useful > (just heard once) Don't know about this. > - callcc is the devil Never used it. :-) > - TIMTOWTDI is a wrong concept Don't know about this. > - general dislike of %stuff literals Don't know about this. > - lack of named arguments Hashes may be used? :-) > - docstrings are cool Cool. > note that not all of them think all this, I just summed all the > different critics. Thanks for them. It's hard to know exactly from where to start when comparing the two. But they aren't interchangeable. I can't use Python with the fluidity that is possible with Ruby. > But I think they just had a quick look at ruby, not a deep one, and they > usually agree that in the end there are far more similarities than > differences. It's hard to study both languages deep enough to make a fair comparision. The best comparision may be with examples. Cheers, Joao