News for hackers. Stuff that matters.
Re:Why we created Julia - new language for fresh approach to... by wbhart on Saturday February 18, 2012 @09:22AM (#3606621)
It would certainly be nice if there was an option to use 0 based indices in blocks of code. It's understandable in that they are pitching at the technical community, and many mathematical papers and books are written with 1 based indices. But I am a mathematician who prefers 0 based indices.
Re:Why we created Julia - new language for fresh approach to... by fijal on Saturday February 18, 2012 @09:43AM (#3606660)
It seems like both 0 and 1 based arrays is asking for trouble :) I would prefer 0-based, but still prefer 1-based to mixed or optional.
Re:Why we created Julia - new language for fresh approach to... by javajosh on Saturday February 18, 2012 @01:43PM (#3607312)
We are scientists and so willing to compromise, yes? So how about 0.5-based arrays? :)
Re:Why we created Julia - new language for fresh approach to... by Danieru on Saturday February 18, 2012 @03:24PM (#3607647)
Only if it is in base .5
Re:Why we created Julia - new language for fresh approach to... by ViralBShah on Saturday February 18, 2012 @01:36PM (#3607278)
Actually, it is quite easy to implement 0 based indices or any other indexing scheme in julia, since all the array indexing code is implemented in julia itself.

https://github.com/JuliaLang/julia/blob/master/j/array.j#L15...

I personally would find multiple indexing schemes confusing both for usage as well as to develop and maintain. Given that 1 based indexing seems to be a popular choice among many similar languages, we just went ahead with that.

Re:Why we created Julia - new language for fresh approach to... by chancho on Saturday February 18, 2012 @03:29PM (#3607660)
Have you looked at the Haskell Ix class? http://www.haskell.org/onlinereport/ix.html

It generalizes the choice of 0 or 1 to an arbitrary starting index. So when you create an array you specify not just where it ends but also where it begins. This lets you do neat things (consider a filter kernel with range [-s,+s]^n instead of [1,2s]^n) and the extra complexity it adds can be hidden when not needed using for-statements or higher order functions.

Nobody uses it because the implementation is not very efficient and Haskellers have a chip on their shoulder about performance. It subtracts the origin and computes strides on every index, but you could easily avoid this by storing the subtracted base pointer and strides with the array. Of course when you go to implement it you'll see light on 0-based indexing :)

Re:Why we created Julia - new language for fresh approach to... by wbhart on Sunday February 19, 2012 @09:22AM (#3609394)
The problem with changing it in the library is that you'd also have to change it everywhere arrays are used in Julia itself.

The only way I could think to manage it would be a pragma which switches 0-based on for a given file. But this is doubtlessly not trivial.

Or there is the less elegant option of introducing a new operator for 0-based arrays. But this is liable to cause confusion I think.

Re:Why we created Julia - new language for fresh approach to... by svdad on Saturday February 18, 2012 @11:33PM (#3608655)
Perl still has this with $[ but it's deprecated as of 5.12.