GitHub Copilot: pros and cons

GitHub Copilot is an AI-based solution designed to simplify and speed up writing code. In this article we will look at the advantages and disadvantages inherent in using this solution.

Pros: speed on routine tasks

Copilot suggests code to insert based on context. In particular, it is enough to write variable, method, and function names descriptively so that those names are used by the AI as an implicit prompt.

For example, if in JavaScript we write getAPISearchResults() as the name of a function, Copilot might suggest the basic skeleton of a RESTful HTTP request using the Fetch API. Obviously, the suggested URL and parameters won’t be the desired ones, because the AI will provide a generic example that we will then have to customize.

However, the speed increase is considerable if you consider that without Copilot we would have had to write the entire skeleton of the HTTP request with fetch() from scratch. In addition to explicit prompts, which can also be written inside a comment block or in the chat, these implicit prompts prove extremely effective when writing code in our projects.

Moreover, the fact that Copilot is seamlessly integrated into a popular editor like Visual Studio Code makes this solution incredibly easy to use.

Obviously, the suggestions proposed by Copilot must be tested very thoroughly before being included in production code. In addition to compile-time and runtime tests, you should carefully verify whether the proposed code is up to date and not violating a best practice of the language or framework you are using (in the areas of security, performance, etc.).

Cons: dependency and laziness

Copilot can be addictive and can make us incredibly lazy. If, after writing the name of a method or a function, you stare at the screen waiting for Copilot to write the code for you, you have effectively become dependent on Copilot and have also grown lazy about turning the ideas in your head into concrete code.

The mental areas affected are:

  1. Memory: you have progressively forgotten the basic syntax of many features of the languages you use. In the case of the Fetch API mentioned earlier, you probably no longer remember that when making a JSON POST request you must specify the HTTP header Content-Type with the appropriate MIME type. Copilot used to do it for you.
  2. Reasoning: you tend to accept all those suggestions that apparently perform the desired task, without thinking about the implications they may have within the entire project, especially in the long term.

To address these problems, the solution is as follows:

  1. Disable Copilot in your editor or IDE so you won’t be bothered by suggestions.
  2. Re-engage your memory by consulting the online documentation and implementing the basic structure of the code from scratch.
  3. Reignite critical reasoning by carefully evaluating the impact of the code you have written on the entire project from the point of view of efficiency and code maintainability.
  4. Re-enable Copilot by disabling or adjusting automatic suggestions.

Conclusion

Copilot is an excellent AI-based solution, but you need to be aware of its limits to use it effectively.

Back to top