LOCI Software Articles

LOCI software articles

View My GitHub Profile

From a practical perspective, we use Java because it is cross-platform and widely used, with a vast array of libraries for handling common programming tasks. C++ or Python would also have been reasonable choices, but we chose Java because it is easier than C++ and faster than Python, with a larger assortment of de facto standard libraries (e.g., Swing) than either.

Java is also one of the easiest languages from which to deploy cross-platform software. In contrast to C++, which has a large number of complex platform issues to consider, and Python, which leans heavily on C and C++ for many of its components (e.g., NumPy and SciPy), Java code is compiled one time into platform-independent byte code, which can be deployed as is to all supported platforms. And despite this enormous flexibility, Java manages to provide time performance nearly equal to C++, often better in the case of I/O operations.

Historically, LOCI’s software projects grew around efforts to harness VisAD, a Java component library for interactive and collaborative visualization and analysis of numerical data, within our VisBio application for visualization of multidimensional microscopy data. We also added support for several microscopy formats to VisAD before splitting the code into a standalone library, Bio-Formats. The choice to use Java and VisAD (rather than, e.g., C++ and VTK) was partially motivated by the fact that LOCI’s lead software architect Curtis Rueden was already an expert on Java and VisAD technologies. Choosing Java also enabled cross-platform integration with ImageJ, one of the most popular freely available image processing tools in the life sciences field, as well as with the OMERO system for visualization, management, and annotation of microscopy data.

Isn’t Java too slow?

Java’s time performance has been comparable to C++ for many years now, especially in the realm of file I/O where SCIFIO is focused. According to one thorough study performed in 2005, “Java often outperforms C++ in operations such as memory allocation and file I/O while C++ often outperforms Java in arithmetic and trigonometric operations.” This statement is corroborated in an earlier study from 2004 that also includes an I/O benchmark: “If we exclude the trigonometry component, Java performed virtually identically to Visual C++, the fastest of Microsoft’s languages.” Some of the theoretical basis for such results is discussed in another 2004 article, which also finds that “Java performance on numerical code is comparable to that of C++, with hints that Java’s relative performance is continuing to improve.”

We have seen two refutations ([1][2]) of these figures, but neither includes an I/O benchmark, and according to their results Java’s computational performance is within a factor of two of C++’s. Even from a pessimistic perspective, we believe the trade-off is acceptable when considering the other advantages of Java such as cross-platform deployment, widespread support and ease of development. As the second article above states: “It seems that it’s much, much easier to create a well performing program in Java. So, please consider it for a moment before you start recoding your Java program in C++ just to make it faster.”

For further reading, check out this June 2010 article on popular Java myths, and Wikipedia’s comparison of Java performance to other languages.

Isn’t Java too complicated?

Compared to Python, sure. But statically typed languages like Java have enormous potential for just-in-time optimization. Check out the GraalVM project. Java combines the benefits of performant JIT-compiled execution with “write once, run anywhere” source code—something other major languages have still not fully achieved.