From: Ryan Leavengood Date: 2006-05-26T22:56:44+09:00 Subject: Re: Equivalent of collections in Java On 5/26/06, Robert Klemme 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.) 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. 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.) Regards, Ryan