Ego: Controlling the Power of Simplicity

Ego is a small research language design that uses a linear type system to statically type changes to the types of objects at run time.  Ego is inspired by the Self programming language's powerful dynamic features, allowing programmers to add and remove methods from objects and to change the inheritance hierarchy at run time.  These facilities are useful for modeling objects that behave in different ways at different points in the object's lifecycle.  Unstructured use of these techniques, however, can result in arbitrary changes to the interface of the object, and thus is incompatible with static type checking.

Ego addresses this challenge with a structural type system for tracking changes to the interface of an object as methods are added and removed, and inheritance is changed at run time.  The type system tracks the linearity of object and method references in order to ensure that objects whose interfaces change are not aliased.  The paper below shows how our type system can express and enforce interesting protocol specifications.  It then defines a formal model of the language and type system, and proves that the type system is sound.  Thus, Ego is a foundation for languages that combine much of the power of dynamic languages like Self with the benefits of static typechecking.



We have released a preliminary implementation of the ideas in Ego.