The “Mirrors” Design Principles

[…] after many years of experience with Smalltalk- and (similar) Java-style reflection, Bracha and Ungar (2004) articulated the “mirrors” design principles which effectively rectified several shortcomings with these VMs’ approaches to reflection. -- Unix, Plan 9 and the Lurking Smalltalk, p. 203

Unix-style reflection adheres remarkably tightly to the very same principles, which we summarise as follows.

* **Encapsulation**, meaning “the ability to write metaprogramming applications that are independent of a specific metaprogramming implementation”, holds that metaprogramming interfaces should not impose undue restrictions on clients, such as reflecting only on the host program (a weakness of Java core reflection). * **Stratification**, meaning “making it easy to eliminate reflection when it is not needed”, intends that reflection can be eliminated on embedded platforms or in applications which happen not to use it. * **Ontological correspondence**, meaning that metaprogramming interfaces should retain user-meaningful concepts, encompasses both structural (e.g. preserving source code features in the metamodel) and temporal considerations (e.g. the distinction between inactive “code” and active “computation”). The Unix approach to debug-time reflection satisfies all of these principles either fully or very nearly; we discuss each in turn.