Artificial intelligence still has a lot to say about programming. If we were first surprised CodeNetthe AI capable of learning to code on its own in dozens of languages, and later came AlphaCode (an AI capable of performing like an average developer) and the controversial code completion service GitHub Copilota perfect assistant that effectively allows AI to co-write software (based on the work of hundreds of thousands of open source programmers, of course).
But what else can artificial intelligence offer programmers?
“Wait, I’ll explain it to you”
Marcel Pociot is the CTO of BeyondCode, a company that develops tools and training material for web developers. A couple of days ago, he posted on his Twitter account a short video accompanied by the following text: “Ever wonder what a particular piece of code is doing? Say hello to TLDR”.
“TLDR” stands for “Too Long, Didn’t Read It”, and is generally used when a text is too long and/or cumbersome to waste time reading it in its entirety and you prefer to be given a summary. Although that is not exactly what we see in the video in question, it does not go that far: there we can instead read code from a web project in Laravel which, obviously, will be difficult to interpret for the untrained eye.
The code seems to be in the work area of some programming environment (probably PHPStorm), judging by the context menu that suddenly appears in the image, until the user selects the ‘TLDR’ option after having selected a portion of the code. text. And that’s when, after a few seconds, we see the result of this mysterious function appear…
Have you ever wondered what a particular piece of code is doing?
Say hello to TLDR pic.twitter.com/wATHh13uJyD
— Marcel Pociot 🧪 (@marcelpociot) September 21, 2022
… suddenly, we are shown a text bullet in which we are explained, step by step, what that code does and what are the possible values that the function can return.
Codex, the (artificial) mind behind TLDR and GitHub Copilot Labs
Any programmer knows that when we are faced with the need to work with foreign code (or with our own code, if we wrote it a long time ago), can be quite confusing until we finally get the hang of what does what and at what time. And not even comments (if they exist) can always be helpful out of the context in which they were written.
That’s where BeyondCode’s ‘TLDR’ comes in, a feature – you’ve probably guessed it already – powered by artificial intelligence. Specifically, as Pociot himself explains, by the OpenAI Codex model, the same one that we can find behind GitHub Copilot. And in fact, Copilot itself has also recently released a very similar function.
And it turns out that, although it has gone quite unnoticed, the GitHub Next team recently released an experimental extension for Visual Studio Code called GitHub Copilot Labs, which also allows us to display an explanation of the selected code (in English)…
…and even a ‘translation’ into another language, which can be very useful if we have to work with a language in which we are still too good, allowing us to translate it into another with which we have more experience. Thus, in the following example, we have a code in JavaScript translated to Python:
Image | Based on originals by Arild Finne Nybø (via Flickr) and generated by DALL-E 2