Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

propose renaming Hash to Dict

2 views
Skip to first unread message

Darren Duncan

unread,
May 31, 2007, 8:10:57 PM5/31/07
to perl6-l...@perl.org
I decided to bring out this Hash->Dict topic in a different thread
from the thread on Synopsis r14407 about Object->Universal since I
consider them separate though tangential matters that should be
argued on their individual merits.

In the interest of that Perl data types are better off being named
primarily after their meaning rather than their implementation,
probably the current worst offender is Hash.

Barring some better name, I highly recommend/propose renaming Hash to Dict.

The term Dict (as a short form of "dictionary") is well understood by
general people and is the term used for associative arrays in some
other languages, so it is easy to learn, and easy to explain to
people in Learning Perl.

The term Dict is easier for new people to Perl, either new
programmers or visitors from other languages, to learn than Hash is.
It allows more self-documenting code where one is used. And writing
Learning Perl should be easier.

For Perl 5 people, it should be very easy to adapt, or for the most
part they may not notice any difference save for documentation
references.

You also have equal huffmanization since the terms Hash and Dict are
both of the same length, and they are also equally easy to type.

And aside from the 4 letter word, all the other details associated
with hashes, eg the % sigil and {} constructor, and parts named
keys,values,pairs,kv et al can/should remain the same as they are.

In fact, since many users of Perl don't refer to the data type by the
name Hash but rather just by % or {}, the change may not take from
their useability at all or they may not even notice that a change
occurred at all, so easy to adapt.

Of course, if that change is made, KeyHash should be renamed to
KeyDict, and so forth.

After this change, the term Hash is then freed up to be used more
specifically to describe an implementation detail of something and/or
hashing functions et al.

I think this change would be a good thing.

Feedback is appreciated, either pro or con.

-- Darren Duncan

Juerd Waalboer

unread,
May 31, 2007, 8:32:28 PM5/31/07
to perl6-l...@perl.org
Dictionaries are usually alphabetically ordered. Hashes are not.
--
korajn salutojn,

juerd waalboer: perl hacker <ju...@juerd.nl> <http://juerd.nl/sig>
convolution: ict solutions and consultancy <sa...@convolution.nl>

Chas Owens

unread,
May 31, 2007, 8:36:40 PM5/31/07
to Darren Duncan, perl6-l...@perl.org
On 5/31/07, Darren Duncan <dar...@darrenduncan.net> wrote:
> Barring some better name, I highly recommend/propose renaming Hash to Dict.

And lets rename Perl to Python. This is just change for the sake of change.

snip


> The term Dict (as a short form of "dictionary") is well understood by
> general people and is the term used for associative arrays in some
> other languages, so it is easy to learn, and easy to explain to
> people in Learning Perl.

snip

Dict also makes it sound like you are talking about pornography. Of
course, hash makes it sound like you are talking about getting high.

snip


> The term Dict is easier for new people to Perl, either new
> programmers or visitors from other languages, to learn than Hash is.
> It allows more self-documenting code where one is used. And writing
> Learning Perl should be easier.

snip

Please provide the peer-reviewed study that proves this as it goes
against my experience.

snip


> For Perl 5 people, it should be very easy to adapt, or for the most
> part they may not notice any difference save for documentation
> references.

snip

The Perl 5 people are already annoyed that . is changing to ~, sigils
are becoming invariant, etc. Why not change the name of one of the
data structures too? If we give them too many things to complain
about they won't be able to decide where to start!

snip


> You also have equal huffmanization since the terms Hash and Dict are
> both of the same length, and they are also equally easy to type.

snip

They may be the same number of characters, but I can type hash without
leaving the home row on QWERTY keyboards, I don't know about Dvorak.

snip


> And aside from the 4 letter word, all the other details associated
> with hashes, eg the % sigil and {} constructor, and parts named
> keys,values,pairs,kv et al can/should remain the same as they are.

snip

Right, because dictionaries have keys and values not terms and
definitions. Of course, it all makes sense now.

snip


> In fact, since many users of Perl don't refer to the data type by the
> name Hash but rather just by % or {}, the change may not take from
> their useability at all or they may not even notice that a change
> occurred at all, so easy to adapt.

snip

Except of course those poor schmucks who foolishly wrote code like

if (ref $arg eq 'HASH') { ... }

