Live data from Hacker News

Numbering should start at zero (1982)

cs.utexas.edu

111–120 of 309 posts

Re: Numbering should start at zero (1982)

#111

Numbering should start at π (2025) (umars.edu) Seriously, it all depends on whether u're counting the items themselves (1-based) or the spaces btwn them (0-based). The former uses natural numbers, while the latter uses non-negative integers For instance, when dealing with memory words, do u address the word itself or its starting location (the first byte)? The same consideration applies to coordinate systems: r u pos…

Why do you write “you” as “u” here? I don’t want to be rude, but it’s very jarring to see juvenile txt-speak in a serious discussion.

I dare u to correct sama’s tweets ;)

Re: Numbering should start at zero (1982)

#112

Earlier quoted context omitted.

That makes sense for the ID system or a database, but for arrays in a language I still prefer starting at 0. It makes frame buffers easier easier to index

I prefer thinking from the first principles, and not according to the current computer architecture fashion. And BTW that ID system was used in the system processing PBs of data in realtime per day back in the early 2000s, so it’s not that it was super-inefficient.

Well, EWD gave a solid argument from first principles, which you choose to ignore.

Re: Numbering should start at zero (1982)

#113
post #71

Earlier quoted context omitted.

American elevators are 1-indexed!

at the whitney art gallery (nyc), the ground floor is 1, but the basement is -1. there's no 0 in between it bothers me way more than it should. i have to tell myself that the point of art is often to evoke emotions, and the rage i feel is included in that

At the University of Arizona (or at least in most of the buildings there), the lowest floor of the building is always 1, even if it’s a basement. So the ground floor is often 2. Maddening.

Re: Numbering should start at zero (1982)

#114

Earlier quoted context omitted.

Why do you write “you” as “u” here? I don’t want to be rude, but it’s very jarring to see juvenile txt-speak in a serious discussion.

“serious discussion” notwithstanding, I thought the “u’re” was particularly interesting. Why not “ur”? “u” is obviously easier to write, so why worry about properly contracting it? Just interesting imo

Abbreviations can only be useful when they're unambiguous within their context. Maybe “u’re” is unambiguous here, but “re” might have been a step too far to still know what word writer was abbreviating.

Re: Numbering should start at zero (1982)

#116
post #20

"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." — Stan Kelly-Bootle

He was right. If the first fencepost is centered at x=0 and the second at x=1, and you want to give the rail in-between some identifier that corresponds to its position (as opposed to giviung it a UUID or calling it "Sam" or something), 0.5 makes perfect sense.

In computer programming we often only need the position of the gap to the left, though, so calling it "the rail that starts at x=0" works. Calling it "the rail that ends at x=1" is alright, I guess, if that's what you really want, but leads to more minus ones when you have to sum collections of things.

Re: Numbering should start at zero (1982)

#117
Whenever I explain to someone when or why to use 0-indexing, I like to say:

Start from 0 if you are counting boundaries (fenceposts, memory addresses)

Start from 1 if you are counting spaces (pages in a book, ordinals)

Floors are a case where both make intuitive sense, which is maybe how we ended up with European vs American floor numbering.

Re: Numbering should start at zero (1982)

#118

Numbering should start at π (2025) (umars.edu) Seriously, it all depends on whether u're counting the items themselves (1-based) or the spaces btwn them (0-based). The former uses natural numbers, while the latter uses non-negative integers For instance, when dealing with memory words, do u address the word itself or its starting location (the first byte)? The same consideration applies to coordinate systems: r u pos…

Why do you write “you” as “u” here? I don’t want to be rude, but it’s very jarring to see juvenile txt-speak in a serious discussion.

>a serious discussion

hardly. this is an informal internet forum of mostly anonymous people chit chatting about random stuff instead of working.

Re: Numbering should start at zero (1982)

#119
post #3

The 1980s were not a particularly enlightened time for programming language design; and Dijkstra's opinions seem to carry extra weight mainly because his name has a certain shock and awe factor. It isn't usual for me to agree with the mathematical convention for notations, but the 1st element of a sequence being denoted with a "1" just seems obviously superior. I'm sure there is a culture that counts their first fing…

> Dijkstra's opinions seem to carry extra weight mainly because his name has a certain shock and awe factor

So you claim this is just an appeal to authority and as a rebuttal you give appeal to emotion without being an authority at all?

> the 1st element of a sequence being denoted with a "1" just seems obviously superior

> I'm sure there is a culture that counts their first finger as 0 and I expect they're mocked mercilessly for it by all their neighbours

> 0-counting sequences represents a crazy choice

5G chess move.

Re: Numbering should start at zero (1982)

#120
post #53

Pretty much any algorithm that involves mul/div/mod operations on array indexes will naturally use 0-based indexes (i.e. if using 1-based indexes they will have to be converted to/from 0-based to make the math work). To me this is a far more compelling argument for 0-based indexes than anything I've seen in favor of 1-based indexes.

Forget multiplication, even addition becomes simpler.
Post reply on HN