<s>
Metaprogramming	B-Application
is	O
a	O
programming	O
technique	O
in	O
which	O
computer	B-Application
programs	I-Application
have	O
the	O
ability	O
to	O
treat	O
other	O
programs	O
as	O
their	O
data	O
.	O
</s>
<s>
Metaprogramming	B-Application
can	O
be	O
used	O
to	O
move	O
computations	O
from	O
run-time	B-Library
to	O
compile-time	B-Application
,	O
to	O
generate	O
code	O
using	O
compile	B-Application
time	I-Application
computations	O
,	O
and	O
to	O
enable	O
self-modifying	B-Application
code	I-Application
.	O
</s>
<s>
The	O
ability	O
of	O
a	O
programming	O
language	O
to	O
be	O
its	O
own	O
metalanguage	O
is	O
called	O
reflection	B-Language
.	O
</s>
<s>
Reflection	B-Language
is	O
a	O
valuable	O
language	O
feature	O
to	O
facilitate	O
metaprogramming	B-Application
.	O
</s>
<s>
Metaprogramming	B-Application
was	O
popular	O
in	O
the	O
1970s	O
and	O
1980s	O
using	O
list	B-Language
processing	I-Language
languages	I-Language
such	O
as	O
LISP	B-Language
.	O
</s>
<s>
LISP	B-Language
hardware	O
machines	O
were	O
popular	O
in	O
the	O
1980s	O
and	O
enabled	O
applications	O
that	O
could	O
process	O
code	O
.	O
</s>
<s>
They	O
were	O
frequently	O
used	O
for	O
artificial	B-Application
intelligence	I-Application
applications	O
.	O
</s>
<s>
Metaprogramming	B-Application
enables	O
developers	O
to	O
write	O
programs	O
and	O
develop	O
code	O
that	O
falls	O
under	O
the	O
generic	B-Language
programming	I-Language
paradigm	O
.	O
</s>
<s>
Having	O
the	O
programming	O
language	O
itself	O
as	O
a	O
first-class	O
data	O
type	O
(	O
as	O
in	O
Lisp	B-Language
,	O
Prolog	B-Language
,	O
SNOBOL	B-Application
,	O
or	O
Rebol	B-Application
)	O
is	O
also	O
very	O
useful	O
;	O
this	O
is	O
known	O
as	O
homoiconicity	O
.	O
</s>
<s>
Generic	B-Language
programming	I-Language
invokes	O
a	O
metaprogramming	B-Application
facility	O
within	O
a	O
language	O
by	O
allowing	O
one	O
to	O
write	O
code	O
without	O
the	O
concern	O
of	O
specifying	O
data	O
types	O
since	O
they	O
can	O
be	O
supplied	O
as	O
parameters	O
when	O
used	O
.	O
</s>
<s>
Metaprogramming	B-Application
usually	O
works	O
in	O
one	O
of	O
three	O
ways	O
.	O
</s>
<s>
The	O
first	O
approach	O
is	O
to	O
expose	O
the	O
internals	O
of	O
the	O
run-time	B-Library
engine	O
to	O
the	O
programming	O
code	O
through	O
application	B-Application
programming	I-Application
interfaces	I-Application
(	O
APIs	B-Application
)	O
like	O
that	O
for	O
the	O
.NET	B-Application
IL	O
emitter	O
.	O
</s>
<s>
The	O
second	O
approach	O
is	O
dynamic	O
execution	O
of	O
expressions	O
that	O
contain	O
programming	O
commands	O
,	O
often	O
composed	O
from	O
strings	O
,	O
but	O
can	O
also	O
be	O
from	O
other	O
methods	O
using	O
arguments	O
or	O
context	O
,	O
like	O
JavaScript	B-Language
.	O
</s>
<s>
General	O
purpose	O
program	B-Application
transformation	I-Application
systems	I-Application
such	O
as	O
compilers	O
,	O
which	O
accept	O
language	O
descriptions	O
and	O
carry	O
out	O
arbitrary	O
transformations	O
on	O
those	O
languages	O
,	O
are	O
direct	O
implementations	O
of	O
general	O
metaprogramming	B-Application
.	O
</s>
<s>
This	O
allows	O
metaprogramming	B-Application
to	O
be	O
applied	O
to	O
virtually	O
any	O
target	O
language	O
without	O
regard	O
to	O
whether	O
that	O
target	O
language	O
has	O
any	O
metaprogramming	B-Application
abilities	O
of	O
its	O
own	O
.	O
</s>
<s>
One	O
can	O
see	O
this	O
at	O
work	O
with	O
Scheme	B-Language
and	O
how	O
it	O
allows	O
tackling	O
some	O
limitations	O
faced	O
in	O
C	B-Language
by	O
using	O
constructs	O
that	O
were	O
part	O
of	O
the	O
Scheme	B-Language
language	I-Language
itself	O
to	O
extend	O
C	B-Language
.	O
</s>
<s>
Lisp	B-Language
is	O
probably	O
the	O
quintessential	O
language	O
with	O
metaprogramming	B-Application
facilities	O
,	O
both	O
because	O
of	O
its	O
historical	O
precedence	O
and	O
because	O
of	O
the	O
simplicity	O
and	O
power	O
of	O
its	O
metaprogramming	B-Application
.	O
</s>
<s>
In	O
Lisp	B-Language
metaprogramming	B-Application
,	O
the	O
unquote	O
operator	O
(	O
typically	O
a	O
comma	O
)	O
introduces	O
code	O
that	O
is	O
evaluated	O
at	O
program	O
definition	O
time	O
rather	O
than	O
at	O
run	B-Library
time	I-Library
;	O
see	O
Self-evaluating	O
forms	O
and	O
quoting	O
in	O
Lisp	B-Language
.	O
</s>
<s>
The	O
metaprogramming	B-Application
language	O
is	O
thus	O
identical	O
to	O
the	O
host	O
programming	O
language	O
,	O
and	O
existing	O
Lisp	B-Language
routines	O
can	O
be	O
directly	O
reused	O
for	O
metaprogramming	B-Application
,	O
if	O
desired	O
.	O
</s>
<s>
This	O
approach	O
has	O
been	O
implemented	O
in	O
other	O
languages	O
by	O
incorporating	O
an	O
interpreter	B-Application
in	O
the	O
program	O
,	O
which	O
works	O
directly	O
with	O
the	O
program	O
's	O
data	O
.	O
</s>
<s>
There	O
are	O
implementations	O
of	O
this	O
kind	O
for	O
some	O
common	O
high-level	O
languages	O
,	O
such	O
as	O
RemObjects’	O
Pascal	B-Language
Script	I-Language
for	O
Object	B-Language
Pascal	I-Language
.	O
</s>
<s>
A	O
simple	O
example	O
of	O
a	O
metaprogram	O
is	O
this	O
POSIX	B-Application
Shell	I-Application
script	B-Language
,	O
which	O
is	O
an	O
example	O
of	O
generative	O
programming	O
:	O
</s>
<s>
This	O
script	B-Language
(	O
or	O
program	O
)	O
generates	O
a	O
new	O
993-line	O
program	O
that	O
prints	O
out	O
the	O
numbers	O
1	O
–	O
992	O
.	O
</s>
<s>
Not	O
all	O
metaprogramming	B-Application
involves	O
generative	O
programming	O
.	O
</s>
<s>
If	O
programs	O
are	O
modifiable	O
at	B-Library
runtime	I-Library
or	O
if	O
incremental	O
compilation	O
is	O
available	O
(	O
such	O
as	O
in	O
C#	B-Application
,	O
Forth	B-Application
,	O
Frink	B-Language
,	O
Groovy	B-Application
,	O
JavaScript	B-Language
,	O
Lisp	B-Language
,	O
Elixir	B-Language
,	O
Lua	B-Language
,	O
Nim	B-Application
,	O
Perl	B-Language
,	O
PHP	B-Application
,	O
Python	B-Language
,	O
REBOL	B-Application
,	O
Ruby	B-Language
,	O
Rust	B-Application
,	O
SAS	B-Language
,	O
Smalltalk	B-Application
,	O
and	O
Tcl	B-Operating_System
)	O
,	O
then	O
techniques	O
can	O
be	O
used	O
to	O
perform	O
metaprogramming	B-Application
without	O
actually	O
generating	O
source	O
code	O
.	O
</s>
<s>
One	O
style	O
of	O
generative	O
approach	O
is	O
to	O
employ	O
domain-specific	B-Language
languages	I-Language
(	O
DSLs	O
)	O
.	O
</s>
<s>
A	O
fairly	O
common	O
example	O
of	O
using	O
DSLs	O
involves	O
generative	O
metaprogramming	B-Application
:	O
lex	B-General_Concept
and	O
yacc	B-Application
,	O
two	O
tools	O
used	O
to	O
generate	O
lexical	B-Application
analyzers	I-Application
and	O
parsers	B-Language
,	O
let	O
the	O
user	O
describe	O
the	O
language	O
using	O
regular	B-Language
expressions	I-Language
and	O
context-free	O
grammars	O
,	O
and	O
embed	O
the	O
complex	O
algorithms	O
required	O
to	O
efficiently	O
parse	B-Language
the	O
language	O
.	O
</s>
<s>
One	O
usage	O
of	O
metaprogramming	B-Application
is	O
to	O
instrument	O
programs	O
in	O
order	O
to	O
do	O
dynamic	O
program	O
analysis	O
.	O
</s>
<s>
Some	O
argue	O
that	O
there	O
is	O
a	O
sharp	O
learning	O
curve	O
to	O
make	O
complete	O
use	O
of	O
metaprogramming	B-Application
features	O
.	O
</s>
<s>
Since	O
metaprogramming	B-Application
gives	O
more	O
flexibility	O
and	O
configurability	O
at	B-Library
runtime	I-Library
,	O
misuse	O
or	O
incorrect	O
use	O
of	O
the	O
metaprogramming	B-Application
can	O
result	O
in	O
unwarranted	O
and	O
unexpected	O
errors	O
that	O
can	O
be	O
extremely	O
difficult	O
to	O
debug	O
to	O
an	O
average	O
developer	O
.	O
</s>
<s>
Some	O
of	O
the	O
common	O
problems	O
which	O
can	O
occur	O
due	O
to	O
wrong	O
use	O
of	O
metaprogramming	B-Application
are	O
inability	O
of	O
the	O
compiler	O
to	O
identify	O
missing	O
configuration	O
parameters	O
,	O
invalid	O
or	O
incorrect	O
data	O
can	O
result	O
in	O
unknown	O
exception	O
or	O
different	O
results	O
.	O
</s>
<s>
Due	O
to	O
this	O
,	O
some	O
believe	O
that	O
only	O
high-skilled	O
developers	O
should	O
work	O
on	O
developing	O
features	O
which	O
exercise	O
metaprogramming	B-Application
in	O
a	O
language	O
or	O
platform	O
and	O
average	O
developers	O
must	O
learn	O
how	O
to	O
use	O
these	O
features	O
as	O
part	O
of	O
convention	O
.	O
</s>
<s>
Common	B-Language
Lisp	I-Language
and	O
most	O
Lisp	B-Language
dialects	O
.	O
</s>
<s>
The	O
IBM/360	B-Application
and	O
derivatives	O
had	O
powerful	O
macro	B-Language
assembler	I-Language
facilities	O
that	O
were	O
often	O
used	O
to	O
generate	O
complete	O
assembly	B-Language
language	I-Language
programs	O
or	O
sections	O
of	O
programs	O
(	O
for	O
different	O
operating	O
systems	O
for	O
instance	O
)	O
.	O
</s>
<s>
Macros	O
provided	O
with	O
CICS	B-Application
transaction	B-General_Concept
processing	I-General_Concept
system	O
had	O
assembler	B-Language
macros	O
that	O
generated	O
COBOL	B-Application
statements	O
as	O
a	O
pre-processing	O
step	O
.	O
</s>
<s>
Other	O
assemblers	B-Language
,	O
such	O
as	O
MASM	B-Application
,	O
also	O
support	O
macros	O
.	O
</s>
<s>
Metaclasses	B-Language
are	O
provided	O
by	O
the	O
following	O
programming	O
languages	O
:	O
</s>
<s>
Common	B-Language
Lisp	I-Language
,	O
Scheme	B-Language
and	O
most	O
Lisp	B-Language
dialects	O
by	O
using	O
the	O
quasiquote	O
(	O
"	O
backquote	O
"	O
)	O
operator	O
.	O
</s>
<s>
The	O
list	O
of	O
notable	O
metaprogramming	B-Application
systems	O
is	O
maintained	O
at	O
List	B-Application
of	I-Application
Program	I-Application
Transformation	I-Application
Systems	I-Application
.	O
</s>
