Live data from Hacker News

Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

sinews.siam.org

21–30 of 249 posts

Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

#21
post #5

what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...

Call it bikeshedding but I totally agree. As someone who used to use Matlab (since it was what more or less everyone else in machine learning did at the time) and was immensely relieved to switch to NumPy a few years back, I’d love to give Julia a whirl but I just can’t stomach going back to a 1 indexed language. I’m surprised nobody maintains a 0 indexed fork of Julia yet (Juli0, anyone?).

If you want to take it for a spin, challenge yourself not to write anything which cares about this. It will force you to learn the some neat features (e.g. for N-dim arrays) instead of indexing with your bare hands like you're in C. And is good style anyway, to be generic to things like https://github.com/JuliaArrays/OffsetArrays.jl

Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

#22
post #7
post #5

what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...

So does: APL, AWK, COBOL, Fortran, Lua, Mathematica, MATLAB, R, Smalltalk, Wolfram Because it is Mathmatics and have 1 be based on 0 makes no sense, you then have to switch between the two and it is easy to make a mistake. This is why I don't use Python and Pandas. I got burnt once and that was enough and switched to R. Sadly we are stuck with 0 based array in programming and due to a historical issue.

It's the difference between numbering the contents of the list (1 indexing), and measuring the distance from the beginning of the list to the start of the item (0 indexing).

Personally I'm happy to switch between both, and they both have positives and negatives when I actually write code.

0 indexing is not incorrect, or incompatible with maths, it is just a different way of conceiving of lists/arrays by considering the index to more like the distance from the beginning. The first item begins 0 spaces from the start position.

That is why in that context array length is usually the highest index + 1, because length is the distance from the start position to the end of the list, whereas the index is the start position of the item in the list.

I will concede that 0 indexing is a little too close to the storage paradigm for arrays (i.e. a sequential list of items of n bytes) and that when so often these arrays point to more complex data-structures / objects, the distance doesn't make as much sense as the item number... but meh - I'd take Python generators / iterators at the expense of 0 indexing any day.

Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

#23
post #5

what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...

as someone who's written a lot of Fortran and Python for the same project I fail to see the problem. I find something like row- vs. column order differences harder to deal with. 1 vs. 0 based is just a matter of choice, a developer should be able to adapt, just like tabs vs. spaces etc.

I think the exact amount of spaces that should make up a tab is an even more controversial point.

I'd love to see what happens to the tabs vs spaces debate once someone makes tabs that aren't an integer multiple of spaces wide.

Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

#27
post #5

what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...

Call it bikeshedding but I totally agree. As someone who used to use Matlab (since it was what more or less everyone else in machine learning did at the time) and was immensely relieved to switch to NumPy a few years back, I’d love to give Julia a whirl but I just can’t stomach going back to a 1 indexed language. I’m surprised nobody maintains a 0 indexed fork of Julia yet (Juli0, anyone?).

Math uses base 1, and so does Fortran and Matlab. While Julia is an incredibly powerful language with things like user-defined unboxed structs and homoiconicity, a key design goal is to make it easy to learn for scientists and engineers who are not professional programmers. Since the vast majority use Matlab, the one-based indexing makes sense.

One-based indexing works just as well as 0-based. I've done a lot in the past in Fortran 90 and (regrettably) Matlab. Some things are very slightly harder, some things are very slightly easier. At any rate, this isn't Fortran 77. You shouldn't be fiddling around with indices much.

The bigger difference IMO is Julia uses Fortran-style column-major ordering, instead of row-major like C and Python. I actually

Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

#29
post #17
post #7

Earlier quoted context omitted.

So does: APL, AWK, COBOL, Fortran, Lua, Mathematica, MATLAB, R, Smalltalk, Wolfram Because it is Mathmatics and have 1 be based on 0 makes no sense, you then have to switch between the two and it is easy to make a mistake. This is why I don't use Python and Pandas. I got burnt once and that was enough and switched to R. Sadly we are stuck with 0 based array in programming and due to a historical issue.

0 based arrays is objectively the preferred way for me and not for historical reasons. I write a lot of low level graphics algorithm stuff, and 1-based arrays would complicate index arithmetic. like now with everything 0 based having something like: arr[offset1 * 32 + offset2] would be the following if all my offsets would be 1-based and arrays would be 1-based: arr[(offset1 -1) * 32 + offset2] which is pretty arbitr…

You could reshape it (https://docs.julialang.org/en/v1/base/arrays/#Base.reshape). But if you're interfacing with libraries written with C interface you'd still have to subtract for both offset1 and offset2.

Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software

#30
post #5

what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...

Can't reply anymore to flagged-to-death sibling, but wrt "1-based array indexing":

I've actually found behaviour of "zero-avoidance" a good battle-tested heuristics to coding. A lot of numeric spaces can be mapped as to be >0 or >0Arithmetic is much safer without 0.

Post reply on HN