[EMAIL PROTECTED] (Nathan Torkington)  wrote on 15.08.00 in 
<[EMAIL PROTECTED]>:

> Stephen P. Potter writes:
> > Why is it silly?  Hashes and arrays are *conceptually* very similar
> > (even if they are extremely different implementation-wise).
>
> If that were the case, I think students would have an easier time
> grasping hashes.  It seems very common (yes yes, you all got them
> immediately, but merely by piping up and saying so, you do not
> invalidate my point, so please don't) that beginners take a long time
> to use hashes because they find them hard to get their heads around.

I see two possible reasons for that:

1. Hashes aren't explained right.
2. They already know about computers and arrays.

To someone who doesn't know about computers and arrays, hashes are the  
more natural concept, because they are how you do stuff like that in real  
life, and arrays are just a special case of hashes.

There's a reason symbol tables are hashes and not arrays: people are  
better with names than with numbers.

(Of course, one of the problems with hashes is the name. For most  
purposes, the fact that a (non-tied) hash uses hashing is completely  
irrelevant to someone learning the language.)

Perl really goofed here. The generic concept should be the collection.  
Collections can be indexed in lots of different ways, and (Perl) hashes  
and arrays are just two of many options. (Think of trees, for example.)

> This isn't why it's silly, just a comment on the idea that hashes
> and arrays are conceptually very similar.

Well, they are.

> world.  I like Perl being able to optimize internally based on my
> simple one-character data typing (%).

I'd actually prefer if the computer could work that out for itself. That's  
the type of stuff computers are supposedly good at.

MfG Kai

Reply via email to