3 ms·
If it weren’t for the one based indexing, I would use Julia for almost all my math research. Overall it is a very well designed language, and a ton of things ju
by daynthelife 3y ago
If it weren’t for the one based indexing, I would use Julia for almost all my math research. Overall it is a very well designed language, and a ton of things just work.
But I can’t for the life of me understand how any language designer signed off on one based indexing.
- HappySweeney 3y agoDon't all the languages geared towards science and math use 1-based indexing?
- soulbadguy 3y agoI think the rational for one based indexing was to be closer to other languages used to numerical computation such as Fortran or Matlab. It's been a long time i have used any language with one based indexing, but i don't remember it being particularly important in my day to day.
- staunton 3y agoI've never understood why this bugs people so much. I switch between languages with zero-based and one-based indexing about every hour or so. Never had a problem beyond the usual "off-by-one's" that I do anyway even without switching. You have to keep track of which language you're using anyway to produce correct syntax...
- j-pb 3y agoJulia 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.