Re:Why we created Julia - new language for fresh approach to...
by StefanKarpinski on Saturday February 18, 2012 @12:59PM
(#3607171)
At first we were going to use 0-based indexing, but it made porting any Matlab code over very hard, which defeats a large part of the purpose of having Matlab-like syntax in the first place — to leverage the large amount of Matlab code and expertise that exists out there.
However, as I've used it more and more, 1-based indexing has really grown on me. I feel like I make far fewer off-by-one errors and actually hardly ever have to think about them. This has led me to conclude that 1-based indexing is probably easier for humans while 0-based indexing is clearly easier for computers.
Re:Why we created Julia - new language for fresh approach to...
by wbhart on Saturday February 18, 2012 @01:35PM
(#3607274)
Many divide-and-conquer algorithms seem to be easier to express with 0 based indexing, whereas quite a few array operations seem to be better with 1 based indexing. I can certainly understand and appreciate the different points of view, I just personally always think about algorithms with 0-based arrays.
Re:Why we created Julia - new language for fresh approach to...
by warmfuzzykitten on Saturday February 18, 2012 @02:15PM
(#3607420)
As does anyone trained in the C tradition, but it's annoying, too, to have to translate 1-based math formulas to the C convention. Having recently used Octave for the Stanford online ML class after a couple decades of C, C++ and Java, I doubt programmers will have trouble with the mental transition.
Re:Why we created Julia - new language for fresh approach to...
by Peaker on Saturday February 18, 2012 @04:43PM
(#3607836)
We shape our tools and then our tools shape us.
Be careful when generalizing from your own personal preferences and cognitive biases to what is easier for humans in general.
Re:Why we created Julia - new language for fresh approach to...
by StefanKarpinski on Saturday February 18, 2012 @06:57PM
(#3608128)
Well, for what it's worth, I certainly also "grew up" with 0-based indexing (actually, literally grew up since I was a kid when I learned Pascal). I'm just saying that 1-based has really grown on me and that I find myself thinking about avoiding off-by-one errors far less often when using 1-based indexing. There are other times when I really wish I was using 0-based indexing. However, I find that that latter are more often times when I'm doing libraryish internals code, whereas the former are more common when I'm doing high level userish code.
Re:Why we created Julia - new language for fresh approach to...
by Peaker on Sunday February 19, 2012 @04:23AM
(#3609029)
My experience is the exact opposite.
I find 1-based indexing to be weird/illogical and prone to off-by-1 errors.
Inclusive/exclusive ranges as in Python along with 0-based indexing means the likelihood of any off-by-1 is negligible...
Also see Dijkstra's take on the matter: http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF for