The article show us an hypothetical situation, were metaprogramming is the solution, so if we want to write an extense source code, without doing manually or using loops, the only thing we can do is write a program that creates it, so the example they show us, is print a sentence too many times. And that is an easier way, also we can do it with images. Another thing, we can do is generating source code and execute it on the spot, only calling eval, which is a function some languages have, allowing to translate and execute an piece of source code contained. This feature is mostly available on interpreted languages as Lisp, Perl, Ruby, Python and Javascript. But eval, can have it's disadvantages, like can be insecure, that's why it exist an other alternatives as quines, quines are defined as a program that generates a copy of its own source text as it's complete output. Another advantage of metaprogramming is the possibility of modifying programs during Runtime.
So, after reading this article I think or I agree that metaprogramming is not only for programming languages gurus, the important here is knowing the tools of each programming language as eval. And metaprogramming have the advantage that for larger programs, we can write a program to do the tedious work, but I think the hardest part is knowing how to write a program that write programs, so it's important knowing the techniques.
For more information visit An Introduction to Metaprogramming by Ariel Ortiz.

No hay comentarios:
Publicar un comentario