David Lloyd

unread,
May 31, 2007, 9:29:45 PM5/31/07
to Chas Owens, Darren Duncan, perl6-l...@perl.org

<big snip>

I thought one of the things that Larry didn't want to do when moving
towards the next big version of Perl was to change the nature of the
language such that it wasn't Perl any more.

I feel that renaming a Hash to Dict would be one of those changes.

Personally, I don't find it difficult to discuss Perl hashes and a
computer science "hash algorithm" with people. One of the things I like
about Perl is that it doesn't presume that its coders are linguistically
impaired.

A Perl program's audience - imho - should be the programmers. That it
can run efficiently and well on a computer, again imho, is a side effect.

DSL

Larry Wall

unread,
Jun 1, 2007, 12:17:17 AM6/1/07
to perl6-l...@perl.org
On Thu, May 31, 2007 at 05:10:57PM -0700, Darren Duncan wrote:
: I decided to bring out this Hash->Dict topic in a different thread
: from the thread on Synopsis r14407 about Object->Universal since I
: consider them separate though tangential matters that should be
: argued on their individual merits.
:
: In the interest of that Perl data types are better off being named
: primarily after their meaning rather than their implementation,
: probably the current worst offender is Hash.

Nope. Hash is mostly about meaning, and very little about implementation.
Please don't assume that I name things according to Standard Names in
Computer Science. I name things in English. Hash is just something
that is disordered, which describes the associative array interface
rather nicely, distinguishing it from the ordered Array interface.
The fact that it *might* be implemented using a hash algorithm is
merely a nice association with some mnemonic value for CSish folks.

Likewise, if I say Object I'm referring not to a CS object so much as
an English object, which is just something that is fairly discrete
and can be handled and treated as a single thing, even if it happens
to contain multiple things. About the only nod to CS here is that
you can call the .HOW method on any Object. Anything beyond that
is the fault of the metamodel.

In general I'm much more interested in the natural linguistic feel
of Perl than in matching up with any particular standard CS terms.
That's why you have "given" and "when", not "switch" and "case".
That's why you say "next" and "last", not "continue" and "break".
That's why we have "state" rather than "static", "my" rather than
"var" or "decl", "contend" rather than "atomic", "maybe" rather than
"orElse", "has" rather than "attr", "role" rather than "interface",
and so on.

Of course, it's possible to pick words that have too much overloading
in the CS literature, but I don't think either Hash or Object really
fall into that category, in the case of Hash because hash algorithms
are a fairly minor thing, and in the case of Object because people are
already used to all different kinds of Object systems, some class-based,
some prototype-based, so generalizing to a kind of object that gives
you both is not really a problem.

And as I said before, part of the reason for using Object is political,
because it means we're Really Doing Real OO™.

