by oneweekwonder · 8y ago · 0 comments
Funny how I always thought zero-based numbering[0] was a hack. Just in computer science a hack will become the right way? Any other fields where hacks became the new norm due to technical restrictions?
Your statement is a opinion.
To add to the list of languages using arrays in a "gross" way: pgsql, pascal, lua.
[1]: https://en.wikipedia.org/wiki/Zero-based_numbering#Origin
Because of this, I figure any language that supports 1-indexing should also support arbitrary ranges for the indexing, like in Ada. (Basically, what's so special about 1?)
At age 0, you have no elements in your array of years. So the first year is also element 1.
If you want code to reflect the way you've done counting and arithmetic your whole life, you'd want it to start at 1.
Which to me is one step away from using the timepoint as the index iteself (zero as start), verus (1 year from zero).
How would you index the time before the first birthday?
Yeah, that's why put a smiley there. :-)