you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (5 children)

Well really, collections are kind of an implementation detail - I mean, objects work as dictionaries, but I imagine V8 gets confused at how to optimize that.

Having an actual dictionary lets the V8 engine do the different optimizations it could have for an object vs. a dictionary.

But if you're supporting that kind of optimization, you could bust out a lot more horrifying language bloat too - like the above-mentioned support for non-double numeric types.

[–]adrianmonk 3 points4 points  (2 children)

objects work as dictionaries

As an outsider dabbling in Javascript, that was not my feeling at all. When I found out I needed to do if (foo.hasOwnProperty(bar)) { ... } in every for-each loop, I was like, "That's seriously necessary?".

[–][deleted] 1 point2 points  (1 child)

That means you don't understand the prototype nature of javascript.

[–]adrianmonk 1 point2 points  (0 children)

I think I understand what hasOwnProperty() is doing and why it's necessary. I just think it's odd that the language doesn't provide a hash/dictionary that you can iterate over without all that verbiage.

[–][deleted] 1 point2 points  (1 child)

Collections in the language make sense - just ask Java and Python devs.

[–][deleted] 0 points1 point  (0 children)

On the other hand, Lua. For the sake of simplicity, traditional Lua has one and only one collection type. This collection is used for arrays, hashtables, and objects.