Oh, and though I don’t have the time, I just feel compelled to do some bitching about the overhead of object headers. In C++ I can instantiate 70 million objects just fine. Try that with Java, and you’ll be hearing the wooshing sound of 560M of pure object header overhead flying by your head. No doubt the objects will be optimized for alignment, so you can be sure to hear hundreds of more megabytes of space go wooshing by in the form of padding.
What’s the only technique to combat this? Allocate everything as freaking arrays:
float node_x[]; // x values
float node_y[]; // y values
int[] link_to_node; // index of to node
int[] link_from_node; // index of from node
int[] node_link_indices; // indices of the links for individual nodes
and so on…
Now you have to use some annoying flyweight pattern all throughout your code. Plus you’ll be suffering array access penalties just about everywhere. sigh
The C++ code is about 10x more readable than the Java code. It’s rare that you’ll hear me make a statement like that.
On the other hand, I can happily say that I’m enjoying the new JNI direct byte buffer facilities in JDK1.4. That was a stroke of pure brilliance.
God bless,
-Toby Reyelts

