What exactly is metaprogramming?

后端 未结 7 2308
醉话见心
醉话见心 2020-12-12 09:00

I was reading an article on TheServerSide on ployglot programming on the Java platform. Some comments in the article refer to metaprogramming as the ability to generate code

7条回答
  •  眼角桃花
    2020-12-12 09:45

    This is just my personal opinion, which is probably the most liberal definition of metaprogramming.

    I think it includes:

    1. Compile code generation or Runtime code generation (or both)
    2. Aspect-Oriented Thinking or Aspect Oriented Programming
    3. DRY Thinking

    I think you can get there by using any of these and in combination:

    1. Reflection
    2. DSLs (Domain Specific Languages)
    3. Attributes (.NET) or Annotations (Java)
    4. Generics (.NET/Java)
    5. Templates (C++)
    6. method_missing (Ruby)
    7. closures / first class functions / delegates
    8. AOP - Aspect Oriented Programming

提交回复
热议问题