Friday, June 26, 2015

Reflection and Automatic Serialization

Before you ask, no...I'm not talking about rendering reflections in a graphics context :)

Reflection is a term used to denote the ability for objects in a language to know about themselves at runtime (or "reflect" on their data). Other languages that have this concept built-in may also call this introspection. Either way, knowing about your objects at runtime can have some pretty amazing benefits, including:

  • A queryable registry of all of your objects and types
  • Objects can iterate over their member variables
  • Easy function binding with a scripting language
  • Automatically expose objects to an external editing tool
  • Automatic serialization and deserialization
These benefits can really save a lot of time and code complexity later on and having it built into your language of choice really makes it easy. However, Qi predominately uses C++ which does not have any concept of reflection at all. Therefore, we have to roll our own!