meta programming — personal reflections

I’m no expert on meta programming. I feel MP is an over-popularized buzzword, with increasingly vague and expanding scope. I’m less interested in what buzzwords are part of MP, and more interested in the very few “pillars” beneath this sprawling complex —

– reflection/introspection
** first-class functions — all functions as first-class objects

– run-time byte-code engineering
– dynamic creation and manipulation of program modules
– nested (often anonymous) code modules[1] such as nested functions/classes — nested in Functions. I feel this is basically “dynamic creation”

– More generally, any compile-time task performed at run time (by your clever hack) is subversive, powerful, dangerous and usually part of meta programming.
** I feel one of the earliest use cases is C++ template meta programming. What used to be a compile-time task — creating similar vector classes for int, float, Dog — is now performed at run time.
** another Simple example in Java reflection — removing “private” access modifier at run time.

Reflection is richer in Python than compiled languages. All functions, methods, types … are first-class objects you can look into at run-time.

Perl offers “subref” and closures, too.

[1] beyond data structure

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s