11 ms·
When I was learning QBasic some billion years ago I recall that I was happy with arrays generally starting at 1 (even though this is user specified in Basic). W
by rhacker 8y ago
When I was learning QBasic some billion years ago I recall that I was happy with arrays generally starting at 1 (even though this is user specified in Basic). When I learned C I initially wasn't thrilled about re-learning arrays, but eventually grew to only like 0-based arrays.
I'm thinking this is like people who drink coffee will cite studies saying it is good for you, and people who hate it will cite opposite studies.
- perl4ever 8y agomy @arr = (1, 2, 3); for my $i ($[...$#arr) { ... } It is however, advised not to change $[.
- perl4ever 8y agoAnd of course, there's Ada where you can use 'First and 'Last.
- kiliantics 8y agoI had been comfortably programming in C and python for years and found 0-based indexing to be perfectly sensible. For the last couple of years I've been programming a lot in Julia. Initially I was horrified by the idea of indexing from 1 but I got the hang of it remarkably fast. Now I feel it's totally natural either way, depending what language I'm in. I think it's only ever been a matter of preference as you say. And Julia was otherwise such a pleasure to write code in that it was easy for me to pay the small price to learn that.