that’s all… why arrays start at zero? I think it would be more practical to start with one. I do not mean just to xojo… In most languages it happens that way
I assume it’s because the index of an array is pointing to an offset within your systems memory.
if you wish to start the address at 1 then all you have to do is make the array 1 larger than you need and just ignore array(0) totally and never use it.
This question recalls me a kid question: from where the wind comes ?
With time, as a developer, you will discover you always have to check if the object is 0-based or 1-based.
Of course as a user, you do not care since it always start at 1.
Historical reasons. And array position zero was often used for other purposes. But no, “most” other languages do NOT start at 1.
P.S. Oops, Sascha beat me to it.
= recipe for disastrous coding. Way, way back I used to do this. Future Basic (remember that?) had an option to start arrays at 1. Caused me untold headaches.
I really liked this explanation (http://developeronline.blogspot.com.ar/2008/04/why-array-index-should-start-from-0.html)…
Your comments have been great and enlightening
link 1 [or zero :-)]–> http://developeronline.blogspot.com.ar/2008/04/why-array-index-should-start-from-0.html
Information in Spanish extracted from the previous link–> Esta es la respuesta de Edsger Dijkstra publicada en Hacker News y que fue enviada como una carta personal del famoso programador a un colega en 1982. La primera respuesta de Dijkstra dice que para denotar una secuencia de números naturales es mejor una notación 0 < i < N, que una 1 <= i < N+1. Habla también de experiencias donde una notación que empieza en 1 lleva a errores al leerla y no determinar bien los límites inferiores/superiores que se quieren denotar–> I think this is a great explanation
i think this is a great explanation too (@Sascha S)–> I assume it’s because the index of an array is pointing to an offset within your systems memory
Starting an array at “0” comes from old times when computer memory was very small. At that time, starting at “1” means a waste of valueble memory space.
I created applications where I had less than 5 KB for the application itself and its data in RAM.
Nowadays developers are spoiled.