Article

Copilot: how to auto-complete code in real time

An AI-based development support tool for real-time code completion suggestions.

How is Copilot used?

Copilot is a code development support tool, distributed as an extension, which integrates directly with the main code editors (Visual Studio, Neovim, VS Code and JetBrains suite tools). It is a tool aimed primarly at pro-coders as an integration to developers’ work.

The most straightforward use of Copilot relates to the auto-completion of code: as the developer writes in a text editor, Copilot suggests the next line of code, which can be confirmed using the Tab key. Copilot can also be used to generate entire code files: starting from a comment or a method header, Copilot is able to deduce and complete the entire implementation of the function.

Reply’s experience

At Reply, we believe that Copilot represents effective support for developers and subsequently started using it during our daily development work, exploring its use cases and possibilities of use. For example, we tested the use of Copilot to automate the writing of repetitive code models, allowing developers to focus only on the code that provides value to a solution. This approach makes it possible to generate data access classes starting from the structure of a database, expose these classes via API Rest services, or automatically generate unit tests for your code.

Thanks to the experience gained in the use of Copilot, we can provide support to customers in the installation and configuration phases of the tool and help them understand how to adopt it effectively for their specific use cases. A trial is currently under way with a customer operating in the manufacturing sector that employs many development teams on various projects. We have provided access to Copilot to members of the various teams, alongside an introduction to its use. We are also evaluating the impacts that the use of Codex has during normal development activities in an area where the quality of the code and the efficiency of the development work are strictly monitored.

Full control over the generated code

Copilot does not simply provide suggestions based on predefined rules but takes into account the context within which the code is inserted, and interprets what the developer intends to achieve. In this way, the generated code respects the style and conventions of the development team and integrates seamlessly into the project in which it is used. 

The developer remains in total control over the generated code: it is always possible to review the suggestions provided and have several recommendations to choose from before choosing the most suitable. 

Although Copilot is a cloud-based tool, and provided as software as a service, the code it generates is always and in any case the property of the developer: Copilot's user licence places no restrictions on the dissemination or manner of use and distribution of the generated code.

Codex: the Copilot engine

Copilot’s operating engine is based on Codex. Created by OpenAI (an artificial intelligence research company), Codex is a code generation model based on GPT-3, one of the largest deep learning-based language models. While GPT-3 is a general-purpose language model, Codex has been explicitly trained and tuned to work on code. 

Recently, all major players in the AI industry have released or announced code generation models. This is why we believe that it is essential to have the necessary tools available to evaluate the effectiveness of a specific model. By analysing the current methodologies, we have developed a framework that facilitates a formal evaluation of the accuracy of these models applied to different programming languages and use cases.

Based on this analysis, we have determined that Codex provides excellent results, even with respect to larger models. The analysis indicates a good level of optimisation in terms of the most common used programming languages. We have also developed an approach that makes it possible to combine the generation of code with validation criteria that verify the correctness of the generated code, ensuring the quality of the results obtained.

You may be also interested in