What is GitHub Copilot?
GitHub Copilot might be one of the most intersting AI use case from Microsoft GitHub in 2021. In this post, we look into an overview of what is GitHub Copilot and how it works with some examples.
If you visit the GitHub Copilot official website, you will see the brief summary of Copilot as "Your AI pair programmer", and with GitHub Copilot, get suggestions for whole lines or entire functions right inside your editor.
How it works?
So based on the above description, we get an idea about what is Copilot - your pair programmer which can provide quick suggestions for completing your code (e.g., entire functions) in your editor so that you can complete your code without actually typing the content of a function for example.
To test with some examples, I applied GitHub Copilot Technical Preview and got approved, and used the following environments for the testing:
- Following the guide of Getting Started with GitHub Copilot in JetBrains
- IDE: PyCharm 2021.2.3 (Community Edition)
- Coding language for testing: Python
First example: Binary Search
The following video shows how we can complete binary_search function with the help of Copilot where its suggested code will be shown in gray color, and if you like the suggestion, you can use [Tab] key to accept the suggested code for your usage instead of coding from scratch - which is super awesome!
First, when I try def binary_search(, the Copilot will suggest two input parameters (i.e., arr and target) for my function based on the function name that I typed.
Secondly, when I move to the body of the function to write, as we can see from the video, Copilot will automatically suggest the entire binary search example code for us to use if we satisfied with the suggested code - which is working without any problem like a charm!
Second example: Bubble, Selection and Insertion Sort
How does GitHub Copilot work?
Does GitHub Copilot write perfect code?
No. GitHub Copilot tries to understand your intent and to generate the best code it can, but the code it suggests may not always work, or even make sense. While we are working hard to make GitHub Copilot better, code suggested by GitHub Copilot should be carefully tested, reviewed, and vetted, like any other code. As the developer, you are always in charge.