What exactly is metaprogramming?

后端 未结 7 2288
醉话见心
醉话见心 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:41

    Well, metaprogramming is just programming, but it's basically "writing code that writes code".

    The ability that you mention, when a program can observe and modify its own structure and behaviour is called reflection and it's a type of metaprogramming.

    Dynamically typed languages, have powerful runtime reflection features, made possible by the interpreted nature of these languages...

    Static typed languages also have powerful metaprogramming techniques, for example the C++ template metaprogramming...

提交回复
热议问题