3 ms·
I started programming in assembly, then Fortran, Algol, COBOL, etc. 0 based index makes sense to me. The memory location is offset 0 bytes from where the firs
by WaitWaitWha 4y ago
I started programming in assembly, then Fortran, Algol, COBOL, etc.
0 based index makes sense to me. The memory location is offset 0 bytes from where the first data byte is stored (without getting into endianism).
- degrees57 4y agoFor me, it was 1 based index that makes sense to me. I started programming in FORTRAN, then COBOL, then (Lord help me) RPG II. All had 1 based arrays. I got paid to program in RPG II eight hours a day, five days a week, for two and a half years. A common bit of code was to create an array of month names. Then take an input date, say 20220825, and split that into $Year (first four characters) and $MonthNumber (next two) and $Day (next two). $MonthIndex = strip the leading zero (if present) from $MonthNumber Then, this code worked: $MonthName = @Month[$MonthIndex] When I ran into my first language with 0 based arrays, and @Month[1] returned February, I was pretty much convinced you all had gone insane. December is an out of bounds condition now? Really? Much later, a friend explained the stuff about multiplying the index by the array element length, and easily getting the memory location of the item in that array. It does make sense; but, I've always hated the code I've had to write that says $MonthName = @Month[$MonthNumber - 1]