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

GitHub Copilot Examples

What Is GitHub Copilot?

GitHub Copilot
GitHub Copilot

In June end 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.

Although there is a waitlist to get hold of the technical preview, the internet is filled with jaw-dropping GitHub Copilot examples by those who managed to get the preview version.

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

1Copilot writes Python code for Zip and Unzip File

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.

2GitHub CoPilot writes Tic Tac Toe Code

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.

3GitHub Copilot Codes to get Cryptocurrency Price

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.

4CoPilot gets Pokemon Data

POKEMON DATA

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

5Speechless with Copilot Autocomplete

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

6Copilot Neatly Writes HTML Tags 

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

7Copilot Gives Different Suggestions

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

8AI 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.

9You 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.

10One 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.

11CoPilot 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

LEAVE A REPLY

Please enter your comment!
Please enter your name here