Java News from Wednesday, October 28, 2009

Sebastiano Vigna has released version 5.1.5 of fastUtil, a collection of type-specific Java lists, maps and sets with a small memory footprint and faster access and insertion. The classes implement their standard counterpart interfaces such as java.util.Map and can be plugged into existing code. However, they also contain type-specific methods. For instance, the CharList class has not only the usual add(Object o) method but also an add(char c) method. Version 5.1.x adds new fast iterators with mutable entries and a hierarchy of function interfaces.

fastUtil suffers from the a common problem of open source projects: good code and thoroughly inadequate documentation. If it were just a question of poorly written documentation, it could be patched. Unfortunately the problem is more serious than end user documentation. The library is severely underspecified. For instance the add() method in IntCollection doesn't say whether the new element is added at the beginning of the list, the end, or some random location. Sure, you can test to find out the answer in this version (It's at the end) but how do I know that this will still be the right answer in 5.1.6 or 6.0? I don't. I can't tell if adding new items at the end is a deliberate decision or an accident of implementation. I thought there might be unit or acceptance tests, but if there are I couldn't find them anywhere. That gives me even less confidence that the contract is stable.

I am seriously considering reimplementing the parts of this library I actually need (just the primitive collection classes) from scratch using fully designed, documented, specified, and tested contracts. You don't need this level of detail for all projects, but for core libraries like this it's critical. fastUtil is published under the GNU Lesser General Public License (LGPL), so if I want to I could just fork it.