GitHub Copilot Guide

GitHub Copilot Guide

GitHub Copilot Guide

GitHub Nov 5, 2022

#1. What is GitHub Copilot

IntelliJ, PyCharm, Microsoft Visual Studio Code, and other programming environments are integrated with GitHub Copilot. An artificial intelligence. Numerous programming languages are supported by the tool, including Java, C, C++, and C#, as well as Python, JavaScript, TypeScript, Ruby, and Go.

It may be started easily by opening the IDE and installing the necessary plugin, which is approved on GitHub. As a result, the development environment connects to GitHub and interacts with the AI.

GitHub Copilot's main attributes are:

  • Write code while parsing comments,
  • Add comments to the final product,
  • and design common algorithms and provide them for the developer.

#2. What does it resemble?

GitHub Copilot
GitHub Copilot

There is a programme here. Additionally, it provides a function that shows the output of an other nonexistent function.

Making a function that will add two numbers is the challenge, and the function's output can be conditionally infinite. This is how it is resolved using GitHub Copilot:

  • We provide feedback, for the intellect to consider;
  • Start writing a function;
  • The system's problems Depending on the work description and the first lines of code, continue the task (highlighted in grey);
  • Hit tab to finish the process.

Another example is to create tests for a function that converts between the Arabic and Roman numeral systems while the function itself does not.

GitHub Copilot
GitHub Copilot

Copilot exclusively used my comments to remedy this issue. He converted Roman numbers into Arabic by himself, accurately swapping the input and output data.

#3. How to work with GitHub Copilot

I've found that the system generates really high-quality code. But under specific circumstances.

The first step is to provide thorough comments that explicitly state what each function should accomplish. Without these, the tool won't be able to predict what you'll need.

I once found the answer to a problem by looking at the value of the sequence's middle member. There was a min (and, optionally, average) function in the code I developed. As a result, Github Copilot had to infer what I wanted from the names of the variables and functions since I didn't leave comments. As a result, he created a median function that searched for the middle element itself rather than just its value.

After a function has completed its work, call it. Additionally, adding sufficient variables won't help; for example, using the names a1, a2, a3, a4, or a5.

Third, it's simple to write. I searched for a code to confuse the system for a very long period.

GitHub Copilot
GitHub Copilot

I created a function here, for instance, that should compare two integers. However, the function's name is insufficient and the implementation is peculiar; as a consequence, Copilot tried to assume what I wanted, what functions, and what data types I use regularly. and mislaid the code.

Code verification is a different subject. The tool occasionally skews or acts weirdly. For instance, it may provide many solutions to the same issue (why this is a mystery) or a wrong code that is strikingly similar to the right one. It's as though Copilot first built the right software, but afterwards added a few mistakes.

Though it's rare, it's still important to exercise caution.

I'll give you a few illustrations. I had to multiply two sequences and add the square roots of each element one by one. The system developed code that conducts a succession of computations, but instead of computing square root sums, it computed square root sums. The outcome was also known as sqrt, indicating that the tool successfully grasped the purpose.

Another instance included GitHub Copilot producing a code blob big enough to parse an expression. However, he only completed half of the if statements correctly. For instance, he entered one operation into the condition rather than two.

#4. Where can you utilise the tool?

The regular job is handled by the tool. This is for him if there is a typical piece of code that is either incredibly dull or too lazy to write. At the same time, comments and verification don't require much time (and they should be done anyway).

Working with unknown libraries and frameworks is also a benefit. Copilot examines the sizable database on GitHub and provides usual fixes, including ones the developer is unaware of. So you don't need to read the documentation or ask questions on StackOverflow, you may securely include a library that you are unfamiliar with.

He can't work without a person, thus he still won't replace programmers. To understand what has to be added, you always need either a detailed explanation of the algorithm in the comments or a code blank.

Additionally, he lacks the ability to produce something original and simply uses substitutions for blocks that he has already seen someplace in a certain location (growing them in an arbitrary order to create something new is also beyond his power yet).

Last but not least, Copilot's code still has to be tested. The programme is capable of providing a sizable snippet that was taken from the unexplored depths of GitHub. Moreover, I have to find out: "What did they offer me? Is this algorithm reliable or reliable? Does it work or not?

#5. Final Words

So, even if the technology is wonderful and engaging, it cannot completely replace a person. Additionally, it's safe for you to develop IT expertise.


Anurag Deep

Logical by Mind, Creative by Heart