Array Syntax History – How Did the Custom of Using Square Brackets Develop?

arrayhistorysyntax

Many programming language use the syntax a[i] to refer to the i'th element of an array, sequence, or vector a – specifically, C and Pascal (from the late 1960s and early 1970s) do this. On the other hand, some earlier languages, like that Fortran (from the 1950s), don't use this convention. Also, I studied a bit of math, and mathematicians use square brackets for intervals, and subscripts for, well, array and matrix subscripting (or regular parentheses if the array is thought of as a function from non-negative integers).

So, my question is: Where/how/in what context did this square brackets for array subscripting develop, and by whom?

Note: Not at all a dupe of this question about the use of curly brackets in C.

Best Answer

The main precursor language to C and Pascal was Algol. The earliest version of that was Algol 58 which used square brackets for array declarations and references.

The reason that Algol used square brackets rather than, for example, parentheses was three-fold:

  1. because they could. The early IBM keyboards, that Fortran was designed with, only had parentheses. This had changed by the time Algol was being specified.
  2. experience with Fortran had shown that programmers were often confused with the over use of parentheses so it was seen as an important syntactic change.
  3. the intent behind Algol was that it would be used for describing algorithms so having it closer to standard mathematical notation made sense.

Note, unlike C, which uses arrays mostly to index memory, Algol allowed both lower and upper index bounds to be specified. Again, this was in keeping with its more mathematical intent. So much so, in fact, that Algol was the de facto language for pseudocode for many years.

Related Topic