From: Nikolai Weibull Date: 2004-10-21T08:42:11+09:00 Subject: Re: Python vs. Ruby (Re: A concise description of Ruby?) * gabriele renzi [Oct 21, 2004 00:40]: > > Counter examples are (somewhat) welcome ;-) > I know some, the points I remember are: And here is what you should respond to their counterexamples: > - @vars sux > - $vars too These are certainly not very hard-hitting counterexamples. @vars tells both you and Ruby that 'var' is a class member variable. What can be better than that? Prefixing class member variables with m_ perhaps? Or perhaps just _? $vars tells both you and Ruby that 'var' is a global variable. What can be better than that? You're supposed to minimize the number of these in a program either way, so seeing these is a bad sign either way and so you solve your own problem with "ugly" variable-scope specifiers by not using them (and thus not global variables). Either way, _you_ win. > - why should I write 'end'?? Because you're telling both Ruby and yourself where something ends? Sure, Python uses indentation (and thus whitespace) for these things and we all know what problems people have with indentation and whitespace (tabs vs. spaces, make, and so on). > - functions should be objects and __call__ is cool (the function > aplication operator, () ) This is a joke, no? I'll assume it is and will stop here. > - multiple inheritance is a good thing Multiple inheritance has its merits, but generally it makes class hierarchies both harder for the compiler and for the programmer to understand. Very few objects one may want to model require multiple inheritance (mostly geometrics). You can do fine without it. > - __nonzero__ is sometimes useful (#to_bool for rubyists ) Why? In Ruby, everything but false and nil is true, so why would you want this? If you would want a #to_bool, then use that instead. Using pseudo-truthvalues on objects is both bad style and confuses the intention of the code. > - blocks are useless You are surely joking again, no? Blocks are probably the _one single thing_ that makes Ruby great. Blocks, or closures as they are often called, are what makes Lisp/Scheme great. They are basically what defines both Ruby and Lisp/Scheme. If you find them useless you surely shouldn't be using Ruby. Also, if they are useless, why does Python have them? > - python's metaclasses are great Why are they better than Ruby's? > - list comprehensions are far better than map() and the likes Yes, that's why Ruby doesn't have map(); that's why we have .map. Why do you find that l = [1, 2, 3] [i * 2 for i in l] is far better than l = [1, 2, 3] l.map{ |i| i * 2 } ? It's not like one version is longer than the other, or one is easier to follow than the other? In fact, the Python version requires the use of two keywords and an additional feature of list creation. > - hey, writing self is good, you can name it cls or ignore it when non > writing instance methods How is that a good thing? If you want to ignore it, then wouldn't you rather simply not mention it at all? If you had given a decent argument for this, such as "I use it as a reminder that obj.method(...) is more or less like writing method(obj, ...) as : is in Lua", then at least you would have made an argument for your point. > - having separated concepts for statements and expressions is useful > (just heard once) What do you mean? That everything shouldn't have a value? If so, why? I admit that it's not always useful, but there certainly are times that one appreciates this and there's no reason it shouldn't be this way. It only simplifies the concepts, both for the programmer, the language designer, and the compiler. Writing a denotational semantics for the language. > - callcc is the devil Yes, certainly, and look how easy it is to simulate in Python: http://www.ps.uni-sb.de/~duchier/python/continuations.html You obviously don't understand what you're talking about. You just followed some of the threads about continuations and thought to yourself, "Boy, I'm certainly not following this discussion. I'll just say that I think that call/cc is evil and people will think that I've thought this through and that I am somehow gifted." > - TIMTOWTDI is a wrong concept That's why Ruby isn't Perl. I can't really tell what you are getting at with this point. > - general dislike of %stuff literals You mean like %{literal}? Don't use them then. Is it better to have '''literal''', """literal""", r"literal", u"literal", ur"literal", U"literal", UR"literal", Ur"literal", and uR"literal". Yeah, that's certainly _a lot_ better. > - lack of named arguments While it is true that Ruby doesn't have named arguments as such atm (you may use hashes instead), there is a nice syntax in the works for later versions. > - docstrings are cool Yes, they are. Finally, an argument that actually stands up against simple critique. Ironic that it should be your last choice ;-). > note that not all of them think all this, I just summed all the > different critics. > 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. Hopefully not too many similarities ;-), nikolai -- ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka ::: ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden ::: ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 ::: main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}