Re:Automatic Differentiation with Julia
by gct on Tuesday October 23, 2018 @09:37AM
(#18283237)
Hear hear. Everyone that's making excuses for one based is wrong. You need a zero in your set of integers to form a Ring modulo N. I hereby declare everyone that wants 1 based indexing out of some naive sense of it being easier a scrub.
[ Parent
| on HN ]
Re:Automatic Differentiation with Julia
by psychometry on Tuesday October 23, 2018 @10:33AM
(#18283668)
That's so absurd I hope it's satire. Humans instinctively reason about iteration in terms of the natural numbers, not the semantic purity of the underlying abstract algebra.
It's not absurd at all. In situations where you need to do modulo arithmetic on array indices 1-based indexing forces you to shift the offset by 1.
Or, you know, just use the `mod1` function in those cases: https://docs.julialang.org/en/v1/base/math/index.html#Base.m... . Even more fun is that you can use the special `end` index to implement a stupid-simple circular index: `A[mod1(i, end)]` will always be in-bounds for integer `i`.
It's not a common case, though. Using inclusive ranges and 1-based indexing makes Julia's slicing syntax use first-class ranges that can behave like arrays themselves. You can do math on them. You can do all sorts of amazing things that make your life easier: https://julialang.org/blog/2016/02/iteration
Sometimes you want to count fenceposts, and sometimes you want the distance (e.g., offset) from the first post. Keep this imagery in mind and it's easy to do either in any language.
Re:Automatic Differentiation with Julia
by psychometry on Tuesday October 23, 2018 @10:49AM
(#18283827)
Yes and that's something most programmers need to do almost never, so let's not make any important design decisions around that very specific case.
Do you suggest that we appeal to tradition instead of practical considerations?
aesthetically i sort of agree, but i just want to type in equations from papers without having to do any error prone arithmetic — it is slightly less frustrating.