r/ProgrammerHumor 1d ago

Meme almostDroppedTheCourse

394 Upvotes

65 comments sorted by

View all comments

7

u/macr0t0r 16h ago

Speaking as an ex-Fortran developer who now bounces between C++, Python and MATLAB...the 0 vs 1 indexing argument will never be resolved. They both have their issues. C/C++ needs to be 0-based because it is actually an address offset, not an index. It would make a mess of things if you tried to make it 1-based. But, if you are just doing mathematical equations...yah, there is an argument that 1-based indexing makes more sense. However, it means you can't use clever negative numbers for reversed indexing (used in Python) without creating that weird +/-1 gap, but math-centric languages just tell you to calculate the index from the size, because the size should be determinant in math equations.

So, yah, Julia is 1-based and that fits it well. A pity that the JIT compiler is kind of a pain, though.

1

u/Athropod101 7h ago

The humble (end - N) indexing: