6 ms·
Every time I look at Julia, I like it a lot, right up to the point where I remember that indexing is 1-based and I loose the will to go on.
by benji-york 9y ago
Every time I look at Julia, I like it a lot, right up to the point where I remember that indexing is 1-based and I loose the will to go on.
- newen 9y agoRolls eyes. 0 or 1 based indexing is one of the smallest thing to worry about in a programming language.
- e12e 9y agoI am in the odd situation that from habit collection[0] feels natural - but I actually think "first element" makes a lot more sense than "item at zero offset". Except maybe for things that are actually pointer+offset (which I think very rarely makes sense in high level languages/most ADTs). In fact, I think for situations where 0-based indexing makes sense, I'd prefer "memory_area+offset" rather than "pretend_collection_type[offset]". I also usually talk about "the first character" of a string, or first word of a sentence; not "word at zero offset from start". So yeah, I think Dijkstra's wrong on this one (or rather he has some very strong opinions on greater-/less-/-and-equal-to, and which are natural - for which I have little sympathy outside of abstract discrete math papers). http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
- KenoFischer 9y agoOne nice thing about Julia is that you basically never have to think about the indices. One of the primary reasons for this is that people using julia like array types with all types of strange and wonderful index sets (e.g. skew lattices to slice through a higher-dimensional array which people in medical imaging like apparently). As such, there are easy and convenient abstractions that are independent of the index space and all of the standard libraries and most external packages use these (to be able to deal with non-standard arrays).