The idea of metaprogramming
When I read the previous functional programming section, I saw another idea of programming, called the metaprogramming.
I think this word is very interesting. At the beginning, I thought it was the author's mistake. It should be the "Source" programming idea. After reading it carefully, the content is as follows:
According to the definition of the free encyclopedia (http://www.wikipedia.org): write some Program To generate data or Code The program used to generate the data information or code is called metaprogram. It is called metaprogramming ).
Metaprogramming is widely used in computer programming. If you have a large application with many functions including the same code, you can create a small program (such as a macro definition in C ), use it to generate these code with common functions, and spend more time to implement the important part.
Metaprogramming has many practical methods, but its core idea remains unchanged: To construct new programs with programs. It seems very advanced to construct a new program. Otherwise, the construction of a new program here only indicates that the program has new functions through a certain logical relationship.
In JavaScript, for a function, the JavaScript engine can execute it as a method and construct it as an object type. However, they are different. They have different roles in addition to their forms. The main difference is: as a function, it can be executed directly and fully utilize the context of the Function Code body, such as being convenient by applying or calling methods; being used as a constructor is greatly restricted and lacks the flexibility of functions.
In JavaScript, metaprogramming is implemented. The so-called metaprogram is function, and the data or code used for running is a series of extensions derived from function or function.
After reading this section, I found that the so-called metaprogramming is similar to functional programming. I can simply understand that metaprogramming is an extension of functional programming.