last day (15 days later) » 

21:26
9
Q: Which programming language/environment pioneered row-major array order?

Leo B.The Wikipedia page describing specifics of row-major vs column-major storage order for multi-dimensional arrays, mentions, among others, C/C++ (*1), Pascal and PL/I for the former, and, surely, Fortran for the latter. Algol-60 is not mentioned. As a matter of fact, the Dijkstra-Zonneveld Algol-60...

Languages can only be said 'have' an ordering of elements when it is possible for a legal program written in that language to perceive that ordering. In Algol 60, for example, there is no way to perceive the 'distance' between a[0,0] and a[0,1]. To put it another way, as long as you remain in Algol 60, the implementation can use row order, column order, Iliffe vectors, or anything else. Fortran has and needs a defined order because of all that EQUIVALENCE and COMMON stuff, which effectively allow overlaying variables on raw memory.
@dave Why the restriction "for a legal program"? It is my understanding that it was possible to perceive the ordering by a difference in performance of native vs transposed matrix traversal by nested loops as soon as mid-1960s.
OK, 'perceive' may have been the wrong word. Nevertheless, the program gives the same results of operations on the array, regardless of the storage order.
@dave True, and how does that observation affect the question? Or am I missing the point?
You said 'Algol 60 is not mentioned' as having either row or column order. My point is that the language (as distinct from a particular implementation) has no such thing. The wording of the question is such that it reads like you're saying a language has one or the other.
21:26
@dave For that reason there is "/environment" In the question title. Also, what language features justify inclusion of PL/I and Pascal in the "row-major" list?
PL/I - the language specification says that I/O of an array involves transfer of items in row-major order, which implies (but does not require, if intermediate buffering is used) the memory order is row-major. Page 83.
Why do you claim that C has no native multi-dimensional array types?
@dave A legal PL/I program is not able to recognize that, contrary to your criterion.
@thebusybee Because the C language syntax doesn't allow defining multi-dimensional arrays, and they have to be simulated using arrays of arrays.
This is simply not true. Even the stone-old K&R introduces them in chapter 5.7 and the standard (I looked into C99) says "When several ‘‘array of’’ specifications are adjacent, a multidimensional array is declared." Therefore, int a[3][5]; declares a 2D array. You might want to call this an array of arrays. But this is the nature of multidimensional arrays.
@thebusybee this is the nature of multidimensional arrays Of course it isn't. A multidimensional array can be represented as a tree-based map or a hash map from index tuples to values, FWIW.
21:26
@LeoB. A multidimensional array can be represented in any way you like in some languages, but C is not one of them. C has multidimensional arrays but the language specification defines their representation in memory. In C, a multidimensional array is defined as using an array of arrays for its implementation.
@JeremyP Jup, true, that 'can' prat is important. And only resolved when looking at a specific implementation. But so is notation moot point. There are languages where array(y,x) and array(y)(x) are alternate ways to address the same element, so neither can be used as indicator what a 'real' multidimensional array is.
@LeoB - re PL/I. I was looking in the language spec for justification for Wikipedia's claim that PL/I required row-major order. If the I/O does not justify that conclusion (though can't you write an array and read it back item by item?) then perhaps Wikipedia is just wrong. I have no opinion on that beyond inferences from the spec.
Storage order wasn't really considered important in high-level languages until the rise of virtual memory. THEN, because of the negative impact of paging caused by accessing memory out-of-order, languages began to be more explicit about their internal storage order.
@thebusybee, it is a fairly widespread interpretation of C that indeed it does not have true multidimensional arrays. This comes from making a distinction between multidimensional arrays as monolithic objects, such as Fortran's, and C-style arrays of arrays that have semantically distinguishable sub-objects between the n-D array and the individual elements. This is probably not a useful distinction within the context of a single language, but it is a reasonable aspect on which to compare different languages.
@JeremyP Precisely. That's why the sentence in bold in the question uses "multi-dimensional array types" rather than "multi-dimensional arrays".
21:26
@RBarryYoung: Storage order was important whenever code written in different languages (including a high-level language and hand-generated machine code) would need to interact; from what I understand, FORTRAN accommodated such possibilities essentially from the get-go.
@RBarryYoung Fortran has the EQUIVALENCE statement. Its semantics demand a well-defined storage order.
Does C even define one thing as rows and another as columns? It seems to me like it doesn't. It just defines a rectangular buffer of lines stacked end-to-end. We tend to think of these as a column full of rows, but without matrix math in the language spec the lines could just as easily be column vectors.
@davolfman If there is a multi-dimensional array stored in memory, and if for such array elements that are adjacent in memory and have all indices but one the same, and the remaining index differing by one, the differing index is the leftmost one, then the array storage policy is said to be column-major; if it is the rightmost one, it is said to be row-major.
 
2 hours later…
23:16
@LeoB. Now that's a nice wording. lovely.

last day (15 days later) »