News for hackers. Stuff that matters.
Re:The unreasonable effectiveness of the Julia programming l... by Athas on Friday October 09, 2020 @04:31PM (#24734123)
Almost all languages above the C level has nice abstractions for this, but you still sometimes need to do it for various reasons. Basically, whenever the indexes don't matter, then 1-indexing and 0-indexing are equivalently good, but when they do matter, then 0-indexing leads to neater calculations.
Re:The unreasonable effectiveness of the Julia programming l... by fghorow on Friday October 09, 2020 @11:23PM (#24736489)
OffsetArrays.jl is your friend.

I'm working on a project where indexing naturally runs from -n to n. I kludged the usual index hackery and was so plagued with off-by-one errors that I gave up on it. Then I remembered Tim Holy had a blog post about OffsetArrays.jl and started using that.

Problem solved.

Seriously, the most annoying thing I find about Julia is that the various packages fairly often have "creative" names, that make it difficult discover that they might actually be useful.

YMMV.

Re:The unreasonable effectiveness of the Julia programming l... by porker on Saturday October 10, 2020 @06:02AM (#24737841)
> I'm working on a project where indexing naturally runs from -n to n. I kludged the usual index hackery and was so plagued with off-by-one errors that I gave up on it. Then I remembered Tim Holy had a blog post about OffsetArrays.jl and started using that.

Ah, thank you. I've been tinkering around with Julia, and was trying out 2D random walks. Not being able to use a 2 dimensional array and store the position [0, 0] confused me. I ended up starting at X,X (where X > total number of moves) and then got stuck with plotting it nicely, because I wanted the plot axes to show how far it had moved, not X +- how far it had moved.

Re:The unreasonable effectiveness of the Julia programming l... by 7thaccount on Friday October 09, 2020 @09:36PM (#24736089)
There are plenty of matrix uses where 1-indexing is more natural. I think the main reason Julia uses it is to be more consistent with Matlab.