4 ms·
No less than Dykstra has weighed in on the numbering of arrays. http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF http://www.cs.utexas.edu/users/EWD/ewd08x
by jandrese 11y ago
No less than Dykstra has weighed in on the numbering of arrays.
http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF
Having worked with both, I'm inclined to prefer 0 based addressing in most cases. It's slightly less intuitive, but it generally leads to cleaner code.
- Avshalom 11y agoNo less than Dykstra spouted a half hearted list of some properties and then made a proclamation based entirely on aesthetics.
- banku_brougham 11y agono less than dykstra was convicted of grand theft auto. https://en.wikipedia.org/wiki/Lenny_Dykstra https://en.wikipedia.org/wiki/Lenny_Dykstra I think you mean Dijkstra, who did say that, because of an argument with mathematicians about indexing from 1.
- pygy_ 11y agoIn Dutch, ij and ÿ are interchangeable.
- saghm 11y agoMy Dutch professor in college actually wrote out the "ij", but the tail of the "i" connected with the "j", making it appear to be "ÿ". It kind of blew my mind the first time I saw him write it out haha
- pygy_ 11y agoIn cursive, it is often indistinguishable too.
- hbogert 11y agoIn print, NO. You really can't interchange the two. As already said, in handwriting they may look similar, however we would never mean the actual ÿ, since it simply is something else which is used in Greek and French (and others). There's even a section about this on wikipedia: https://en.m.wikipedia.org/wiki/IJ_(digraph) https://en.m.wikipedia.org/wiki/IJ_(digraph) subsection "technical details".
- pygy_ 11y agoAt the very least it happens in Flanders. I've seen ijs ("ice") capitalized in cursive as Ys[0] on an ice truck, for example. Edit: from Wikipedia[1]: "It used to be common, in particular when writing in capitals, to write Y instead of IJ." So it's an obsolete practice... ---- 0. something along those lines: http://alphabetprintables.org/alphabet_printables_cursive/uppercase/alphabet_cursive_letter_y.jpg http://alphabetprintables.org/alphabet_printables_cursive/up... 1. https://en.wikipedia.org/wiki/IJ_%28digraph%29 https://en.wikipedia.org/wiki/IJ_%28digraph%29
- e12e 11y agoThat argument never felt very convincing to me. Perhaps because it really is about aesthetics, not some deep philosophical ideas connected to numbers. I see it as rather simple. If you're listing off-sets, starting at 0 makes sense, because there'll be something there. But if you're counting elements starting at 1 makes more sense. I don't have 9 fingers offset from my first one, which I call finger zero; I have ten fingers, starting with the first one. A set with no members is the zero set, once you add one element, you have a set of one. An empty list contains no elements. It does not have a first member, because it's empty. Add an element, and it will have one member, and it will be in the first position. Not in the zeroeth offset from the beginning. You can the numeric names of letters of a string in an array, but I don't see that as a compelling reason for naming the first letter of a word, the letter which is at the zero-eth offset from where the word is held in memory. At best, it's a low level optimization, at worst it's just a leaky abstraction. Maybe you want to store the length of the word there (like in Pascal), for a different trade-off in terms of what is optimized.
- rixed 11y agoIndexing is not for counting elements, it's to reach a particular one.
- e12e 11y agoI still find it more useful to name it my tenth finger, rather than the ninth from the first. And I'm fine with my middle finger, finger number three - being the one that sits between the pairs of fingers made up of finger number one and two, and fingers four and five. I don't really see how it's any better to count up from the zeroeth offset of the first finger to the second offset to get to the middle finger.
- garyclarke27 11y agoI don't buy the Dykstra argument,1 base is more intuitive for me and for most non programmers, I would guess. Funny though how Americans use 1 based indexing for building floor numbers, but Europeans use zero based i.e. ground floor is zero in a European lift, 1 in a US lift.