Top features of Github Copilot that every software developer should know

In this article, I will discuss github copilot and its top six features that every software developer should know.

Top features of Github Copilot that every software developer should know

What is GitHub Copilot? #

  • Coding assistant that helps developers write better and faster code.
  • Autofill for repetitive tasks right in your editor and far better than traditional editor intellisense.
  • Uses generative AI to suggest lines of code or entire functions right inside your editor in real-time.
  • Based on Open AI's Codex, a new AI system created by OpenAI that translates natural language to code.
  • Trained on billions of lines of public code including github repositories and works pretty well with many languages such as Python, JavaScript, TypeScript, Ruby, and Go.

Github Copilot is your pair programmer which helps to write code faster and accelerate developer productivity by suggesting code snippets, code completion, and documentation.

Github Copilot avoids googling since there is no need to google for code snippets or documentation. It will do it for you in your editor.

Code generated by github copilot may be wrong or not perfect. It is the developer's responsibility to review the code and make the decision to include it in the codebase.

Features of GitHub Copilot #

Video examples presented in this blog post are based on the VS code editor and use the official GitHub Copilot extension with GitHub Copilot enabled in the settings.

1. Build new features #

We can think of creating a new module, component, class or function. As an example, I will be creating a few REST API endpoints using express in node.js.

Example: create REST API endpoints using express in node.js

2. Generate code from comments #

Four Principles (4S) of prompt engineering is of paramount importance to generate relevant and accurate code from comments. Effective prompts should follow these core principles.

  • Single: Focus on a single, well-defined task.
  • Specific: Be specific and precise.
  • Succinct: Be concise and to the point.
  • Surround: Keep related files open to provide more context to github copilot.

In the following video, I will be generating a few utility functions from comments.

Example: create utility functions from comments

3.Generate Docs #

Github copilot can generate relevant documentation by analyzing the source code, right alongside the code itself. This is very useful for developers to understand the code better.

Example: generate document from code

4. Explain code #

Github copilot can explain code in plain english. This is very useful for junior developers to understand code better. Even senior developers can use this feature to explain code to their peers.

Example: explain code

5. Generate Tests #

We can generate tests for our code. This saves a lot of time and developers can focus on other important tasks. Even though the generated tests are not perfect, it is still a good starting point for developers to write tests.

Example: generate unit tests from code

6. Optimize code #

Github copilot can optimize code by fixing code smells, security issues with proper refactoring. This is very useful for developers to improve code quality.

Example: optimize code

Conclusion #

Github copilot is a great tool for developers to write better and faster code. It is not a replacement for software developers but a tool to help developers to improve their productivity and velocity. Developers are still in charge of whether accepting the code suggested by github copilot or not.