1. A method implemented at least in part by a computer, the method comprising: obtaining a grammar that defines a format for serializing an object, the grammar representing rules for serializing the object, the grammar defining a header and a payload for serializing the object, the header including metadata for the grammar, the metadata usable in de-serializing objects serialized using the grammar, the payload including an identifier of each descendent object of the object, the payload further including reference data for each reference, if any, included in the object, the reference data indicating relationships of the object, the reference data potentially referring to one or more of: an object type supported by a scripting environment in which the object resides, an object type supported by a host environment of the scripting environment, and a foreign object type that is defined outside of both the scripting environment and the host environment; and serializing the object into serialized data by executing code that implements the grammar.