Quote: "I would like to see them fix arrays. I've never seen a programming language where if you change the size of an array you get an extra element on it.
array.length should return and set the correct array size. If I say array.length = 3, it needs to be 3 elements, not four. That doesn't make any sense to me when they do weird stuff like that."
It does return the correct array size.
Array As Integer = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 )
That's 10 Elements. The difference is the Language is putting the 0 at the Start., where-as if you count it you're putting it at the end.
C / C++ Arrays work the exact same way; the reason you can use the length as a signifier "as-is" is because you're always using the < conditional., which is something most people learn or mimic from others code without ever understanding why.
for( int i = 0; i < array::count( ); i++ )
is IDENTICAL to
for( int i = 0; i == array::count( ) - 1; i++ )
which is also IDENTICAL to
For i = 0 To array.length - 1
Now as a note., ::count() is a StdC Libaray Function for Template Arrays (List/Map/Vector/etc.)... if you wanted to do this for built-in Arrays; well the easiest approach is:
sizeof(Array) / sizeof( ArrayType )
int ArraySize = sizeof(Array) / sizeof( int ); // this would return 11 as a note
but then this brings up another point to make... it's also common practice in C/C++ to write the number of arrays that you'd count., even though you'll never use 1 of those elements.
So for an 10 Element Array you'd write:
But as any number from 0 ... 10 becomes valid; this is 11 Elements.
People do this again because OTHERS do this., without every questioning why; but it's partly because it's easier to understand (i.e. you'd count 1, 2, 3 ... 8, 9, 10... rather than from 0) but also it provides a buffer element; which allows concepts such-as "Null Terminator" say when working with Strings; where a value of 0 means "End"; as strictly speaking Arrays are just "easy" Pointers to Memory Addresses., without actually using a Pointer; so you can just KEEP reading Memory beyond the Allocated Array itself.
This will either cause an Access Error (in the case of Protected Memory) or it'll read unrelated Data; which as Memory is rarely purged to Zero (it's just allocated., meaning it's tagged to be used again) then this means whatever existed there before will remain until new information is allocated.
Allocation is usually what "Zeros" said Data Area; and why Allocation can be costly.
I'm actually unaware of ANY other language that handles this differently., you're just typically compensating; and if you think they work differently, I'd wager without you ever realising you are.