This is the sixth day of my participation in the First Challenge 2022.
- Github Copilot: Review After 3 Months of Usage with Examples
- Volodymyr Golosay
- The Nuggets translation Project
- Permanent link to this article: github.com/xitu/gold-m…
- Translator: jaredliw
- Proofreader: Alfxjx
Three months ago, I was allowed to join the Github Copilot test project. During this time, I tested Copilot in Angular, LitElement-based Web components, Node.js (TypeScript), and Vanilla JavaScript projects. How can AI pair programming help us? Does it really work? Let’s watch.
What exactly is GitHub Copilot?
GitHub Copilot is an AI tool created by GitHub and OpenAI. The tool helps programmers write code by automating code completion. The plug-in is already available to users of Visual Studio Code, Neovim, and JetBrains.
GitHub Copilot is based on the OpenAI Codex model, trained in natural language and billions of lines of public source code, including projects on GitHub.
This tool can write code for you or provide alternative solutions. The service supports all programming languages, but works best in Python, JavaScript, TypeScript, Ruby, Java, and Go.
According to their statistics, 50% of GIthub developers continue to use the service after the trial period ends in July 2021.
How to use it?
Github Copilot is still in technical preview status; This is only available to some testers. To join the waiting list, see copilot.github.com.
Before using GitHub Copilot, you’ll need to download the Visual Studio Code plug-in.
- Browse the GitHub Copilot plug-in page in The Visual Studio Code Marketplace (or JetBrains Marketplace) and download the plug-in.
- Open Visual Studio Code and you’ll be prompted to log in to GitHub and authorize the plugin;
- After you authorize the plug-in, Github will take you back to Visual Studio Code.
Once the installation is complete, create a new file and you can start writing your code.
For example:
- Create a new JavaScript file (
.js
); - Declare the function and wait for the magic to happen.
It’s that simple. If you don’t like the suggested code, you can also use shortcuts to toggle options.
availability
I’ll start with the weaknesses, because there aren’t many to discuss, and it’s always more pleasant to end on a positive note.
disadvantages
First, I’d like to mention the issue in the GIF above — after using Copilot, I have to manually remove the extra parentheses each time. I’ve done this from time to time during these three months, especially when writing conditions or functions.
The second question is about HTML. I know HTML isn’t one of the supported languages, but by default, Github Copilot suggests code every time. Maybe I wrote a layout that was too unpredictable, or maybe I was unlucky, but I never received a code completion that was available.
That’s all I want to say. Now let’s talk about the pros, because it really is like magic.
advantages
The biggest value Github Copilot brings is the time you spend looking through your documents. For example, when dealing with keyboard events, do you remember the key code of the d-pad? I don’t remember. Fortunately, with Copilot, you don’t have to memorize or search for those keycodes online. Instead, write your requirements in comments.
Also, you don’t need to search for formulas, such as the conversion between Fahrenheit and Celsius.
Great, right?
Copilot is not only suitable for common functions, it perfectly recognizes file context and takes advantage of existing variables and functions for code completion.
Write API service classes using Github Copilot:
Copilot suggests an entire class that contains methods. When I modify the constructor to add host and JWT strings, it can also suggest GET and POST methods based on those variables.
It can also recognize a JWT variable name and understand how to use it. It adds a request header: “Authorization” : “Bearer” + this.jwt.
Finally, let’s look at how it works between classes. For example, Copilot can analyze imported/existing methods and reuse them, regardless of whether they are in the same class or Object.
How does Copilot compare to Tabnine?
The topic of Github Copilot V.S. Tabine has been discussed online and even has a dedicated page on Tabnine’s website.
Indeed, one of Copilot’s big downsides is putting code into the cloud for analysis, as this can be a huge security issue for large companies. Therefore, make sure this is allowed before using it.
For this reason, I didn’t risk using it in my main business. Tabnine operates locally; It’s a great way to protect your privacy. In addition, Tabnine can also operate offline.
For the rest, I find these comparisons moot — you can use both tools at the same time. Although I use standard Visual Studio Code IntelliSense, I still need to remove the extra parentheses frequently.
You start typing something, Tabnine suggests methods, and Copilot does the rest 🤖.
Copilot also leaves a trap for the company. In interviews, companies often ask candidates to complete a test, such as writing an algorithm or polyfill.
If the interviewer has Copilot on his computer, he simply enters the task into a note and Copilot does the rest. I’ve met such “savvy” candidates in real interviews.
Like other new technologies, Copilot not only improves lives, but also raises policy and process questions. Anyway, I love Copilot and will be using it in my projects.
Thanks for reading! Be sure to get company permission before using the Copilot plug-in in your team.
If you find any mistakes in your translation or other areas that need to be improved, you are welcome to the Nuggets Translation Program to revise and PR your translation, and you can also get the corresponding reward points. The permanent link to this article at the beginning of this article is the MarkDown link to this article on GitHub.
The Nuggets Translation Project is a community that translates quality Internet technical articles from English sharing articles on nuggets. The content covers Android, iOS, front-end, back-end, blockchain, products, design, artificial intelligence and other fields. If you want to see more high-quality translation, please continue to pay attention to the Translation plan of Digging Gold, the official Weibo, Zhihu column.