In computer science, we learned about different programming paradigms, and one that always fascinated me was declarative programming. This type of programming differs from imperative programming (such as C, Python, Go, etc.) in that, instead of telling the computer HOW to do something step by step (like a cooking recipe), you simply specify WHAT it has to do.

Declarative Programming

In our studies, we work with two declarative languages: Lisp and Prolog. Of these, Prolog stood out for its ability to solve logic problems. A classic “Hello World” in Prolog involved solving family questions through a family tree, a simple but powerful example of how declarative programming could facilitate complex tasks with simplicity.

Arrival of true declarative programming with Generative AI

Well, with the generative AI revolution, true declarative programming has arrived. For example, here’s a button.

When learning frontend development with modern frameworks such as Vue, Angular or React, a common exercise is to create an application to manage a ToDo list. Typically, a single page application (SPA) is created where, in addition to a list, a text input with a button to add a new task is included.

We have gone a step further by creating an updated, much more powerful and flexible version of one of these applications, and best of all, 100% declarative. The important thing here is that we don’t use the AI just to generate the code, but the AI itself, based on a prompt, actively manipulates the task list.

Application implementation with AI

For its implementation, we use a workflow of n8n connected to a Telegram bot. As LLM model, we used GPT-4o mini and for storage we used Redis with persistence.

Screenshot of a list of reminders in a chat app

In this example, you can see how I ask the AI to list pending reminders for me. The power of natural language processing means that I don’t have to send a structured command or a specific keyword; the AI is able to detect the intent. Doing this with an imperative language would require adding additional, often complex logic.

Adding and deleting tasks with AI

Adding tasks or reminders is equally simple. To delete tasks, it is also not necessary to give it the exact words, since, in the black box of the model, the AI analyzes the options and looks for the most similar one. If there are two very similar tasks and the AI is in doubt, it will ask us directly which one we are referring to.

Screenshot of a WhatsApp conversation with a list of reminders.

All the magic of this lies in a simple prompt.

And here’s the magic, a system prompt, 100% declarative.

The Future of Programming

As nVidia CEO Jensen Huang rightly says, the programming language of the future is English. And at Montevive.ai we completely agree.

“Programming language should be human”

-Jense Huang, nVidia CEO

The flexibility and ease offered by this type of programming is immense, although there is always an argument against it. A frequent challenge is the energy and computational expense, seemingly excessive for a relatively simple task. However, costs are constantly optimized and, in the long run, flexibility and efficiency outperform traditional methods.

Conclusion

In short, we are moving into a new era of programming, where declarative programming meets generative AI to facilitate our interaction with technology in ways never seen before. Welcome to the era of future programming.

I hope you find this new perspective on programming and the power of generative AI interesting and useful. 馃殌馃敟

Imperative programming is dead, long live declarative programming!