I was looking at the Julia Developer Survey 2022 and noted that one-based indexing was a feature of the language that you could choose to like or dislike.
In the light of recent discussions here, here, and here and the general recommendation to avoid using the idiom
for i=1:length(v)
Can we still say that Julia’s indexing is one-based?
I would argue that most things in julia core/base are still using 1 based, so I’d call it one based.
Then there have been built some generic interfaces so that code can support general cases, and that is just nice so you dont have to specialize on everything. Makes it more composable.
Julia’s Array is one-based. That doesn’t mean “Julia’s indexing” is one-based though, since indexing is clearly defined as the dispatch getindex and the available indices are defined in the interfaces as those returned by axes. Because of that, “is Julia one-based” is somewhat undefined: types can have an indexing Base but the language does not.
Everyday use doesn’t 1-base because if you do that instead of using more generic iterators then GPUs and other array types aren’t supported. Most libraries are careful not to do this for a reason.
To truly eliminate the influence of 1-based indexing outside of Array and Tuple, I propose Julia 2.0 should rename first(1:10) as beginning(1:10), and provide an offset option for users who prefer zeroth(1:10) or second(1:10), all of which should evaluate to 1.
This is basically a legacy discussion at this point, held over from an ancient time. As already highlighted, you can index however you want and the best practice is to dispatch for different index schemes.