top of page

Github Copilot - Good Or Bad? A Developer's view on its usefulness

Note: this article does not represent the opinion of TDP as a whole, just the author himself.

A screenshot of Github Copilot in action
A screenshot of Github Copilot in action

Preface

It's been roughly half a year (or slightly more) since using Github Copilot for developing a project in Unity with Oculus SDK. Had some inspiration for giving a small commentary on the usefulness of Github Copilot for developers, since generative AI seems like the in-thing nowadays~ :D


A developer's personal view of Github Copilot's usefulness

To start off, I've yet to use (possibly) advanced features of Github Copilot, so take this commentary with a slight pinch of salt~


Let's dive into the details of some examples where Github Copilot's usefulness can be leveraged for developers.


Example 1

With a predominantly gameplay-programming background, I wasn't too familiar with the domain of Unity Materials and Shaders. So, I was having to deal with dynamically-setting material properties of a GameObject's MeshRenderer due to the need to reconstruct an object's visuals from a provisioned data.


Classically, one would just consult Unity's API documentations and read up on the Material class. This is necessary, but it does take time to read and understand things from documentation. Here's where Github Copilot comes into the picture: it tries to guess what you want to do in the current context, and offers suggestions for what it thinks you want to achieve.


For example, if you were freezing up in the middle of something like this...

...
<E.g. I want to alter a specific property of this material>
myObject.GetComponent<MeshRenderer>().materials.
...

At this stage, depending on what code you have already written in the current session before getting stuck here, Github Copilot might prompt an auto-suggestion based on your current state, after a while of waiting:

...
<E.g. I want to alter a specific property of this material>
myObject.GetComponent<MeshRenderer>().material.<auto-suggestion>
...

The auto-suggestions provided at this stage may or may not meet your needs since it's just guessing from its own prior knowledge base, with your code in the current code file serving as a guiding additional context.


Here's how to attempt to make it provide a more-intelligent guess (I only found out about this technique just before writing this article):

...
<E.g. I want to alter a specific property of this material>
// (WRITE THIS COMMENT) Set the material of GameObject 'myObject' to a default material
<after writing the comment above, press 'Enter' and wait for Copilot to try to suggest something>
...

Example 2

File IO functions get on my nerves pretty much all the time. It's a fairly commonly-used feature and yet I can never remember their syntax or whatever. It's a similar problem with Android Activities and Intents, save me please. :')


Leveraging on the technique mentioned above, you can probably try to 'prompt' a suggestion via the following:

...
// Generate a method to read a text file and print all lines of its contents, that accepts the filename as a parameter, and returns the number of lines read.
public int ReadTextFileAndPrintAllLines(string filename)
{
    int linesRead = 0;
    string[] lines = System.IO.File.ReadAllLines(filename);
    foreach (string line in lines)
    {
        Debug.Log(line);
        linesRead++;
    }
    return linesRead;
}
...

After Copilot has first suggested something, you could then work off that as a starting base. Anyways, as with all generative AIs, you might need a couple of tries to modify your 'prompt' until Copilot suggests something good enough for you to start working off with; I got the above after tweaking my comment prompt a few times.


Example 3

I typically employ the approach of using string interpolation when composing certain logging strings. So Github Copilot eventually picked up on that pattern, and whenever it offers auto-suggestions that also logging certain messages, it composes those log messages as an interpolated string too. Pretty neat, huh?


Verdict

Overall, I believe Github Copilot can make for a more productive programming experience, which is also backed by their own research.

The numbers speak for themselves Research has found GitHub Copilot helps developers code faster, focus on solving bigger problems, stay in the flow longer, and feel more fulfilled with their work. 74% of developers are able to focus on more satisfying work 88% feel more productive 96% of developers are faster with repetitive tasks Taken from https://marketplace.visualstudio.com/items?itemName=GitHub.copilotvs

Personally, I feel that Github Copilot has indeed improved my programming productivity, albeit gradually. As with generative AIs, the suggestions still require manual eyeballing, and one needs to do their due diligence to check that those auto-suggestions are appropriate.


There's also one setting that determines whether your Github Copilot can offer suggestions that match public code; although enabling this means getting higher quality suggestions (since public code's likely more closely vetted by other developers), it may potentially be a can of worms on blatantly copying code from another source.

A screenshot of a setting in Github Copilot to enable suggestions matching public code

Overall, Github Copilot is highly promising, and it's probably one of the few generative AIs that I'm personally very supportive of. It stands as a 6/10 for me for now, and I would recommend other devs to use it~


GeeCue @ TDP

Comments


bottom of page