And maybe part of the reason for *not* using Universal is also
political, insofar as Perl 5's UNIVERSAL has been sorely abused in
various ways, and I don't want people to have that mental association.
(Kinda like the fact that Captures resemble anonymous typeglobs but
we're *not* going to call them that...)

Larry

Darren Duncan

unread,
Jun 1, 2007, 1:39:19 AM6/1/07
to perl6-l...@perl.org
At 9:17 PM -0700 5/31/07, Larry Wall wrote:
>Nope. Hash is mostly about meaning, and very little about implementation.
<snip>

>And as I said before, part of the reason for using Object is political,
<snip>

Okay, thanks for addressing these 2 naming concerns I talked about;
I'll drop the associated matter now. -- Darren Duncan

Chromatic

unread,
Jun 1, 2007, 2:48:37 AM6/1/07
to perl6-l...@perl.org, Chas Owens, Darren Duncan
On Thursday 31 May 2007 17:36:40 Chas Owens wrote:

> Except of course those poor schmucks who foolishly wrote code like
>
> if (ref $arg eq 'HASH') { ... }

I know you're teasing, but it *would* be nice to see that sort of code just
magically go away.

-- c

Thomas Wittek

unread,
Jun 1, 2007, 5:44:53 AM6/1/07
to perl6-l...@perl.org
Larry Wall:

> Nope. Hash is mostly about meaning, and very little about implementation.
> Please don't assume that I name things according to Standard Names in
> Computer Science. I name things in English. Hash is just something
> that is disordered, which describes the associative array interface
> rather nicely, distinguishing it from the ordered Array interface.

Hm, but with which would you explain a "hash" in plain english?
What would be the closest equivalents in the real world?

I'm not a native english speaker, but I've never heard or read the word
"hash" outside CS.

I guess this ones are close:
- collection (contra: doesn't imply the access to an item)
- dictionary (contra: might be assumed ordered)
- directory (contra: might be assumed ordered, clashes with a file
directory)
- index (contra: might be assumed ordered, might be too technical)

The problem with the implication of an order in the real world concepts
is that you probably won't find one that isn't ordered.
Those things allow us to find something easily by a word. But as we
first have to find that word, we have an ordered list of the words...

So there is no perfect candidate in the above list.
But in my opinion they are still more "english" than "hash".
Additionally I believe it would be easier to learn that it's (e.g.) a
dictionary that just is not ordered than learning a whole new word like
a "hash" (which it was for me as a non-native english speaker).

--
Thomas Wittek
http://gedankenkonstrukt.de/
Jabber: strea...@jabber.i-pobox.net

Daniel Hulme

unread,
Jun 1, 2007, 6:44:49 AM6/1/07
to perl6-l...@perl.org
On Fri, Jun 01, 2007 at 11:44:53AM +0200, Thomas Wittek wrote:
> Larry Wall:
> > Nope. Hash is mostly about meaning, and very little about implementation.
> > Please don't assume that I name things according to Standard Names in
> > Computer Science. I name things in English. Hash is just something
> > that is disordered, which describes the associative array interface
> > rather nicely, distinguishing it from the ordered Array interface.

> I'm not a native english speaker, but I've never heard or read the word
> "hash" outside CS.

I suppose that as a non-native English speaker you've never eaten
"corned beef hash". I quote from Wikipedia:
"Hash is a mixture of beef (often leftovers of corned beef or roast
beef), onions, potatoes, and spices that are mashed together into a
coarse, chunky paste, and then cooked, either alone, or with other
ingredients."

It's a bit of a working-class dish, for using up your leftovers, so not
the sort of thing you'd eat as a tourist, but it seems many other
countries have the same sort of thing: using your leftovers is a pretty
universal need.

In colloquial English there's also the expression, "to make a hash of
something," which means to make a mess of it, to screw up.

That said, the dish and the idiom are both dying out, and the current
generation of school leavers might not have heard of either. I didn't
make the connection until Larry described it as being "disordered".

As a general point, I think it's pretty easy to make a mental
distinction between a 5ish hash and a hashtable, just as it's easy to
remember that 5's abstracted lists and arrays aren't the same concepts
as linked lists and C-style concrete arrays.

--
"It must be accepted as a principle that the rifle, effective as it is,
cannot replace the effect produced by the speed of the horse, the
magnetism of the charge, and the terror of cold steel."
-- British Cavalry training manual, 1907 ::: http://surreal.istic.org/

signature.asc

Mark J. Reed

unread,
Jun 1, 2007, 6:52:37 AM6/1/07
to perl6-l...@perl.org
On 6/1/07, Larry Wall <la...@wall.org> wrote:
> Nope. Hash is mostly about meaning, and very little about implementation.
> Please don't assume that I name things according to Standard Names in
> Computer Science. I name things in English.

Then why did we need a separate "use English" pragma? :)

Are you the one who originally came up with "hash" for %vars? IIRC,
they were officially called just "associative arrays" through Perl4,
but "hash" was a well-understood community nickname for them for some
time before you canonized it with ref($var) eq 'HASH' in Perl5...

--
Mark J. Reed <mark...@mail.com>

Brandon S. Allbery KF8NH

unread,
Jun 1, 2007, 7:07:06 AM6/1/07
to Thomas Wittek, perl6-l...@perl.org

On Jun 1, 2007, at 5:44 , Thomas Wittek wrote:

> Larry Wall:
>> Nope. Hash is mostly about meaning, and very little about
>> implementation.
>> Please don't assume that I name things according to Standard Names in
>> Computer Science. I name things in English. Hash is just something
>> that is disordered, which describes the associative array interface
>> rather nicely, distinguishing it from the ordered Array interface.
>
> Hm, but with which would you explain a "hash" in plain english?
> What would be the closest equivalents in the real world?

