Hacker News new | ask | show | jobs
by KenoFischer 3556 days ago
Many people think this was added for support of 0 offset arrays, but that's only a side effect really. This feature was requested by people who work with rather odd arrays (e.g. diagonal slices through high dimensional data). I have mentioned in previous threads on the subject that julia's 1-indexed arrays don't matter much in practice because the generic APIs hide that fact most of the time. This just adds the last bit of code to make that completely true and adds documentation/cleanup. For those seeking more information, I'd recommend Tim Holy's JuliaCon keynote on the subject: https://www.youtube.com/watch?v=fl0g9tHeghA
1 comments

> I have mentioned in previous threads on the subject that julia's 1-indexed arrays don't matter much in practice because the generic APIs hide that fact most of the time.

My guess is that most people who prefer zero-based feel strongly about it, and most people that like one-based don't care that much. If it really doesn't matter that much, I think Julia should've gone with zero. FFTs, Vandermonde matrices (least squares), polynomials, and pretty much anything where the array subscript relates to the mathematics is cleaner with zero-based arrays.

> My guess is that most people who prefer zero-based feel strongly about it, and most people that like one-based don't care that much.

FWIW, as someone in the latter category (liking one-based indexing), I'd say you're partially correct: I'm not emotional attached to 1-based indexing the way some 0-based folks seem to be, but it's a practical nicety and one of the things I'm really glad Julia chose to do. Making 0-based the default would definitely reduce its appeal to me.

Call it emotional if you like, but I won't use a language that has an off by one error built into its specfication :-)