News for hackers. Stuff that matters.
Re:PyTorch: Where we are headed and why it looks a lot like ... by dash2 on Saturday November 27, 2021 @03:57AM (#29358739)
The reason beginners have a hard time with 0 based indexing is that humans count from 1. Seriously, I've spent weeks trying to tell people "yeah, we want rows 4 and 5, so that's, uh, rows 3 and 4..." and they think it's nuts, and I now think they're right.
Re:PyTorch: Where we are headed and why it looks a lot like ... by goerz on Saturday November 27, 2021 @07:26AM (#29359648)
Right. Zero based indexing makes zero sense, unless you explain the underlying technical reason, that it’s an offset relative to a memory pointer (spend a week teaching pointers first!).

It makes sense in certain context (and in languages like C that have a low-level mental model). For scientific computing at a higher level of abstraction where the mental model of a multidimensional array is a tensor, and not a memory offset location, zero-based indices really get in the way

Re:PyTorch: Where we are headed and why it looks a lot like ... by ChrisRackauckas on Saturday November 27, 2021 @08:11AM (#29359892)
> Zero based indexing makes zero sense

The sensibility of the index choice is equal to the starting value of the index.

Re:PyTorch: Where we are headed and why it looks a lot like ... by jonniedie on Saturday November 27, 2021 @12:06PM (#29361591)
StarWars indexing makes 4 sense.
Re:PyTorch: Where we are headed and why it looks a lot like ... by ChrisRackauckas on Saturday November 27, 2021 @01:37PM (#29362304)
yupyupyup, you got it. :)
Re:PyTorch: Where we are headed and why it looks a lot like ... by hpcjoe on Saturday November 27, 2021 @04:08PM (#29363520)
Precisely. Indexing makes sense in a context, and it is trivial in general to switch. This said, telling people that the first element they want is the "0th", is completely unnatural.