As developers, we constantly seek new and interesting tools to make our work more efficient and enjoyable. And with the rising popularity of AI in recent years, the options have only grown. That's why I recently tried one of the most talked-about AI coding assistants - Github Copilot. I want to share my experience and give you a perspective on how Github Copilot works and how it could impact your workflow.

What is it, and how to use it?

GitHub Copilot is an AI tool that presents itself as a code assistant, helping you program faster and more efficiently. It is available as an extension for various IDEs, including VS code, which I use in my daily work. Based on the analysis of your previously written code, names of your functions, and comments, Copilot creates a recommendation of code snippets and completes lines of code in real-time, right from your editor.

image1.png

One great function is the completion panel, which can provide multiple recommendations for a given code at once. This feature can be particularly helpful when trying to explore different options and find the best solution for a specific problem.

image2.png

Cool, right? All we need to do is accept or reject Copilot’s suggestion, and that’s it.

GitHub Copilot: How does it work?

At first sight, it may seem like magic, but in reality, behind the GitHub Copilot is one of the transformer models OpenAI Codex, which was trained on a large amount of code from public GitHub repositories.

Transformers are a deep learning model that can process sequential input data, such as text, speech, or code, and predict the following sequence elements. And that's exactly how the model that powers Github Copilot works – it takes the prompt or partial code that the user provides and generates a set of possible code suggestions based on it. You have probably heard about ChatGPT and, generally, about GPT (Generalized Pre-trained transformers) models created by OpenAI – the Codex is one of them.

First impressions

When I started using the Copilot, my biggest first impression was that it was emotionally pleasant to work with. In the first few days, I felt like someone was always sitting next to me, throwing thoughts and solutions at me. Those solutions may not always be perfect, but they are still helpful.

As I continued using Github Copilot, I noticed that some of the suggested solutions could have been better. In fact, at times, they even prevented me from thinking through the problem and coming up with my own, maybe better, solution. There were moments when I spent more time editing the code generated by Copilot than I would have spent had I just written the code from scratch. Our brains can be lazy sometimes, and it can be hard to come up with something better after seeing one solution. And that's why it's so important to remember that GitHub Copilot is just a tool, and often the best solutions can come from our creativity and problem-solving skills. 💡

Examples where it was useful

Let's explore a few examples of how GitHub Copilot has helped me delegate my work. In my job and university, I usually use two languages: TypeScript and Python. It's worth noting that these languages are widely used on Github, meaning that Copilot was trained on a large amount of code written in these languages. However, for less commonly used languages, Copilot's performance may vary.

  1. One way or another, Copilot covers a portion of programming when you are not quite sure how to best implement a small piece of code and end up googling it. If you're googling, you're spending time opening different websites, reviewing solutions, and choosing the one that fits your needs. With Copilot, however, you don't need to open anything, and the solutions appear right before of you. This saves time and allows you to stay focused on the task at hand.

  2. Copilot is excellent at copying simple patterns. It can easily identify the pattern and generate corresponding code by giving it a small hint. This can be a huge time saver when you need to implement something quickly and don't want to spend time writing out the same code repeatedly.

  3. Copilot may also help refactor/rewrite the code you have in a different way. Sometimes we get stuck in our thinking and need help finding a new approach to a problem. That's where Copilot can come in and suggest alternative solutions that we may have yet to think of on our own. By examining the suggestions, we can gain new insights into the problem and discover more efficient ways of solving it.

  4. Copilot is also skilled at writing simple tests. All it takes is a descriptive comment specifying the test's purpose - the more detailed, the better.

image4.png

  1. Although not necessarily a practical use case, at times, Copilot may even ridicule your coding skills and suggest that you improve or refactor your solution. This may not always be appreciated, but it can add a fun element to your coding experience. 😀

image3.png

Security

As stated on the official source, GitHub Copilot's training was done on public repositories available on GitHub. Therefore, the first thing to keep in mind when it comes to security is that the suggested code is only as secure as the code Copilot was trained on. Blindly trusting the generated code is not recommended, and it's important to remember that Copilot is only a tool, not a substitute for human thinking and expertise.

GitHub Copilot: Summary

Overall, GitHub Copilot is a great tool. Still, like any other tool, it requires some knowledge and experience to use it effectively and reap its benefits. After using it for a few months, I've become so reliant on it that I can hardly imagine my workdays without it. In the meantime, the development does not stand, and on March 14, 2023, OpenAI released its highly-anticipated GPT-4 model. In addition, on March 22, 2023, GitHub introduced its vision for the next version – GitHub Copilot X – which promises to be even more powerful than the current version. We'll see what new updates they will bring us!

Karina Balagazova
Karina Balagazova
Backend DeveloperKarina develops backend applications and studies Data Science at FEL CTU. She is inspired by learning new things, has a passion for figure skating, plays the piano and loves nature.

Are you interested in working together? Let’s discuss it in person!

Get in touch >