Sigh - I remember one-based.

Well, I know this is nothing new, but:

What's with this zero-based (nearly) everything

For i = 1 to Thingy.Count

or

For i = 0 to Thingy.Count -1

It is simply not true that the first element of anything in the universe is ZERO. It is not common-sense thinking.

"How many items do you have in your hand "

"One"

"Show me the first item"

"Error, you should have asked for the zero-th item"

ha ha ha

I would like to request that two versions of the .Net Framework be made available. One for those who love zero, and another one for those who love one.



Answer this question

Sigh - I remember one-based.

  • huriye

    I feel the OP's sentiment. I remember a horrible few years where I was simultaneously working amongst a combination of Matlab, S-PLUS and C++. Matlab and S were 1-based, C++ not so.
    It was annoying to get index exceptions but after a while they became pretty quick to spot.


  • Alcide

     

     

    "Isn't the computer supposed to abstract away all that unfortunate zero-based reality for us "

    Applications do. Computers don't. There's a difference.

    "It is not common-sense thinking."

    This is a good thing.

    "Aren't we supposed to be using "higher-level languages"

    Do you do everything you are told I thought we use what does the task best.

    Isn't Object-oriented Programming supposed to mimic real-world objects

    Sometimes.



  • LondonSte

    Good explanation Jared!

    It was also common to store information such as the size of the array in the 0th element.

    Contrary to another reply to the OP, 0-basing is not more efficient (why not based on -1, -2, etc. ). But it is so ingrained that you have to just accept it.

    Personally, I have no problem counting from 1.



  • ivanFSR

    You'll just need to get over it. Zero-based is far more efficient for computers, and you want your foundation algorithms to be efficient, don't you

  • DKB

    0 Based arrays is a hold over from the days of C (more appropriately B but it was made popular by C). In C arrays are a very loose memory concept representing a set of types allocated one after the other in a block of memory. Under the hood arrays are just pointers (most of the time). So the first object was offset 0 from the pointer, the second element, 1 and so on.

    C/C++ is an extremely popular language so 0 based offsets rolled over into most modern programming languages.

    0 based offsets are fairly ingrained into the computing world beyond arrays. For instance I had several professors in college who named the first homework "Homework 0" as opposed to "Homework 1".



  • James_Steven

    :-) well computing technology generally is 0 based in terms of indexing etc...

  • JLarkin

    I hear ya

    But, isn't a development environment an application


  • al_puff

    Yes, yes, all of you have valid points.

    8^D<====

    BUT......

    Isn't the computer supposed to abstract away all that unfortunate zero-based reality for us

    Aren't our development environments supposed to be "higher-level languages"

    Isn't Object-oriented Programming supposed to mimic real-world objects

    Huh Huh

    HUH !!!

    Right, deep down, we all know that my original post makes sense. We don't want to think like computers, we want computers to think like us.

     

     


  • vincent90152900

    Sigh, Jared, you are so young. Zero-based is a holdover from assembler practices. Not something today's folks need to deal with anymore. As pointed out earlier, the beginning of any datastructure is location zero. It follows that the beginning of element "n" is location zero plus (n-1) times "n". If the assembler guy has to do the (n-1) calculation to interpret your higher-level compiler's reference, it propogates that calculation many times more than if the higher-level language were zero-based. Of course, I'm wrong anyway, because the higher-level compiler could do some of the math at compile time, but someplace, somewhere, one must be subtracted from "n" each time it's referenced...

    It's fun to discuss, but in my mind the shame isn't one-based versus zero-based, it's the lack of consistency. Even MS mixes its metaphors as it were when referring to collections versus columns, etc. The experimentation takes too long to verify, the documentation is sometimes difficult to ferret out, and my memory is not even a consideration. Too bad everyone could not have made consistent choices on this issue.

    Jim



  • V.E

    You stand two hopes of a two versions of the framework, one for zero and one of one.

    Bob Hope and No Hope.

    As has been said, zero based is the default and likely to stay that way, there are a few exceptions to this and many are VB related legacy issues but now that we have a common framework and base library - its really unlikely that you'll get two versions.


  • Biceps

     

    At one level it is. It's not hardware. It's not the OS. Everything else IS an application.

    It's an application for writing user applications as well as many system applications. It's certainly not a user application. You're the first person I've ever seen to attempt to couple "common-sense" and OOP.



  • SelTel

    One would think that the first value in a binary representation is 0. Hence the first item would be 0 and this concept was brought forward in memory and data structures etc. as computers use binrary representations inside.

    Basic was designed around making things simple for people - hence many novices are more familar with 1 based (real world items). The 1st item is in position 1. Unfortunately as things have progressed in VB and we have a common framework for C and VB - we needed to standardize on a single concept. 0 based won out which is probably correct in reality for almost all languages except Basic.


  • Sigh - I remember one-based.