Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

The battle of the container frameworks: which should you use?

We compare ObjectSpace's JGL and Sun's Collections Framework to help you pick the best option

  • Print
  • Feedback
No self-respecting developer wants to spend his or her talents and precious time writing from scratch a linked-list or queue data structure, nor a simple sort or search routine to operate on the former. In this context, Sun made a big mistake by not including a container framework in the JDK beginning with version 1.0. Fortunately, ObjectSpace Inc. offered JGL -- The Generic Collection Library for Java (formerly known as the Java Generic Library). JGL gave those who refused to reinvent the wheel an extremely powerful framework for data structures and algorithms; a framework that made those who took the time to understand its philosophy more productive than those who didn't.

JavaWorld's own recent Collections-versus-JGL poll generated passionate responses from supporters of both frameworks. By now, JGL is an old and faithful friend to many Java developers (and my integrity as a reporter demands that I disclose my membership in this group), so it didn't come as a surprise that the new kid on the block, Collections, was greeted with mixed feelings -- at least by the majority of respondents to the poll.

In this article I attempt to compare the two frameworks objectively, without letting adrenaline (or testosterone) affect my evaluation. For the record, my personal goal for this comparison exercise was to determine the true value of Sun's Collections Framework. Before porting my JGL-based code to Collections, I need to know whether the hardly negligible resources spent on porting will be a worthwhile, long-term investment. I suspect many of you are considering the same question, and hope this comparison will help you as much as it has helped me.

This article does not provide an introduction to ObjectSpace's JGL nor Sun's Collections, although the fundamental nature of these libraries should mean that most readers will be able to follow the material and discussion that will follow. Refer to JavaWorld's previous articles on JGL and Collections for detailed introductions. (See the Resources section at the end of this article for links.)

In the course of this article, I will present some tables (in the same style as those in my comparative book reviews) that will necessarily have framework A on the right, and framework B on the left. After careful consideration, I've chosen to put JGL on the left and Collections on the right of all side-by-side tables -- mainly because JGL, in most instances, provides more features than Collections. This ordering does not imply that this comparison is a guide-in-camouflage to porting from JGL to Collections (nor that porting from Collections to JGL is an unreasonable option to consider).

The versions of the libraries compared are:

  • JGL version 3.0.2 (from now on, simply called JGL)
  • Collections from JDK 1.2 Beta 4 (from now on, simply called Collections)


(Although I -- and JavaWorld -- normally frown upon comparisons between unfinished and finished products, Sun assured me that the Collections API is highly unlikely to change in any significant way from beta 4 to its final release, so the advanced beta status for Collections should be irrelevant. Only the implementation, which lies thoroughly behind the API facade, may change between now and the final release of the Java 2 platform.)

  • Print
  • Feedback

Resources
  • ObjectSpace's JGL home page http://www.objectspace.com/developers/jgl/
  • Sun's Collections Framework home page http://java.sun.com/products/jdk/1.2/docs/guide/collections/index.html
  • See the JavaWorld article on JGL "Need a good set of abstract data structures? ObjectSpace's JGL packs a punch!" http://www.javaworld.com/javaworld/jw-06-1997/jw-06-jgl.html
  • See the JavaWorld article "Get started with the Java Collections Framework" http://www.javaworld.com/javaworld/jw-11-1998/jw-11-collections.html
  • See the JavaWorld article "Speed up batch file processing using generic programming and core reflection" http://www.javaworld.com/javaworld/jw-11-1998/jw-11-batch.html
  • The Java Tutorial section on Sun's Collection Framework is available at http://java.sun.com/docs/books/tutorial/collections/index.html
  • For an interview with Alexander Stepanov, see http://www.bml.ca/marine/stepanov.htm
  • David R. Musser provides a page on generic programming (Musser worked with Stepanov) http://www.cs.rpi.edu/~musser/gp/
  • Matthew Austern and Alex Stepanov did some generic programming work for JavaJAL (Java Algorithm Library) http://reality.sgi.com/austern/java/index.html