You’ve probably heard about Github Copilot by now. Github Copilot is an AI-driven pair programmer who can help write code more efficiently and faster. Here’s a quick review of Copilot.
How to install Copilot?
If you’re using VSCode, then installation is pretty simple as it can just be installed as an extension.
Once installed, you want to make sure you have either an active trial or a subscription. You can manage your subscription from https://github.com/features/copilot
How does it work?
Using Copilot is simple. As you start writing code in either Go/NodeJS/Typescript or Python, it will give you small previews of code snippets. You can even get full functions written by AI. All you need to do is add a comment explaining what this next block of code is supposed to do.
load all tweets of user
As shown above, once you write a comment explaining the next code block, Copilot automaticlaly suggests a python defintion with all of its code. In this case, Copilot handed me all code to retrieve tweets of a specific user.
This was a simple example, so I decided to try out using pymongo for interacting with a MongoDB database and its collection. See what happened this time.
update age of all users to 20
I was pleasantly surprised that Copilot was able to generate code that connects to a MongoDB database, uses a collection, and then sets the age of all users to 20.
It’s impressive that it knows the “custom” MongoDB syntax to query and update something in a collection but also that it has chosen to use update_many() which is different than update_one().
As my last test, I figured it would be worth testing if Copilot can create multiple functions that interact with each other. Of course, it didn’t disappoint. This time I decided I wanted to read something from a database, store it in a Pandas dataframe and then update a column within that dataframe.
function to read from sql database and load to dataframe
read dataframe and update column age
What does it cost?
After you use your 60-day trial, you’ll be charged $10/month or $100/year.
In my opinion, if you write code daily, this is a no-brainer and it seems obvious how it can help you to be more efficient.