GitHub Copilot

Sujith C
3 min readJul 27, 2021

AI as your pair programmer..

Every programmer is used to auto completion feature that various IDEs provides . In fact auto-completing code makes a developers life easier . GitHub copilot is something similar to this but provides lot more ..

In agile environment pair programming is getting popular and according to the experts , this provides lot more quality to the code being written and ultimately helps to build logic that is more effective in terms of time and space. GitHub comes with an AI solution to this, according to the GitHub copilot is your AI Pair Programmer .

Copilot provides flexibility to get suggestions for a line of code or a entire function .This is backed and powered with OPENAI which is trained by billions of public code , and which provides a strong knowledge at our finger tips and makes the life even easier .

Copilot is now available as a visual studio code extension with lot of flexibility to the user , developer can accept a suggestion if he/she feels it appropriate , or he/she can go through other available suggestions and can manually edit before accepting it .This provides a freedom to developer where he/she can choose from different approaches for a particular solution .

Comments to code

This is a cool feature that copilot provides , it helps us to derive a well written code from set of comments that we provide .The intelligent AI understands the comments and in turn makes it to a well formed production ready code

/** * json schema: * [ * { name: “John Doe”, * collaborators: [“Jane Doe”, “Herbert Frapp”, “Elsie McEwan”] * }, * { name: “Jane Doe”, * collaborators: [“John Doe”, “Karen Smith”] * }, * { name: “Skittles the Cat”, * collaborators: [] * } * ] */

For example the we will get a code block below as a suggestion for function function collaborators_map(json: any): Map<string, Set<string>>

function collaborators_map(json: any): Map<string, Set<string>> { const map = new Map<string, Set<string>>(); for (const item of json) { const name = item.name; const collaborators = item.collaborators; const set = new Set<string>(collaborators); map.set(name, set); } return map; }

*code taken from copilot documentation

GitHub Copilot telemetry

As per the official documentation , the copilot collects some additional data from the code editor , beyond what other GitHub products and services collect . The GitHub Copilot collects activity from the user’s Visual Studio Code editor, tied to a timestamp, and metadata.

Conclusion

The beauty of GitHub copilot lies in the mechanism that it uses to make suggestions.These suggestions are of course adapted to the code that we write , at the same time they are ultimately informed by the code written by others .An intelligent mechanism is also built in to dismiss the suggestions that are not apt to the current code and at the end provides scope for manual bucketing .

Copilot becomes very handy when we are working with an unfamiliar code or learning to code in a new language, if you have a solid logic to cross check copilot provides you code in that language which you can check and finalise .

--

--

Sujith C

A Technology enthusiast and self learner , Passionate about coding and building products that impact daily lives