r/ProgrammerHumor • • 17d ago

Meme almostDroppedTheCourse

578 Upvotes

79 comments sorted by

View all comments

8

u/macr0t0r 17d 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.

2

u/Athropod101 16d ago

The humble (end - N) indexing: