Github Copilot: Review After 3 Months of Usage with Examples

How does it go on real projects, and does it really help?

ā€¢

Purchased on Shutterstock, edited by me šŸ˜Š

Three months ago, I was allowed to use Github Copilot with my private Github account, and since then, I can use this tool during my day-to-day programming. During this period, I had a chance to test it with Angular, web components based on LitElement, Node.js (TS), and VanillaJS projects. So, letā€™s see how AI for pair-programming assists us, and does it really help?

What exactly is GitHub Copilot?

GitHub Copilot is an AI tool created by GitHub and OpenAI to help programmers write code using autocompletion. Visual Studio Code, Neovim, and JetBrains users already can use the plugin.

GitHub Copilot is powered by the OpenAI Codex model, trained on natural language and billions of public source code lines, including GitHub projects.

The Copilot tool on GitHub can write the code or offer an alternative. The service supports all programming languages but works best with Python, JavaScript, TypeScript, Ruby, Java, and Go.

According to their data, 50% of developers on GitHub continued to use the service after the trial period in July 2021.

How to use it?

Copilot is currently under Technical Preview. The Technical Preview is open to a limited number of testers. To join the waitlist, visit copilot.github.com.

To use GitHub Copilot, you first need to install the Visual Studio Code extension.

  1. Visit the GitHub Copilot extension page on the Visual Studio Code Marketplace (or JetBrains marketplace) and install the extension.

  2. Open Visual Studio Code. You will be prompted to authorize the extension by signing in to GitHub.

  3. After you have authorized the extension, Github will return you to Visual Studio Code.

After installation, you need to open or create a new file for the supported language and start typing your code.

For example:

  1. Create a new JavaScript (.js) file.

  2. Start to declare any function and wait for the magic.

A function declaration with Github CopilotA function declaration with Github Copilot

Thatā€™s it. If you donā€™t like the proposed code, you can switch between options with keyboard shortcuts.

Picture from copilot.github.com documentationPicture from copilot.github.com documentation

Usability

I will start from negative points because there are not many topics, and itā€™s always more pleasant to finish on a positive note.

What can be improved

First of all, I want to highlight on the GIF above how I have to remove a redundant parenthesis after Copilot. During these three months, I used to do it all the time. Especially when you write conditions or new functions.

The second issue for me was HTML. I know itā€™s not listed as a supported language, but Copilot, by default, proposes code all the time. Maybe I was writing a super unpredictable layout, or perhaps Iā€™m not lucky enough, but I literally never received acceptable code autocompletion.

Thatā€™s it. Now I want to talk only about positive things because it makes real magic.

What was good

The most significant value of Github Copilot is saving your time reading the documentation. For example, do you remember the key codes of arrow buttons to handle clicks on them? I donā€™t know either. Luckily with Copilot, you donā€™t have to keep in mind key codes or search it in google. Instead, just type the comment what do you want.

Keyboard events handling with CopilotKeyboard events handling with Copilot

Also, you even donā€™t need to search for formulas. For example, how to convert Fahrenheit to Celsius degrees.

Convert Fahrenheit to Celsius degrees with CopilotConvert Fahrenheit to Celsius degrees with Copilot

Awesome, right?

But it works great not only with popular functions. It perfectly recognizes the context of your file and tries to write the code instead of you reusing existing variables and functions.

Let me show you how to write an API service class using GitHub Copilot.

Writing API service with Copilot.Writing API service with Copilot.

Did you see that? From the beginning, it proposed even the entire class with methods. But when I changed the constructor and added host and JWT strings, it adopted and suggested writing get and post methods using my variables.

Also, it recognized a JWT variable name and understood how to use it. It added a header to requests: ā€œAuthorizationā€: ā€œBearer ā€œ + this.jwt.

Last but not least is how it works between classes. For example, Copilot can analyze imports or existing methods and reuse them. Even if they are in other classes or objects.

Reusing service methods in another classes with CopilotReusing service methods in another classes with Copilot

How does it work compering with Tabnine?

Topics like Github Copilot VS Tabnine are popular, and there is even a comparison page on the Tabnine site.

Comparison from Tabnine siteComparison from Tabnine site

Yes, itā€™s a significant minus for Copilot that your code goes somewhere to the cloud for analyzing because it can be a huge security issue for large companies. So make sure before using, you are allowed to do it.

For this reason, I didnā€™t risk working with projects from my primary job. Tabnine works locally and keeps your privacy. Also, Tabnine works offline.

But I donā€™t see any reasons to compare the other things because you can ideally use them together. I have to remove redundant brackets from time to time, but this happens even with standard VS Code IntelliSense.

You can start to type something. First, Tabnine will suggest some methods, and then Copilot will write the rest of the code šŸ¤–.

There is one more pitfall for the companies. During interviews, companies often ask candidates for the test task. For example, to write an algorithm or implement a polyfill.

If the candidate does his task on his own laptop with installed Copilot, he can simply type his task as a comment, and Copilot will do the rest. I have already had a chance to meet such a ā€œsmartā€ candidate in an actual interview.

Like many other new technologies, Copilot brings not only lots of life improvements but also issues with policies and procedures. Anyway, I really like it and will use it for my projects.

Thanks for reading! And make sure you are allowed in your company to use the Copilot extension.

If you liked my post and, for some reason, you are still not a Medium member, you can support me and get a membership by this link. Join Medium with my referral link - Volodymyr Golosay *As a Medium member, a portion of your membership fee goes to writers you read, and you get full access to every storyā€¦*golosay.medium.com

Enjoyed this article?

Share it with your network to help others discover it

Continue Learning

Discover more articles on similar topics