Are metaprograms the future of programming?

Marie Lopez B
Metabob
Published in
2 min readMay 23, 2020

You may have heard the term “metaprogram” before. And even though this term has been used for a long time, the real definition of it and what is considered a metaprogram is still blurry.

A metaprogram is defined as a program whose inputs and outputs are another program or itself. A metaprogram is a program that can read, generate, analyze, or transform other programs.

However, a search for examples of metaprograms is more confusing than helpful. Some programs/tools are considered to be metaprograms when they are not (at least not according to the definition above). For example, some articles find that assemblers, compilers, etc. are metaprograms.

Some consider monkey patching being a metaprogram. In most of the dynamic programming languages, the term “monkey patch” refers to dynamic modifications of a class or module at runtime, motivated by the intent to patch existing third-party code as a workaround to a bug or feature that does not act as desired.

https://medium.com/@rafsan.nybsys/monkey-patching-in-python-4fab5e5da347

But a program with functions for changing itself is not a rare pattern to find in many applications. The difference being that the program is not applying any ‘reasoning’ when it is modifying itself, it is simply changing a component to an alternative that was defined by the programmer, not the program itself, which is also the case for “monkey patching.”

There are programs that do changes to the code such as Pylint or Pyflakes, but more in an aesthetic way. These so called linters look at your code and inform you of basic stylistic or syntax problems. Because they don’t modify the source code, they are not considered metaprograms.

Metabob is a tool that helps you while coding. It allows developers to review and visualize their Python code thanks to a visual chart that detects (potential) coding errors (see picture below).

Metabob is not a metaprogram yet. Metabob currently assists the developer when writing code (by visualizing the code base and suggesting changes for improvements). However, it is Metabob’s goal to take the source code of other programs and then change this code to eliminate problems. As a metaprogram, Metabob will then help create programs and other programming tools.

It is said that in the future, machine learning will be the standard feature of programming. This means it will become easier to build metaprograms and make the developer’s life easier. https://www.infoworld.com/article/3154313/11-predictions-for-the-future-of-programming.html?page=2

Did we forget any metaprograms? Please let us know your opinion!

--

--