By Qinqi
GitHub Copilot has attracted a lot of attention since its inception. It is needless to say that its code recommendation ability is amazing, but some subsequent problems have aroused heated discussions, including whether programmers will lose their jobs because of Copilot and the copyright of its recommended code. However, this article does not intend to discuss these points. This article is some practice of Copilot's code recommendation ability after I passed the trial application. I hope it can be helpful to you.
I roughly classify GitHub Copilot's capabilities into three types: assisted programming, text-to-code transformation, and empirical inference.
Assisted programming predicts and recommends possible codes based on the context of user input to make programming efficient. Here are some examples. The first example is the writing and comparison of the most common React components:
IProps
, the recommended component code contains interface definition.Dialog
and Table
components, here is the recommended code:When there is no context, Copilot can also recommend a usable code, although it is possibly not what we want. When there is a context, the recommended code is more accurate. The richer the context, the more accurate the recommendation.
Text-to-code transformation refers to the automatic generation of object code based on a description. Here are some examples:
Although it takes more time, Copilot still recommends a decent code, whether it is available or has not been verified yet.
(P.S. /*@cc_on!@*/
is a unique code below ie11. Please refer to this link for more information.)
Some commonly used functions and algorithms can generate codes according to descriptions, but the accuracy of generated codes cannot be guaranteed. These codes most likely come from actual code fragments. Whether they are correct or not needs to be judged by developers. I suggest that the generated code should be for reference only. It should not be used directly in production.
Copilot can automatically find out some laws implicit in the code. It can learn personal coding habits and recommend personalized codes if it is used often. Here is an example:
Another more complicated example:
The ability is quite amazing. I guess the logic behind it is similar to code2vec, which recommends according to the similarity of text semantics.
Copilot is useful as a coding aid, but here are some tips:
⚠️ Don't rely too much on the generated code since its accuracy is not guaranteed.
⚠️ Currently, there is no local version of Copilot. Thus, the Internet is a requisite. Pay attention to the code security risk.
⚠️ Think of it as a development aid (like code completion or code search) but not a tool for making a living.
66 posts | 3 followers
FollowAlibaba Cloud Native - August 6, 2024
Alibaba F(x) Team - June 20, 2022
Alibaba Cloud Native Community - December 7, 2023
Alibaba Cloud Data Intelligence - August 14, 2024
Alibaba Clouder - December 31, 2020
Alibaba F(x) Team - February 21, 2022
66 posts | 3 followers
FollowA low-code development platform to make work easier
Learn MoreA one-stop, multi-channel verification solution
Learn MoreMore Posts by Alibaba F(x) Team