"...make a hash of things" (meaning, a mess)
"corned beef hash"

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] all...@kf8nh.com
system administrator [openafs,heimdal,too many hats] all...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH


Mark J. Reed

unread,
Jun 1, 2007, 8:07:00 AM6/1/07
to Brandon S. Allbery KF8NH, Thomas Wittek, perl6-l...@perl.org
Let's not forget that the CS meaning of "hash" didn't spring forth
fully-formed from the skull of Donald Knuth or anything. A "hash
function" is so called because it "makes a hash of" the inputs. That
is, its output, while deterministic, is at first glance a random
rearrangement of the inputs. Hence, a hash.

John Macdonald

unread,
Jun 1, 2007, 10:30:08 AM6/1/07
to Brandon S. Allbery KF8NH, Thomas Wittek, perl6-l...@perl.org
On Fri, Jun 01, 2007 at 07:07:06AM -0400, Brandon S. Allbery KF8NH wrote:
>
> On Jun 1, 2007, at 5:44 , Thomas Wittek wrote:
>
> >Larry Wall:
> >>Nope. Hash is mostly about meaning, and very little about
> >>implementation.
> >>Please don't assume that I name things according to Standard Names in
> >>Computer Science. I name things in English. Hash is just something
> >>that is disordered, which describes the associative array interface
> >>rather nicely, distinguishing it from the ordered Array interface.
> >
> >Hm, but with which would you explain a "hash" in plain english?
> >What would be the closest equivalents in the real world?
>
> "...make a hash of things" (meaning, a mess)
> "corned beef hash"

That's two people that have given the same list, but both
have omitted the more common (in modern times) phrase "hash
browned potatos" which is a hash of chopped potato, onion,
and sometimetimes other things fried brown. I'll ignore the
McDonald's version which hashes together just the potatos,
since a collective of a single element is still a collective
mathematically, but not usually considered so linguistically
unless you've got a big enough advertising budget to pull it
off.

--

Daniel Hulme

unread,
Jun 1, 2007, 9:09:36 AM6/1/07
to perl6-l...@perl.org
On Fri, Jun 01, 2007 at 10:30:08AM -0400, John Macdonald wrote:
> > "...make a hash of things" (meaning, a mess)
> > "corned beef hash"
>
> That's two people that have given the same list, but both
> have omitted the more common (in modern times) phrase "hash
> browned potatos" which is a hash of chopped potato, onion,
> and sometimetimes other things fried brown.

Well, I have eaten hash browns on many occasions, but in my mind they
just don't have the same association with a disordered mess, as they are
served as discrete units rather than a mass. But let's stop talking
about food now.

--
There once was a teacher of great renown, Gather your goods
Whose words were like the tablets of stone, and follow me
Because it's easier to learn than unlearn, Or you will surely die.
Because we've passed the point of no return. Paul Simon, 'The Teacher'

signature.asc

Thomas Wittek

unread,
Jun 1, 2007, 12:05:58 PM6/1/07
to perl6-l...@perl.org
Daniel Hulme:
>> Larry Wall:

>>> I name things in English. Hash is just something that is disordered
>
>> I'm not a native english speaker, but I've never heard or read the word
>> "hash" outside CS.
>
> you've never eaten "corned beef hash".

To conclude, as hash definitely tastes better than a dictionary, we
should stick to that name. ;)

At least nobody can say that Perl is bad taste!

Larry Wall

unread,
Jun 1, 2007, 12:15:21 PM6/1/07
to perl6-l...@perl.org
On Fri, Jun 01, 2007 at 06:05:58PM +0200, Thomas Wittek wrote:
: Daniel Hulme:

: >> Larry Wall:
: >>> I name things in English. Hash is just something that is disordered
: >
: >> I'm not a native english speaker, but I've never heard or read the word
: >> "hash" outside CS.
: >
: > you've never eaten "corned beef hash".
:
: To conclude, as hash definitely tastes better than a dictionary, we
: should stick to that name. ;)
:
: At least nobody can say that Perl is bad taste!

Then maybe we should rename Array to Skewer or Kabob or some such...

Hmm, except it's hard to random access the middle...

Maybe AntsOnALog... (celery, cream cheese/peanut butter, and raisins)

Larry

Larry Wall

