Lisp is recognized to be one of the best programming language on meta programming. I think that mainly comes from its feature of program as data, that is, lisp program itself is most commonly used lisp data structure, such as list, symbol, etc. Based on that, lisp has a very powerful macro system, which is kind of static, and finally, the program can be generated and compiled or interpreted easily at run time, that is even more dynamic.
Is this kind of meta programming possible in other language? C programming language has macro too. The standard C macro is too limited in feature, but we can implement a much more powerful macro system for C too. And we can generate C program text and invoke the C compiler at run time too. That way, C can achieve similar meta programming capability.
Even it is possible to do meta programming in other languages, it may be more convenient to do that in lisp. Because lisp program is structural data, such as list, symbol, etc, while C program text is just un-structural string. It is much easier to program the data structure instead of the string except some relative simple operations. But if a standardized abstract syntax tree is defined for C, and a compiler backend is made available at run time to compile the abstract syntax tree, we can work with abstract syntax tree when do meta programming in C too.
But I still guess lisp could be better than other languages on meta programming, although I haven’t very rich experience on meta programming. The possible reasons could be:
- The syntax of lisp is easier to program than abstract syntax tree of other programming languages (such as C). Because it is common to parse and generate program in lisp.
- There is no standardized syntax tree defined for many other languages, even if it is possible. Maybe the abstract syntax tree is too complex for people to program in.
- Even if an abstract syntax tree is defined for some language, people may feel like they are programming two different languages, one is the language itself, the other is its abstract syntax tree.