3 ms·
it is nicer than javascript where associative arrays (ie objects) and real arrays are entirely different types. Actually, while we're on the topic: these shoul
by aphyr 16y ago
it is nicer than javascript where associative arrays (ie objects) and real arrays are entirely different types.
Actually, while we're on the topic: these should be separate types, for exactly the reasons I outlined in that code snippet. Arrays and hashes have entirely different memory characteristics, access times, growth strategies, and indexing semantics! Trying to smush both models into the same construct is what leads to PHP's befucked implementation of "arrays"/"hashes", which succeed at being neither.
As an example, compare Ruby (an abysmally slow language) to PHP on array iteration--a task in which PHP loses by a huge margin on both memory and time complexity.