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.
  • B BobJanova

    The compiler could simply do the -1 calculation, at least for any static indices. You'd have a language where you don't need to do for-loop indexing of arrays if possible (by permitting array operations as a language feature – think APL or R) and anywhere where the looping over an array is done as part of the language, the compiler knows the fixed offsets and can generate the appropriate native code. Only in the case of indexing a fixed-memory array directly by specifying a calculated index would there be an extra operation. And, frankly, that operation is of zero importance for performance on a modern system, where performance is far more about data volumes fitting in chip caches and the parallelisability of algorithms.

    N Offline
    N Offline
    Nagy Vilmos
    wrote on last edited by
    #30

    BobJanova wrote:

    The compiler could simply do the -1 calculation

    It can't. It would need to place an extra step into the machine code to subtract 1 from the index.


    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

    B 1 Reply Last reply
    0
    • M Marc Clifton

      BobJanova wrote:

      It's pretty difficult to work without lists, and you need to get things out of a list.

      Iteration doesn't require indexing to be exposed. If I need to index something by a hard-coded value, then that's bad. If it's a computed value (like a portion of a string) then it should be able to be represented in a better way, again hiding the details of indexing.

      BobJanova wrote:

      but a lot of real world problems would be much more difficult without being able to look things up by index in arrays or collections.

      For example? Even matrix operations can be coded with more clarity if the matrix array could be mapped onto a structure so one didn't have to write "[0]". Marc

      My Blog

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #31

      Iteration requires looking at all the items, sometimes you don't want to do that. For example? You've got a list of purchase records in some form of ID-indexed structure, and presented to the user is a list of their titles. When they select one, you want to generate a report of the details of the record they selected (i.e. records[record_id]). You've got a network protocol where the last byte of a message (bytes[bytes.length - 1]) is a checksum. Various string manipulations as currently done with Substring methods (extracting particular fields from a combined text string of some kind). One of the parameters to that method in all conventional languages is an 'index' (actually an offset in most of them).

      M 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?

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

        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.

        G W R 3 Replies Last reply
        0
        • N Nagy Vilmos

          BobJanova wrote:

          The compiler could simply do the -1 calculation

          It can't. It would need to place an extra step into the machine code to subtract 1 from the index.


          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

          B Offline
          B Offline
          BobJanova
          wrote on last edited by
          #33

          Did you read the rest of the post? As I said there, "Only in the case of indexing a fixed-memory array directly by specifying a calculated index would there be an extra operation". And most of the times you have to do that now are because of a language deficiency. And finally one instruction is so trivial that who cares anyway (on a 4Ghz machine it will cost you 0.25ns, and that's if getting the data your algorithm is working on onto the core cache isn't the limiting factor already) – language design should not be constrained by such trivia.

          N 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)

            R Offline
            R Offline
            realJSOP
            wrote on last edited by
            #34

            Great. Now I'm going to have to find/edit all of my messages where lists start with 0.

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

            1 Reply Last reply
            0
            • G gumi_r msn com

              From your post you seem to be implying we should just do without levels of abstraction. So what if the compiler has to do some dirty work for you just because you start at 1 and not at 0? I wouldn't care less, there is no meaningful implication anyhow. Also, the way we count apples, apple nº0 is not meaningful, it is not an apple. Having 0 apples means you have...well no apples at all. We start to count in 1 because that is the first meaningful number when we have apples to begin with, that's why we count all the way up to apple nº10 and do not stop at apple nº9 (apple nº9 is the 10th apple...hmm isnt that obvious? now try explaining that to somenone who has never programmed and you'll really see how intuitive zero based indexing is).

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

              gumi_r@msn.com wrote:

              From your post you seem to be implying we should just do without levels of abstraction.

              Not at all. I am implying there is no reason to abstract it. A programmer should understand the bases of what they are programming in (for efficiency). Yes the compiler can handle it. But when it comes to dynamic allocations you end up in the run time. Now it is about perfomance of the app (rather than speed of the build) so not such a good thing. When you count Apples you DO start with 0. You used the word APPLE No? In computers that is where 0 starts, The definition. In Human tounge it is an implicit deffinition. Computers must work in concrete terms. You can't change that. Yes you can abstract it. But at a cost of efficiency.

              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.

              G 1 Reply Last reply
              0
              • N Nikunj_Bhatt

                I mostly like loosely typed languages, it decreases programming code. When I program, I know that what type of value the function will accept and return, and I can trap it in anyway by the language's features. So I don't need to know the exact data type.

                W Offline
                W Offline
                Wjousts
                wrote on last edited by
                #36

                nikunjbhatt84 wrote:

                I mostly like loosely typed languages

                I don't

                nikunjbhatt84 wrote:

                it decreases programming code

                By increasing (potential) bugs.

                nikunjbhatt84 wrote:

                When I program, I know that what type of value the function will accept and return

                So what's the problem with specifying that in the code, since you know it already.

                nikunjbhatt84 wrote:

                and I can trap it in anyway by the language's features.

                Sounds like more code to me :confused:

                1 Reply Last reply
                0
                • D Dr Walt Fair PE

                  I'd make it specifiable so you could decide in each case what made better sense as the base index. (Didn't Algol have that?) I certainly wouldn't mix boolean and integers, though. That's why there are two types!

                  CQ de W5ALT

                  Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

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

                  Walt Fair, Jr. wrote:

                  I'd make it specifiable so you could decide in each case what made better sense as the base index.

                  That seems dangerous. If the system is changing its base index how is a maintainer of the system suppose to understand the logic of the one whom developed it in the previous decade? Yes in some cases you want 1 base. The only time I run into this is if some values are making it to the UI. E.g. I have a grid displaying products. Users understand it as 1,1; 1,2; 1,3 but the system understands it as 0,0; 0,1; 0,2 This is exactly why patterns exist for what we display versus the business logic (MVVM, MVC etc.) Your business logic should NOT be using a modified index as it is leads to confusion in other parts of the system (non viewable). I have seen code where the developers tried to be clever and do these things. You end up with a freaking mess. Keep it consistent across the board.

                  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.

                  D 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

                    W Offline
                    W Offline
                    Wjousts
                    wrote on last edited by
                    #38

                    I agree with you, and I absolutely believe in counting from zero, but to be fair, if a language is compiled, then all those MyArray[n] can be replaced with MyArray[n-1] by the compiler making it a moot point at run time. [Edit: actually ignore that. It would only work for statically indexed arrays and maybe for loops. For calculated indexes, the -1 has to be done at runtime]

                    1 Reply Last reply
                    0
                    • 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.

                      B Offline
                      B Offline
                      BobJanova
                      wrote on last edited by
                      #39

                      This makes no sense. Counting and indexing are completely different things – even the 0 based computing world accepts that a collection of things A, B and C has 3 items, even if it calls them '0', '1' and '2'. The fact is if a person is counting objects they do use 0, it is just omitted. That doesn't mean anything either. A count of 0 is when there are no things to count. But if there are 6 apples, it doesn't matter what indexing system you use, or how many you count at once, there are always 6. What 'indexing' is about it labelling. Ask anyone to label those apples with numbers and everybody (unless they're being deliberately silly) will call them '1', '2', '3', '4', '5' and '6'. Look at things which are labelled in the real world: bases on a rounders/baseball field, quarters or halves in a sports match, aisle numbers in the supermarket. Even in the computing world this is often true; look at the MRU on Excel or Word, it numbers your recently used files from the first (1) up. Well starting the index at 1 for computers is inefficient As I'm discussing with Nagy above, technically true in a small number of cases (many of which are due to language deficiencies regarding array operations in C family languages) but so small as to be irrelevant as a consideration in the modern world. The fundamental question is really: do you want a language for the computer, or one for the people who write it? I would prefer to write one for people and let the compiler or interpreter deal with the translation.

                      L 2 Replies 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.

                        G Offline
                        G Offline
                        gumi_r msn com
                        wrote on last edited by
                        #40

                        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.

                        L J 2 Replies 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?

                          L Offline
                          L Offline
                          Luc Pattyn
                          wrote on last edited by
                          #41

                          Mine would be user definable, with a default value of zero. Many languages have user-definable index ranges: Ada[^], Fortran[^], Modula-2[^], and more. Other languages have more complex schemes, such as the mapping provided by PHP[^]. :)

                          Luc Pattyn [My Articles] Nil Volentibus Arduum

                          G 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.

                            W Offline
                            W Offline
                            Wjousts
                            wrote on last edited by
                            #42

                            Collin Jasnoch wrote:

                            In human languages we tend to use 0 explicityly.

                            I think you mean implicitly.

                            Collin Jasnoch wrote:

                            Example, I want to order 5 Chicken strips.

                            Damn, now I'm hungry. Is it lunch time yet?

                            L 1 Reply Last reply
                            0
                            • L Luc Pattyn

                              Mine would be user definable, with a default value of zero. Many languages have user-definable index ranges: Ada[^], Fortran[^], Modula-2[^], and more. Other languages have more complex schemes, such as the mapping provided by PHP[^]. :)

                              Luc Pattyn [My Articles] Nil Volentibus Arduum

                              G Offline
                              G Offline
                              gumi_r msn com
                              wrote on last edited by
                              #43

                              That I honestly would not like at all. I think a bad standard is better than no standard at all. It would be a nightmare if everytime you had to get your hands dirty with some codebase you had to factor in the index base whoever wrote the code decided to use on that given day/project/etc.

                              L 1 Reply Last reply
                              0
                              • B BobJanova

                                Iteration requires looking at all the items, sometimes you don't want to do that. For example? You've got a list of purchase records in some form of ID-indexed structure, and presented to the user is a list of their titles. When they select one, you want to generate a report of the details of the record they selected (i.e. records[record_id]). You've got a network protocol where the last byte of a message (bytes[bytes.length - 1]) is a checksum. Various string manipulations as currently done with Substring methods (extracting particular fields from a combined text string of some kind). One of the parameters to that method in all conventional languages is an 'index' (actually an offset in most of them).

                                M Offline
                                M Offline
                                Marc Clifton
                                wrote on last edited by
                                #44

                                Intriguing discussion. :)

                                BobJanova wrote:

                                When they select one, you want to generate a report of the details of the record they selected (i.e. records[record_id]).

                                Erm: what about DataRow selectedRow = selectionEventArgs.SelectedRow; ?

                                BobJanova wrote:

                                You've got a network protocol where the last byte of a message (bytes[bytes.length - 1]) is a checksum.

                                Been there. I submit that the packet can be coded into a memory map (I did this as a union ages ago) to a structure, so I could write packet.Checksum OK, granted the packet was a fixed length. :)

                                BobJanova wrote:

                                One of the parameters to that method in all conventional languages is an 'index'

                                Yeah, which I find annoying. If the fields within the string are fixed length, then they can be put into a structure. If the fields aren't fixed length, then I submit that the language (you did ask originally, if I was defining a language) should allow for specifying, say, delimiters (which a variable length string of sub-fields would almost always need unless there was some encoding, like in compression, that determines the length) so that again, the programmer would be isolated from using indices. Marc

                                My Blog

                                B 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

                                  L Offline
                                  L Offline
                                  Luc Pattyn
                                  wrote on last edited by
                                  #45

                                  Nagy Vilmos wrote:

                                  Which is easier to compute?

                                  Neither. p+(n-1)*s equals (p-s)+n*s where (p-s) is a constant, just like p is, so all it takes is a different origin, the computational effort is exactly the same. :)

                                  Luc Pattyn [My Articles] Nil Volentibus Arduum

                                  N 1 Reply Last reply
                                  0
                                  • W Wjousts

                                    nikunjbhatt84 wrote:

                                    the function can return Zero and thus making the IF condition false.

                                    No, because using zero as false is dangerous. That's why strongly typed languages (such as C#) have an actual bool class. So you don't accidentally mix up using an int as a bool when it was supposed to be an int.

                                    P Offline
                                    P Offline
                                    PIEBALDconsult
                                    wrote on last edited by
                                    #46

                                    Wjousts wrote:

                                    using zero as false is dangerous

                                    Correct. Zero should be true. :-D I further agree that programming languages need a definite boolean type. Back when D was still being ironed out, I was one who argued in favor of a boolean type. It didn't happen, I don't use D.

                                    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

                                      P Offline
                                      P Offline
                                      PIEBALDconsult
                                      wrote on last edited by
                                      #47

                                      Nagy Vilmos wrote:

                                      The array variable will be a pointer to a memory address

                                      That's just a detail of implementation, this is a conceptual discussion.

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        gumi_r@msn.com wrote:

                                        From your post you seem to be implying we should just do without levels of abstraction.

                                        Not at all. I am implying there is no reason to abstract it. A programmer should understand the bases of what they are programming in (for efficiency). Yes the compiler can handle it. But when it comes to dynamic allocations you end up in the run time. Now it is about perfomance of the app (rather than speed of the build) so not such a good thing. When you count Apples you DO start with 0. You used the word APPLE No? In computers that is where 0 starts, The definition. In Human tounge it is an implicit deffinition. Computers must work in concrete terms. You can't change that. Yes you can abstract it. But at a cost of efficiency.

                                        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.

                                        G Offline
                                        G Offline
                                        gumi_r msn com
                                        wrote on last edited by
                                        #48

                                        Collin Jasnoch wrote:

                                        When you count Apples you DO start with 0. You used the word APPLE No? In computers that is where 0 starts, The definition. In Human tounge it is an implicit deffinition. Computers must work in concrete terms. You can't change that. Yes you can abstract it. But at a cost of efficiency.

                                        That is a really wierd way to undersant it. We live in a 1 based indexing world. You said it yourself, we have the luxury of being able to omit the 0th element in our life precisely because it means NOTHING to us. Quite the contrary in the programming world, where the 0th element or the nth element are equally meaningful.

                                        L 1 Reply Last reply
                                        0
                                        • N Nagy Vilmos

                                          BobJanova wrote:

                                          It would be simple enough for a compiler to calculate the offsets to put into the byte code, anyway.

                                          How? See my comment above, by reducing the number of steps, you produce more efficient programs.


                                          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

                                          P Offline
                                          P Offline
                                          PIEBALDconsult
                                          wrote on last edited by
                                          #49

                                          Nagy Vilmos wrote:

                                          by reducing the number of steps, you produce more efficient programs

                                          Who cares? :confused:

                                          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