In the latest in our ‘New Beings’ series, we explore AI and coding. Today, we delve into Copilot.
What is Copilot?
Copilot is an AI pair programmer developed by GitHub that helps developers write code faster and with less effort. It uses OpenAI’s Codex, a generative pre-trained language model, to provide context-aware code suggestions and completions based on comments and existing code. Copilot is available as an extension for various integrated development environments (IDEs), including Visual Studio Code, Visual Studio, Neovim, and the JetBrains suite of IDEs [1].
The whole point of GitHub Copilot is having an AI assistant suggest to you what to write. There is the upcoming Copilot X that will have integrated ChatGPT functionalities and much more, but the current version is “just” a helper.
The name Copilot is exactly about this. In “pair programming”, there are two people working on the same computer: the pilot, the developer actually having the responsibility of writing the code; and the copilot, there to suggest, advise, and check that everything is being developed correctly.
While you are typing, Copilot keeps sending your code to GitHub servers, and when it has a suggestion, it provides it to you by writing it in light grey. If you like what it is proposing, you can press TAB to approve it, or you can keep writing to ignore it, waiting for the next suggestion.
Features and resources
Copilot has the following key features:
- Code Suggestions: Copilot suggests individual lines and whole functions in real-time, drawing context from comments and code.
- Context-Awareness: The AI model analyses the code you are writing and provides relevant suggestions based on the current context.
- Multiple Language Support: Copilot supports various programming languages, including C#, C++, Python, and more [2].
It also has a GitHub Extension.
Copilot is available as an extension for Visual Studio Code, Visual Studio, Neovim, and the JetBrains suite of IDEs. Developers can install the extension from the respective marketplace or plugin repository for their preferred IDE.
Setup
To use Copilot, developers need to install the Copilot extension for their chosen IDE. The installation process may vary depending on the IDE being used. Once installed, Copilot integrates with the IDE and provides code suggestions and completions as developers write code [2].
Real-Life Action
In real-life scenarios, developers can leverage Copilot to speed up their coding process and reduce the time spent on repetitive tasks. Copilot analyses the code being written and suggests relevant completions, snippets, or even entire functions. It provides assistance throughout the development process, helping developers write code more efficiently and accurately.
Sometimes, it happens, and when Copilot suggests like the next 10 lines of code and they are all correct, it feels like magic.
Concerns about Copilot
While Copilot can be a valuable tool for developers, there are a few concerns to consider.
Copilot’s suggestions are not perfect and may require careful review and testing. It doesn’t guarantee flawless code and may generate code that doesn’t work or make sense in certain situations.
Copilot also has limited context and may not utilise helpful functions defined elsewhere in a project or even within the same file. It may also suggest old or deprecated usage of libraries and languages.
We will be looking at the legal position around Copilot in New beings: Legal issues and AI.
Alternatives to Copilot
While Copilot is a popular AI pair programmer, there are alternatives available in the market. Some notable alternatives include:
- Tabnine: An AI-powered code completion tool that provides intelligent suggestions for multiple programming languages.
- Kite: A code completion tool that uses machine learning models to offer contextually relevant code suggestions.
- Codota: A code completion tool that leverages machine learning to provide code recommendations based on millions of open-source code examples.
Key Takeaways and conclusions
- Copilot is an AI pair programmer that assists developers in writing code faster and with less effort. It provides context-aware code suggestions and completions based on comments and existing code.
- Copilot supports multiple programming languages and is available as an extension for popular IDEs.
- While Copilot can be helpful, developers should carefully review and test the suggested code. Copilot may have limitations in utilising external functions and may suggest outdated code practices.
- There are alternative AI-powered code completion tools available, such as Tabnine, Kite, and Codota.
Copilot is a valuable tool for developers, offering AI-powered code suggestions and completions. It can enhance productivity and reduce repetitive coding tasks. However, it’s essential to review and test the suggested code for quality assurance. Developers should also consider alternative code completion tools based on their specific needs and preferences.
If you’re interested in learning more about our exploration of AI for development, see our previous articles in the ‘New Beings’ series.