Will Github Copilot help me write code?

I am a developer working mainly with Go and PHP on a daily basis. This past weekend I got invited to the Github Copilot Technical Preview and decided to spend my entire weekend testing it out. I know there is some controversy regarding Copilot and I want to disregard that and focus on the practicality of using Copilot as a tool while typing code.

I was working on an addon for a game I play in my spare time called Elder Scrolls Online. The addon is called Trade Guild Ledger and is available on Github and is written in Lua. In addition to the Lua addon it has a client and server written in Go which extracts item pricing data from the game and uploads it to the server.

Overall Impressions

Github Copilot is a nice addition to my toolset as a developer, it’s like autocomplete when writing emails in Gmail. This is how Gmail auto-completes your sentences:

Gmail auto-complete finishes sentences for you.

Copilot gets rid of the boring, repetitive tasks that I am doing over and over again as a developer. Here is an example of how Copilot auto-completes your code:

Github Copilot finishes code snippets for you as you are programming.

In the same way that Gmail can make typing emails faster, Copilot makes me able to write code faster. Copilot runs as a Visual Studio Code extension and code hints typically show in less than a second. If I am typing code fast I don’t see suggestions but it is when I pause to think that a suggestion typically pops up.

Most of the suggestions I have seen while working normally have been suggestions which are based off of other code in the same file. During regular use I did not see any obvious code which was a verbatim copy from other repositories or anything that resembled sensitive data. There was only one suggestion I noticed which was completely new to my own codebase, shown below.

Github Copilot gives a good suggestion for a function named regionFromIndex. Only typing the name and first parameter Copilot is able to finish the rest of the functions logic automatically.

In this example Copilot gets the names of my structs right and also knows what I want to return. A pretty simple example but it saved me time as I didn’t have to write this simple function.

Bad suggestions

Copilot doesn’t always get the right suggestions as I expected. Just like auto-complete for typing gets the wrong sentences. When this happens I simply ignore the suggestion and keep typing. I think the most annoying suggestions are those for really large code snippets like this example:

Github Copilot gives a bad suggestion which is a verbatim copy of a code snippet in the same file.

The code suggestion above gets cut off after 30 lines or so but it is a copy of another function in the same file. The only difference between the two is that Copilot has replaced all occurrences of “Items” with “Listings” instead.

As a developer you would need a bit of experience to determine of the code being suggested is right or not. The code suggested is also not the best code most of the time. Copilot saves me time where I might otherwise use a search engine to find an answer.

Would I use Github Copilot all the time?

Yes.

Am I going to use Copilot all the time? No.

For personal projects I will keep using it as much as I can, it definitely helps more than it hurts. For work I will wait a bit and see how things play out as I know that not all of my colleagues are huge fans of Copilot. I hope that Copilot starts discussions that lead to better tools for everyone in the end.

Github Copilot will probably not improve my code or magically replace what I do. However, it can speed up my work by automating repetitive functions which I keep writing over and over again in slightly different variations.

Author: Markus Tenghamn

I have been building websites and apps since I was 13. At 18 I was running my own web hosting company. Today I work on a bunch of different projects and hope that I can create something useful for others. See my projects on Github. I love writing, it is one of my favourite hobbies which lets me share things I find interesting with others. Don't forget to follow me on Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.