GitHub Copilot will explain and translate code, now supports Visual Studio and .NET

containerd graduates

GitHub has introduced improvements to its Copilot AI coding service, though it remains in invite-only technical preview. Copilot Labs, currently only available as Visual Studio Code extension separate from (but dependent on) the main Copilot extension, adds two new features.

The first is called “explain this code” and aims to provide a plain language description of what a chunk of code does, with potential for speeding the process of understanding an unfamiliar codebase. This is a common problem faced by newcomers to a project, or by developers who need to get up to speed quickly with legacy code that requires maintenance.

The second feature, “translate this code”, is for porting code to a different programming language. A dropdown in the extension panel offers an impressive list of around 60 languages,  from ABAP (Advanced Business Application Programming, a SAP language) to yaml, and including most languages in common use, though Pascal is curiously absent. Copilot is happy to have a go at porting C code to Rust, for example. Porting code is another frequent requirement, as developers convert projects to run in different environments or to take advantage of modern programming techniques.

Translating open source code from C++ to JavaScript with Copilot

Last week the company also announced the availability of Copilot for Visual Studio 2022. Copilot was already available for VS Code, Neovim, and JetBrains IntelliJ-based IDEs. Visual Studio is the second most popular IDE after VS Code according to the most recent Stack Overflow survey. The new Visual Studio extension also explicitly supports .NET languages including C#. When Copilot was launched in June 2021, Github said that “Copilot works with a broad set of frameworks and languages, but this technical preview works especially well for Python, JavaScript, TypeScript, Ruby and Go.”

Early reaction to Copilot Labs is positive. “From my quick tests it works really well,” said  one developer, and another added that “the language translation tool is awesome.” That said, developers must be realistic about what AI can do and also understand the risks of generated code that may have subtle bugs. Presented with a Bubble Sort routine in C, Explain – a function of Copilot that aims to describe what code does in plain language – delivered a line by line description such as “the sixth line of code is to declare the variable n as an integer and assign it to 0,” and when asked “Code does following” stated in a few lines that it reads numbers into an array and sorts using bubble sort. A good start, though we found it less useful with business-specific code.

GitHub has yet to announce when Copilot will come out of preview and on what terms. The company has said that “If the technical preview is successful, our plan is to build a commercial version of GitHub Copilot in the future.”