Artificial intelligence is the buzzword of the moment. (To learn more about why, check out our primer on recent AI developments). But it can be hard to separate the hype from reality. In what ways can AI make a difference and when is it a waste of your time and money?

One promising use of artificial intelligence is code generation. In this article, we look at GitHub Copilot, an AI pair programmer. We’ll tell you what you need to know about Copilot — what it is, what it costs, and what it can and can’t do for you.

What is GitHub Copilot?

GitHub Copilot is an AI pair programmer. In other words, it’s meant to assist you on coding tasks. You can use it with a variety of editors and programming languages.

Copilot’s primary use is providing suggestions for individual lines of code or whole functions, but it can do some other things too, as we’ll see below. For some of the features we discuss, you’ll need GitHub Copilot Labs, which is a separate VS Code extension for experimental applications of Copilot. These experimental features may eventually become part of the official product.

What can GitHub Copilot do?

How can you use GitHub Copilot to make coding faster and easier? Here are some of the main ways Copilot can assist you.

Autocomplete suggestions

Getting started coding with GitHub Copilot as your pair programmer is easy. Just start typing and GitHub will give you autocomplete suggestions. You don’t have to go with the first suggestion offered – you can toggle through options or ask Copilot to generate more.

The cool thing about these suggestions is that they use the context of your existing code. For example, if your code uses repeated patterns, such as the CQRS pattern, Copilot will recognize those patterns and conventions and match them in the code it generates.

To get the most out of GitHub Copilot, make sure you’re providing adequate context. Copilot doesn’t have the ability to use your entire codebase for context. Rather, it’s reading your current file and other open tabs. If you have files you want it to reference for its suggestions, have them open.

Code based on natural language prompts

You don’t even have to write code to get suggestions from GitHub Copilot. You can use everyday natural language to tell Copilot what you want to do. For example, you could prompt Copilot to “write a RegEx string to validate a phone number.” Copilot will generate actual code that you can use to validate a phone number. Of course, this will need to be tested and validated to ensure it meets your requirements.

In addition to knowing a variety of programming languages, Copilot understands many human languages. That means that your natural language prompt doesn’t have to be in English — a helpful feature for developers who aren’t native speakers.

Explanations

Understanding existing code can be a major obstacle. Maybe you’re new to a project and need to understand what’s been done so far. Maybe you’re working with an unfamiliar codebase.

GitHub Copilot can help.

The “Explain the Code” feature is available with GitHub Copilot Lab. It lets you highlight a block of code and ask Copilot to explain it in plain language. You can even tailor the type of response you want. For example, you could ask it to “explain this code as a senior developer speaking to a brand new developer."

Language translation

Another Copilot Labs feature is translation of your code from one programming language to another.

These translations aren’t perfect and should definitely be thoroughly checked, but they can be a good starting point for adapting a chunk of code to a different language.

The downsides of GitHub Copilot

Now that you know what GitHub Copilot can do, let’s look at the pros and cons of Copilot so you can decide if it’s worth the investment. First, the disadvantages.

It makes mistakes

As with any AI tool, one of the biggest disadvantages of using Copilot is that it’s not always accurate. For example, the code generated could be insecure, or reference outdated APIs, or simply not work. This is especially true if you’re using a less common programming language.

The fact that GitHub Copilot makes errors doesn’t mean you shouldn’t use it. Just remember that even if you have a copilot, you’re still the one flying the plane. In other words, you’ll still have to review and test everything yourself.   

It’s not creative

Copilot generates new code based on patterns found in existing code. Consequently, the suggestions it gives you are not particularly innovative.

However, it will be easier for you to be innovative if GitHub Copilot is saving you time on other parts of your project.

GitHub Copilot is not free

To gain the many benefits of GitHub Copilot, you do have to pay. Copilot for Individuals currently costs $10 per month or $100 per year (after a 30-day free trial), while Copilot for Business is $19 per month per user.

Why should you use GitHub Copilot?

Sure, Copilot can write code, but so can you. What’s the point of using an AI tool that’s less innovative and more error-prone than a human?

We think there are still plenty of reasons. Let’s take a look at the advantages of GitHub Copilot.

Copilot is fast

Quickly accepting autocomplete suggestions is much quicker than writing all of the code yourself.

It can take the boring stuff off your plate

GitHub is great for boilerplate code. It takes the easy tasks off your plate so that you have more time to spend on more interesting, creative work.

It has a perfect memory

Have you ever forgotten how to write a particular function?

Of course you have, you’re human.

But GitHub Copilot isn’t, and you can use it to jog your memory. You can use natural language to ask Copilot how to do something. Or just start typing what you do remember and see what Copilot suggests next.  

It’s a learning tool

You can learn from GitHub Copilot. For example, looking at Copilot’s outputs can teach you about a new language feature, a different syntax, or a new way of thinking about a solution. Using the translate feature to translate your code to a less familiar programming language can help you learn it. Seeing how GitHub interprets your natural language prompts can teach you new ways of achieving a particular objective. And if you don’t understand something in the code, you can ask GitHub Copilot for an explanation.

AI code generation now and in the future

There are a lot of fears surrounding AI these days, but at Emergent Software, we've embraced this new technology to improve our productivity wherever possible. Our entire development team is licensed, and most engineers use it on a daily basis.

For example, Zach Green, Senior Software Architect at Emergent, uses GitHub Copilot to generate database schema in SQL Server Database Projects. He finds Copilot to be helpful for generating foreign key and index definitions when creating new tables and great for generating the column lists when defining a new view, temp table in a stored procedure, a new user-defined table type, or for just selecting all or most columns from a table. Zach also uses GitHub Copilot to generate unit converters to convert metric values to imperial and vice versa.

At Emergent Software, we're excited about the future of GitHub Copilot and artificial intelligence. We don’t think that AI is a threat to software engineering or technology jobs — rather, AI will help increase productivity and drive down costs, leading to more new software being developed than ever before.

Work with us

Contact us today to get started on your AI-assisted software development project.