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

That's not code, that's English.

When we start indexing from 0, the only time we need to do a +/- 1 is when we need to index the last element. All other times (iterating, mapping) we don't need to.

Also, starting indices at 1 would change the idiomatic iteration to:

   for (int i = 1; i <= SIZE; ++i)
I find that the <= and >= operators add more to my cognitive load than the strict relation operators < and > because there's an or in there. I don't find the alternative to that idiom any better:

  for (int i = 1; i < SIZE + 1; ++i)
Your original argument was that we should make it easy for humans to understand, not computers. I think that starting indices from 0 is easier for humans to understand because it simplifies the code we must write and read.



No, your language limitations don't have to force the rest of the world to accept them.

As I alreay said, some languages use the simpler construct:

For i=1 to N

And C could easily use:

for(i=1;i==n;i++)

just by changing the way the loop condition works.

So as you say, it is all about the language.


No way I would trust a language design with your semantics for this syntactic construct: for(i=1;i==n;i++)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: