Hacker News new | past | comments | ask | show | jobs | submit login

The scientists can do what they want until they start using computers, then they should listen to the software engineers.



This is silly. Different domains have different needs. If you think of arrays as pointer + offset calculation, and your only for loop has an explicit index increment in it, then starting at 0 is natural. If you are a systems programmer then a language targeting you should accommodate that.

If you are anyone who doesn't want to care (too much) about how things are implemented, then it's a lot less error prone to mark the 1st element of an array a[1]. Having taught and written fairly complex scientific code in both 0 and 1 indexed languages, there really is no good reason to do anything else.

    for a in array[3:6]
Should iterate over the third to sixth element of the array.


I dunno man, it's Dijkstra's essay. He has a pretty good reputation.


Nah everyone should just listen to the mathematicians and allow for arbitrary index sets.

Seriously though you save yourself a lot of trouble if you don't worry that much about what range your indices have but rather what they represent. The fact that they're integers starting at 0 is just an implementation detail.


Software engineers made the first high level programming language called Fortran, which starts indexing at 1 by default.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: