Contacts
Opinions

The essence of programming

, by Carlo Baldassi - professore associato di computer science, Universita' Bocconi
The future lies in prompt engineering, which is the ability to know how to ask the right requests to an AI algorithm whose task is to write code in collaboration with a more or less expert human agent

«What I mean is that if you really want to understand something the best way is to try to explain it to someone else. That forces you to sort it out in your own mind. And the more slow and dim-witted your pupil, the more you have to break things down into more and more simple ideas. And that's really the essence of programming: by the time you've sorted out a complicated idea into little steps that even a stupid machine can deal with, you've certainly learned something about it yourself. The teacher usually learns more than the pupil. Isn't that true?».

For a few years now, during the first lesson of my basic programming course, I show a slide with the above quote taken from Douglas Adams (Dirk Gently's Holistic Detective Agency, 1987). I'm not entirely sure if I'll be using it much longer: the meaning of "program" could quickly diverge from that of "writing code". Machines are no longer that stupid anymore.
The first test I did once I had access to ChatGPT was to submit one of the exercises of the final exam of the course that had just ended. I had invented the exercise and ChatGPT could not therefore know it. Compared to the real exam, I initially asked it for a simplified version, but (paradoxically) I used a much more approximate and colloquial description than the one I had written down for the students, as I would have done if my interlocutor had been an expert programmer with whom certain details could be left unsaid. The machine figured out exactly what it was supposed to do and produced fully functional code in seconds (the students have about 20 minutes at their disposal). I wanted to go to the complete version of the exercise: I therefore asked him to modify the code in order to make it more efficient (continuing to express myself as if I were dealing with a human expert). This time the answer contained an error, although it went in the right direction. Having pointed this out, ChatGPT produced flawless final code.

Naturally similar experiences, of so-called "program synthesis", have been made by many programmers in recent months, and immediately raise obvious questions about the future of programming, the labor market in this sector and, as a consequence, the whole of society.
ChatGPT is not the only or even the best program synthesis system out there. More specialized systems (but also obtained through the training of the same type of neural architecture, called Large Language Models) had already demonstrated to be at the level of an average human expert in programming competitions for specialists. The best-known case is AlphaCode, presented by DeepMind in February 2022.

At the moment these systems are however able to write only short programs, which solve specific and well-defined problems. Most specialists believe that their role will be to allow laymen to program simple systems without knowing how to write code, and experts to drastically increase their productivity in the development of complex systems that require overview (and already exist today some programming assistants, for example Copilot from Github and Code Whisperer from Amazon, able to suggest entire portions of code). In both cases, the meaning of the term "programming" would be transformed: from writing code in the first person to so-called "prompt engineering", i.e. knowing how to ask the right requests to an AI algorithm, in the context of a collaborative dialogue. Collectively, the societal consequences will be dramatic and potentially disruptive.

This forecast could even be considered cautious: as recently as 2017, in the ponderous volume Program Synthesis (by Sumit Gulwani, a Microsoft researcher, and co-authors), which presented the techniques developed in the previous decades to address what the authors defined «the holy grail of Computer Science», only a few pages were devoted to AI-based approaches. Progress has therefore been very rapid and unexpected. Obstacles that seemed critical have been overcome, and there are currently no signs that progress will slow down. We may very well be just getting started.

In any case, even if coding eventually becomes a hobbyist activity, it will still be a great way to train yourself to dissect complicated ideas into their elementary constituent steps, and in so doing understand what we are trying to do, or make an artificial assistant do.