Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. From where should the index start?

From where should the index start?

Scheduled Pinned Locked Moved The Lounge
questionphpdatabasedesignhelp
114 Posts 31 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    gumi_r@msn.com wrote:

    How does a small kid learn his numbers? I find it hard to imagine some little boy counting 0, 1, 2, ...
    We start at 1, and do so even when we are grown ups.

    You eventually teach children the concept of 0. It is something you must teach them. However, we need not teach computers the concept of 0. The fact is if a person is counting objects they do use 0, it is just omitted. For example, I have 6 apples all lined up. I want to count them. Now I am a smart chap so I can just look and say there are 6 apples. Someone else may need to at the minimum count by 2's (omitting the odds). And yet another will count from 1 to 6 (omitting the 0). The fact is all counting of objects (which is what your comparison is about) start with 0, we just choose to omit for efficiency. Well starting the index at 1 for computers is inefficient because the fact is 0 exists, and the computer knows that. If you start at 1 you now have to proram at the base level speacial instructions for it to understand 0. Why would you do that? So you example of going to the grocery store. What are you going to do when the clerk hands you 1 Orange, 1 watermelon and 1 zuchini?? "Hey I didn't ask for these!" "Oh sorry, you forgot to say 0 of those items..."

    Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

    R Offline
    R Offline
    Rob Grainger
    wrote on last edited by
    #84

    I fundamentally disagree. We have always begun counting at 1, we do not begin at zero but omit it. That's an incredibly wierd outlook. Get out more - you're spending too much time with programmers. Consider bananas - if I have three bananas I count them 1, 2, 3. Yet, if I have no bananas, I'm unlikely to begin counting them at all. I don't think we're omitting the zero - it was never there to begin with. Zero was introduced much later as a concept then counting, and is one of the most significant developments in mathematics, but its not involved in counting.

    L 1 Reply Last reply
    0
    • N Nikunj_Bhatt

      In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

      S Offline
      S Offline
      Stuart Rubin
      wrote on last edited by
      #85

      In general, I try to make my variables "domain specific" and single purpose. So, if my function returns "milliamps" but can also return an "error code", I will usually have the function return an enumerated "error code" like

      typedef enum {ERR_NONE, ERR_BAD_READING, ERR_BUSY} AdcErrCode;

      and pass the returned "milliamps" value by reference. When I'm feeling really disciplined, I may even define the data type like "typedef uint16_t Milliamp". For your example, I would certainly return a separate error code like

      typedef enum {STR_SRCH_FOUND, STR_SRCH_NOT_FOUND, STR_SRCH_BAD_STR} StrSearchErr;

      or something and return the error code by reference. Typedefing your domain specific types add ZERO additional run time or memory overhead. Thoughtful, explicit typedefs also make your static code analyzers work a lot better. Note that these are examples from a C point-of-view. So, the point is not whether to use 0 or 1 as the first index, or what your error code should be, but to be extremely explicit in your data types (even in loosely typed languages) and variable names. An "index" in your search is not necessarily the same as a letter "count".

      1 Reply Last reply
      0
      • N Nikunj_Bhatt

        In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

        M Offline
        M Offline
        Mark AJA
        wrote on last edited by
        #86

        Bit off subject but sometimes I want the HTML command <LI> to start at 0 and not 1, or allow numbers under 1. but <LI VALUE="0"> will not set it to 0 I ended up using a table and not <UL> <LI>'s.

        1 Reply Last reply
        0
        • R Rob Grainger

          I fundamentally disagree. We have always begun counting at 1, we do not begin at zero but omit it. That's an incredibly wierd outlook. Get out more - you're spending too much time with programmers. Consider bananas - if I have three bananas I count them 1, 2, 3. Yet, if I have no bananas, I'm unlikely to begin counting them at all. I don't think we're omitting the zero - it was never there to begin with. Zero was introduced much later as a concept then counting, and is one of the most significant developments in mathematics, but its not involved in counting.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #87

          Rob Grainger wrote:

          We have always begun counting at 1, we do not begin at zero but omit it. That's an incredibly wierd outlook.

          Actually it is a scientific way of looking at it.

          Rob Grainger wrote:

          I don't think we're omitting the zero - it was never there to begin with. Zero was introduced much later as a concept then counting, and is one of the most significant developments in mathematics, but its not involved in counting.

          No it was not introduced at the same time as counting. "Hey Ugh. Get me 3 sticks for fire".... "1.. 2... 3" Counting has been around for a while, but math proofs and formulas which require enumeration did require it and still do (ohhh wait... Is that one computers are doing??? Math formulas? Hmmm I thought it was just for perrty pictures of Salma Hayek) If you are familiar with math proofs you should know the most common value that you are converging from or to is 0. If you are using a 1 base index (or counting and ommitting 0) you will make the algorithms more complicated. Here is another way to show we are indeed omitting in human language. If you write down "10", we know you mean "10". A computer however will use the data before it. If you did nothing to the data it will not be "10" but could be 26310 or 28510 and so on and so on. Now I know what you are thinking. Compiler handles that why can't it do this for us. Because wether you wrote "10" or "0010" has absolutly no effect on the algorithm. You starting your array from 1 does. If you do not grasp that you may need to study mathematics a little more.

          Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

          R 1 Reply Last reply
          0
          • I Ian Shlasko

            Clearly, all indices should start from -2 and count in base 13.

            Proud to have finally moved to the A-Ark. Which one are you in?
            Author of the Guardians Saga (Sci-Fi/Fantasy novels)

            C Offline
            C Offline
            C Grant Anderson
            wrote on last edited by
            #88

            Except on Tuesdays when it should start at a random number and use base 6 or 18 depending on if it is raining or not.

            1 Reply Last reply
            0
            • G gumi_r msn com

              As I posted before you'r reasoning IMHO is not solid. The fact is that array[0] is a meaningful item in a zero based indexing system, while in our everyday life, 0 is the contrary; it can be omitted, as you well say, precisely because it is not meaningful, we live in a 1-index based world like it or not. And I absolutely disagree with the supposedly overhead paid when the compiler has to correctly interpret array[1] as the first item of the array (that is, offset zero in the uderlying pointer) when it spits out machine code, CIL or what have you. Why should there be any performance issue at all? Let the compiler transform everything to zero based indexing that the computer natively understands at compile time (we may have a 1 ms compile time overhead in there somewhere...). Or should we also start writing our programming in assembly code just to make the computers understand us better? Obviously this is of course a hyothetical discussion. We are stuck with zero based indexing and it is after all trivial to understand how it works.

              J Offline
              J Offline
              jocstar
              wrote on last edited by
              #89

              In my everyday life (at least for the first 365 days) I was in year[0] :)

              1 Reply Last reply
              0
              • N Nikunj_Bhatt

                In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

                A Offline
                A Offline
                Alan Balkany
                wrote on last edited by
                #90

                A rule I follow for indexes/ordinals is: "If it's visible through the GUI, start at 1. If it's internal to the program, start at 0." The zero-based index is elegant because it's naturally the offset from a base. The one-based index is intuitive because in the real world, counting starts with one (i.e. the first item).

                1 Reply Last reply
                0
                • N Nikunj_Bhatt

                  In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

                  S Offline
                  S Offline
                  SeattleC
                  wrote on last edited by
                  #91

                  Array indices start at zero because inside the hardware what you need is the offset from the beginning of the array to index the element. It sounds silly, but the cost of subtracting one from every index expression adds up to a noticable cost in a decent sized program. Optimization in this years' compilers is probably good enough to overcome this cost in statically typed languages but these languages are all old enough to vote now. In a byte-code language or interpreter, you pay this price forever. Getting confused between 0 (false) and 0 (first character) results from a lack of imagination in the design of string handling routines. A find-substring function could return the substring or the empty string, instead of the index. It could return a slice of the string, an iterator, etc. It seems like every third-year CS undergrad wants to design their own programming language after taking the compilers class. It's like a rite of passage. It's probably best to wait until they've written significant programs in several languages before they actually do it.

                  1 Reply Last reply
                  0
                  • N Nikunj_Bhatt

                    In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

                    A Offline
                    A Offline
                    Antonino Porcino
                    wrote on last edited by
                    #92

                    I've designed a script programming language which was intended to be used by entry-level programmers. With that in mind, I've adopted 1-based indexing (both for strings and arrays) in the hope of making it simpler to understand. My reasoning was that it is easier to remember that 1st element is [1] and not [0] for unskilled coders. Now that a lot of code has been written in that language, I really repent of my choice. On average I see that code is slightly longer than it would be if it was 0-based, and often wrong access to [0] element causes problems. At a certain point I decided to revert to 0-based indexing but it was too late because there was too much code to fix. So my advice is, stick to 0 indexing, especially if your audience has background in c/c++/java/c#.

                    N 1 Reply Last reply
                    0
                    • A Antonino Porcino

                      I've designed a script programming language which was intended to be used by entry-level programmers. With that in mind, I've adopted 1-based indexing (both for strings and arrays) in the hope of making it simpler to understand. My reasoning was that it is easier to remember that 1st element is [1] and not [0] for unskilled coders. Now that a lot of code has been written in that language, I really repent of my choice. On average I see that code is slightly longer than it would be if it was 0-based, and often wrong access to [0] element causes problems. At a certain point I decided to revert to 0-based indexing but it was too late because there was too much code to fix. So my advice is, stick to 0 indexing, especially if your audience has background in c/c++/java/c#.

                      N Offline
                      N Offline
                      Nikunj_Bhatt
                      wrote on last edited by
                      #93

                      Seeing all the replies, I think you have provided a very strong PRACTICAL answer. All other are just saying on their own thoughts and not going deep to the actual problem. However, I still would like to use 1 based index. Presently I could be wrong. I would & should first check some of my programs using 1 based index instead of 0 based index. I don't think using 1 based index would create any problem. You may be facing the problem because the entry-level programmers will move on to other higher generation languages in future and thus, from starting, they would think of using the same methods as provided in the higher generation languages. And I don't think using a 1 based index would create any noticeable time-delay because 1 based index would be only for programmer but in the machine language, it can use 0 based index and this conversion can be applied at compile time and the execution speed will not be affected. Programmers may not need to became comfortable to computer language/computer, but the languages can be designed to become comfortable to programmers. In common sense, if I say someone (as I am a teacher, I often say this to my students) to display value of the 1st element of an array, what he/they would understand? the first element of array which is array[0] OR array[1]? I then have to say display value of the 0th element! Isn't this strange (actually, weird)?

                      A 1 Reply Last reply
                      0
                      • N Nikunj_Bhatt

                        In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

                        W Offline
                        W Offline
                        wbaxter37
                        wrote on last edited by
                        #94

                        I Was going to say I really don't care, but thwn remembered my stint in Rocky Mountain BASIC (in HP technical computers for engineering and test) where one could use any set of indices you wanted. I ended up settling on 0 for all arrays because it made bound checking a lot easier. Remember the 3-week rule: Agter 3 weeks you'll look at you're code and mutter "Why the hell did I do that and what does it do?". It's a lot easier if there is consistency in your code. After years of C/C++/C# and recent Ruby I have no problem with 0 based indices.

                        1 Reply Last reply
                        0
                        • N Nikunj_Bhatt

                          In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

                          A Offline
                          A Offline
                          Alan Burkhart
                          wrote on last edited by
                          #95

                          I would favor a 1-based index instead of zero based. "First" is "1st" not "0st". Humans automatically think of first as being #1. No blue ribbon ever had a "0st" on it. Back in the day when BASIC allowed us to choose how to index, I always chose one-based indexing. And, I've always thought it a bit clumsy that a For-Next loop had to stop at Count-1 instead of Count.

                          XAlan Burkhart

                          L 1 Reply Last reply
                          0
                          • A Alan Burkhart

                            I would favor a 1-based index instead of zero based. "First" is "1st" not "0st". Humans automatically think of first as being #1. No blue ribbon ever had a "0st" on it. Back in the day when BASIC allowed us to choose how to index, I always chose one-based indexing. And, I've always thought it a bit clumsy that a For-Next loop had to stop at Count-1 instead of Count.

                            XAlan Burkhart

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #96

                            Alan Burkhart wrote:

                            "First" is "1st" not "0st".

                            Actually is "0th" :P

                            Alan Burkhart wrote:

                            And, I've always thought it a bit clumsy that a For-Next loop had to stop at Count-1

                            Don't use For Next. (I would go as far as to say don't use a language that supports it;)) Use for loops that have end conditions and your end condition should be Less than the count (not less than equal) Lastly,

                            Alan Burkhart wrote:

                            Humans automatically think of first as being #1

                            Are you saying that Mathematicians are not human?? ;)

                            Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                            A 1 Reply Last reply
                            0
                            • N Nagy Vilmos

                              Simply put, it makes sense to have it start at 0. The array variable will be a pointer to a memory address p and each item is an offset from there so, for item n where each element is size s the memory address is p+n*s. If you want 1 based arrays then the element would be found at p+(n-1)*s. Which is easier to compute?


                              Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                              J Offline
                              J Offline
                              jschell
                              wrote on last edited by
                              #97

                              Nagy Vilmos wrote:

                              Simply put, it makes sense to have it start at 0.

                              Opinion.

                              Nagy Vilmos wrote:

                              The array variable will be a pointer to a memory address p and each item is an offset from there so

                              Wrong. First that point only applies to the first value. Any other value in the array needs to be offset anyways. The advantage is so trivial that it probably isn't possible to measure it even in somthing like C using a byte array (noting that access is to the entire array not just the first byte.) Second the point of a modern programming language is to distance oneself from the actual implementation on the machine.

                              Nagy Vilmos wrote:

                              Which is easier to compute?

                              I write financial systems that communicate with databases and many different service providers. There is no possible way that would ever have any impact on any part of a system like that. And many problem domains are like that. There are some problem domains in which some functionality might actually be impacted by that. In that case then one should use C or even assembler (or mixed mode) to do just that.

                              1 Reply Last reply
                              0
                              • N Nikunj_Bhatt

                                In almost all programming languages, the index number of arrays, strings and other starts with 0 (Zero). Now suppose, presently you are going to design a new language and forget that any programming language already exist. Then from where would start the index number? Zero or One or something else? Here I am mentioning the reason behind coming this question in my mind. The problem with Zero based index is faced (a little) in the function of finding position of a string inside another string and/or checking existence of one string into another. When the searched string is found at the first character (index=Zero), the function will return Zero and if it is found elsewhere, it will return that Zero based position, and it is NOT found, it may return -1 (depending on the language). { In PHP, however there is a good function which return "false" if the string is not found. } But what if we just want to check weather a string exist in another string or not? There could be another function for this purpose OR you may need to check 2 conditions, one for its index and second for its existence. Now, if the index starts from 1, the function will return 1 if the searched string found at the first character, and this will make easy for checking existence of one string into another, because if the string is not found, the function can return Zero and thus making the IF condition false. So, what do you think about starting number for index in a language if you are going to be the founder of the language?

                                I Offline
                                I Offline
                                Ishmael Turner
                                wrote on last edited by
                                #98

                                I skimmed through this whole thread to see if there was any mention of Dijkstra, but didn't see any so here it is: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html[^] Personally, I prefer 0-based indexes. It makes code dealing with index comparison less clumsy for me.

                                N 1 Reply Last reply
                                0
                                • L Lost User

                                  Alan Burkhart wrote:

                                  "First" is "1st" not "0st".

                                  Actually is "0th" :P

                                  Alan Burkhart wrote:

                                  And, I've always thought it a bit clumsy that a For-Next loop had to stop at Count-1

                                  Don't use For Next. (I would go as far as to say don't use a language that supports it;)) Use for loops that have end conditions and your end condition should be Less than the count (not less than equal) Lastly,

                                  Alan Burkhart wrote:

                                  Humans automatically think of first as being #1

                                  Are you saying that Mathematicians are not human?? ;)

                                  Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                                  A Offline
                                  A Offline
                                  Alan Burkhart
                                  wrote on last edited by
                                  #99

                                  Collin Jasnoch wrote:

                                  Actually is "0th" :P

                                  Well, see. I said it wasn't 0st. :)

                                  Collin Jasnoch wrote:

                                  Don't use For Next. (I would go as far as to say don't use a language that supports it;))

                                  I prefer For Each. But on occasion For Next is appropriate for whatever I'm doing. And I'm one of "those people" who use VB.Net.

                                  Collin Jasnoch wrote:

                                  Are you saying that Mathematicians are not human??

                                  I have been advised by counsel that it is in my best interest to invoke the privilege provided in the 5th Amendment of the US Constitution. ;)

                                  XAlan Burkhart

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    Rob Grainger wrote:

                                    We have always begun counting at 1, we do not begin at zero but omit it. That's an incredibly wierd outlook.

                                    Actually it is a scientific way of looking at it.

                                    Rob Grainger wrote:

                                    I don't think we're omitting the zero - it was never there to begin with. Zero was introduced much later as a concept then counting, and is one of the most significant developments in mathematics, but its not involved in counting.

                                    No it was not introduced at the same time as counting. "Hey Ugh. Get me 3 sticks for fire".... "1.. 2... 3" Counting has been around for a while, but math proofs and formulas which require enumeration did require it and still do (ohhh wait... Is that one computers are doing??? Math formulas? Hmmm I thought it was just for perrty pictures of Salma Hayek) If you are familiar with math proofs you should know the most common value that you are converging from or to is 0. If you are using a 1 base index (or counting and ommitting 0) you will make the algorithms more complicated. Here is another way to show we are indeed omitting in human language. If you write down "10", we know you mean "10". A computer however will use the data before it. If you did nothing to the data it will not be "10" but could be 26310 or 28510 and so on and so on. Now I know what you are thinking. Compiler handles that why can't it do this for us. Because wether you wrote "10" or "0010" has absolutly no effect on the algorithm. You starting your array from 1 does. If you do not grasp that you may need to study mathematics a little more.

                                    Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                                    R Offline
                                    R Offline
                                    Rob Grainger
                                    wrote on last edited by
                                    #100

                                    I absolutely disagree, and would need to see good evidence that counting began with a concept of zero. Types of number: Cardinal: counting numbers 1, 2, 3, ... Ordinal: place numbers 1st, 2nd, 3rd, ... Natural: 0, 1, 2, 3, ... Integers: ..., -3, -2, -1, 0, 1, 2, 3, ... Number representation: Addition Systems: Roman Numerals are the best known example: MCXXIX Position Systems: These require a zero: 3501 Our use of the position system derives from the Hindu system, through the Near East (hence Arabic numerals). The introduction of zero as a number occurred around 800AD. Are you seriously proposing people didn't count until then? Sources: VNR Concise Encyclopedia of Mathematics, Kustener and Kastener. Wikipedia.

                                    L 1 Reply Last reply
                                    0
                                    • L Lost User

                                      Simply put it should be 0 or it becomes more confusing. Many have pointed out why it is 0 and to not grasp that is then dangerous for you to program. The reasoning is simple. You are working with a system that reconizes 0 implicitly. There is no changing that. The reasoning for this is that 0 does exist. In human languages we tend to use 0 implicitly. This means that unless I say otherwise assume 0. Example, I want to order 5 Chicken strips. The waitor will hopefully not bring me 1 of everything else on the menu. Collections being 0 based indexing are indirectly related to this. Define Chicken stripsBasket (implicityly I have 0 chicken strips but I have my basket) Fill basket with 5 chicken strips Now to access your chicken strips you have a reference to the basket... Not your friends basket... Not the basket on the table next to you. Your basket. For efficiency referencing the basket gets you a chicken strip, unless you wanted to actually eat the basket. By requiring 1 based indexing you are adding a step to the chicken strip access which when compounded with the complexity of systems we create today would have horrible performance (and for no reason). If one does not grasp why computer languages use 0 based indexing (more importantly that they do), one should not be a programmer IMHO.

                                      Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                                      R Offline
                                      R Offline
                                      Rob Grainger
                                      wrote on last edited by
                                      #101

                                      I beg to differ. When I order 5 Chicken Strips (unlikely, as I'm veggie, but I digress), I am not referring to 0 of anything at all. Indeed, this is often explicit when it need to be :- "Can I have a full English? but hold on the beans" for example. Referring to none, or zero of something is as explicit as any other reference, but occurs less frequently. I refer to you my post elsewhere in this discussion on the history of zero. tl;dr; it did'nt exist as a number until the year 800CE.

                                      L 1 Reply Last reply
                                      0
                                      • R Rob Grainger

                                        I absolutely disagree, and would need to see good evidence that counting began with a concept of zero. Types of number: Cardinal: counting numbers 1, 2, 3, ... Ordinal: place numbers 1st, 2nd, 3rd, ... Natural: 0, 1, 2, 3, ... Integers: ..., -3, -2, -1, 0, 1, 2, 3, ... Number representation: Addition Systems: Roman Numerals are the best known example: MCXXIX Position Systems: These require a zero: 3501 Our use of the position system derives from the Hindu system, through the Near East (hence Arabic numerals). The introduction of zero as a number occurred around 800AD. Are you seriously proposing people didn't count until then? Sources: VNR Concise Encyclopedia of Mathematics, Kustener and Kastener. Wikipedia.

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #102

                                        I think you misread my post. I said 0 did NOT come at the beginnings of counting. It came with mathematics requiring it. Also I pointed out that mathematics are the basis of computational theorems and this is why we have 0 based indexing.

                                        Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                                        1 Reply Last reply
                                        0
                                        • R Rob Grainger

                                          I beg to differ. When I order 5 Chicken Strips (unlikely, as I'm veggie, but I digress), I am not referring to 0 of anything at all. Indeed, this is often explicit when it need to be :- "Can I have a full English? but hold on the beans" for example. Referring to none, or zero of something is as explicit as any other reference, but occurs less frequently. I refer to you my post elsewhere in this discussion on the history of zero. tl;dr; it did'nt exist as a number until the year 800CE.

                                          L Offline
                                          L Offline
                                          Lost User
                                          wrote on last edited by
                                          #103

                                          I think you missed the point. If you were to write an application for ordering and you define chicken strips collection what do you have? My point is that computer language and human languages are different. In human language we can imply numerous things and this omit details. This is not true of programming languages nor should it be. As I have tried to point out computers require explicit communication since mathematics requires it. Using a 0 base index is in most cases convenient. If it is not the case for your programming I would bet most of your programming deals with UI arrays. These are a small subset of the arrays that exist inside the entire system.

                                          Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups