Objects, attributes, maps, oh my!

Or, IC UC we all C for ICs.

In many dynamically typed programming languages, objects look like a big ol’ mapping of names to values. The languages encourage this flexibility. Consider for example Python:

class C:
    def __init__(self):
        self.a = 1
        self.b = 2

Or Ruby:

class C
  def initialize
    @a = 1
    @b = 2
  end
end

Or JavaScript1:

let obj = {};
obj.a = 1;
obj.b = 2;

This might encourage the VM implementor to model object attributes using a hash table. Hash tables, after all, are very good at mapping names to values.

Here is, by way of example, a Python sketch of what this object model looks like. Because it is a sketch, it uses write_attr and read_attr instead of the much more common syntax that your programming language comes with.