By: Robin Granström Käll

2024-03-19

GitHub Copilot Insights

I’m Robin, a consultant at Dynabyte, where my expertise lies in web technologies. For the past two years, I’ve been utilizing GitHub Copilot in my projects and recently shared my findings in a presentation. This includes the advantages and disadvantages I’ve encountered, along with strategies to address the latter.

Advantages – What GitHub Copilot Excels At

Firstly, let’s explore what GitHub Copilot does well. It supports an extensive array of programming languages, and I’ve yet to encounter any it cannot handle. I particularly appreciate how it encourages me to name variables and functions clearly, promoting cleaner code and aiding in faster code generation.

GitHub Copilot is exceptionally proficient at generating regular expressions from various inputs, such as templates, written queries, and patterns. While it can validate regexes, I prefer to use another tool for validation to guarantee accuracy.

Its biggest strength lies in productivity enhancement, significantly reducing time spent on mundane code and allowing more focus on complex problems. It’s akin to an advanced autocomplete tool, simplifying coding without tackling the more challenging tasks directly.

Integration with major IDEs (Integrated Development Environments) like VS Code, Visual Studio, JetBrains, etc., is straightforward. However, the Copilot chat function, which is akin to ChatGPT but focused on programming, isn’t fully supported across all IDEs. This feature shines in scenarios requiring detailed context, allowing for code explanations, fixes, optimizations, or complete rewrites directly within the IDE. I find it particularly useful for crafting unit tests, as it can generate test cases based on provided descriptions and code references.

Disadvantages – Where GitHub Copilot Falls Short

Regarding drawbacks, code ownership frequently arises as a point of concern. GitHub maintains that the user owns and is responsible for the generated code, but this doesn’t fully clear copyright obligations. A quick online search to check the uniqueness of the suggested code is advisable, though shorter code snippets are generally less concerning. The legal implications of this have yet to be tested in court.

Sometimes, GitHub Copilot can be challenging to steer, fixating on unwanted solutions or elaborating too much without solving the problem. This can often be rectified by tweaking the query or indicating a desired direction through partial solutions.

Another consideration is the subscription fee for GitHub Copilot. In my view, the time savings justify the cost, and there are enterprise solutions that are cost-effective for project integration. A key drawback is its propensity for errors or producing unclear code. It’s wise to either refine the code or improve query clarity to ensure the generated code’s quality. Reviewing or unit testing the AI-generated code is crucial, as ultimate responsibility for the code’s integrity rests with the user.

In certain situations, especially when needing information newer than GitHub Copilot’s last training cut-off, I turn to ChatGPT 4, which can provide real-time information and is better suited for discussing issues or exploring hypotheses. Although GitHub updates Copilot’s training data for some libraries beyond the cut-off date.

In summary, utilizing AI for programming, as demonstrated by GitHub Copilot, significantly boosts productivity, aids in catching mistakes early, focuses attention on more challenging questions, and, most importantly, makes programming more enjoyable.

#Copilot #Github

Midjourney vs DALL-E

A Glimpse into the future