4 ms·
I don't get why people care about this. How often does that hit you in normal code? It never bothered me in Lua, and certainly not in Julia. For me I just do a
by socialdemocrat 6y ago
I don't get why people care about this. How often does that hit you in normal code? It never bothered me in Lua, and certainly not in Julia. For me I just do a context switch. I know when I am in Julia I have to think about things like in my mathematics books. Just like you index a matrix.
When I am in other languages like C/C++ I tell myself that I working with memory addresses. For memory addresses 0-index makes more sense. For tables, matrices etc I honestly think 1-based indexing makes more sense.
Only time I dislike 1-based indexing in Julia is when I write code which is strongly related to how memory works. Like when I was implementing a CPU simulator and assembler.
- henearkr 6y agoIt depends on which kind of maths you refer to. After studying ordinal numbers, I feel like the normal way to start counting is from 0 (or the "empty set" ordinal). This is also how you prove something by transfinite induction, you need to start by 0. I wish I could easily recompile Julia so that it is 0-indexed. But then what about all the libraries...
- DNF2 6y agoMost well-written libraries do not depend on the specific type of indexing in an array. There's a strong convention for writing index-agnostic code, with eachindex(), enumerate(), firstindex(), lastindex(), begin, end, etc. I try to write code to accept 0-, 1-, 2-, and StarWars-based indexing.