From: Ryan Paul Date: 2004-05-13T04:38:53+09:00 Subject: Re: in search of a compelling reason to use ruby.... On Wed, 12 May 2004 18:04:17 +0000, gabriele renzi wrote: > il Wed, 12 May 2004 16:37:42 GMT, Ryan Paul > ha scritto:: > > > >> >>In python, we have map, filter, and list comprehensions, all of which can >>be used to manipulate lists in very general ways. In order to do certain >>things, python users have to stack multiple functions into map statements. >>Generally, this is actually pretty simple to do, and makes things somewhat >>intuitive. In ruby, there are a multitude of rather oddly named array >>functions that have very specific behaviors, most of which can be used >>with blocks to concisely describe extremely sophisticated operations. > > > In ruby there are a lot of Enumerable functions, not array's :) > What method do you think is oddly named ? > I for one, would say inject() but using reduce() or fold() is equally > non intuitive for me :) Its not so much that their names are strange, its the fact that they exist at all. In python, lists only have like 8 or 9 functions, and they are all pretty standard and self explanatory (append, count, extend, insert, remove, reverse, and maybe two or three others). Having things like collect, replace, assoc, and compact built into arrays is something of a novelty for a python programmer. I'm used to having to do replacement like this, for example: [y for x in listobj if x == z] Personally, I feel that it is better to have functions that do these things, because list comprehensions scale grotesquely, so I prefer the way ruby does it. Not only does ruby provide a ton of useful functions to start with, but I can add as many of my own as I want! Also, the fact that collect doesnt automatically compact really threw me for a spin. I was using "x.collect {whatever}.compact" until I figured out that it is easier to do a reject on the inverse of what I would have put in a python 'filter'. I added a 'filter' function to the array class that fixes this for me. Additionally, having two different names for the same thing (eg: collect and map) was initially confusing, but only because i'm not used to such things. Python would NEVER do that. --segphault