Tuesday, November 20, 2007

@mediaAjax day 2.3: Metaprogramming JavaScript

Dan Webb's talk turned out to be an explication of the JS language, notably the primitives, objects, functions and prototype inheritance. It was good to see those concepts explained in a clear fashion again but at the time I didn't get the link with metaprogramming which Dan defined as:

Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data...
(http://en.wikipedia.org/wiki/Metaprogramming)

which was a shame (it's the as their data bit I missed.) Actually, Dan did show examples of using class methods from Array with other array-like objects (notably arguments), building push methods in implementations that don't have them and a genuine "Meta" addEvent function that self-modified on the 1st call to avoid repeatedly checking for implementation features (namely IE vs DOM2 event model), so that seems to cover the metaprogramming aspect — guess I wasn't paying sufficient attention (or it's a classic example of how taking and writing-up notes can clarify things in your mind.) He finished with a book plug: "The Art and Science of JavaScript", soon to come from SitePoint. (Note to self: get a copy for the library!)

No comments: