4 ms·
Much like turing completeness, you can build systems with any choice that "work", so an argument always has to be from aesthetics, which can include simplicity
by zimablue 8y ago
Much like turing completeness, you can build systems with any choice that "work", so an argument always has to be from aesthetics, which can include simplicity and "uglyness", but these aren't totally individual (you can get 99/100 people to agree on which of two schemes is "simpler"). Simplicity and beauty aren't something that even mathematicians dismiss as they can be trying to tell you something.
There's another argument, I can't remember if I originated it or read it but it's the one I find most convincing.
Consider that you have finite units of equal length 1 stretching away from you in a line. How would you specify to someone (using real-number measurements) to retrieve the first N=6, or describe the vector they occupy? You would say, take everything between [0.0, 6.0). If you use zero-based indexing, the numbering scheme specifying the interval is identical across both systems: [0.0, 6.0) => (python)[0: 6]== 0<=x<6. In real numbers the interval could be open or closed for this argument to work, because for there to be any elegant translation the integer upper bound has to be open. That's the only way you can keep the elegant transformation with 0 and 6. Caveat that thie works because you're numbering the real-number origin as 0 but try telling physicists that they're not to do that! O=(1,1,1) is an even more indefensible position.
So there's another mathematical argument that I either came up with or read elsewhere that feels deeply convincing to me. If there's 2 there's probably more, and here's the list of languages on wikipedia, you tell me which you'd rather work in.
https://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28array%29#Array_system_cross-reference_list https://en.wikipedia.org/wiki/Comparison_of_programming_lang...
Sorry for the irate tone but I really think that on reflection and fair consideration this is an obvious one.
- saosebastiao 8y agoIt sounds like you haven't considered any of the multiple reasons or situations where 1-based indexing works out better.
- zimablue 8y agoIf you're going to give a counterexample, please give it. I thought about my post after I read it and came to this- given Djikstra's (only system which can describe an empty interval and interval with first element without "unnaturals" ) and (?)'s argument that it creates a nice homomorphism between real-number intervals and integer slices then it's inarguable to me that 0-based is more mathematically elegant. Where I guess there's space to disagree is this, I believe (to almost a point of faith I guess) that mathematical/logical elegance is important, and moving away from it is normally a mistake which leads to more pain in the long run.
- saosebastiao 8y agoWhy? You've already come to the conclusion that anybody that disagrees with you is an idiot, and you think your argument is fully reasoned and covers all bases. Why should I believe that you would change your mind given new information?
- zimablue 8y agoI guess, because often you're not arguing in order to convince your opponent, you're arguing to sway the crowd (and sometimes, decide yourself). And I don't think they're idiots, I just think that they're wrong. Not many people have read Djikstra and (?) and have deep faith in mathematical beauty, or have even thought about this much, doesn't make them idiots.
- saosebastiao 8y agoThe most prominent programming languages designed specifically for mathematical purposes (Mathematica, MatLab, Julia, R, Fortran), all have 1-based indexing. That should be a sign to you that 1-based indexing has a legitimate mathematical rationale. Djikstra wasn't speaking on behalf of the mathematics community. The idea that if you have deep faith in mathematical beauty that you'll come to the same conclusion is absurd.
- zimablue 8y agoI'm pretty sure that they just copied Fortan, which was written most of a century ago. That's the second time you've ridiculously misrepresented my statements: "anyone disagreeing with you is an idiot" "deep faith will lead you to the conclusion" (and not deep faith + thinking about the actual problem, several convincing arguments and some ability)
- darksaints 8y agoOne based indexing is used in tons of domains within mathematics. Fortran chose 1-based indexing for a very obvious reason...it was the best translation from the mathematics literature that they were trying to implement. Because matrix notation uses 1-based indexing! MatLab, a language designed specifically as a high level language for matrix mathematics, chose it for the same reason. R, a language for statistics, chose 1-based indexing because it is a statistical language, and counting is one of the most fundamental operations in statistics, and 1-based indexing is the form used for counting. Mathematicians obviously have no problem switching back and forth between 0-based and 1-based indexing for different domains, so it boggles my mind that computer scientists have turned it into such a huge holy war, and even more mind-boggling that 0-based zealots claim to have mathematics on their side.
- throwawaymath 8y ago> an argument always has to be from aesthetics, which can include simplicity and "uglyness", but these aren't totally individual (you can get 99/100 people to agree on which of two schemes is "simpler"). Putting aside the implicit claim that something as subjective as aesthetics will be agreeable by 99% of the population...is 0-based indexing simpler? Why? Your next example is...a little all over the place mathematically, if I’m being honest. I’m having trouble following it. But let me try... So you’re saying I have a 1-dimensional, ordered set S, whose elements are real numbers. It can’t be an interval, because S needs to be discrete for this to be possible computationally or even theoretically (S is uncountable if its continuous, and thus cannot be indexed). It needs to have an order to have a sense of position in the first place, so map S to the natural numbers in whatever way you choose. Now choose an element s in S. You want me to pick the first n elements from s that are “next”, for whatever your order relation is. We’ll call that relation <. In that case I would respond by saying, “Let s be an element of S, and choose an n-tuple N of elements (x_1, x_2, x_3, x_4, x_5, x_6) in *S* such that s < x_1 < x_2 < x_3 < x_4 < x_5 < x_6, and there exists no element k of S such that k in S, s < k < x_6, k not in N. Haven’t I accomplished your exercise just fine without using 0 indexing? If I were programming this, I could index the n-tuple starting with x_0 or x_1. I don’t understand the issue - what are you trying to convey here? Personally, I’d program this by defining S to be my vector or list or whatever, k to be the index of s in S, then defining my n-tuple with: N = [] for (i = 1, i <= n, i++): N.append(S[k + i]) I feel as though you only believe your example is compelling because you’re overlapping the origin with the initial index. But when you abstract your problem to the general case (as I did), then it doesn’t really seem to matter much. Your example is actually kind of a narrow edge case.
- zimablue 8y agoHey, thanks for trying to reply substantively. You haven't understood what I was saying, which is fair enough because I didn't present it very clearly probably. The line where you start talking about something else is this: "So you’re saying I have a 1-dimensional, ordered set S, whose elements are real numbers". No, I'm not saying that. Firstly to define the question as Djikstra does: we're arging about, if I have a list L, and I write into my computer L[a, b], which elements of L are returned? My argument is kind of a physical metaphor, take the real number line as a physical axis (like you're doing physics), and take a load of toy trucks that each have length of 1 (I guess you choose your coordinate system to make the length 1) and put them down end to end. If I was a physicist, and I asked you to pick up 3 trucks starting at 0, and I was using real numbers and a vector I'd say it like this, pick up the trucks in the range [0, 3) on my axis. Now if you choose 0 indexing + (closed, open) for your slicing, then a (python) programmer would say to another programmer, take the slice [0:3] to get the 3 trucks. So the slice numbers correspond perfectly to the vector description of the space that the items occupy. That's why in this slicing system taking L[a, b] then b-a = the number of items you get. Because it's matched perfectly with a real-number vector description of the space the items occupy on a real number line. All the other advantages like (I can describe an empty interval: [0:0]), I can describe taking the last element and it feels right [-1: 0] follow from this physical-space homomorphism. That last one: in a circular (modular?) space, walk left 1 and then come back right 1 and pick up the element you pass over. In 1-based: [0: 1] = the last element? I don't know if any languages do this but either you can't and that's sad or you can and it is incredibly counterintuitive.