[self-interest] prototypes, "meta" and reflective programming

cramakrishnan at acm.org cramakrishnan at acm.org
Thu Jan 11 00:25:13 UTC 2001


Albertina Lourenci writes:
> 
> Faré suggests that in the current computing projects necessarily
> appears a divergence of point of views, as soon as multiple actors
> (programmers, users) or in presence, and/or as soon as  these
> actors evolve and that their points of focus change with time
> (a same person can take several roles in succession even
> simultaneously). Hence metaprogramming would be useful to
> enforce consistency between these aspects that else would have to
> be managed manually; it allows to handle once and for all
> an uninteresting aspect so as to forget it afterwards.

Hmm... I've been thinking about metaprogramming lately, and though I
think meta facilities in a language increase the expressiveness of the
language, I'm coming to the conclusion that having to resort to meta
facilities is a symptom of lack of expressiveness.

For example, one common use of reflection is implemeting proxies in
Smalltalk/ObjectiveC.  You subclass nil, implement doesNotUnderstand:
to invoke the method on the wrapped object.  But the fact that you
have to do this is a symptom of the fact that Smalltalk doesn't have
the notion of delegation, the way Self does.

Another example is something I just did yesterday in Java.  I received
a HashMap from an HTTP request that contains the changes a user made
to an object.  I need to stuff these changes into a persistent object
so i can get the changes into the Database.  In Java, I had to get a
PropertyDescriptor and then retrieve the setter method and invoke it,
etc.  

In JavaScript, however, objects are just the same as arrays with the
slot names being the index.  So I could have just done:

  myObject[key] = value;

No need for reflection.

Another thing i find interesting is that there are some types of meta
programming which are common (like the two above examples), but others
which are quite rare (like people creating their own meta-classes).  I
think this is significant, though I'm not sure what that means. :)

I also remember that in the Self Programmer's Manual there is a
section that discourages reflective programming.

What do you guys think of this? 

- sekhar

--
C. Ramakrishnan        cramakrishnan at acm.org



More information about the Self-interest mailing list