Live data from Hacker News

Numbering should start at zero (1982)

cs.utexas.edu

181–190 of 309 posts

Re: Numbering should start at zero (1982)

#181

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.

Not sure if it's the case here but over the decades I've observed there's a cultural aspect here. When I've had colleagues from the Middle East and/or South Asia I've found they're much more likely to use `u` and `r` colloquially than western counterparts.

This could be what you're observing. Or perhaps they just like the aesthetics.

Re: Numbering should start at zero (1982)

#182
post #173

Earlier quoted context omitted.

Zero is a natural number. It is in the axioms of Peano arithmetic, and any other definition is just teachers choosing a taxonomy that best fits their lesson.

+1 for peano arithmetic club. I never realized it was controversial. I think I've always included 0 in the nat numbers since learning to count. But there are some programming books I've read, I want to say the Little Typer, or similar, that say "natural number" or "zero". Which makes actually confuses me.

IMO zero represents an absence of quantity and doesn't appear in Nature, so it cannot be classified as a Natural number

Just like a negative numbers, it's a higher-level abstraction or a model, not a direct observation from the Nature

Likewise, the digit "0" originating from the Hindu-Arabic numeral system[1] is merely a notation, not a number

---

1. https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_s...

Re: Numbering should start at zero (1982)

#183
post #68

Earlier quoted context omitted.

if you see how its implemented in machine code (on most modern archs) you will see how it is logical. once you see that, you cannot unsee it. people call these things an index, but really it is an offset from the base of the array. not an index into it. hence, base + 0 is the first entry. as the offset to that entry is 0. thats how it will work in generated machine code on all the machines i saw (i did not see all of…

Yes, it's the offset from a pointer in some languages. But to the user, it's presented as an index, not an offset. In normal syntax, you don't access an array value using a construct like *(arraypointer+offset) If you did that, then using 0 as the start offset would make intuitive sense. In fact, if not for this technical reason, I doubt that any programming language would have 0-based indices.

im not debating the user level stuff. honestly i think there's fair argument for not letting users get bogged down in system level details. but in my opinion, if people dont understand this why, its a useful thing to learn. its only a small detail in the end.

i think, because software is built up abstractions over abstractions, its unavoidable such details creep into languages from the depths of the system. its not too long ago people didnt even have C or such high level constructs. so coming from there and building up its logical. Now, making something new, from above, one might put 1 as an index for the first element, but its likely during writing of a language you'll end up in the depths and come up with 0 anyway.

think of how a 1 index will work vs a 0 index on ptrs. (pseudo code)

ptr += index x size_of_object

ptr += (index-1) x size_of_object

if you wanna run that on the cpu, either compiler needs to come up with the first one or it will have an additional sub or decrement?

or do you want the compiler to have a duty of doing the index-1, it will result in the original code again, also possible. it will take extra compiler or interpreter time.

(or am i missing something completely?)

Re: Numbering should start at zero (1982)

#184
post #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 rai…

I can't find a reference, but I have a vague memory that in original Mac OS X, 1-pixel-width lines drawn at integer locations would be blurred by antialiasing because they were "between" pixels, but lines drawn at e.g. x = 35.5 were sharp, single-pixel lines. Can anyone confirm/refute this?

Re: Numbering should start at zero (1982)

#185

Earlier quoted context omitted.

“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.

Maybe “u’re” is unambiguous here, but “re” might have been a step too far to still know what word writer was abbreviating.

The question was about contracting “u’re” to “ur”, as is commonly done in text-ese, not to “re”.

Re: Numbering should start at zero (1982)

#187

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…

Zero is a natural number. It is in the axioms of Peano arithmetic, and any other definition is just teachers choosing a taxonomy that best fits their lesson.

> Zero is a natural number. It is in the axioms of Peano arithmetic, and any other definition is just teachers choosing a taxonomy that best fits their lesson.

It is, but it need not be. In the category of pointed sets with endofunctor, (Z_{\ge 1}, 1, ++) and (Z_{\ge 0}, 0, ++) are isomorphic (to each other, to (Z_{\ge 937}, 937, ++), and to any number of other absurd models), so either would do equally well as a model of Peano arithmetic.

Re: Numbering should start at zero (1982)

#188
post #116

Earlier quoted context omitted.

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 rai…

I can't find a reference, but I have a vague memory that in original Mac OS X, 1-pixel-width lines drawn at integer locations would be blurred by antialiasing because they were "between" pixels, but lines drawn at e.g. x = 35.5 were sharp, single-pixel lines. Can anyone confirm/refute this?

Not sure about old Mac OS, but I think HTML canvas works that way.

Re: Numbering should start at zero (1982)

#189
post #186

Earlier quoted context omitted.

Who?

Sam Altman: https://x.com/sama

I knew who it was, sorry, I was just trolling. Both twitter and AI-bro culture are extremely distasteful to me so I thought citing an AI bro’s twitter account as an example of how it’s acceptable to behave online was absurd.

Re: Numbering should start at zero (1982)

#190
post #52

Earlier quoted context omitted.

There is no good reason to cater to non-technical users when designing programming languages. In what way is Lua “aimed at casual audiences”?

A lot of Lua users are kids playing Luanti or Roblox or WoW who also spend a little time modding them—mostly editing textures or 3-D model meshes, but also scripting. Lua is a small and simple language which can be learned easily, prefers to produce incorrect answers instead of throwing exceptions when confronted with ambiguous situations (for example, permitting undeclared variables), has an interactive REPL, is mem…

Okay, fair enough. I stand corrected.
Post reply on HN