Hacker News new | ask | show | jobs
by postalrat 32 days ago
Better than calling it a hash.
2 comments

I don't think it is, tbh.

Perl's hashes are a complete mystery to me still, but at least it lets me know that it's not just a linear, uh, well, array.

> Perl's hashes are a complete mystery to me still

They're unordered mappings from strings to arbitrary values ("scalars" in Perl jargon). In this sense they're just like an object in JavaScript.

Where this gets a little weird is that Perl arrays and hashes are fundamental types distinct from scalars - you can't put a hash into a $variable without taking a reference to it first, for instance. But that's more a matter of Perl being picker about the value/reference distinction than a hash-specific thing.

PHP arrays are vectors, hash maps and doubly linked lists in one
My issue is a ton of people call all maps a hash regardless how it's implemented.
With good abstraction the implementation can be swapped without many noticing.

However PHP leaks different aspects hear and there, making this harder ...