unread,
Jun 1, 2007, 1:08:11 PM6/1/07
to perl6-l...@perl.org
On Fri, Jun 01, 2007 at 06:52:37AM -0400, Mark J. Reed wrote:
: On 6/1/07, Larry Wall <la...@wall.org> wrote:
: >Nope. Hash is mostly about meaning, and very little about implementation.
: >Please don't assume that I name things according to Standard Names in
: >Computer Science. I name things in English.
:
: Then why did we need a separate "use English" pragma? :)

We needed "use English" because I was temporarily drawn to the shell
side of the Force. I have repented.

: Are you the one who originally came up with "hash" for %vars? IIRC,


: they were officially called just "associative arrays" through Perl4,
: but "hash" was a well-understood community nickname for them for some
: time before you canonized it with ref($var) eq 'HASH' in Perl5...

Yes, I believe I was the one who decided that associative arrays needed
a shorter name, and after a period of discussion on perl5-porters,
settled on "hash" as the new technical term in Perl culture. But I'm
not sure the mailing list archive goes back far enough to verify the
exact sequence of events. Certainly I made the final decision, but
it's quite possible someone else suggested it first. But I seem to
recall getting extremely tired of typing "associative array" while
working on Camel II, and that was likely the instigation.

Larry

Doug McNutt

unread,
Jun 1, 2007, 3:11:21 PM6/1/07
to perl6-l...@perl.org
At 09:15 -0700 6/1/07, Larry Wall wrote:
>: To conclude, as hash definitely tastes better than a dictionary, we
>: should stick to that name. ;)
>:
>: At least nobody can say that Perl is bad taste!
>
>Then maybe we should rename Array to Skewer or Kabob or some such...
>
>Hmm, except it's hard to random access the middle...
>
>Maybe AntsOnALog... (celery, cream cheese/peanut butter, and raisins)

Since Larry started it:

Don't forget that a common form of hash as a food is SPAM in all capitals. Perhaps perl6 could get special dispensation from Hormel.

--

--> From the U S of A, the only socialist country that refuses to admit it. <--

Chas Owens

unread,
Jun 1, 2007, 3:50:11 PM6/1/07
to Doug McNutt, perl6-l...@perl.org
On 6/1/07, Doug McNutt <doug...@macnauchtan.com> wrote:
> At 09:15 -0700 6/1/07, Larry Wall wrote:
> >: To conclude, as hash definitely tastes better than a dictionary, we
> >: should stick to that name. ;)
> >:
> >: At least nobody can say that Perl is bad taste!
> >
> >Then maybe we should rename Array to Skewer or Kabob or some such...
> >
> >Hmm, except it's hard to random access the middle...
> >
> >Maybe AntsOnALog... (celery, cream cheese/peanut butter, and raisins)
>
> Since Larry started it:
>
> Don't forget that a common form of hash as a food is SPAM in all capitals. Perhaps perl6 could get special dispensation from Hormel.
>
> --
>
> --> From the U S of A, the only socialist country that refuses to admit it. <--
>

That is just not kosher.

Ruud H.G. van Tol

unread,
Jun 1, 2007, 7:42:53 PM6/1/07
to perl6-l...@perl.org
John Macdonald schreef:

> "hash
> browned potatos" which is a hash of chopped potato, onion,
> and sometimetimes other things fried brown.

That comes from the French haché, meaning chopped. Best with lots of
small pieces of beef in it as well.

--
Groet, Ruud

Mark J. Reed

unread,
Jun 1, 2007, 9:36:47 PM6/1/07
to Ruud H.G. van Tol, perl6-l...@perl.org
On 6/1/07, Ruud H.G. van Tol <rv...@isolution.nl> wrote:
> John Macdonald schreef:
>
> > "hash
> > browned potatos" which is a hash of chopped potato, onion,
> > and sometimetimes other things fried brown.
It's usually "hash browns" or "hashed browns", and I've always assumed
the former to be a shortened form of the latter.

>
> That comes from the French haché, meaning chopped.
...the past participle of hachier, which is literally "to axe", from
hache "axe". Ultimately, yes, the English word "hash" comes from the
French "hache", but you have to go back to Norman times to get there.
The word "hash" has been an English word for almost a millennium, and
"hashed browns" are simply browns (browned potatoes) that have been
hashed...
0 new messages