4 ms·
> "hash" in this context means what other languages would call a hash map Interesting. The only other time I've seen this term used for a hash map is in the co
by 3PS 4y ago
> "hash" in this context means what other languages would call a hash map
Interesting. The only other time I've seen this term used for a hash map is in the context of Redis hashes [0], which confused me to no end when I first encountered them for the same reason. Given that Redis itself is written in C, I wonder where the term originated.
[0] https://redis.io/docs/data-types/hashes/ https://redis.io/docs/data-types/hashes/
- syrrim 4y agoPerl, probably.
- danielheath 4y agoThis got me curious, so I went and looked what it was called in a few languages. Perl: Hash Ruby: Hash PHP: HashMap Java: HashMap Haxe: Map Golang: map Swift: Dict Python: Dict C#: Dictionary Javascript: Object Redis: Hash Postgresql: hstore, json
- pclmulqdq 4y agoC++: unordered_map
- duncan-donuts 4y agoDoes PHP have a HashMap class now? I haven’t written PHP for a few years now but associative array used to be how they were referred to.
- meling 4y agoYeah, I pretty sure Perl also called them associative arrays, but like you I haven’t written much Perl since Perl 4/5.
- darrenf 4y agoIn all my time as a Perl dev (since 1996) I don't think I've ever heard the term "associative array" except at the start of `perldoc perldata` - which says they're known as hashes and then never uses the term again. DESCRIPTION Variable names Perl has three built-in data types: scalars, arrays of scalars, and associative arrays of scalars, known as "hashes". A scalar is a single string (of any size, limited only by the available memory), number, or a reference to something (which will be discussed in perlref). Normal arrays are ordered lists of scalars indexed by number, starting with 0. Hashes are unordered collections of scalar values indexed by their associated string key. Hash is ubiquitous.
- draegtun 4y agoYes they used to be called Associative Arrays. I think the change occurred between Perl4 & Perl5. In Programming Perl it says "Associative Arrays" in 1st edition and "Hashes (Associative Arrays)" in 2nd edition. NB. 2nd edition was the first to cover Perl5
- kijin 4y agoIt doesn't, at least according to the current documentation. Not sure why they would need a class for that when they already have a primitive type that does the job. I guess maybe a new OO interface will have its parameters ordered more consistently?
- thayne 4y agoJavaScript also has Map. Which is more general since the keys don't have to be strings.
- voidfunc 4y agoKeys do not need to be strings in Java either, you need to properly implement equals and hashCode() methods though for the key type. Also Java has like ten different implementations of Map<K,V> depending on various use cases.
- thayne 4y agoI wasn't comparing to Java. I was commenting on > Javascript: Object And in javascript, if you use an Object as a map, the keys do have to be strings (if they aren't already, they are converted into strings).
- flir 4y agoAssociative array in PHP. As opposed to indexed array.
- synu 4y agoThe oldest example I can think of is Perl.