Github Copilot is no match for these guys

What Github Copilot is bad at

Filip Razek
4 min readFeb 26, 2023

--

Released in July of 2022, Github Copilot is a new feature that allows developers to use AI to write code for them. It’s a great tool, but it’s far from perfect. Here are a few things it’s bad at.

1. It distracts you a lot (from learning and thinking)

If Copilot is good at one thing, it is giving you suggestions about your code. However, it tends to give suggestions whenever it thinks it is a good idea. As a programmer, how much you think about your code before writing it is often more important than how fast you can write it.

Copilot is really good at automating the manual part of coding (adding tests manually, generating documentation), but it will also offer you snippets all the time, especially when you need to think about what you want to write.

When you know exactly what you want to write, this is an amazing edge: just add a clear comment, name your variables correctly and it will give you exactly what you were thinking of. But when you don’t know how you want to write something, it will still offer you an implementation of what it thinks it might be — which takes time to evaluate and reject, distracting you and fragmenting your attention.

To sum up, if Copilot makes implementation a breeze, it is way too intrusive to be helpful when you have to think about the overlaying architecture.

2. It does make mistakes

The first time I used Copilot, (in addition to being impressed by its abilities), I only used it to complete my code when it matched what I was thinking of. As I got better at writing my code to move its prompts in the right direction, I started relying on its suggestions to write code blocks, sometimes entire functions. While this is great in terms of productivity, it makes you less aware of any mistakes it might have done.

Let’s take an example you might come across: the haversine formula is a formula to compute the distance between two points on a sphere. A quick Google search will give you the entire formula, and multiple Stack Overflow threads give direct implementations.

Copilot-generated haversine distance function — why all the Greek letters?

If you remember the name of the formula, and use Copilot to generate it, it will often give you one of these implementations, often with var keywords mixed in, or the degToRad or toRad function appearing from nowhere (in the threads, it appears below — but Copilot won’t necessarily complete it). This might lead to incorrect code, since you can’t see the source of the snippet — unlike when copying from SO, where you can read the warnings in the comments or see the 20 downvotes ;)

Copilot-generated haversine distance function — vars and missing helper function

I’ve found it to make mistakes mostly on harder problems, where you could have made the same without thinking — probably because code it was trained on contained them, or because it doesn’t understand the context of your code sufficiently well.

On those problems, if you’re familiar with Daniel Kahneman’s Fast and Slow Thinking, it seems like Copilot is between the two systems, a kind of System 1.5.

The issue is, when thinking about a nonintuitive piece of code, you know you have to switch to System 2 and think more carefully. However, when using Copilot, when System 1 sees a suggestion that approximately corresponds to what it had in mind, it immediately takes it, without really thinking it through. On harder problems, this may be a costly mistake. Of course, as AI gets better, this will become less likely — but the bugs it will leave in production code (especially if you’ve used it to write its own tests) will hurt that much more.

3. It doesn’t give you confidence in your code

Finally, when Copilot assists you on larger projects, you might find yourself being less confident in what you wrote. As we’ve seen before, Copilot gives you speed, but it also leaves you with more error-prone code.

I would argue this to be the biggest drawback of what Copilot offers — as developers, we want to be confident in our code. This is one of the main goals of documenting, commenting and testing our code — we want to know that our code won’t cause bugs in production and will be as easy as possible to maintain over time.

Every time Copilot misunderstands the context and gives you buggy code, your confidence in what you write will diminish — since, after all, you’re still the only author of your code ;)

Conclusion

In the end, I find Copilot to be a wonderful tool to have in your development toolbox. Whether you want to write tests, clearer documentation or understand a function, Copilot has got you covered. But when you need to think about your code before writing it (which is what you should be doing most of the time), I’ve found it to be too much of a distraction.

Thanks!

Still reading? You must be pretty good at paying attention!

I would love to hear your feedback on my other projects, so feel free to look at my GitHub ;)

Thanks for reading and happy coding!

--

--

Filip Razek

A CentraleSupélec student living in the Czech Republic. Check out my other projects at https://github.com/FilipRazek/