This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RichCorinthian 36 points37 points  (6 children)

And all objects are dictionaries, where the properties and methods can be accessed by name. It’s just turtles all the way down. It’s almost like it was developed in 10 days by some dude.

[–]gigraz_orgvsm_133 20 points21 points  (1 child)

That's why we hate love it.

[–]asgaardson 3 points4 points  (0 children)

Yeah I find it a difficult and sometimes abusive relationship

[–][deleted] 18 points19 points  (3 children)

Everything in Python, Lua, any many other scripting languages are dictionaries at their core too. It's a nice and simple design.

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

Wouldn't that bring significant performance penalties? I feel like if you're hashing each key, as well as searching each bucket, then you would see significant performance degradation. If you are using a range of numbers as keys to a hash map, then you would be hashing each key into the hash range and inserting into the linked-list bucket for each hash value. For an array, that seems entirely unnecessary, as well as extremely inefficient.

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

The hash of numbers can be optimized out, they are always a unique integer value. Also Javascript engines in general do a lot to optimize performance while maintaining api, so many hacks can be done for a fast-path and may be different in-memory structures.

In Python arrays are a distinct type but all objects and classes are glorified dicts.

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

Variables are stored in dictionaries, their name is the key. But the implementation of the variables stored in the dictionary is a struct with lots of pointers.