News for hackers. Stuff that matters.
Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @09:28PM (#15475353)
It's not that one is incapable of doing it. It's that one way is wrong and the other is right!
Re:Some Insights from a Julia Developer by btschaegg on Sunday October 15, 2017 @07:08AM (#15476663)
The argument of zero vs one-based offset is not very new, and since there's a record of musings from Dijkstra on the topic[1], I feel obliged to mention it.

Note: Although I'd side with EWD on this one (for now, at least), I don't intend to reference it as an "appeal to authority", but as an example of someone producing a reasonable, properly worded and thought-through argument on the topic, which I've not really seen since. I'd be very interested in what similar arguments would look like from the other perspective. If someone would like to convince me, feel free give me a link to some reasoning :)

Also: I personally find "it's always been like this" to be a terrible argument in either case. Those are the reason we weren't able to standardize for one system of units, for example. In the Swiss army, there's a saying that is used to explain the various idiotic decisions and the bogus explications thereof a soldier has to endure:

  Ist so weil ist so, bleibt so weil war so.
Liberally translated:

  Things are like that because they are like that.
  All stays that way because it was that way.
[1]: EWD831, https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
Re:Some Insights from a Julia Developer by goatlover on Saturday October 14, 2017 @09:30PM (#15475361)
Right, so zero-based is wrong unless one is using a language close to assembly.
Re:Some Insights from a Julia Developer by Bromskloss on Saturday October 14, 2017 @10:39PM (#15475580)
Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion.

I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.

Re:Some Insights from a Julia Developer by goatlover on Sunday October 15, 2017 @12:31AM (#15475896)
Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages?

Everyone starts counting objects at 1. Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number.

Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages, although maybe there are some mathematicians who think otherwise?

Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @01:14AM (#15476005)
> Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages?

I don't take programming languages as a reference point. It's the other way around. I try to figure out what the most natural, principled, and elegant way would be, and I would base my programming language on that, if I were to design one.

> Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number.

We should distinguish between two uses of the natural numbers, I think:

0. _Ordinal numbers_, for assigning labels to things. "This is car 3." 1. _Cardinal numbers_, for saying how many things there are. "There are 7 cars."

The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars.

> Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages

What is the most common isn't what determines, for me, what is the most proper. I will play along and use 1-based indexing when I have too, but in my heart I know how I think it should _really_ be.

> maybe there are some mathematicians who think otherwise?

Yes, though starting numberings on 1 is still common (maybe the most common). Zero is at least recognised as a natural number nowadays. Historically, this wasn't the case. Apparently, Peano started on 1 in his axioms for the natural numbers [0], and zero, as far as I understand, hardly had the status of being a number at all during much of Greek and Roman antiquity [1].

[0] https://en.wikipedia.org/wiki/Peano_axioms#Formulation [1] https://en.wikipedia.org/wiki/0#Classical_antiquity

Re:Some Insights from a Julia Developer by goatlover on Sunday October 15, 2017 @01:55AM (#15476091)
> The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars.

But who thinks that way? I just see 7 cars, not an indexed listing. And anyway, the 0 indexed car doesn't exist.

Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @11:47AM (#15477616)
He who finds zero-based indexing to be the proper way and wants to shape his thinking thereafter!
Re:Some Insights from a Julia Developer by rrock on Sunday October 15, 2017 @12:39AM (#15475914)
No, zero is the right number to start an offset, not an enumeration. No one starts counting from zero in real life.
Re:Some Insights from a Julia Developer by Bromskloss on Sunday October 15, 2017 @01:15AM (#15476010)
> No one starts counting from zero in real life.

The question for me is what one _should_ do, not what is usually done.