next up previous contents index
Next: Syntax Up: Multiarrays Previous: Multiarrays   Contents   Index

Multidimensional Arrays and Multiarrays

Standard Java provides multidimensional arrays. These multidimensional arrays are implemented as arrays of arrays. Amongst other things, this means they can be ``ragged''--not all rows of a two-dimensional array, for example, need be the same length. Even if an array is initially created as rectangular, later assignments to the elements of the outer array can change this. The shape of a Java multidimensional array is not immutable. Here are a couple of examples:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{verbatim}int ...
...first row twice as long as others).\end{verbatim}\end{minipage}\end{displaymath}

This flexibility might be exactly what is needed in certain contexts. But in other contexts--if we only ever needed a rectangular array--it is an overhead. It makes the program somewhat harder to analyse, both by the programmer and by the optimizer embedded in a compiler or virtual machine. Also it makes it hard to sensibly define the general kind of regular sections that Fortran programmers are accustomed to using in their programs.

Various people have pointed out this shortcoming of Java, including members of the Java Grande Numerics Working Group (math.nist.gov/javanumerics), who made a series of proposals to improve Java in this respect--both through class libraries and syntax extensions. The general idea is to introduce a new kind of multidimensional array, different from the existing multidimensional arrays of Java. The working group called the new arrays multiarrays. HPJava follows their terminology, and our syntax also closely parallels many of their recent proposals.

Another interesting development in this connection has been the emergence of Microsoft's competitor language to Java, C#. Along with several other extensions relative to Java, Microsoft have added a kind of multiarray. One defect of C# multiarrays, however, is that they don't currently support regular sections.


next up previous contents index
Next: Syntax Up: Multiarrays Previous: Multiarrays   Contents   Index
Bryan Carpenter 2003-04-15