It occurs to me that I could monkeypatch Array in Ruby and replace it with an associative array and my site would probably function fine... Maybe I'll try it just to prove a point.
Why bother? Just spend half an hour learning PHP, which works exactly like this. It has a data structure named "array" that is actually an associative array, and which supports both array semantics and hash semantics (and, if you're not careful, will assume one when what you want is the other).
Is this a wise design decision? Yes and no. One less data structure to think about is perhaps easier for beginners. But, as we see here, it also encourages people to remain ignorant of how their data structures actually work. If you ask yourself "would I ever use PHP to teach a data structures class", the answer would seem to be "hell, no" -- which tells you something. And when you do have to think seriously about performance (which, though it often happens too soon, does have to happen eventually) it seems to me that you'd want an array primitive in your toolkit. (At that point, hardcore PHP developers would probably advocate just dropping into C and writing C extensions.)
Why bother? Just spend half an hour learning PHP, which works exactly like this. It has a data structure named "array" that is actually an associative array, and which supports both array semantics and hash semantics (and, if you're not careful, will assume one when what you want is the other).
Is this a wise design decision? Yes and no. One less data structure to think about is perhaps easier for beginners. But, as we see here, it also encourages people to remain ignorant of how their data structures actually work. If you ask yourself "would I ever use PHP to teach a data structures class", the answer would seem to be "hell, no" -- which tells you something. And when you do have to think seriously about performance (which, though it often happens too soon, does have to happen eventually) it seems to me that you'd want an array primitive in your toolkit. (At that point, hardcore PHP developers would probably advocate just dropping into C and writing C extensions.)