miércoles, 4 de noviembre de 2015

Comments on "An introduction to Metaprogramming"

In this article we could learn about some methods and ways of auto generating code for other programs in other to do something in an automatic way without having to write huge programs.

Metaprogramming means a program that generates other programs or generates program parts. It can become very useful when we are trying to reduce a tedious or error-prone program.

Then way metaprograms work is by creating scripts that will generate other code that will eventually be executed to give the expected outcome.

There is also the possibility to generate source codes and also executes it in real time, this facility is commonly called eval, which allows the metaprogram to generate and execute a piece of code at the moment. This features is commonly available in languages like LISP, Perl, Ruby, Python and JS.

This eval function must be used carefully, it can become dangerous if it’s coming from an untrusted source, and although it can be dangerous there are some alternatives to this to avoid security concerns.

There are other types or source code generators such as Quines which is a program that generates a copy of its own source text as its complete output.

Some dynamic languages such as Ruby, allow the programmer to modify different parts of the program in an easy way during its executions. Some frameworks, such as Ruby on Rails allow the programmer to make automatic common programming tasks.


Metaprogramming may seem a complicated technique, but it is actually not complicated as it might look. It allows the programmer to automate some error vulnerable or repeated programming tasks. It can be used to pre-generate stuff like data structures and data tables, or test some of our programming abilities and save huge amounts of time by eliminating the need to right repeated code and improve our programming strengths.

No hay comentarios:

Publicar un comentario