Fog Creek Software
Discussion Board




"Metaprogramming?"

The problem with googling for something you know nothing about is you have no way to judge the merit of the sites you find.

Does anyone have a link to a very basic "what is metaprogramming" explanation?  This term ("metaprogramming") has come out of the blue (to me, anyway)... does it just mean, "templates"?  Or is there more to it?

Thanks.

Grumpy Old-Timer
Thursday, November 13, 2003

Meno::  And how will you enquire, Socrates, into that which you do not know? What will you put forth as the subject of enquiry? And if you find what you want, how will you ever know that this is the thing which you did not know?

Socrates::  I know, Meno, what you mean; but just see what a tiresome dispute you are introducing. You argue that man cannot enquire either about that which he knows, or about that which he does not know; for if he knows, he has no need to enquire; and if not, he cannot; for he does not know the, very subject about which he is to enquire.

-- Plato, Meno

Tapiwa
Thursday, November 13, 2003

http://www.mywikinet.com/mpl/paper/mpl_paper.html

seems quite good.

Or read Modern C++ by Andrei Alexandrescu.

It's interesting stuff but I wouldn't be too comfortable with it being used in a production codebase unless I was certain of the abilities of those who needed to maintain it... Then again, I guess you can say that about lots of C++ techniques...

Len Holgate (www.lenholgate.com)
Thursday, November 13, 2003

Tapiwa, thanks for nothing. I mean, really, man, WTF?!

Grumpy Old Man
Thursday, November 13, 2003

I appreciated the comment Tapiwa.


Thursday, November 13, 2003

There is only one good, knowledge, and one evil, ignorance.

So Crates
Thursday, November 13, 2003

Tapiwa's metacomment was appreciated^2 here as well.

Elegant showing Tapiwa!

Dennis Atkins
Thursday, November 13, 2003

Old Man

I just need to get out more! I collect interesting quotations.
http://www.tapiwa.com/quotes
for some of my favourite ones.

It's just interesting that problems which existed in 400BC still remain today. The conversation that Socrates has with Meno (about the quest of knowledge and evaluating sources) is in essence what Old Timer is asking.

History does teach us a lot. Furthermore,

"What a good thing Adam had. When he said a good thing, he knew nobody had said it before."
-- Mark Twain

History, and indeed conversations do repeat themselves.

Oh, back to the original question. Why? A bit of meta-posting (a post about a post!)

Tapiwa
Thursday, November 13, 2003

[It's just interesting that problems which existed in 400BC still remain today.]

Not really. I would think the fact that history repeats itself and certain (kinds of) problems will always be with us wouldn't be a revelation to anyone.

In any event, I would humbly suggest to the original poster that perhaps a call or trip to a local university with a respectable CS department might be in order, perhaps one of the professors there is doing research in metaprogramming. As well as contacting other technical colleagues who might have some knowledge of metaprogramming.

Either suggestion might bear more fruit than, say, quoting a conversation from a long-dead Greek philospher. :-)

Grumpy Old Man
Thursday, November 13, 2003

> As well as contacting other technical colleagues who might have some knowledge of metaprogramming.

Such as by, say, posting a question on a forum where several technically-minded people are known to congregate?

One-Armed Bandit
Thursday, November 13, 2003

Am I the only one confused by having a "Grumpy Old-Timer" and "Grumpy Old Man" on the same board?  Maybe I'll change my moniker...

Anyway, thanks for the link - it was very informative, and really, really dense.  The idea of being able to choose a variable's type at runtime fascinates and repulses me at the same time!

The Socrates quote seemed, to me, a little pedantic, but hey, I went to college, too, so I'm used to "errant pedantry"...

Grumpy Old-Timer
Thursday, November 13, 2003

Tapiwa - I liked the quote.

Grump-old-man - are you Grump-old-timer as well?

Well done [both of] you for living up to your handle[s]!

Ged Byrne
Thursday, November 13, 2003

Oh, and my cost of admission for the thread:

http://www.c2.com/cgi/wiki?MetaProgramming

If you ever have a question about advanced programming issues, then the c2.com (the very first Wiki) is always a good place to look.

Ged Byrne
Thursday, November 13, 2003

" The idea of being able to choose a variable's type at runtime fascinates and repulses me at the same time!"

Don't we Java programmers do that all the time?

Object o = foo();
public Object foo();

Russell Thackston
Thursday, November 13, 2003

[> As well as contacting other technical colleagues who might have some knowledge of metaprogramming.

Such as by, say, posting a question on a forum where several technically-minded people are known to congregate? ]

One-Armed Bandit, I should've made it clear that I was talking to someone you actually know and whose technical skills and knowledge you respect. Some online forums can be useful, others may not. YMMV.

Grumpy Old Man
Thursday, November 13, 2003

[I was talking to someone you actually know and]

I was talking *about talking* to someone you actually know...

Ok, I guess it's nap-time now. :-)

Grumpy Old Man
Thursday, November 13, 2003

Tapiwa, I loved your comment.  I had to repeat it (in context) to a colleague.

David B. Wildgoose
Thursday, November 13, 2003

>>I was talking *about talking* to someone you actually know...

Metatalking.  How appropriate!

Ged Byrne
Thursday, November 13, 2003

"The idea of being able to choose a variable's type at runtime fascinates and repulses me at the same time!"

Old Timer: factory function?  We do this stuff all the time, just at different levels of syntax & generality :-)

H. Lally Singh
Friday, November 14, 2003

To grok metaprogramming, you might as well look at the best example: Lisp.

Here's a langauge with a small, but wierd syntax. When you look at it closely, you realise there's no difference between the  format of the program and the data itself. Then you realise that with this kind of wierd grammar, it's easy for programs to operate on other programs.

Just suspend your C/C++ based myopiea here for a minute. Metaprogramming with a C/C++ based perspective is like trying to make a paper aeroplane out of a housebrick: You really are making your life very difficult. Lisp is (usually) an interpreted language, which means that the source is available at runtime. This means that you have to opportunity to write programs that can operate on themselves.

I wouldn't bother trying to learn metaprogramming by comparison to C++ - it's not up to the job. Lisp is going to give you the ultimate in syntactic metastructure.

Exercise 1: Find out what "eval" does in Lisp and think about what use could it be in production software. What could it let you do that you'd never ever be able to do in C++?

Dafydd Rees
Friday, November 14, 2003

"Metaprogramming with a C/C++ based perspective is like trying to make a paper aeroplane out of a housebrick..."

I love it!!!  That's exactly my point.  Right tool for the job.  Right tool for the job.. ...

christopher baus (www.baus.net)
Friday, November 14, 2003

*  Recent Topics

*  Fog Creek Home