06 December 2005

He hasn't a queue



James Robertson has an interesting and telling post in his blog,
We have a failure of Imagination, which has a reply to Elliotte Rusty Harold's Today's News, although my problems with the post are different than James'.

Java's List class does not lack any of the functionality in Ruby's. Java just factors it out into a few more classes, especially the Collections class, and skips a couple of rarely used "convenience" methods. The result is a simpler, easier-to-understand, easier-to-use, more humane API.

I'd hardly call the feeble classes in Java "humane", maybe "less intimidating" for the type of programmers that use Java. Programmers that have had some time using Java end up with large libraries of "methods" that work, and that fill in the holes in the Java libraries.

A bigger problem that I have with Elliotte Rusty Harold's post is that he makes some comments that I find astonishing.

Another example: Fowler likes the first and last methods in Ruby, but list.first() is not significantly simpler than list.get(0). list.last() is perhaps a little simpler than list.get(list.size() - 1) but only because Java stupidly indexes everything from 0 rather than 1.

Well, other than list.get(0).list.last() is considerably uglier and less obvious than list.first(), but then again, you can always document what you were trying to do so that some other programmer can understand the code.

But this is the comment that really takes the cake.

And how often do you actually need to get the first item in the list? Needing the last item in a list is even less common.


Is he kidding? Has he taken a Data Structures and Algorithms course? I'd recommend that he get the Data Structures book by Aho, et al. It's right on Amazon. The second chapter, "Basic Data Types", has sections on "The Data Type, List", "Implementation of Lists", "Stacks", "Queues", "Mappings", and "Stacks and Recursive Procedures". Since stacks and queues are pretty vital parts of quite a bit of the programming I've done and Mr. Harold's ignorance about the subject leads me to believe that he must have slept through that part of the course, since I assume that he does have training in the field of Computer Science. Hell, I learned that stuff ages ago, even though I went to college in the early '70s when that type of course didn't exist at the University of Michigan.

Cees deGroot has a similar viewpoint here.
(Trackback)