Published on November 21, 2007
What? “ the writing of computer programs that write or manipulate other programs (or themselves) as their data”
4 building blocks
(Nearly) everything is a hash
number string boolean undeﬁned
everything else is an Object
This works with any object
Expandos: a special case
First typeof then instanceof
Functions are Objects
'Methods' are just functions that are assigned to a property of an object
Functions can return other functions
Back to wikipedia... “ A closure occurs when a function is deﬁned within another function, and the inner function refers to local variables of the outer function.
Why is that useful?
Functions can be used to make objects
Constructor functions are just functions
The magic is in the new operator
The point is: its all just functions, objects and properties
We can hack it all.
So what can you do with this stuff?
Patch holes in bad implementations
Self optimising code
Domain Speciﬁc Languages
DIY language features
Prototype 1.6 Classes http://prototypejs.org/learn/class-inheritance
and a lot more...
The opfuncs function should be called exactly once. These functions shouldn’t be generated multiple times because the benefits of the metaprogramming ...
Metaprogramming, writing code that augments itself at runtime, is a very powerful technique gaining popularity in scripting languages like Python and Ruby ...
Metaprogramming... The writing of programs that write or manipulate other “ programs or themselves. ”
About Jeremy Miller Jeremy is the Chief Software Architect at Dovetail Software, the coolest ISV in Austin. Jeremy began his IT career writing "Shadow IT ...
Clone via HTTPS Clone with Git or checkout with SVN using the repository's web address.