1. Blog
  2. Innovation
  3. How to Prepare for the Metaprogramming Revolution
Innovation

How to Prepare for the Metaprogramming Revolution

With software capable of writing itself, are we on the verge of a new paradigm in software development? What are the implications?

Rocío Belfiore

By Rocío Belfiore

As Chief Research and Development Officer, Rocio Belfiore heads internal software development and boosts BairesDev's growth with her specialized teams.

6 min read

Featured image

In James Cameron’s flagship film The Terminator, an AI known as Skynet becomes sentient and launches an all-out war against humanity. In one of the many iterations of the franchise, this moment, known as J-Day, happens on June 18, 2021. While full sentience and general intelligence are still a pipe-dream of computer science, what the movie got right was just how much our life would come to rely on interconnectivity and smart systems.

But what is sentience? That’s a difficult question, one that philosophy has tackled for hundreds of years. One which not even science has been able to adequately answer. At the very least, most people would agree that any form of humanlike sentience would involve the possibility of thinking about oneself and self-actualizing

For example, I can look at the way I interpret life and question my biases. I can, with effort, break and change my thought patterns and in turn change my outlook on life. Software requires a third party, an engineer or software developer who rewrites the code to make changes to the system. At least, that’s how it’s been so far, but software that can write itself isn’t as far off as one might think.

What Is Metaprogramming?

Metaprogramming is a technique in which a program treats other programs as data, allowing it to read, analyze and transform other programs or even itself. In other words, it’s a program that writes programs. As far-fetched as it may sound, there is really nothing new about the concept. 

For example, I could write a script that goes over my code and points to every line that’s missing an indent; I could even program it to fix the indent without human intervention. Metaprogramming has been around since the 1970s at least. So, why talk about it now?

As we’ve mentioned in the past, artificial intelligence has grown exponentially in the last couple of decades, in no small part thanks to the overwhelming growth in processing power and speed of modern CPUs and GPUs. Add some very interesting developments in inferential algorithms, big data, and data gathering, and we have all the ingredients for a new paradigm in metaprogramming.

Imagine that we had an open source repository of hundreds of millions of lines of code. Now picture a program that gathers all that code, reads the comments with natural language processing, and then feeds it to a machine learning algorithm that learns to predict, given previous lines of code, what the next line should be.

It’s a bit like a chatbot or a generative language algorithm, something that, based on previous data, makes an educated guess on the next step in a logical sequence. Plot twist: something like this already exists, and it’s called Github Copilot, IntelliCode, SecondMate, Tabnine, and many more.

Some of these are paid, others are open source, but all of them promise the same: an AI assistant to write safe code and help software developers solve complex issues. But, is this a good thing?

Advantages of Metaprogramming

On the plus side, imagine implementing this technology on your projects. Your developers can use AI to write simple code that requires very little creativity but a lot of time to code and test. It’s first and foremost a fantastic time-saver. 

But there is more to it:

  • You could use it to refactor spaghetti code.
  • Faster development cycles mean it’s less likely that the team will accumulate technical debt.
  • It can be used to test out alternative solutions to the same problem, kind of like comparing notes with another software engineer.

Aside from helping with code, AI assistants open a whole new venue for developers, who can use them to write code in new languages and frameworks and learn as you go. It’s another way to approach new technologies without having to spend hours going through pages upon pages of documentation. Do you need to learn how to rotate a matrix in a new language? Just comment on it and let the copilot do its thing. 

Of course, as with any tool, it can be misused. Yes, a software developer could become dependent on an AI assistant to write their code. Or they could stop doing thorough code reviews, overestimating their friendly helper, and let unintended bugs creep their way into the final product. 

It’s just common sense to determine good practices regarding AI assistants before implementing them as a solution. It might be tempting to jump headfirst into the technology, but it’s probably safer to start small. Run tests or implement it on a small project first and gather feedback, find out how the developers and project leaders felt with the tool, and make an educated choice based on the results.

While the technology will be extremely helpful for junior developers, it’s a good idea to have a senior developer providing insight and feedback. That way, they can help the newcomers build good habits.

Disadvantages of Metaprogramming

While I’m a big proponent of AI assistants, there are a few things that we have to keep in mind. First and foremost, no matter how huge your data sample is, there is always the possibility of bias. What does that mean?

Some communities can develop and share bad practices for any number of reasons. And those practices can work their way into the algorithm. Code reviews may catch the issue, but if you trust the assistant too much, you could assume that the code is perfect as is. That can lead to any number of issues, from bugs to security concerns.

Security is another point we have to keep in mind. Copilot and similar products use semantic clues from open source code that might have calls to outdated APIs and very little security. Also, anyone with the same assistant, given the right queues, will be able to figure out a company’s source code if they use the output without editing. Unlikely? Yes. Impossible? No.

Finally, there is also the matter of intellectual property, which is a whole new can of worms. Let’s just say that generative code will probably be a huge legal headache in the next few years.

So, should we jump on the bandwagon? I would say cautiously yes. As long as you train your team and set a guide of good practices to follow, AI assistants can be a great asset for faster and better software development.

Rocío Belfiore

By Rocío Belfiore

Chief Research and Development Officer Rocio Belfiore manages teams of specialists and heads all internal software development, from big data projects to business intelligence algorithms. Her department's cooperation and conviction contributes to BairesDev's continual growth.

Stay up to dateBusiness, technology, and innovation insights.Written by experts. Delivered weekly.

Related articles

Contact BairesDev
By continuing to use this site, you agree to our cookie policy and privacy policy.