11 GitHub Copilot Examples : Can A.I. Actually Help You Code?

What Is GitHub Copilot?

GitHub Copilot
GitHub Copilot

In June 2021 GitHub (owned by Mircosoft) announced a new extension for Visual Studio Code – Github Copilot that has become the talk of the town in the programmer’s community ever since. Marketed as an AI pair programmer, GitHub copilot is more than just an autocomplete or regular code assistant as it can understand the context of the code better and can complete the entire code block or function. Currently, it supports all the popular languages like Python, Javascript, Typescript, Ruby, and Go.

GitHub Copilot uses OpenAI Codex 

GitHub Copilot is powered by Codex which is a model created by OpenAI for code. For the uninitiated OpenAI is a startup that has recently become popular for delivering breakthroughs in the field of AI year after year.

Last year they had released the language model GPT-3 whose astonishing capabilities gained viral popularity on the internet even outside the ML community.

Even at that time, some people had able to use GPT-3 to convert natural language into code. However, all this was quite rudimentary, because GPT-3 was not trained explicitly trained for generating codes, yet it showed a glimpse of the future.

Below you can see a user generating a Keras model using GPT-3.

GPT-3 as Code Generator
Last year’s GPT-3  workings as Code Generator

This time OpenAI has developed Codex, a GPT version that only specializes in converting natural language into codes. Codex has been trained on publicly available GitHub code. Its performance benchmarking in generating standalone Python code from docstrings can be found in this paper.

How Does GitHub Copilot Work?

Copilot Working
Copilot Working

Github Copilot is currently available as an extension for Microsoft Visual Code only. It is claimed that the user just needs to define the function in plain English and the Copilot has the ability to converts it to actual code.

To do so Copilot tries to gain a contextual understanding of the code that you have written by using the Codex Model in the background and generate suggested code based on it.

But one has to note that at the end of the day it is “artificial” intelligence. Thus, the suggested code may not be accurate or may not work sometimes since the copilot is unable to check/test the suggested code. (So we are not even going in the direction that how it can steal Coder’s job!)

GitHub Copilot Examples

Copilot writes Python code for Zip and Unzip File

GitHub Copilot Example
ZIP and UNZIP file

This example shows how Copilot produces the code for unzipping and zipping of the file just by reading the comments given by the coder.

GitHub CoPilot writes Tic Tac Toe Code

GitHub Copilot Example
TIC TAC TOE

In this intriguing example, GitHub Copilot is able to produce the Tic Tac Toes code just by reading the comments written by the developer.

GitHub Copilot Codes to get Cryptocurrency Price

GitHub Copilot Example
CRYPTO PRICE

Just look here how effortlessly you can get a code for getting the price of a cryptocurrency from Copilot just by writing your requirements in a comment.

CoPilot gets Pokemon Data

GitHub Copilot Example
POKEMON DATA

Want to write a code to get pokemon data, just sit back and let Copilot do it for you.

Speechless with Copilot Autocomplete

Even we are speechless of how effortlessly Copilot autocompletes the lines of codes here.

Copilot Neatly Writes HTML Tags 

This GitHub Copilot example truly shows how it can pair up with you for programming.

Copilot Gives Different Suggestions

This example of GitHub Copilot shows that it is flexible enough to offer different suggestions to the coders.

AI writes Machine Learning Code

This is getting more intriguing now, in this example, Copilot is writing machine learning code itself. We are not going to say the end of the world is near now. It is good for data scientists who can focus on experiments in model building and less on writing codes.

You Don’t Need to write Regex Again 

We all know how difficult it becomes to write regular expressions even for simple things. But now you need not worry more about it as CoPilot can take care of it.

One More CoPilot Autocomplete Example 

This is yet another example of GitHub Copilot where it can autocomplete codes by understanding the context of what you are coding.

CoPilot Writes R Code

CoPilot knows R syntax as well and this is yet another good news for data scientists and statisticians who prefer to work in R.

How can I get Github Copilot?

Currently, there is a small set of people being able to use Copilot since it being an invite-only testing phase. But you can sign up for the Copilot waiting list to be able to use it in the future. Copilot waiting list.

What Does It Mean For The Future of Coding?

The official body of GitHub clearly mentioned that Copilot is not designed to write code for developers. Instead, it is meant to suggest alternative codes based on what the user is working on this should be carefully tested and reviewed.

“While we are working hard to make GitHub Copilot better, code suggested by GitHub Copilot should be carefully tested, reviewed, and vetted, like any other code. As the developer, you are always in charge.”

As we discussed earlier that Github Copilot is just a language model powered by OpenAI Codex that specializes in code. But these language models do not have the ability to ‘comprehend’ what is being fed to them. They cannot come up with new ideas or designs. They simply convert the input into artificial outputs to degree that it is indistinguishable.

However, the Copilot suggested code can be rarely found in the training set (almost 0.1 percent). It is no surprise that AI in coding is a breakthrough but it was met with rather frightening comments online:

  • “All this time we were using Github thinking “hey, this is neat and free”, but didn’t know that actually, we were feeding the AI that will replace us all.”
  • “It is certainly impressive to see how much the GPT models have improved let’s how this changes things.”

But some were hopeful and welcoming

  • Your mother-in-law is not going to install Copilot and start knocking out web apps. Tools like this allow programmers to become more productive, which increases demand for the skills.
  • While this is cool and I look forward to trying it, it’s not going to replace software engineers. Even if it worked 100% correctly, it would be a tool for software engineers. There are still a ton of problems for engineers to solve – Architecture, maintenance, and increasingly, we’re getting pulled into dev ops and data science roles.

Source – GitHub Blog, Reddit

  • Gaurav Maindola

    I am a machine learning enthusiast with a keen interest in web development. My main interest is in the field of computer vision and I am fascinated with all things that comprise making computers learn and love to learn new things myself.

    View all posts

Follow Us

Leave a Reply

Your email address will not be published. Required fields are marked *