4 ms·
The problem with "introducing" metaprogramming is that you first have to have a solid understanding of the language itself in order to manipulate it. From your
by arthurbrown 15y ago
The problem with "introducing" metaprogramming is that you first have to have a solid understanding of the language itself in order to manipulate it. From your examples in the article, I think that anyone who genuinely has no programming experience outside Java is going to have very serious problems understanding even the example you've given. Putting myself in those shoes, I have no idea what defun, let, do, when, setf, nth, length, and funcall are. I can assume they must be function names because they seem familar, but that still doesnt tell me how they should be called, how to give them arguments, what to expect they will return, or even how to know where they're defined.
There's no way to teach someone how to programatically manipulate code if they can't mentally parse the code in the first place. Even if you were to completely teach Lisp as a language before introducing metaprogramming you still run into the experience issue. It takes personal experience to understand where and when to use macros. Like you said yourself in the article, most things can be expressed as a normal function. It takes the experience of writing a lot of code to be able to make the judgement of what actually belongs as a macro, and not just a function.
I understand that metaprogramming is very exciting because it opens up so many doors, but it's easy to forget about everything that you had to already know to get to the point where it becomes useful. Lisp makes it very easy to repeat this problem because the language itself is so small and consistent. It doesn't take long to get to the point where you feel comfortable enough to try writing macros.
It seems that you want to share how great metaprogramming can be and how much it simplifies the work you're doing. That's great, you and I can look at it and appreciate it. But framing it as though it's appropriate for Java programmers as an introduction to Lisp just serves to make Lisp programmers look arrogant, and builds even more resent amongst Java programmers.