Mariano Crosetti
  • Github Copilot
  • Code Generation
  • Generative Model
  • Product Design
  • Programming

My 3-days experience using Github Copilot: surprisingly smart!

Github Copilot logo is a cute flight copilot.

Github Copilot is an editor extension launched by Github which makes code suggestions while you are programming.

Microsoft came up with this disruptive product as a result of their association with OpenAI (and the state of the art on generative text models) and the acquisition of Github (data for training!).

You only have to join a waitlist. Wait for their invitation to try it. Install it in an editor. I personally installed it on VSCode (don’t forget to associate your github account and agree with the terms and conditions).

Far away from being a post full of text and explanation (you have many other posts on Google for it) I want to share with you my personal experience after using Copilot for just 3 days.

First experience

The first dummy tests I made were trying to code some famous competitive programming codes: dfs, segment tree, binary search. Not too surprising: it could be copying from some repository after all.

Working on real project

Context: I’m programming ESP32 on an Arduino environment to upload some sensor data to a cloud. The device is configured by a local website accessible for a self-provided WiFi network (provisioning mode) and has a physical button to switch to “operative mode” (the self-provided WiFi network disappears and connects to the configured WiFi). Notice is quite “niche” project so I was not expecting a good accuracy with the suggestions.

Detecting patterns of code

I have many <function>_loop that are called periodically. Many of them (but not all) have an analogous logic: an if statement to control that the main logic executes with certain periodicity. Apparently Copilot not only noticed that, but also created a new constant to specify the time period length! Mindblowing!!
I have many <function>_loop that are called periodically. Many of them (but not all) have an analogous logic: an if statement to control that the main logic executes with certain periodicity. Apparently Copilot not only noticed that, but also created a new constant to specify the time period length! Mindblowing!!

Understanding algorithmic logic

Copilot is also good at generating non-existing logic (at least in the present codebase). Here I was forming an IPv4 address by concatenating 4 numbers. And the Copilot noticed that was necessary to erase the first dot character. Smart!
Copilot is also good at generating non-existing logic (at least in the present codebase). Here I was forming an IPv4 address by concatenating 4 numbers. And the Copilot noticed that was necessary to erase the first dot character. Smart!

Proposing alternative way of doing something

Not as awesome as the before but helpful: I was refactoring and commenting on the “sendToBackend” function that uses XMLHttpRequest. Automatically Copilot suggests a way of doing it using jQuery.
Not as awesome as the before but helpful: I was refactoring and commenting on the “sendToBackend” function that uses XMLHttpRequest. Automatically Copilot suggests a way of doing it using jQuery.

Understanding the purpose and the context

I was surprised by this example for two reasons: Copilot noticed my intention when I said “change_mode” (switching between providing a WiFi network or not) and also it detected and understood what triggered the function call (that the button was pressed).
I was surprised by this example for two reasons: Copilot noticed my intention when I said “change_mode” (switching between providing a WiFi network or not) and also it detected and understood what triggered the function call (that the button was pressed).

I personally think that it’s better to put the debug message where the function was call (because in that way you can call the function in another place and the comment will still make sense). But one of the big pitfalls of Copilot is (I say next) that it only proposes changes after where you have the cursor.

Personal opinion

I think that as challenging as the teach-skills necessary for developing AI products is the product design.

Copilot seems amazing , capturing the semantic of what we are trying to accomplish. But my humble opinion to make a better product is: coding is not always about adding lines of code. Think about how much time do you spend modifying copy-pasted code?

Proposal #1: It would be awesome if it suggested you make modifications on the code you already have. (maybe selecting the block of code that must suffer modifications).

I was creating some constant for not repeating some string literals around this module. Copilot successfully proposed to me to create all the constants I need after I wrote the first one (and proposed it with a consistent naming). But it did not help me replacing the literals below with the created constants.
I was creating some constant for not repeating some string literals around this module. Copilot successfully proposed to me to create all the constants I need after I wrote the first one (and proposed it with a consistent naming). But it did not help me replacing the literals below with the created constants.

Also there are some jobs that are not critical but necessary. The copilot does it very well: commenting on the code and suggesting logging messages.

Proposal #2: A shortcut that you press and start suggesting you comments/logging all around the codebase. Think about it: I’m sure I’m not the only one that leaves the comments/logging for the very end and this feature seems straightforward with the already existing functionality and very time saving probably.

An example of good comments generated by Copilot: it noticed that the class was responsible for writing the flash memory.
An example of good comments generated by Copilot: it noticed that the class was responsible for writing the flash memory.
I can only check if a button is currently pressed or not. So I wrote the logic for “keystroke”. Here Copilot awesomely captures the meaning of “released”: was pressed last time this code executed and now is not. Amazing!! It just makes a mistake after it: we are not resetting factory settings but changing operationals mode.
I can only check if a button is currently pressed or not. So I wrote the logic for “keystroke”. Here Copilot awesomely captures the meaning of “released”: was pressed last time this code executed and now is not. Amazing!! It just makes a mistake after it: we are not resetting factory settings but changing operationals mode.
Here Copilot really surprised me: it assosciated the macros CONFIGVAR_<…> with a method declared but not currently implemented! Below you have the delcaration at the time of the suggestion.
Here Copilot really surprised me: it assosciated the macros CONFIGVAR_<…> with a method declared but not currently implemented! Below you have the delcaration at the time of the suggestion.
The only clue that had for the suggestion showed before, was the comment on the declaration of the function. Notice also that the arguments type are String so no very helpful for deciding anything.
The only clue that had for the suggestion showed before, was the comment on the declaration of the function. Notice also that the arguments type are String so no very helpful for deciding anything.

About me

A picture of me

If you liked this post / my style follow me.

I will try to keep on posting regularly about SE, Web, ML and DApps always with an objective in mind:

  • keep it short
  • being meaningful
  • explain with examples

My 3-days experience using Github Copilot: surprisingly smart! was originally published in Bootcamp on Medium, where people are continuing the conversation by highlighting and responding to this story.