The weekend reached, I'm heading to my home. I reached the railway station, and I went to a long queue in front of the ticket counter. After some time, I got my ticket to my place, and I queried the counter that where my train halts. He replied the train will arrive in the second platform. "OK Thank you!" I replied with a smile. I took my bags and walked to the platform, but I got confused and I'm unable to find the second platform! I headed to the queries section and I asked them. They also replied the same answer. Still, again I'm confused. What's wrong with me, why I can't find the second platform?!?
I just throw my bags to a seat and I sat aside, in despair. The train will arrive in any time, and I still have no idea where it arrives. I wiped my face and I started analyzing the problem. I looked on the platforms. They are situated in both sides of the railway tracks, in a face to face manner. The problem with me is that, I learned to count things from 0 when I learned programming languages. So I counted the platforms as platform 0, and platform 1 so when they said platform 2, it is out of my bounds! By the time I solved my problem, the train reached, got a good seat and went home happily.
In the mean time, I just started thinking why the array index starts from 0. When I learned programming languages in my school, I learned counting from 0 is a de-facto standard in almost all programming languages. I found some convincing reasons from my imaginations. First one is, Computer memory is composed of bits that can store 0 and 1. Every memory byte has eight bits, and they stores any value from 0 to 255. If it is four bit memory, it can hold values from 0 to 15. Every address space starts from 0 and ends in memory size - 1. Hence every memory can store the value 0, it is a valid address in the address space. If we uses the convention of counting from one, it requires a translation operation of decreasing one from the index to map onto the actual memory address. So counting from zero can avoid that translation, hence it is a good idea. And the hardware context, counters can start from zero to the maximum possible value, so we can avoid that address translation subtractor, keeping things simple.
Sometimes we have to pick a random item from an array. We makes use of random number generators that usually generates in its range, that we dont want. So we makes use of modulus operator to operate in the size of the array, and it returns a value from 0 to array size - 1. Hence it is a great idea to count array elements from 0. As a programmer, it is good to learn counting from zero, since it reduces complications, for programmng simple programs to advanced graphics based applications. But in real life, leave the zero and count like 1....2....3... :)