| Julia was developed by scientists that used math software like MATLAB. Most mathematics software uses 1-based indexing. (Previous comment about this.[1]) >with 1-based indexing: T[(h-1) * W * C+(w-1) * C+c] Your example showing how cumbersome and ugly it is to subtract 1 -- isn't how the intended audience uses mathematics software. Instead, they would use idiomatic multidimensional access with commas or multi-brackets syntax that understands 1-based indexes. They do not manually multiply and add the offsets into a raw 1-dimensional array. (E.g. idiomatic T[x,y] or T[x][y] instead of contrived T[(x-1) * W+(y-1)]) It's also the same concept for MS Excel. In VBA macro programming code, one doesn't need to litter the code with "minus 1" everywhere. The 1st row and 1st column (cell A1) is addressed as "1,1" in the Visual Basic function "Worksheets!Sheet1.Cells(1, 1)" Mathematics software has a tradition of 1-based indexing probably because many (most?) equations in written mathematics are 1-based. (Examples [2] [3].) It doesn't seem so unreasonable that scientists prefer that their math programming code has 1-based indexes to match the 1-based indexes in traditional math notation. [1] https://news.ycombinator.com/item?id=11072438 [2] average : summation symbol ∑ has "i=1..n" not "i=0..n-1": https://en.wikipedia.org/wiki/Average#Arithmetic_mean [3] linear algebra matrices : i and j subscripts begin at 1,1 and not 0,0: https://en.wikipedia.org/wiki/Matrix_(mathematics) |