2006/5/26, Ryan Leavengood <leavengood / gmail.com>: > On 5/26/06, Robert Klemme <shortcutter / googlemail.com> wrote: > > > > With all due respect, what you wrote shows that you lack some basic > > understanding of software engineering. Choosing between a Set and a > > List is by far not a premature optimization but a deliberate design > > decision. Knowing algorithmic properties of these basic abstract data > > types is one of the required skills of someone engaged in software > > engineering - even if Ruby has only so few of them, and probably needs > > less of them because of its design. I suggest you get yourself a book > > on Data Structures and Algorithms (for example the excellent books of > > Robert Sedgewick) and digest it. > > Believe it or not, I actually have a degree in Computer Engineering > and have been paid to develop software for about 10 years. I realize > in languages like Java and C++ you are going to consider the > application when choosing a data structure...that is drilled into you > in algorithms and data structures class. I get that. > > My argument is that in my experience, this is not necessary in high > level languages like Ruby. There are two reasons I feel this: > > 1. Ruby doesn't really provide a wide variety of data structures to > work with. Do you consider this a flaw Robert? It seems you do. I > would argue adding too many data structures would overly and > needlessly complicate Ruby, at least where those data structures > provide duplicate functionality, but through different means (linked > list versus array list versus stack, etc.) I did not say that I consider Ruby's design of collection classes flawed. Some classes would come in quite handy once in a while (a sorted set for example) but it's nothing I'm seriously missing. And it's certainly not a handicap of Java to have so many of them. In fact I like that having such a rich standard lib - this is something that sets Java apart from C++ where you usually need some external libs to get the same functionality - even collection wise - which often causes a lot of headache. I am arguing against your statement that Java's design is negative because it contains so many collection classes. And I was pointing out that Java's multitude of collection classes is not caused by static typing. I still don't see that static typing causes this, maybe you can shed some more light on this. > 2. In most uses of Ruby, drilling down to determine the right data > structure in the beginning of development is a waste of time and is > certainly premature optimization. If you are writing a script to > process some text files I seriously doubt using the "proper" data > structure will improve performance in any noticeable way. Even with > bigger apps like Rails most of the overhead is in the database and > network calls, so why would you waste time optimizing data structures > which will not really impact real performance? That sir, is premature > optimization. Choosing data structures is not only about performance. It's about functionality and also documentation - if I need a set I choose Set, if I need a map I choose Hash, if I need a stack or list I choose Array... And it doesn't take me much "drilldown" time to determine if I use a set or a list. > Since we are recommending reading, I would suggest you read some > articles or books about agile development, and such concepts as You > Aren't Gonna Need It (YAGNI.) I don't think agile methodologies make the distinction between sets and maps or sets and arrays superfluous... Regards robert -- Have a look: http://www.flickr.com/photos/fussel-foto/