4 ms·
It's just bikeshedding IMO. When I write C# code, array indices are like memory operation in my mind. When I go to Octave indices are like subscripts on sequenc
by jjaredsimpson 11y ago
It's just bikeshedding IMO. When I write C# code, array indices are like memory operation in my mind. When I go to Octave indices are like subscripts on sequences to me. Anyone who think it really makes a difference is being ridiculous.
I think zero based is "prettier" because of half open intervals, but it really doesn't matter.
- eggy 11y agoI don't think it is bikeshedding IMO from a pure mathematics point of view. In set theory you begin with the empty set as zero, and the next integer is N+1. I find it interesting that the Julia devs have gone with APLs style of slicing, and did not move to 0-based indexing. Ken Iverson, who created APL and later the J programming language, chose 0-based indexing for J. APL has a system variable QUAD-IO that allows you to choose your indexing value of 0 or 1, which leads to many issues. Iverson's books on math (Arithmetic, Calculus, and the Concrete Math Companion (Knuth's book done in J)) all to demonstrate mathematics in J, all begin at Chapter 0. I think the choice of index in APL is a bad idea. I have run other people's code, and realized it doesn't work because they set their indexing to 1 vs. 0 for me. People and programmers can work around most things, but I think if you are a functional programmer, and mathematics is your thing, you are more comfortable with 0-based indexing. This of course does not address scientists, for whom pure mathematics is not at the forefront of whatever they are working on. I do think it leads to problems down the road for 1-based indexing.