Ask HN: [0] or [1] for First Ref?

1 points by sbr464 ↗ HN
I see both, was curious which is correct.

4 comments

[ 3.2 ms ] story [ 16.3 ms ] thread
Latex/Bibtex/natbib generates [1]. Actually I never have seen a tool starting with [0].
I agree, but people frequently submit with [0] so wanted to ask. Here’s an example from today:

https://news.ycombinator.com/item?id=22316070

I suppose the average HN commentator is used to indexing arrays using the postfix []-operator, thus starting at 0, while the tools mentioned by GP are aimed at everyone - and most "normal" people start counting at 1.

For references in manually written text, it doesn't matter at all - as opposed to programming language design. E.g. in C the equality x[a] == <star>(x + a) holds because we start at 0.

OTOH if we started at 1, it would become x[a] == <star>(x + a - 1). Mathematically it does not really matter as well, but if you're doing lots of pointer arithmetics in C, causing massive bugs by forgetting a crucial " - 1" might be all too easy. No idea if this was inherited from predecessors or an original design decision. Might also be just a coincidence and the reason to start at [0] is an entirely different one ;-)

(sorry for the <star>, I mean * -- but using multiple of these is interpreted as formatting/italics and I don't know how to avoid this)

It doesn't matter. HN has no PEP8.