Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

How often do you or have you seen meta-programming be used in projects? In uni I've never seen this be applied, but I've seen this on my previous job (when I saw it I was blown away of how effective it was).

But how common is it? Is it used all the time, or just occasionally?

share|improve this question
It might not be that common; though quite common in Lisp, Lisp is not that common -- not even Common Lisp. – paul Oct 10 '12 at 16:03

5 Answers

If you consider reflection a kind of meta-programming, it is relatively common. For some people even generic programming (templates and generics) is a form of meta-programming, so that's even more common.

In my opinion, however, meta-programming is something more complex, that involves actual code generation, and therefore quite uncommon, even in scripting languages.

share|improve this answer

I think it depends strongly on what language you use. Common Lisp people probably make a fair use of it - the Meta-Object Protocol allows for neat things transparent/orthogonal persistence, for instance - and Smalltalkers use it frequently.

share|improve this answer

If you are using C++ wit liboost there is a high chance you are already using metaprogramming, even if you don know it.

share|improve this answer

It tends to show up commonly and consistently in Common Lisp projects. Check out OnLisp and Let Over Lambda for some explanation/insight.

If you're just after examples (and know CL), check out the Antiweb repository; there's a good deal of meta-programming going on under the covers.

share|improve this answer

For the past two years the first bit of programming on a new task has almost always been writing code to write code. There's a ton of boilerplate associated with interactions with a database that can be simplified down to automatic script generation. Think of things where you need to query 3 tables to form an object or some such. Why write it yourself if there's 10 of these things that might change in the future?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.