Are AI tools like Copilot worth it?

The rapid development of Large Language Models (LLMs) changed the way how we work. Tech companies have released their own models for the public to use, or provide them as a service through APIs and software products.

One field that embraced this technological wave is (unsurprisingly) software development. As LLMs are now able to read entire codebases, compose code with just a prompt, and consolidate information from the internet, this opens up a new opportunity for software developers.

Two of the most popular AI coding tools are Github Copilot and Tabnine. This article refers mainly to Copilot as I have been using this tool for several months now.

Installation

Copilot is best used as an extension in your code editor/IDE. As of this writing, it is available for:

  • Visual Studio Code/Visual Studio
  • Vim/Neovim
  • JetBrains IDEs
  • Azure Data Studio

If you are using Visual Studio Code, you can refer to the following documentation on how to add Copilot as an extension.

Copilot Features

AI pair programmer tools have these main capabilities that aid you during coding:

Code autocomplete

While you are typing, Copilot suggests the remainder of the code. You can then opt to accept it (by pressing a key, usually Tab), or decline the suggestion. Often, you only need to type the function or method name and the tool can already generate the code that is needed.

Auto-completing the deactivate! method for a User

AI tools become more helpful the more you use them. Copilot gets better as you work as more context of the codebase becomes available. At the beginning, the generated code is more miss than hit. But as you continue to work on the code, suggestions become better and more accurate.

Answer coding questions

Developers don’t have to know all the syntax, arguments, and interfaces of all the languages and libraries they use. Before using Copilot, I often do a web search if I forgot how to use a library, the arguments of a method, or available APIs of a third-party service. Today, Copilot Chat replaced my web searches related to programming.

Copilot has a built-in chat within the IDE where you can ask programming questions. To further enhance my query results, I also use a separate service like Phind. As these LLMs are trained with data from the internet, they can collect and summarize the information you need for any programming question.

Copilot provides the summary as well as sample code on the answer

In order to prevent abuse, though, Copilot has a built-in guard that prevents you from asking questions not related to programming. If you need a more general-purpose AI chat bot, you can use GPT-4 instead.

Assistance for other languages

Suppose you get assigned a new project requiring a language or framework you haven’t encountered before. In the past, it takes a significant amount of time to learn new languages and frameworks. Today, starting these projects are much easier as these tools can generate the initial files needed to run the first version of the application.

Copilot understands many programming languages (through its training). Currently, JavaScript has the best language support since it is the most common language used in the training data (from public repositories).

For example, with no prior experience in the framework, Copilot helped me make the changes necessary to extend a JavaScript application using the Remix framework.

A nice way to learn how code is structured in a framework

Instant unit tests

Perhaps my most-used feature of Copilot is generating tests in RSpec. While building your application code, the tool keeps track of the methods, arguments, and conditions used in your classes. When writing tests, it then uses that information to auto-generate the test and also suggest additional test cases.

Copilot can also suggest other test cases you may have missed

I found that it becomes more accurate the more test cases I implement (or accept from a suggestion). This is especially useful for tests that only change a few variables or a few conditions. Instead of the usual copy-paste-modify routine for these tests, you just need to place your cursor at the next lines and tab your way to completing your specs!

Documentation

As with the most-used feature of LLMs (generating text answers), Copilot can be used to generate code comments and short explanations on how a method or a snippet of code works. I find it valuable when I want to add comments to methods, regular expressions or when editing a crontab.

Suggesting a simple comment on a method

Brainstorming

Another powerful feature of AI code tools is the ability to throw around ideas and checking the responses that are returned. As AI responses become better the more information (context) it has, asking follow up questions can also lead to solving problems you encounter during development. A large number of programming problems have already been solved before, and having this tool at your disposal will allow you access to learn and use these solutions.

Caveats

With all of the features and benefits listed above, there are also some things to keep in mind when using AI tools for software development.

Incorrect output

LLMs are not magic, and we should not assume that it is correct all the time. Hallucinations happen with Artificial Intelligence, and code tools are not an exception. Some example of incorrect output of these tools that I also personally experienced are:

  • Bad syntax
  • Incorrect logic
  • Wrong class or method used
  • Incorrect links or API endpoints used

This means that you still need to review the output of AI tools to verify that everything is correct. To guide my thinking, I think of these tools as an army of junior to mid-level developers working for me. These “developers” though can provide responses to my queries much faster than an actual human.

Since they are just “junior developers”, it still falls to you as the “senior” one to review the output they made and make sure it is correct and can integrate well with the overall code architecture.

Quality In, Quality Out

By using simple prompts and questions, AI tools can already return a significant amount of answers. However, the quality of these answers ultimately depend on how the question is phrased. For example, if the method name is vague, then the suggested code by Copilot will likely be incorrect. If the coding question lacks details, then the answers will be inaccurate as well.

In a previous analogy we likened these tools to having an army of “junior developers” at your disposal. It is up to you to drive the performance of the team by constant follow up and asking the right questions. You will also need to providing information for any deficiencies the team may have.

Perhaps this is also the main reason why I don’t believe AI will replace entire software development teams (at least for now). As requirements for the software application become more complex, you will still need people that are able to architect data flows, design the integration between systems, foresee potential issues, and maintain security and performance.

Is Copilot worth it?

Despite its flaws, I believe the benefits far outweigh any issues you may have when using AI tools for development.

The time savings become more apparent as you code and Copilot gains more context. The output is unmatched when the code follows a specific pattern. A good example of this is when I create test cases, as discussed previously. Copilot is smart enough to get the overall gist of the class you are testing and can suggest test cases to cover each scenario. This makes writing tests blazingly fast.

You may think that this just shaves off a few seconds of manual coding. That is true, but your work isn’t just composed of one test or one class. A few seconds saved here, a few minutes saved there, and these seemingly small gains become more significant within the scope of a large project.

Remember that software development is more of designing and thinking rather than coding itself. The extra time you saved can then give you more time to think of better solutions, debug issues more deeply, and do the tasks that matter beyond coding.

Leave a Reply

Your email address will not be published. Required fields are marked *