avatarNicholas Obert

Summary

GitHub Copilot is an AI-powered code assistant that has both positively influenced developers' workflows by speeding up coding tasks and raised concerns due to its limitations and potential to introduce bugs.

Abstract

GitHub Copilot, powered by OpenAI Codex, has garnered significant attention in the programming community for its ability to suggest code snippets and implement popular algorithms, potentially accelerating development workflows. While it is adept at handling common APIs and frameworks, it sometimes falls short in understanding complex data structures and multi-file codebases, which can lead to errors. The tool is not a replacement for human programmers, as it requires oversight to ensure the accuracy and efficiency of its suggestions. Developers have noted improvements in prototyping speed and ease of learning new APIs but caution against over-reliance on Copilot for critical tasks.

Opinions

  • The author believes that Copilot can greatly improve productivity by providing context-aware code completions.
  • Copilot is seen as a valuable asset for writing repetitive code patterns and for creating structures like lookup tables that optimize runtime performance.
  • The author suggests that Copilot is not infallible and can introduce bugs or misunderstand the developer's intent, necessitating careful review of its suggestions.
  • Copilot is acknowledged for its ability to help developers quickly adopt new APIs and frameworks, but the author still recommends reading documentation for nuanced details.
  • The author dismisses the notion that Copilot can replace human programmers, emphasizing that it is merely an assistant and not a solution for building complex systems independently.
  • There is skepticism about Copilot's ability to create new algorithms from scratch, with the author advising its use primarily for well-known algorithms or combinations thereof.
  • The author criticizes misleading representations of Copilot as a general-purpose chatbot, clarifying that it is not designed for non-coding-related interactions or humor.
  • The conclusion reiterates that while Copilot is a powerful tool for developers, it should be used with caution and not be solely relied upon for software development tasks.

The Current State of GitHub Copilot: Is It Awesome or Rubbish?

How it affected my workflow and what it can and cannot currently do

Photo by Ashim D’Silva on Unsplash

In the last few months, GitHub Copilot has caught the attention of the programming community by bringing both amazement and scare among us. In case you have been living under a rock, Copilot is an AI assistant that helps you write code faster. Since it was first announced in June 2021, it has gained popularity very fast, despite being still in an early-access stage.

Copilot is powered by OpenAI Codex, an artificial intelligence model that is trained to understand and generate both natural language and, most importantly, source code. Despite the huge hype Copilot has raised in the programming community, many haven't had the opportunity to try it, yet. For this reason, I’d like to share the current state of Copilot and also my thoughts on how my workflow has changed because of it.

What Can Copilot Do?

As you probably already know, Copilot analyzes your source code and makes suggestions accordingly. However, this statement is very broad and doesn't actually include any detail on how it affects your workflow.

First of all, Copilot knows popular APIs and frameworks and how to use them. Because of this, you can simply describe the task through a comment, or just let Copilot infer your intentions, and let it take care of writing the proper API calls.

In my experience, this feature mostly works seamlessly. However, the code hints don’t fully reflect your purpose and it might introduce sneaky bugs in your software, either because of unwanted side effects of some operations or also because of some specific data structures it doesn’t know how to handle.

Similarly, Copilot can also suggest popular algorithm implementations in various programming languages. Say you have to sort a list of items, you can just tell Copilot what you are trying to achieve and it will write the code for you. To get even more appropriate results, you might also specify the algorithm name in a comment.

For instance, you could tell your code writing assistant to sort a list of numbers using selection sort or bubble sort.

Now, you might think Copilot should also be able to create new algorithms from scratch, according to the situation. Well, that’s not always the case.

Copilot can indeed analyze your source code to understand your intentions and, if guided through descriptive comments, it’s able to write the right algorithm, most of the time. However, it’s definitely not failproof and it can often mess up the data types and data structures, especially if they are not built-in into the language.

Because of this, I think you should not rely on Copilot to write algorithms specific to your problem unless it can be traced back to a combination of two or more popular algorithms.

What Copilot Cannot Do

Despite all its abilities, Copilot can neither replace a human programmer nor go anywhere near building a complex system by itself.

First of all, Copilot currently struggles when dealing with multiple files in a single codebase. It doesn't seem to be able to understand imports across files, often messing up names and data types. My guess is that it only analyzes the currently focused file instead of the whole codebase, which would be very inefficient, by the way.

Secondly, sometimes Copilot struggles to understand your real intentions from the context and ends up suggesting some absurd nonsense. Sometimes, though, code completions can seem right or even smart but can introduce weird, hard to debug errors instead. Because of this, you should always double-check Copilot’s suggestions for sneaky bugs or possibly unwanted side effects. After all, Copilot is just an assistant and you are the one in charge of developing software.

Finally, despite what some people may think and even though a handful of YouTubers, who I won't mention, show Copilot telling jokes, responding to weird questions, and talking about non-coding-related topics as it was a general-purpose chatbot, no, Copilot cannot tell jokes. That’s just a smart scam to make a lot of views from those who haven’t had the opportunity to try Copilot, yet.

How My Workflow Changed

Now, let’s get to the most important part of the article: how Copilot has affected my workflow and which benefits it has brought to my developer experience.

The most important aspect of using an AI code writing assistant is speed, especially for repetitive patterns or structures that cannot, or should not, be created at runtime. An example of such structure is a lookup table, whose main purpose is to reduce runtime computations in exchange for memory. If you’re not familiar with lookup tables, I strongly suggest you check out my article on the topic, since they are a powerful tool to boost your programs’ execution speed.

Another big improvement in my programming experience is how fast I can pick up new APIs and frameworks. Since Copilot usually already knows the technologies I will be working with, it can easily suggest whole lines of code or patterns specific to the particular context I’m working in and thus allowing me to focus more on writing code rather than scanning the API documentation. However, I still recommend reading the documentation for structures and calls that are not so obvious, since they might have some implementation details that Copilot is not aware of.

Last, but not least, my speed when prototyping has gone up by a great extent. You can use the algorithms suggested by Copilot or let it implement your own to speed up your coding time. You can then refactor and optimize your code after you have created the proof of concept. This way you don’t spend your precious time writing code that will probably have to be rewritten anyway.

Conclusion

To wrap it up, Copilot is a great tool for developers that allows you to greatly improve your productivity by providing smart code completions based on the context. While it’s usually good at its job and greatly speeds up your writing, it neither can build a system by itself nor its suggestions are always appropriate. Because of this, you should always double-check the code completions for eventual bugs and unwanted side effects. After all, it’s just an AI assistant and you are the one in charge of developing the software.

I hope you enjoyed this article. If you have anything to add or you have a different experience with Copilot, please share your thoughts in a comment. Thanks for reading!

If you liked this article and are interested in more content about Copilot, I suggest you check out this story below:

Programming
Github Copilot
Coding
Software Development
Software Engineering
Recommended from ReadMedium