Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:56:06+00:00 2026-05-26T01:56:06+00:00

I used to think that metaprogramming involved modifying the program, and (as do some

  • 0

I used to think that metaprogramming involved modifying the program, and (as do some answers to What is reflection and why is it useful? ) that reflection merely consisted of introspection of a program. However, the reflection tag wiki says

Reflection is the process by which a program can observe and
modify its own structure and behavior at runtime.

Reflection is the process by which a program can perform
introspection. This introspection usually involves the ability to
observe and modify its own structure and behavior at runtime. From
theoretical perspective reflection relates to the fact that program
instructions are stored as data. The distinction between program code
and data is a matter of how the information is treated. Hence programs
can treat their own code as data and observe or modify them.

[emphasis added]

And the description for metaprogramming is

Metaprogramming is writing programs that write or manipulate other
programs as their data.

Metaprogramming is useful because it can save programmers valuable
time. Some languages have support to metaprogram themselves and this
allows to create code with great expressive power.

(I assume that “write” doesn’t mean writing source code to a file, because that’d be code generation.)

Would this make metaprogramming merely a subset of reflection?

Or are the terms distinct because some programming languages are metaprogrammed by another language, in which case metaprogramming occurs but not reflection? (There was a single uncited sentence claiming this in the metaprogramming Wikipedia article)

Or do the terms “reflection” and “metaprogramming” get used differently depending on what programming language the person is using?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:56:07+00:00Added an answer on May 26, 2026 at 1:56 am

    No. Rather, reflection provides facilities that are a subset of what metaprogramming can do.

    Metaprogramming is “programs which write programs”. This includes programs that read the text of programs (arguably including themselves but that is rather rare), analyze that code, and make changes. Yes, it includes writing source text to files. Code generation is a special case of metaprogramming.

    Reflection as I understand it is the ability for a program to inquire about its own structure. In virtually every system I have seen in which reflection is possible (with the really exceptional case of Lisp and equivalent variants), the reflection machinery provided only a limited means of introspection. Java and C# will let you find out the names of classes and methods, but you cannot ask these systems for the content of a method, statement or local declaration. Nor can you ask most such reflective langauges to actually change their structure, that is, you can’t add new classes or fields using the reflection facilities. Most langauges (e.g., C++) have basically no built-in ability to “reflect”. While the reflection utilities built into langauges can be useful, they tend to be idiosyncratic with respect to what the language designers/compiler builders decided to keep around at runtime.

    You end up with a much more powerful “reflection” capability if you step outside the language and the set of restrictions the langauge designers built into it. A really good metaprogramming system has access to the entire program structure, and thus can answer arbitrary questions about the program structure (modulo Turing limitations).

    As an example, our DMS Software Reengineering Toolkit is a program transformation tool that has complete access to the abstract syntax tree of the program and many other facts derived by the various DMS language front ends. So DMS can “reflect” (inspect/analyze/reason) rather arbitrarily about the language which it is processing. And it can do so for C, COBOL, Java, C# and C++; for many of these langauges, it can not only provide access to the AST, but access to symbol table information and various forms of control and data flow, which no reflection facilities I’ve ever seen offer you.

    Additionally, a program transformation tool like DMS can modify the code based on the “reflection” to generate new code, optimize, restructure, instrument, … The variety of effects achievable this way is surprisingly broad.

    [Since DMS is implemented as set of DSLs, it in fact can and does reason (“reflect”) about its own code. We use DMS to synthesize large parts of itself from its DSLs, including code generation with some pretty interesting optimizations, including working parallelization.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to think that Flash was a program for designers or just for
So... I used to think that when you accessed a file but specified the
I think that it used to the be the case that in Liferay 4,
I used to think that cache is browser driven and browser dont request the
I used to think that an assembly could have only one main() method until
I used to think that everyone used relative paths (e.g. /styles/style.css ). But I
I used to think that once a module was loaded, no re-importing would be
I used to think that folders needed to have an extension so that they
This example works but I think that the memory leaks. Function used in the
At my previous job they used a product called Whole Tomato (I think that's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.