Why does coldfusion number arrays and dates from 1
Why does coldfusion number arrays and other structures from 1. Its pretty infuriating when the rest of the world mostly starts from 0?
Why does coldfusion number arrays and other structures from 1. Its pretty infuriating when the rest of the world mostly starts from 0?
Zero-based arrays are a legacy of the days of the system needing to work out the offset from the base memory address that the array is stored at to locate the start address of each element. So it makes kinda sense that the first element is offset from the base address by a factor of zero.
There are languages that predate C (from which C++ sprouted as some sort of horrendous nightmare) which use 1 as the starting index... it's just C was pared down to minimise the translation from C to machine code, and in this case 0 makes more sense. And other "curly bracket" languages just copied it. It certainly - in modern times in which the source language is generally so far removed from machine language - makes little sense to persist with this sort of approach for any good reason other than copying what some other language has done.
In human terms, there is not a zeroth element in a collection, and given there isn't really any processing saving any more in just starting the array from a more human-friendly position, why not?
I mean... how confusing is it really to remember which language does which?
--
Adam
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.