Hacker News new | ask | show | jobs
by j_col 5287 days ago
I don't think that PHP referring to hash maps as an array is a bad thing, in fact I've always loved the flexibility of the overloaded array implementation in PHP.

> ...due to whatever backwards incompatible changes have been made.

PHP is normally very good that way, does anyone know of any backwards incompatible changes that have been made?

> I know it's all the rage to hate on PHP these days, but even giving an objective look at the state of the language, given the thriving ecosystems of its competitors, makes it look to me like something I would never touch.

Yes you're right, it is quite fashionable to hate PHP and has been so for the ~10 years I've been using it, but who cares it gets the job done (a language for the pragmatists not the purists).

1 comments

> I don't think that PHP referring to hash maps as an array is a bad thing, in fact I've always loved the flexibility of the overloaded array implementation in PHP.

But they're not arrays. JavaScript and Lua do the same thing, allowing you to assign numeric or hashed keys on objects (or tables in Lua), but they don't call them Arrays, because they aren't. Arrays have expected behavior and implementations. So do hash maps. It's fine to amalgamate them, just give it the right name.

> PHP is normally very good that way, does anyone know of any backwards incompatible changes that have been made?

I haven't looked at any in this version, but recently there was an article (I think on HN) complaining about severe ABI changes that required all compiled modules to be recompiled, leading to adoption problems.

> Yes you're right, it is quite fashionable to hate PHP and has been so for the ~10 years I've been using it, but who cares it gets the job done (a language for the pragmatists not the purists).

I used PHP for many years as well, and for that reason I don't think it's a language for the pragmatist at all. It's not expressive enough, it encourages bad coding, and it doesn't have an ecosystem comparable to Ruby, Python, or even the amazing one Node.JS has managed to garner in the past year or so.

But they're not arrays. JavaScript and Lua do the same thing, allowing you to assign numeric or hashed keys on objects (or tables in Lua), but they don't call them Arrays, because they aren't.

PHP's arrays combine both vectors and associative arrays, but both numerically indexed arrays and associative arrays are types of arrays, are they not?

Arrays have expected behavior and implementations. So do hash maps. It's fine to amalgamate them, just give it the right name.

Whether associative arrays use hash maps underneath is an implementation detail, not fundamental to the interface PHP provides to [associative] arrays.

> ...it encourages bad coding...

I would love to explain to my boss when I introduced some bad code into our repo: "But the PHP made me do it!". Really, if you can't use a tool without blaming it for when you use it badly, well...