Metaobject protocol is protocol for metaobjects in a programming languages. Although I understand it on simple terms, I want to know the reason and a summary of real world usage patterns of this protocol. So, why exactly is metaobject and more importantly metaobject protocol is such a good idea. I want to know the problem which led to its evolution and also, its high power usage. Opinions as well as general overview/description/alternate explanations are also welcome.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Meta-object protocols are very good to decouple clients from servers.
Some control systems I've worked on I added meta-object protocols and it worked really well. The exchange of messages look like this....
So the overhead of messages you use for real tasks is low because they can even be a compact binary from, and the server is self-documenting for integrators.
Allows integration really easily.
Also allows you to extend the server really easily IF you can add stuff to the server using the meta-protocol. Does start to look like AOP
The Perl library Moose is using the MOP to allow a large ecosystem of extensions to work smoothly together. It also allows for introspection and reflection, for instance the generation of a web form by providing an object. The reflector would look at the class, take (for example) it's attributes or attributes that implement a specific behavior, and generate form fields depending on the attributes and their types.
There are of course many other implementations and use cases for the MOP, Moose is just the one I use most frequently.
One way of thinking about a meta-object protocol is that it's like aspect-oriented programming. AOP really came out of MOP, but extended it with point-cuts (and probably other stuff).
So, things that AOP is good for I would expect MOP to be good for. The classic example is, of course, profiling. You want to take an existing program and modify it to e.g. record every method that is invoked. With MOP you could do with this some kind of proxy object which intercepts messages, records the profile data and then passes control onto the original message handler.