Thursday, February 24, 2005

The STL in Java

One of the most pleasurable parts of C++ is the STL. Some benighted souls have created Java equivalents in the JGA project now that JDK 5 has generics. If this excites you, read what you can do with iterators and functors. It is not as elegant as C++, but the idioms are much more functional than most Java coders are used to. Until Java has closures, it will do.

UPDATE: I do not want to give the wrong impression. JGA is quite nice for what it is trying to do. The inelegancies that crop up are due to Java, not JGA. It is the same old story: trying to use anonymous classes for closures, lack of mixins, et al. If you want a more elegant version of Java, try Scala or Nice. But do try JGA for your Java projects.

2 comments:

Anonymous said...

Thanks for the link to the jga project. I hope that what you found inelegant is more a reflection of java and its generic mechanism, but if it's anything I can improve in the design, I'd be interesting in getting the feedback.

Anonymous said...

Thanks for the clarification: I was never really worried about how you'd phrased it, and I hope some humor came through in my comment.

There was a semi-serious root, though. I have made a few design decisions that have been questioned, and legitimately so -- anytime you do something that's a little out of the main, those that view the work are right to wonder if the reasoning is sound. So far, once I've explained the causes and goals that have led me in the direction I've gone, folks with questions seem satisfied with the justifications.