Re:Correctness and composability bugs in the Julia ecosystem
by rocqua on Monday May 16, 2022 @11:38AM
(#31399016)
My experience is that 0-based offsets (and use of < or even != for upper bounds) mean that I should almost never have to write something like idx - 1 or idx + 1.
I came to 0-based offsets later in my career, having started with Matlab. So I have some real experience with 1-based offsets. Experience that was 'untainted' by being used to a different option. I much prefer 0-based.
Especially because I now sort-off have a linter rule in my head 'if I am writing i - 1 then I am making a mistake or doing something the wrong way'. Which has been quite successful.
Re:Correctness and composability bugs in the Julia ecosystem
by drBonkers on Tuesday May 17, 2022 @01:29AM
(#31406367)
I have a similar experience. Matlab was my first experience with computational work. Now I use Python and 0-based is still more natural.
Re:Correctness and composability bugs in the Julia ecosystem
by jjgreen on Monday May 16, 2022 @10:04AM
(#31397384)
Not for polynomial coefficient indices :-)
Re:Correctness and composability bugs in the Julia ecosystem
by xscott on Monday May 16, 2022 @10:35AM
(#31397962)
Or Fourier coefficients :-) Or pretty much anything where the index/subscript is related to the math itself.
Math textbooks and papers tend to use 1-based subscripts when it doesn't matter. It's hard to come up with examples where starting at 1 facilitates the actual math.
Re:Correctness and composability bugs in the Julia ecosystem
by MzxgckZtNqX5i on Monday May 16, 2022 @10:40AM
(#31398074)
Just for consistency: a_n is the coefficient of x^n, so the constant term ends up being a_0.
Based on my experience, numbering starts from one (like (x_1, x_2, x_3) as point of R^3) and off-sets from zero, e.g., when dealing with discrete time, t_0 is the first.
0 makes sense as the '0-th offset' when thinking from a pointer perspective, but I often find when teaching, that 1-based comes more naturally for many students (the 'first' item).
You mention mathematical or scientific work...but I often/mainly see enumerations (such as weights x_1, x_2, ... x_n or SUM 1 to N) start with 1, so for these 1-based can be a more natural/direct translation of mathematical notation to code.