News for hackers. Stuff that matters.
Re:TOML, Tom's Own Markup Language by dkersten on Saturday February 23, 2013 @10:55PM (#5272726)
Urg. Off topic, but I dislike this perl/ruby tendency of calling hash tables hashes. When I see the word hash, I always think of a value (ie a hash code) and not a data structure. Why couldn't they call it a hash map, hash table, map, table, dictionary etc like all the other languages...?
Re:TOML, Tom's Own Markup Language by charlieok on Saturday February 23, 2013 @11:00PM (#5272737)
I agree with that. 'map' or 'dictionary' are the best choices I think (or 'associative array', but why bring arrays into it). That's the interface, of which a hash table is just one possible implementation.
Re:TOML, Tom's Own Markup Language by Myrmornis on Sunday February 24, 2013 @01:14AM (#5273108)
I've never liked 'dictionary'. The analogy isn't at all apparent to me. A dictionary explains what words means. The thing we're talking about doesn't explain what keys mean. (Someone who spends most of his time writing python here.) 'map' or 'mapping'.
Re:TOML, Tom's Own Markup Language by charlieok on Sunday February 24, 2013 @02:56AM (#5273345)
It's about the operations. One Does Not Simply (tm) read a dictionary. One instead performs a “lookup” for a particular item. The dictionary is designed to make this lookup fast and reliable, which matches the purpose of these data structures in software.
Re:TOML, Tom's Own Markup Language by SoftwareMaven on Sunday February 24, 2013 @01:37AM (#5273154)
A dictionary maps words to their definitions. The words are the keys, the definitions are the values. Seems reasonable to me. Though as another predominantly pythoner, I do prefer map as well.
Re:TOML, Tom's Own Markup Language by Myrmornis on Sunday February 24, 2013 @02:07AM (#5273214)
In a dictionary the value (meaning) is often (partially) implied by the key (word), by etymology etc. In the data structure there need be no relationship between the key and value other than the fact that they are a key-value pair in this instance. It introduces messy cultural concepts into what should be a clean, abstract concept.
Re:TOML, Tom's Own Markup Language by mmahemoff on Sunday February 24, 2013 @01:34AM (#5273145)
I think dictionary is a useful high-level analogy. Small key objects mapping to potentially large, and often structured, value objects. (By structure, I mean the definition in a dictionary often includes fields like pronunciation and origin.)
Re:TOML, Tom's Own Markup Language by aamar on Sunday February 24, 2013 @02:14AM (#5273229)
Sadly "map" is also the name of the critical "map" function which operates on lists. Maybe with an indefinite article ("a map") it's clear enough.
Re:TOML, Tom's Own Markup Language by dkersten on Sunday February 24, 2013 @07:40AM (#5273992)
Sure, so go the Lua route: table. Or the python route: dictionary. If neither of those do it for you, how about "mapping"?

Hash (and hash map, hash table etc) leak too much implementation detail. What if you want a tree-based mapping instead? I like how in C++ it's map (for ordered, rb-tree based maps) and unordered_map (for unordered, hash table based maps).

Re:TOML, Tom's Own Markup Language by aamar on Monday February 25, 2013 @10:59PM (#5283861)
I'm going to try out "mapping" -- good suggestion.
Re:TOML, Tom's Own Markup Language by markov_twain on Saturday February 23, 2013 @11:03PM (#5272746)
This bit of ruby should take care of it

    HashMap = HashTable = Map = Table = Dictionary = Hash
And if you're feeling adventurous,

    Object.send :remove_const, :Hash
Re:TOML, Tom's Own Markup Language by agscala on Sunday February 24, 2013 @12:41AM (#5273028)
Please never, ever do this
Re:TOML, Tom's Own Markup Language by DanWaterworth on Monday February 25, 2013 @12:36AM (#5277485)
If doing this is such a bad idea then why is it so easy?
Re:TOML, Tom's Own Markup Language by jlgreco on Monday February 25, 2013 @02:01AM (#5277700)
If doing:

  #define BEGIN {
  #define END }
