Jump to content

User talk:Kim Bruning/Compiler metaprogramming example

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

I'd originally intended to see what would happen if I tried -funroll-loops (and no I wouldn't have put all of *THAT* expected result into wikipedia), but to my surprise, there was no difference in the output of g++. Apparently there are still some things I don't undestand about gcc, can anyone help?

Turns out that by default GCC doesn't unroll loops that are too large (have too many iterations). This is actually logical/useful, since otherwise such an unrolled loop might not fit into the processor-cache of the specific target processor.(Loop unrolling is supposed to be an Optimisation )) . At some point it might be interesting to get gcc to work like that, and modify the example page.


So every time I write a c++ program and compile it I'm doing compiler metaprogramming? Josh Cherry 03:18, 15 Jun 2004 (UTC)

I really don't think this is generally considered metaprogramming. Metaprogramming usually means having the compiler do work other than simple translation. (Even though that assembly is very complex and no human would write it, it's nothing unusual for a compiled program!) - Furrykef 06:55, 16 Aug 2004 (UTC)

OK, that's what I thought. This needs to be fixed. Josh Cherry 21:48, 16 Aug 2004 (UTC)

Originally compilers were dreamt up as assembly metaprogramming tools. Some languages like fortran and c even still show some of their assembly roots. Kim Bruning 19:52, 8 Mar 2005 (UTC)

Length

[edit]

Uh.. WTF?!?! I know little to no assembler but... i belive to count from 1 to 1k in asm you only need like 20 lines of code, and all the operations you need are jmp, cmp, add, mov and int10h to print it... where am I mistaken? Tordek

This piece of assembly was written by a computer. Computers possess no true intelligence, so they have to write code by rote. As a rule of thumb, code written by a computer will tend to be rather less efficient than that written by a human being. Kim Bruning 19:52, 8 Mar 2005 (UTC)

pos

Is using a compiler metaprogramming?

[edit]

I made this example a long time ago, to serve as an example for metaprogramming.

A compiler is a program which generates programs based on its input, (originally often even by copying in parts of itself). In that strict sense I think it certainly does qualify as as a metaprogramming tool.

Compilers evolved from ye olde assembler macros and other assorted assembly metaprogramming tricks.

The idea of this particular example is to show how a current real-world compiler expands a fairly trivial 3GL example into 2GL code. Note how this expansion is still not very efficient, even today!


I'll also answer some folks above.

Kim Bruning 19:52, 8 Mar 2005 (UTC)

(PS. To complete the story: there even exist compiler-compilers, which are quite definately metaprogramming tools. :-P Kim Bruning 19:59, 8 Mar 2005 (UTC) )

I think most programmers will agree that compiler-compilers are metaprogramming tools, and I think most programmers will agree that converting a 3GL to a 2GL is not. Unfortunately, your personal opinion on that matter must play second banana to the majority opinion. Ask yourself: would an encyclopedia covering metaprogramming include an example using an ordinary compiler? I think the answer is "no". - furrykef (Talk at me) 04:41, 9 Mar 2005 (UTC)
A compiler compiler essentially converts an input that's a form of 4GL into an output that's (typically) a form of 3GL. So your point is... ?
Historically (n+1)GLs have often evolved from metaprogramming being done in a preceding nGL. (think machine code->assembler->fortran, or ->C , or ->forth.
The main problem for the position you're holding is that compilers neatly fit the definition at Metaprogramming_(programming). In fact they don't fit the definition there loosely, they actually fit it very tightly indeed! If it turns out that the position holds true, then the definition there is wrong, and we'll need to modify both pages. Conversely both places could be quite alright, and the position will at very least need some kind of backing to be sustained. Thirdly perhaps we all hold correct positions, and there is simply yet another definition of metaprogramming that has been omitted on wikipedia so far, and we'll need to disambiguate some more. Kim Bruning 12:39, 9 Mar 2005 (UTC)

VfD result

[edit]

This page was voted on for deletion at Wikipedia:Votes for deletion/Compiler metaprogramming example. The final result was Delete. I userfied the article as requested by the original author --Deathphoenix 21:17, 18 Mar 2005 (UTC)