Writing programs that generate other programs may seem esoteric, but once you learn why metaprogramming is so powerful, it’s a skill you’ll want to cultivate. This article explains why you might consider metaprogramming and looks at some of the components of this art.
The Art of Metaprogramming
Submitted by anonymous 2005-10-25 General Development 18 Comments
I’m impressed. I expected YA (worthless) exposition of C++ template metaprogramming, but I got an overview of several different techniques, even including Scheme/Lisp, which is pretty much the only language with builtin metaprogramming worthy of the name.
Nothing here new or revolutionary here, but interesting reading and there’s likely something useful to be found.
I’m amazed they included Scheme. Syntax-case is a bit of overkill for my tastes, but that’s still incredible that Scheme got any mention.
The art perfected by virus-writers
(who use assembly code no less!)
But yeah, actually a surprisingly readable article from IBM.
Surprisingly there wasn’t any mention of C++ meta programming (using templates). It also fails to mention the really rich code generation library in .Net (which lets u generate code in any MS .Net language ), but thats ok, since this article if from IBM.
actually i thought it was a bit thin on the ground. M4? please. eeesh. nice to see some lisp but really. a SWAP macro in C pre processor??
the embedded sql was good.
Dynamic compilers easily implement metaprograms. To generate programs is just one feature. Dynamic compilers also reprogram code for optimization. The article is just one perspective without the older self-modification style view.
Jonathan Bartlett wrote it, as it mentions at the bottom, his “programming from the ground up” is good even for begginers like me.
Why its on the ibm website is something i don’t understand.
is going to be a fantastic addition to .Net 2.0…I know there’s nothing new or revolutionary about it, but we .Net folks have long been looking forward to something like this.
The ability to define out own DSL will lend itself pretty well to this paradigm also.
The Scheme example doesn’t tickle my asthetic fancy like the Common Lisp version does (sorry that OSNews borks the formatting completely):
; define vector containing square roots
(defmacro define-roots (name (start end))
(vector ,@(loop for in from start to end
collect (sqrt i)))))
; example usage
(define-roots root-table (5 20))