were such a bad idea, then why is it so easy?
Re:TOML, Tom's Own Markup Language by DanWaterworth on Monday February 25, 2013 @03:01AM (#5277833)
Maybe the language is poorly designed.
Re:TOML, Tom's Own Markup Language by jlgreco on Monday February 25, 2013 @03:08AM (#5277853)
Or maybe the connection between being able to do something and it being a good idea to do something is just in your head.
Re:TOML, Tom's Own Markup Language by DanWaterworth on Monday February 25, 2013 @03:21AM (#5277890)
In my experience, making obviously bad things difficult or impossible improves reliability. This idea certainly resides within my cranial cavity, but that doesn't necessarily make it wrong.
Re:TOML, Tom's Own Markup Language by jlgreco on Monday February 25, 2013 @03:51AM (#5277971)
How could:

  HashMap = HashTable = Map = Table = Dictionary = Hash
possibly not qualify as "obviously bad"? The only reason you've offered up is because it is easy...
Re:TOML, Tom's Own Markup Language by DanWaterworth on Monday February 25, 2013 @04:19AM (#5278023)
I think this is fine. The obviously bad part is being able to remove/change constants, especially as these changes are global.
Re:TOML, Tom's Own Markup Language by agscala on Monday February 25, 2013 @03:06PM (#5281404)
The obviously bad part is that you pollute the global namespace for no reason other than laziness. When someone comes across code that uses a "Table" object interchangeably with "Dictionary" and "Hash", then he's going to have to look through the source code to find this bizarre line only to find out that you renamed a built-in container for no good reason.
Re:TOML, Tom's Own Markup Language by DanWaterworth on Monday February 25, 2013 @03:57PM (#5281741)
Yes, I suppose that's also true.
Re:TOML, Tom's Own Markup Language by knewter on Sunday February 24, 2013 @02:32AM (#5273277)
I approve of this. Don't listen to that other guy. This should be standard.

One addition though:

    Cocktionary = HashMap
"Dictionary" never really made sense.
Re:TOML, Tom's Own Markup Language by grey-area on Sunday February 24, 2013 @02:56AM (#5273343)
Because the primitive is called Hash

    my %hash = ();
    Hash.new
So naturally people talk of Hashes etc. I understand where you're coming from, but it's really not very important, and it would be more confusing to talk of Hash Tables as learners would naturally look for HashTable in the stdlib.
Re:TOML, Tom's Own Markup Language by oleganza on Sunday February 24, 2013 @06:31AM (#5273851)
That was the question: why the class is named Hash instead of HashMap or Dictionary? Was it done intentionally, or it is just an accident because someone did not know English very well?
Re:TOML, Tom's Own Markup Language by grey-area on Sunday February 24, 2013 @08:24AM (#5274105)
I agree Map or Dictionary would have been fine too, but it's so widely used it needs to be easy to type so two words is not great (HashMap). However I suspect it was just named that way following perl (written by an english speaker). Obviously it's far to late to change it now and I can't say it bothers me or most Ruby users. It's something you get used to very quickly.
Re:TOML, Tom's Own Markup Language by dkersten on Sunday February 24, 2013 @04:14PM (#5275943)
So do what python did: dict

Though even HashMap isn't bad because typing is a solved problem - with auto completion and touch typing two words really aren't an issue in my mind.

People get used to living with all kinds of things, but that doesn't make them any better. Yes I'm aware that this applies equally to my typing comment as to you having got used to hash.

Re:TOML, Tom's Own Markup Language by Terretta on Sunday February 24, 2013 @09:55PM (#5277063)
> why the class is named Hash instead of HashMap

Why in golang is a function denoted by func instead of function?

I'd guess it's because programmers prefer fewer keystrokes as long as the term remains sufficiently mnemonic.

Re:TOML, Tom's Own Markup Language by jlgreco on Monday February 25, 2013 @02:00AM (#5277699)
The name 'func' doesn't collide with anything else though. It is an entirely more reasonable abbreviation.
Re:TOML, Tom's Own Markup Language by draegtun on Sunday February 24, 2013 @11:07AM (#5274654)