Zero based indexing gone too far



  • Alright, zero based indexing has really gone too far this time:

    SQL Server 2008 Release Candidate 0

     



  • I really hate zero-based indexing.  Can't we move on beyond this?



  • @morbiuswilters said:

    I really hate zero-based indexing.  Can't we move on beyond this?
     

    Obviously, you don't understand how pointers work. Get a C book.



  • This isn't new. They did it for Windows Server 2008, too.



  • @DrJokepu said:

    @morbiuswilters said:

    I really hate zero-based indexing.  Can't we move on beyond this?
     

    Obviously, you don't understand how pointers work. Get a C book.

    I do understand the reasoning.  It's because C is barely-abstracted assembly and we still haven't moved beyond memory offsets for specifying an index.  It's still fucking retarded. 



  • @bstorer said:

    This isn't new. They did it for Windows Server 2008, too.
     

    Agreed, but I am tired of seeing it.

    It is really ridiculous now.



  • It can't tell if you're being sarcastic or not. One of the best things about 0-indexing in higher level languages is the ability to access elements at the end of an array with a negative integer (i.e. -1 is the last element). Obviously this wouldn't work with 1 based indexes and would be a major step back in useability.



  • yes because let's do one additional subtract-immediate operation every time we do an array index... it won't add up to billions of instructions or anything

     

    You must generate some good WTFs with your total disregard for TECHNICAL reasons for doing things.

     



  • @duder said:

    It can't tell if you're being sarcastic or not. One of the best things about 0-indexing in higher level languages is the ability to access elements at the end of an array with a negative integer (i.e. -1 is the last element). Obviously this wouldn't work with 1 based indexes and would be a major step back in useability.

    Why the hell do you think this wouldn't work if arrays were 1-indexed? What effect would that have on anything?



  •  Well, it could work...

    array[1] is the first element

    array[-1] is the previous element

    array[0] is lost somewhere in space-time.

    &array[2] = &array[1] + 1;

    BUT &array[1] = &array[-1] + 1;

    Who cares about inconsistencies? Go code PHP FFS :P.



  • @Kazan said:

    yes because let's do one additional subtract-immediate operation every time we do an array index... it won't add up to billions of instructions or anything
    Oh, noes! Billions of instructions! That's like, seconds of lost time! Do you really think that high-level languages are concerned primarily with performance anyway?



  • @Kazan said:

    yes because let's do one additional subtract-immediate operation every time we do an array index... it won't add up to billions of instructions or anything

     

    You must generate some good WTFs with your total disregard for TECHNICAL reasons for doing things.

     

     

    Please use the quote button. You could be referring to just about anyone here.



  • @Kazan said:

    yes because let's do one additional subtract-immediate operation every time we do an array index... it won't add up to billions of instructions or anything

     

    Are you serious or is this just a flamebait?


  • @MasterPlanSoftware said:

    Please use the quote button. You could be referring to just about anyone here.

     

    Oh, here we go again... 



  • @morbiuswilters said:

    I really hate zero-based indexing.  Can't we move on beyond this?

    $[++;



  • @Kazan said:

    yes because let's do one additional subtract-immediate operation every time we do an array index... it won't add up to billions of instructions or anything
     

    Why would you have to execute an add instruction? If it's defined to work this way in the language, the compiler can take care of this. For example, you can store the memory address minus one for array references.

    You don't really want to move away from 0-based indexes, as that's what is commonly used in mathematics. Unfortunately the one program that tried to 'simplify' indexing is Matlab, which starts indexes at 1, which makes entering (0-based) formulas needlessly confusing.



  • @morbiuswilters said:

    I really hate zero-based indexing.  Can't we move on beyond this?

    Zero indexing is how computers work, and it makes the most sence. Most languages (except VB and a few other POS languages) use 0 indexing. Think about it, if an index is an offset of the array, it follows that 0 is the first element because it has an offset of nothing, and 1 has an offset of one and therefore is the element after the first. Now, when presenting offsets to users, how hard is it to just add one to the index? For example, in a mysql query you use the LIMIT clause, and LIMIT 0, 30 is the first page with 30 elements per page. When making the query in the back end, its much simpler to call that page 0 (instead of 1 - 1); but when showing the use which page it is on, it is not hard to just add one so that page is 1 instead of 0.

    Also, many people use languages like C++, where you have to deal with pointers. In that case, 0 indexing is a must, as in C++ vectors or C++ 'arrays' the pointer always points to the first element, and an offset of zero is the same as using the pointer directly.

    I see no single good reason why we should use 1-indexed arrays, and many reasons not to. The first of which is that you will encourage high level/scripting language developers to use a different scheme of indexing arrays then unmanaged/low language developers, and because I program in both C++ and C#/PHP/JavaScipt/Perl - it would just make language switching more difficult.

     Please give meone good reasen why 1-indexing is a good idea.



  • @NorseLaQuet said:

     Most languages (except VB and a few other POS languages) use 0 indexing. Think about it, if an index is an offset of the array, it follows that 0 is the first element because it has

     

    When did VB not use a zero based index?  Just curious.



  • @NorseLaQuet said:

    Please give meone good reasen why 1-indexing is a good idea.
     

      print goodReasons[0];

     

    damn it...



  • @NorseLaQuet said:

     Please give meone good reasen why 1-indexing is a good idea.
     

    Because that is how people think and therefore it is more natural?

    Why should the language make sense to the computer and not to the person instead?



  • @NorseLaQuet said:

    Zero indexing is how computers work, and it makes the most sence.
    High-level languages are supposed to abstract away how the computer works. Why should you bend to the computer? You're the one whose time is valuable.
    @NorseLaQuet said:
    Most languages (except VB and a few other POS languages) use 0 indexing.
    Cute piece of trolling here. Also, VB lets you pick between 1 or 0.
    @NorseLaQuet said:
    Think about it, if an index is an offset of the array, it follows that 0 is the first element because it has an offset of nothing, and 1 has an offset of one and therefore is the element after the first.
    The first element: that is, element 1. Humans count starting at 1, not zero. If you had a stack of paper on your desk, you don't call the top sheet the 0-th; you'd call it the first.
    @NorseLaQuet said:
    Also, many people use languages like C++, where you have to deal with pointers. In that case, 0 indexing is a must, as in C++ vectors or C++ 'arrays' the pointer always points to the first element, and an offset of zero is the same as using the pointer directly.
    People love to use this defense, but it's really not true. Starting arrays at 0 was a design decision. There's really no reason that C couldn't start array indices at 1 and let the compiler convert this down. Fortran is 1-indexed, and even older than C.
    @NorseLaQuet said:
    he first of which is that you will encourage high level/scripting language developers to use a different scheme of indexing arrays then unmanaged/low language developers, and because I program in both C++ and C#/PHP/JavaScipt/Perl - it would just make language switching more difficult.
    If you can't handle switching between high- and low-level languages, that's your problem, not mine. I can manage to program in a variety of languages, and I'm not special in that regard.



  • @NorseLaQuet said:

    Zero indexing is how computers work, and it makes the most sence.

    No it isn't.  You are an idiot.  Computers have no notion of "indexing", it's merely an abstraction to help humans.

     

    @NorseLaQuet said:

    Most languages (except VB and a few other POS languages) use 0 indexing.

    That's why I said we should move beyond it.  Just because it's "the way it's done" doesn't mean it is right or optimal.

     

    @NorseLaQuet said:

    Think about it, if an index is an offset of the array, it follows that 0 is the first element because it has an offset of nothing, and 1 has an offset of one and therefore is the element after the first.

    The offset thing has nothing to do with indexes, it has to do with poor abstraction of the memory model used underneath.  Counting starts at 1.  That's how it works, okay?

     

    @NorseLaQuet said:

    Now, when presenting offsets to users, how hard is it to just add one to the index? For example, in a mysql query you use the LIMIT clause, and LIMIT 0, 30 is the first page with 30 elements per page. When making the query in the back end, its much simpler to call that page 0 (instead of 1 - 1); but when showing the use which page it is on, it is not hard to just add one so that page is 1 instead of 0.

    This is all completely irrelevent.  If you used 1-based indexing there would be no reason to "add one for display".  It all has to do with a horribly antiquated system that makes me cringe every time I see it.

     

    @NorseLaQuet said:

    Also, many people use languages like C++, where you have to deal with pointers. In that case, 0 indexing is a must, as in C++ vectors or C++ 'arrays' the pointer always points to the first element, and an offset of zero is the same as using the pointer directly.

    "C++ uses pointers so all languages should have manual memory management!"  Really, that's what you are saying.

     

    @NorseLaQuet said:

    The first of which is that you will encourage high level/scripting language developers to use a different scheme of indexing arrays then unmanaged/low language developers, and because I program in both C++ and C#/PHP/JavaScipt/Perl - it would just make language switching more difficult.

    Wow, if 1-based indexes would throw you for a loop then there's no way you're programming effectively in high-level languages.  The whole point of high-level languages is that they abstract things better than low-level languages.  Zero-based indexes are the exception that we have unfortunately been stuck with. 



  • @MasterPlanSoftware said:

    @NorseLaQuet said:

     Please give meone good reasen why 1-indexing is a good idea.
     

    Because that is how people think and therefore it is more natural?

    Why should the language make sense to the computer and not to the person instead?

    0 is commonly seen as "the beginning". That's why we have stuff like "Year Zero", "zero-day event", "Day Zero", "Ground Zero" ... it has meant "beginning" ever since the 0 was introduced.

    Older cultures simply ignored the 0, and part of the bad symptoms of doing this are still haunting us to this day. For example, according to historians there is no "Year Zero", even though Jesus was theoretically born on Dec 25, 0000; you'll find historians referring to that date as Dec 25, -1 (or 1 BC.) Fortunately sticking to the ISO definition gives us our nice "Year Zero", but it will not match with historian's information because they omit the 0. (Plus, if we did have a Year Zero in the calendar, centuries would be counted in a sane way, rolling over at 1900,2000,2100 and such!)

    Roads have "Mile 0" or "Km. 0" at some point. Tracks have similar markings. Any measuring scale starts at 0, like it or not. Even beta software starts at 0.1 or similar versioning schemes ... usually 1.0 means "first production release". Cartesian coordinates have zeroes too, and well arrays are nothing more than Cartesian-measured n-dimensional spaces, aren't they?



  • @danixdefcon5 said:

    0 is commonly seen as "the beginning".
     

    So you normally start counting at '0' and not '1'?



  •  @MasterPlanSoftware said:

    Because that is how people think and therefore it is more natural?

    Why should the language make sense to the computer and not to the person instead?

    When you need to find the position in a 1D array based on 2D coords with a width (w) attribute:

     i=y*w+x

    coord 0,0 equals 0, as it should.  0,5 is 5... etc, easy, clean, effecient.  granted you could wrap it all in (y*w+x)+1 but, it still has to convert it back behind the scenes, since position 1 has to translate to memAddress+(index-1)*sizeOfDataType if item 0 is accessed at 1.

    Another reason is how we deal with coordinate systems in general, assume we are using only positive coord space:  0,0 is naturally the first 'spot' in the coord space.  0,0,0 is the first spot in 3D coord space.  0 is the first spot in 1D space - so we've really been trained to think this way since basic geometry and formula graphing in highschool math.

    When you allocate a block of memory for an array, you are creating a 1D coord space of memory, each unit being equal to sizeOfDataType.  It just seems more natural to me, more effecient, and makes it easier to model data in the array itself. 

    I can understand how someone new to programming can mess up.  The "a[a.len-1]" thing can be a bit annoying at first, but it makes sense when you get under the hood.


    You can also think about it this way:

    You need to put a value that is 32 bits long, into an array that expects 32 bit blocks.  Its the first item for the array - where do you want to start writing it?  You want to write it from the beginning of the array, to its length, so it fits nicely in the very first slot.  So you want it to start writing at bit 0 of index 0.  Same with accessing, the index is for where you want to start reading from, for the length of the data type.

    That's basically why it makes more sense to me, than treating it as a container of discreet units.  The first unit of a motel is numbered "1" but the row of rooms starts at "zero feet" and ends at "unit width in feet."  Calling it "room 1" for the motel customer makes sense, in the same way as you don't start displaying "page 0" on a webpage.  For the engineers and artitects, they always start from "0" and it makes sense to me that its the same for software engineers.


  • @MasterPlanSoftware said:

    So you normally start counting at '0' and not '1'?
     

    One exists in the space from zero and one.  That's not supposed to be some wierd zen quote.  Look at a ruler - it starts at zero and has a one at the distance of one unit.  The value "one" is not an object, its a quantity, with a span of a single unit. 



  • @NorseLaQuet said:

    I see no single good reason why we should use 1-indexed arrays, and many reasons not to.
     

    I see no single good reason for 0 based indexes. It really is silly to not abstract this. This has already been solved in "ancient" languages like Fortran77, which lets you declare multidimensional arrays with arbitrary lower and upper bounds on each dimension.

    Why should the programmer have to do index arithmetic to make life easier for compiler designers? If you have a data set that runs from (-10,-20) to (22,30) and you're stuck with {0,1}-based indexes, you end up doing busy work adjusting your indexes. It's unfortunate that most (all?) recent languages haven't picked up on this yet.



  • @BeenThere said:

    @MasterPlanSoftware said:

    So you normally start counting at '0' and not '1'?
     

    One exists in the space from zero and one.  That's not supposed to be some wierd zen quote.  Look at a ruler - it starts at zero and has a one at the distance of one unit.  The value "one" is not an object, its a quantity, with a span of a single unit. 

    Like Lyle, MPS always has one of everything. Not having something is for normal people.




  • @Nandurius said:

    I see no single good reason for 0 based indexes. It really is silly to not abstract this. This has already been solved in "ancient" languages like Fortran77, which lets you declare multidimensional arrays with arbitrary lower and upper bounds on each dimension.

    Why should the programmer have to do index arithmetic to make life easier for compiler designers? If you have a data set that runs from (-10,-20) to (22,30) and you're stuck with {0,1}-based indexes, you end up doing busy work adjusting your indexes. It's unfortunate that most (all?) recent languages haven't picked up on this yet.

     

    Look at a ruler, with 12 inches on it.  Mark 1 and 9 the way you would with your Fortran array(1,9) and see how much room you have in there.  Measure it with another ruler if you have to.  You have 8 inches of space in between your marks. You can measure that with another ruler and verify what I'm talking about. Eight inches of space is not enough to hold 9 values each 1 inch long each.  Doesn't it make sense to store "the first inch" from 0 to 1 then?



  • @BeenThere said:



    You need to put a value that is 32 bits long, into an array that expects 32 bit blocks.  Its the first item for the array - where do you want to start writing it?  You want to write it from the beginning of the array, to its length, so it fits nicely in the very first slot.  So you want it to start writing at bit 0 of index 0.  Same with accessing, the index is for where you want to start reading from, for the length of the data type.
    Now you're begging the question. I could just as easily say that one wants to start writing at the first bit of the first index, that is, bit 1, index 1. In fact, I'd say this makes more sense: if you have n slots for things, you number them 1...n, not 0...n-1.
    @BeenThere said:
    That's basically why it makes more sense to me, than treating it as a container of discreet units.
    But arrays ARE containers of discrete units. Just because you know how C does them behind the scenes means nothing in terms of the abstraction they represent. You need to divorce yourself from this; there's no reason an array cannot be stored as a linked list, a tree, or even a freaking skip list.
    @BeenThere said:

    That's basically why it makes more sense to me, than treating it as a container of discreet units.  The first unit of a motel is numbered "1" but the row of rooms starts at "zero feet" and ends at "unit width in feet."
    Again, you're thinking about it wrong. When you measure something 1 foot long, it will line up with the 1 on the ruler. When your room is n feet wide, it will line up with n on the tape measure.



  • @BeenThere said:

    Doesn't it make sense to store "the first inch" from 0 to 1 then?
    We're not storing intervals, we're storing discrete values. If you have 1 thing, you put it in slot #1.



  • @Nandurius said:

    Like Lyle, MPS always has one of everything. Not having something is for normal people.


    When are people going to learn that if you mock someone, it should be clever/amusing or at least make sense so you don't just annoy everyone else?

     



  • I joined right after seeing this thread. Let's see...

    So you normally start counting at '0' and not '1'?

    That's right. [i]Counting[/i] starts from 1. However, indexing is not a method for counting. It's a method for [i]referencing[/i] elements in an array. For example, std::vector::size() returns 1 when the last element in a vector is 0. It returns 1. So you see, computers also count starting from one (how would they define emptiness if they started counting from zero?).
    There's no such thing as a "zeroth element". In C/++, is first element (ordinal notation) in an array is element 0 (cardinal notation). In BASIC, the first element in an array is element 1.
    While the index for the first element could start at any number (0, 1, -145, 12.5), it makes more sense for it to be an offset from the start of the structure, since this is the way computers work. And yes, it [i]is[/i] the programmer who has to adapt to the computer (at least for now), not viceversa. Otherwise, a typical computer program would be "print my name to the screen" or "integrate f(x)=(x^2+x)/2, then save the result in LaTeX and print it".

    Now, using 1-based indexing can actually be [i]more[/i] confusing than 0-based indexing. For example, when questioned about the first year of the 21st century, most people will answer it's the 2000, when it's actually the 2001. That's because there never was a year 0. The first day of the age was 0001-01-01 (I'm ignoring such details as calendar conversion. This is just a demonstration). If the 21st century started 2000 years after the year 1, then it started on 2001. So the problem here is that we're using an ordinal system as if it was a cardinal system.



  • @Helios said:

    That's right. Counting starts from 1. However, indexing is not a method for counting. It's a method for referencing elements in an array. For example, std::vector::size() returns 1 when the last element in a vector is 0. It returns 1. So you see, computers also count starting from one (how would they define emptiness if they started counting from zero?).
    Look, I said this to BeenThere above, and I'll repeat it for you: you need to divorce yourself from how you think computers handle arrays. It doesn't matter how computers handle them. Programming languages are intended to be an abstraction away from how the computer works to the way humans think.
    @Helios said:
    While the index for the first element could start at any number (0, 1, -145, 12.5), it makes more sense for it to be an offset from the start of the structure, since this is the way computers work. And yes, it is the programmer who has to adapt to the computer (at least for now), not viceversa. Otherwise, a typical computer program would be "print my name to the screen" or "integrate f(x)=(x^2+x)/2, then save the result in LaTeX and print it".
    That's the stupidest argument I've seen yet. You suggest that since computers don't understand natural language, we should go entirely in the other direction? Instead of, say, making computers bend to our needs as much as current technology allows?
    @Helios said:

    Now, using 1-based indexing can actually be more confusing than 0-based indexing. For example, when questioned about the first year of the 21st century, most people will answer it's the 2000, when it's actually the 2001. That's because there never was a year 0.
    Yes. There's a reason for that, and I'm going to emphasize it because people don't seem to be picking up on it. Ready? There was no year 0 because PEOPLE DON'T START COUNTING AT ZERO!



  • @Stan Kelly-Bootle said:

    <font><font face="Verdana, Arial" size="2">Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.
    </font></font>

    :-)



  • @bstorer said:

    @Helios said:

    Now, using 1-based indexing can actually be more confusing than 0-based indexing. For example, when questioned about the first year of the 21st century, most people will answer it's the 2000, when it's actually the 2001. That's because there never was a year 0.
    Yes. There's a reason for that, and I'm going to emphasize it because people don't seem to be picking up on it. Ready? There was no year 0 because PEOPLE DON'T START COUNTING AT ZERO!
    No, the reason there is no year 0 is because 2008 years ago, people didn't even know ZERO! In fact, thats where the Mayans 0wned the occidental culture: not only did they "discover" zero and use it in their base-20 system, they actually set their calendar epoch as 0.0.0.0.0 and 0 is used in the Long Count calendar. And if anyone decided to "reset" the year count in a modern calendar, they would do it starting by year zero.



  • @bstorer said:

    Now you're begging the question. I could just as easily say that one wants to start writing at the first bit of the first index, that is, bit 1, index 1. In fact, I'd say this makes more sense: if you have n slots for things, you number them 1...n, not 0...n-1.


    That bit exists from zero to one, thus starts at zero.

    You are right that it makes more sense when your 'index' is a 'slot identifier' - that's true.  You don't book "room zero" at a motel or view "page zero" of search results.  At that point, your 'index' is really just a numeric identifier for a slot - not really an indexed starting point anymore.  That's fine for lists or container objects, when it comes to arrays I think of the index as the 'starting point reference' for the data there.  You start at the beginning, before anything else, which is zero - the only thing less than one.  

    @bstorer said:

    But arrays ARE containers of discrete units. Just because you know how C does them behind the scenes means nothing in terms of the abstraction they represent. You need to divorce yourself from this; there's no reason an array cannot be stored as a linked list, a tree, or even a freaking skip list.

    That's when you chose to use a vector or linked list or something other than an array - which is a block of fixed memory where elements can be accessed by an index value indicating their starting position.  I hate it when a language abstracts an array out to some resizeable stretchy container class - if I want an array of 1024 bits I won't want a 32 bit memory address for every single stink'n bit, with a numerical 'int' key mapped to the bit value, sunk into a binary tree... if I did - I'd use a container class that functioned that way.

    @bstorer said:

    Again, you're thinking about it wrong. When you measure something 1 foot long, it will line up with the 1 on the ruler. When your room is n feet wide, it will line up with n on the tape measure.


    But that something starts at zero and lines up with the one or 'n' on the ruler/tape measure.  The index is where something starts, and that something ends at the index+ the length unit.  Things are 'spans' and have a start and an end.  The first 'bit' in a backup tape starts at 0,0 in relation to the physical 2D space the tape occupies, and takes up a small but specific amount of space.


    I really do understand your point:  That most people want a 'container that can hold x values' when they make an array, and the most logical way to deal with a "container of slots" is to access them as "slot 1, slot 2" etc.  I get that.  The thing is, while you can use an array like that, that's not really what an array is.  Its intentionally not abstracted out as a container, but a 'span of memory' designed to hold a fixed number of units.  This is done for certain effeciency reasons, and at times that is exactly what you want. 

    Most container classes copy the array indexing model, just to keep it consistent, even if its not as logical - its harder for some people to remember the difference between a sequential numeric identifier and an index... so that's how it worked out. 

    I don't mind that you disagree, but personally, I'd rather have arrays work with actual indexes and have containers act like them for consistency, than have arrays act like containers for consistency.



  • 1.  using an array index has nothing to do with"counting."  Last time I checked, I don't count to which index to use.

    2.   I'm a little confused why this is even worth discussing.  In high level languages you should rarely be using array indexes anyways.  You should usually be using an iterator or for-each loop.

    3.  I do not change my thinking to program with array indexes.  I think in 0-indexes.  Sure, it's because that's what I am used to, but there is a substatial argument to be made here.  Why should a million people change their mind when there is really no compelling reason to.  And saying the reason is because it makes learning to program harder is bullshit because it's not hard to learn.

    4.   usign 1 indexing causes a minor inconsistency when doing some common arithmatic.  For instance:

    sat you have an array with length 4 and an array of length 5.  Lets show some examples of what happens when you find the middle element:

     

    1 indexing:

    middle = array4[array4.length / 2 ] = array4 [ 4 / 2 ] = array4[2] = the second of four item.

    middle = array5[array5.length / 2] = array5[ 5 / 2] = array5[2] = the second of five items = wrong

    So lets fix that:

    middle = array5[1+ arrray5.length / 2] = array5[1 + (5/2) ] = array5[3] = the third item.  correct this time.

    5.  If you are programming and you are using indexes as an abstraction and saying: "I want the third item from this array,"  then I contest that you are not programming at a very high level at all.  Unless you are doing some kind of vector work (like graphics or something) you probably shouldn't really say to yourself....  "let me get the Nth object from this array..."

    6.  Vector and Matrix mathematics is 0 indexed.



  • @bstorer said:

    There was no year 0 because PEOPLE DON'T START COUNTING AT ZERO!

    I'm not sure if there was no 0 two thousand years ago, but you are correct. Counting doesn't start at zero (that's what I said, by the way). The current calendar is not using an offset since the epoch. It's using ordinals. So it's actually incorrect to say "year 2008" instead of "2008th year" (yes, there is a difference).
    @bstorer said:
    You suggest that since computers don't understand natural language, we should go entirely in the other direction?

    No. The completely opposite direction would be making programmers write in machine code. That is just silly nowadays. However, there's nothing ludicrous about wanting to understand the computer better by trying to think a bit like it.



  • Hey guys, there are reasons for and against both systems.

    Zero based indexing make sense when we are dealing with distance. Distance equations are at their simplest to calculate within a zero based system.

    One based indexing is easier for people to think in if they aren't really concerned with distance.

    But what would be nice are arrays that start at an arbitrary offset and go to an arbitrary offset, so people can have thier one based, zero based, and 5894335 based indexing



  • @Kain0_0 said:

    But what would be nice are arrays that start at an arbitrary offset and go to an arbitrary offset, so people can have thier one based, zero based, and 5894335 based indexing

     

    I guess you could use Perl...



  •  I would like to add two things to the thread.

    First, at least in C#, it is possible to create a class/struct having an indexer which emulates a 1-based behaviour.

    Second, I think we can agree the most disgusting example of the 0-based insanity is that in Java dates are zero based. That is, 02/15 is in fact the 16th of March. Disgusting.



  • @DrJokepu said:

    Second, I think we can agree the most disgusting example of the 0-based insanity is that in Java dates are zero based. That is, 02/15 is in fact the 16th of March. Disgusting.

     

    agreed.



  •  @DrJokepu said:

    Second, I think we can agree the most disgusting example of the 0-based insanity is that in Java dates are zero based. That is, 02/15 is in fact the 16th of March. Disgusting.

    Yes, that's also how the hardware stores dates. However, if I'm not mistaken, when you write the date to a string or something (let's say, with the format "yyyy-mm-dd", it doesn't write it as 2007-05-25. It writes it as it should be. The internal representation is not important as long as it's consistent and can be easily converted to other formats (for example, for data transmission across different platforms). It would be a problem if May was represented as, say,10, because that would require a table to convert it to a more sane format.



  •  @Helios said:

    However, if I'm not mistaken, when you write the date to a string or something (let's say, with the format "yyyy-mm-dd", it doesn't write it as 2007-05-25. It writes it as it should be. The internal representation is not important as long as it's consistent and can be easily converted to other formats (for example, for data transmission across different platforms). It would be a problem if May was represented as, say,10, because that would require a table to convert it to a more sane format.

    First, data represenation of dates and times depends on the architecture, but Java supposed to be platform-independent anyway. Second, it's not just the internal format, it's what the programmer need to pass to the constructor of whatever the datetime object is called in Java this week. If I get the data from an external data source, I need to substract one before passing it to the constructor. There is no excuce for that, because the whole world is using one indexed dates. Everybody, except Java programmers.



  • If I get the data from an external data source, I need to substract one before passing it to the constructor.

    Isn't there a constructor that takes a formatted string as a parameted? If there is, then you can just pass it that. If the source is user input,you'll need to do the conversion anyway, so not much is lost.



  • @Helios said:

    Now, using 1-based indexing can actually be more confusing than 0-based indexing. For example, when questioned about the first year of the 21st century, most people will answer it's the 2000, when it's actually the 2001. That's because there never was a year 0. The first day of the age was 0001-01-01 (I'm ignoring such details as calendar conversion. This is just a demonstration). If the 21st century started 2000 years after the year 1, then it started on 2001. So the problem here is that we're using an ordinal system as if it was a cardinal system.
     

    This so has nothing to do with the conversation its not even funny.  What people decided to do when they started counting dates after a guy they liked got nailed to somthing thousands of years ago has absolutely no relevance to the discussion.  The simularities are exceptionally superficial at best.  

    If you want to use the tracking of time, try this:  A person's birthday.  If you consider "the year they are in" a series of buckets, and when the kid is born, you put them in the first bucket, when their first year is over you move them to bucket #2 etc.... you have the "identifier key" model in a nutshell.  The moment they are born they are in "their first year" end of story, and are thrown in the "first year bucket" and that's that.  That is how "start at one" proponents conceptualize this.

    Before you are even one year old, you are in your first year, your first decade, your first century etc.  All those are valid indentifiers for a 4 month old. 

    If you want to track based on units of age - a 4 month old is zero years old, zero decades old, zero centuries old. Getting age to the 'month' level of detail is as simple as yearIndex+monthsIndex.  This is how "start at zero" proponents conceptualize this.

    This is why we say "Happy 30th Birthday", and "have a great 31st year" on the same day and both are common and correct.  Both perspectives are correct - but just apply to slightly different ways of organizing data.  Both methods are useful tools depending on how you need to conceptualize the data you are working with.

    Anyway, I think this has been beaten to death. 


    And, MPS - your OP is right on WTFwise, releasing "candidate 0" is pretty retarded.  "Candidate 1 patch 0" would actually make sense (no need to even include 'patch 0' in that case), but not Candidate 0.

    DrJokepu:  I do consider that pretty retarded when we all use '1' as an identifier for 'January' and '15' as an identifier for the 15th day  - I'd say you are right there.



  • @BeenThere said:

    This is why we say ... "have a great 31st year"

     

    TRWTF is that you say that.



  • @tster said:

    TRWTF is that you say that.
     

    No different than saying the 1800s consisted of the 19th century.



  • This so has nothing to do with the conversation its not even funny.

    How is it not relevant to the discussion? We're talking about 0-based indexes versus 1-based ones and I pointed out how 1-based indexing creates confusion. While this confusion has little repercussions in everyday life, in programming, off by 1 errors can be disastrous. Now, how is that irrelevant?
    This is why we say "Happy 30th Birthday", and "have a great 31st year" on the same day and both are common and correct.

    So what's your point? Age is the span of time since the birth of a person to a given point in time, so both phrases are, indeed, correct. You're not comparing two indexing systems, you are just using two different ways of calling the elements in a 0-based one (like I said, C arrays' first element and element 0 are the same).

Log in to reply