Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Matlab, Octave, Mathematica, and other mathematical programming environments use 1-based indexing, it's a well-established norm for the domain.


Fortran too and in HPC we all code in Fortran a lot. Look at the loop construct:

     for i = 1:t
in Fortran:

     DO I=1,T
The ability to load both C and Fortran dynamic libraries is also really really nice.


Does 1-based indexing have any advantage, beyond familiarity to scientists?



With 1-based indexing, length == last index.

Does 0-based indexing have any advantage, beyond ability to do pointer arithmetic with indexes?


In 0-based indexing, n % length is a value inside the range.


Not really, but it's not important either way.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: