Why Does Every Developer Need GitHub Copilot in Their Toolkit?
C++ Software Developer
Let’s begin with a quick survey. If at least one of these questions resonates with you, it might be worth considering Copilot for your development needs:
Have at least two positive responses to our questions? If yes, this article is tailored just for you!
GitHub Copilot is an AI assistant developed by GitHub and OpenAI, which can be used directly in Visual Studio Code, Visual Studio, JetBrains, and Neovim.
Unlike ChatGPT and other browser-based AI tools, the IDE integration of Copilot is the main feature that significantly changes the way of coding.
I am an experienced C++ developer and have been using Copilot for almost a year in the VS Code environment. Let me share my user experience and tell you why I became an average Copilot enjoyer.
Clever Auto-completion
While IntelliSense only offers function or member name completion while typing, Copilot provides more advanced inline suggestions based on the current file or function context. It can be a function call suggestion with prefilled arguments or even the whole line of code or function body implementation.
It works perfectly in 80% of cases, so it guesses quite accurately what you intend to write. No more need to type everything yourself - just accept and adapt Copilot’s suggestion. It really saves time, especially when you develop new functions or classes from scratch.
As a result, you can keep concentrating on the high-level design of a new class (or architecture of the program) and let Copilot fill in the obvious details and routine work.
The more structured and readable your code is (hello, best practices and SOLID!), the more precise and accurate Copilot's output will be.
Example 1 - Interface Generation
For example purposes I decided to create a very simple user database. I only defined a UserData structure and the way to store it and search for users. Copilot got my idea and filled in the rest (good enough, although some small fixes are still needed). Note how cleverly it treated the unique ID field - std::map instead of std::multimap , which is absolutely correct.
Example 2 - Function Body Generation
The next step is to work on the function implementations. In my case, they are quite trivial - an easy job for Copilot. The only thing I should do manually is to check the correctness and refactor the duplicated logic, if necessary.
Great Support in Unit Testing
Let’s not talk about TDD, as it’s a different story. In a classic approach (”post-factum” unit tests), there is a well-known dilemma. From one side, 100% unit test coverage is a must for delivering high-quality code. From another side, there might be many reasons not to write them: deadlines, budget constraints, untestable code, or laziness.
Unfortunately, the last one is quite common among developers. But you already know what can beat the routine and turn the decision towards “yes”. Copilot is well-suited for this task.
Just write a couple of unit tests manually and let Copilot fill the rest according to your coding style. Adapt the output and add missing use cases. The more detailed unit tests you develop for the first component, the more accurate tests will be generated for the second component. Yes, Copilot considers your previous work.
With the help of such auto-generated unit tests, you considerably save your precious time.
Example 1 - Basic Tests Out of the Box
Generate a bunch of generic unit tests in two clicks. Not very practical, but sometimes better than nothing.
Example 2 - Human-controlled Unit Tests
This example is closer to my reality. As a developer, I define a test fixture and test cases following clear and straight-forward naming convention. Copilot takes it as an input and generates the test bodies that I was thinking about.
Mass Correction of Data Structures
If you have an array of structured data that needs to be modified in any way - add new column, remove existing column, change the values of existing columns - it can be done by Copilot. Of course, it will most likely be limited (due to a token length restrictions), but for relatively small arrays of data it works fine.
For bigger structures or higher number of rows RegExp does the job. But even here Copilot is in play: just explain what kind of data modification you need and get a working suggestion of RegExp expression that you can use in VS Code.
Example 1 - Semantic Data Correction
Imagine that I need to have all job titles written in lower-case letters for some reason or that I introduced another enum field in UserData structure and want to consider it in my massive data array. See how easy it is with Copilot.
Example 2 - RegExp Support
The previous example worked fine, because that array was relatively small. How to deal with big ones, more than 1000 lines long? Not being a guru in RegExp, I still can easily solve the problem in collaboration with Copilot. Note that sometimes you still have to slightly fix the output from it - not everything works out of the box.
Recommended by LinkedIn
Easy Documentation
Documenting the code is another pain point from one project to another. Legacy code doesn’t have any doxygen comments? Are you finished with a new component but too bored to document it manually? You guessed right - leave this last job for Copilot! With a couple of clicks and you will get each function and class doxified according to your project rules with meaningful explanations. Spend two more minutes to fill the missing details or correct the suggested ones, and voila: your code is good to go for a pull request.
Example 1 - Dream of Doxification
In my project, my team is following a certain doxygen comments style. See how Copilot can deal with it and do the routine part for me. The only thing left to do by myself is to check the correctness and fill @details where it is necessary.
Google Alternative
Thanks to the Copilot chat integrated in VS Code directly, you can ask abstract questions like in the browser ChatGPT. However, the way you provide the context of your question stands out in Copilot from other chatbots. Before sending a question, you can select a block of code (in IDE), file (#filename), or even the whole workspace (@workspace) as a reference. No need to copy-paste the stuff! Copilot will suggest a solution that you can apply directly in your code with a single click. After several iterations, you’re going to get a feeling of real pair programming.
This feature becomes extremely handy when you start working with new frameworks or libraries (OpenCV, boost, Qt, etc) and want to get quick turn-key solution.
Of course, normal “googling” is still needed sometimes when you doubt in Copilot’s suggestion. But for simple and basic things, it is faster than Google.
This little thing breaks another psychological barrier; you know that you can get an instant (and most likely working) solution within a few seconds without even switching internet browsers. It makes you more open-minded with diving into the unknown and trying out new technologies.
Example 1 - Abstract Questions
You can directly ask simple questions in Copilot Chat, and in most cases get okay-ish answers. However, I would not encourage trusting it until Microsoft introduces reference link proofs like in Microsoft Copilot in Edge browser or Search GPT. In the current example I was lucky and got the right answer for my question about std::map.
Example 2 - Turn-key Solution
Let’s imagine that I have never worked with nlohman json library, but still I want to use it in my saveToJson function. See how Copilot automatically adjusts the solution according to the contents of my SimpleDB class.
Cross-language Support
You are no longer limited to one programming language if you know the main concepts and principles of software development.
One day I realized that some tasks are much easier to accomplish with bash/cmd/powershell/python scripts rather than in C++. For example, renaming all files in the directory or sorting them according to a certain criteria. Since I don’t have profound experience in scripting languages, ChatGPT has been filling this gap.
But with Copilot it became even easier and more effective. I just need to explain the task and add a magic keyword @workspace to my request. With such input, Copilot generates a working script with correct paths, which again saves a bit of time.
I also remember another good example from my experience. I used to develop PoC’s and prototypes in MATLAB for algorithms or data analysis. I could not share MATLAB scripts with colleagues, since not everyone had this software installed. Thanks to Copilot, I managed to migrate them into python and even added some GUI features on top. Despite my limited python syntax and modules knowledge, this task didn’t cost me too much time. The most important thing: I enjoyed the process.
Example 1 - New Python Script
Say, I have a text document with comma-separated raw data which I want to quickly convert into a json format. In order to save time, I ask Copilot to generate a python script for this simple task. As a result, I solved a problem in less than 1 minute without typing a word (except in Copilot chat).
What’s Next?
Copilot is not a programmer, it’s just a tool. A great tool, which only unleashes its full power when in the right hands. In my opinion, middle & senior developers can benefit the most from it, as it's crucial to understand what Copilot is doing, and more importantly - what you are doing.
Let me draw a bottom line and summarize my subjective experience.
Positive Sides
Negative Sides
Copilot is a powerful tool. It should be used as an assistant to augment human expertise. Careful planning, training, and oversight are essential to leverage Copilot effectively and responsibly within your organization.
Contact our GenAI team for a free consultation!
Crafting web experiences | Tech enthusiast
4moIt's true LLMs have greatly aided software development, making it faster to get started, debug and document. As for privacy of code, if one has a beast of a machine you can use LLMs that run purely on your machine or as in your organization's server never leaving that network