4 ms·
Julia aims to also be a C-Compatible low-level language with manual memory management in addition to the GC. When building data-structures you're often using s
by j-pb 3y ago
Julia aims to also be a C-Compatible low-level language with manual memory management in addition to the GC.
When building data-structures you're often using small unsigned integers that use the complete value-space, (e.g. u8s and their bitsets in tries, u16s and blocks with that size in sparse vectors).
With 1 based indexing, you can't do that anymore without first having to cast the index into the next larger integer, adding 1, and then doing the access, which is a PITA, adds instructions, and messes with prefetching, while you're already working with difficult, hard to read, and heavily optimised stuff.
- raccoonDivider 3y agoWhy can't the compiler decrement indices as needed? It makes sense to keep 0-based indexing in the final binary, but the language's design doesn't constrain that.
- daynthelife 3y agoMy issue with one based indexing is more philosophical in nature. I truly believe to the core of my being that zero is the first number, and that indexing from one is simply wrong. The evidence leading me to this conclusion is that I have yet to know of a single instance where a procedure or mathematical formula becomes simpler when indexing from one; yet there are so many that become simpler when indexing from zero. To this extent, I find it almost offensive that a language geared toward mathematicians would intentionally choose to index from one.