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

I can remember that out of all the code I've written, I've very rarely needed a +1/-1 except as part of accessing a next/previous element, so at least from this data point, zero-based indexing makes the code simpler and easier to understand. That second example of yours I had to spend a lot more time reading (and mentally doing increments/decrements) to figure out. I'm almost willing to bet there would be more off-by-one errors if one-based somehow became the norm.


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

Search: