GitHub Copilot: Your AI pair programmer – what is all the fuss about?
GitHub just released Copilot, a code completion tool on steroids dubbed your "AI pair programmer." Read more about it, and see what all the fuss is about.
Last week, GitHub publicly unveiled Copilot, the preview of its "AI pair programmer," a code completion style tool designed to provide line or function suggestions in your IDE. It has certainly made waves in the world of programming and beyond, and you have likely heard at least something about it.
But Copilot is more than simple autocomplete and is more context aware than other code assistants. Powered by OpenAI's Codex AI system, Copilot contextualizes a situation using docstrings, function names, comments, and preceding code to best generate and suggest what it determines to be the most appropriate code. Copilot is designed to improve over time, "learning" from how developers use it.
Trained on billions of lines of public code, GitHub Copilot puts the knowledge you need at your fingertips, saving you time and helping you stay focused.
Some of the major selling points of Copilot, as evidenced by their highlighted inclusion on the Copilot website, include the following (taken directly from the website):
- Convert comments to code. Write a comment describing the logic you want, and let GitHub Copilot assemble the code for you.
- Autofill for repetitive code. GitHub Copilot works great for quickly producing boilerplate and repetitive code patterns. Feed it a few examples and let it generate the rest!
- Tests without the toil. Tests are the backbone of any robust software engineering project. Import a unit test package, and let GitHub Copilot suggest tests that match your implementation code.
- Show me alternatives. Want to evaluate a few different approaches? GitHub Copilot can show you a list of solutions. Use the code as provided, or edit it to meet your needs.
How Copilot works (source)
These are all impressive use cases and claims, and from the examples provided they are also impressive results. Here is an example of a prompt that Copilot has treated as context to generate code from, consisting of a combination of function name and verbose docstring:
import datetime def parse_expenses(expenses_string): """Parse the list of expenses and return the list of triples (date, value, currency). Ignore lines starting with #. Parse the date using datetime. Example expenses_string: 2016-01-02 -34.01 USD 2016-01-03 2.59 DKK 2016-01-03 -2.72 EUR """
And here is the function that Copilot generates:
expenses =  for line in expenses_string.splitlines(): if line.startswith("#"): continue date, value, currency = line.split(" ") expenses.append((datetime.datetime.strptime(date, "%Y-%m-%d"), float(value), currency)) return expenses
That certainly functions as described.
I have applied for, but, as of publication time, have yet to been granted access to Copilot. Therefore, we will have to, unfortunately, rely on what we read elsewhere for our first impressions at this point.
More so than anything, I am excited about the "comments-to-code" context use case of Copilot, in particular as relates to function docstrings. As a good programmer, you should be writing (and I certainly do!) quality docstrings for your functions, after you have planned out what the function should do, and prior to implementing said function. With the use of Copilot, we should be able to devote more time to the planning and documenting steps, and perhaps skip much of the initial phase of the implementation step altogether, focusing instead on tweaking the generated code afterwards.
Here is another simple yet powerful example of a comment turned into a block of code (from an analysis of Copilot on the GitHub documentation, something I encourage you to read):
I recently wrote an article on organizing your code as a data scientist, but I fear that it may soon need an update, given how I anticipate Copilot may change the way I write code to some degree.
The Copilot page also has a number of testimonials, from GitHub and OpenAI devs who have been using the system for some time, and beyond. Here's a ringing endorsement from someone you may have heard of:
— Mike Krieger // Co-founder, Instagram
Copilot thus far seems like a mightily impressive application of machine learning. Even more noteworthy, it is not something that is theoretical or impractical; Copilot is immediately useful and poised to have an actual impact on how coding is performed.
Trust me when I say that I am legitimately excited about getting my hands on Copilot, and promise to follow up with some observations from my own first-hand experiences once I do.
- Managing Your Reusable Python Code as a Data Scientist
- Data Scientists, You Need to Know How to Code
- 5 Tasks To Automate With Python
|Top Stories Past 30 Days|