News for hackers. Stuff that matters.
Re:Julia's Arraypocalypse Release by jules on Sunday September 27, 2015 @01:07PM (#10287144)
For what it's worth, I've ran into this a couple of times. Maybe it's just because I'm more familiar with 0-based indexing, but I think it's not just that. In every case the 0-based indexing had fewer (+1)'s and (-1)'s than the 1-based code. For instance k%n returns a number in the range [0,n), or in Julia notation [0:n-1]. When you want to do array indexing with that, you need (k%n)+1 in Julia.

Btw, Matlab also uses 1-based indexing, no? I thought that Julia chose 1-based indexing to get brain backwards compatibility with Matlab.

Re:Julia's Arraypocalypse Release by ViralBShah on Sunday September 27, 2015 @01:26PM (#10287200)
Not just Matlab, but many technical computing languages use 1-based indexing. Julia was never intended to have any compatibility with Matlab.
Re:Julia's Arraypocalypse Release by jjaredsimpson on Sunday September 27, 2015 @02:16PM (#10287345)
It's just bikeshedding IMO. When I write C# code, array indices are like memory operation in my mind. When I go to Octave indices are like subscripts on sequences to me. Anyone who think it really makes a difference is being ridiculous.

I think zero based is "prettier" because of half open intervals, but it really doesn't matter.

Re:Julia's Arraypocalypse Release by eggy on Monday September 28, 2015 @07:44AM (#10289903)
I don't think it is bikeshedding IMO from a pure mathematics point of view. In set theory you begin with the empty set as zero, and the next integer is N+1. I find it interesting that the Julia devs have gone with APLs style of slicing, and did not move to 0-based indexing. Ken Iverson, who created APL and later the J programming language, chose 0-based indexing for J. APL has a system variable QUAD-IO that allows you to choose your indexing value of 0 or 1, which leads to many issues. Iverson's books on math (Arithmetic, Calculus, and the Concrete Math Companion (Knuth's book done in J)) all to demonstrate mathematics in J, all begin at Chapter 0. I think the choice of index in APL is a bad idea. I have run other people's code, and realized it doesn't work because they set their indexing to 1 vs. 0 for me. People and programmers can work around most things, but I think if you are a functional programmer, and mathematics is your thing, you are more comfortable with 0-based indexing. This of course does not address scientists, for whom pure mathematics is not at the forefront of whatever they are working on. I do think it leads to problems down the road for 1-based indexing.
Re:Julia's Arraypocalypse Release by onnoonno on Sunday September 27, 2015 @01:53PM (#10287273)
Julia looks very interesting but honestly, exactly the 1-based indexing makes it feel really awkward and turns me off every time I think about using it somewhere.

Wouldn't it be possible to create array classes in Julia that all indexed zero-based? I would welcome a 'Julia0' fork :-)

Re:Julia's Arraypocalypse Release by jules on Monday September 28, 2015 @03:31PM (#10292549)
While I agree that it's an annoyance, it's a very small annoyance. Since Julia has for loops and Julia ranges use the same 1-based convention you don't run into it often.