In development as much as any other industry, there’s a growing chorus yelling “Artificial Intelligence IS GOING TO TAKE OUR JOBS”! And like in most other industries, my take is that this take is overblown (at least for now). AI is a tool, and it has strengths, weaknesses, and appropriate uses like anything else in our toolbelt.
One of these new AI tools in the development world is Github Copilot. Copilot is trained on a number of things, most notably all public Github code repositories. Github is far and away the most popular location for developers to keep their code, so in reality it’s trained on a huge portion of the code that exists in the world.
Additionally, when it’s incorporated into your code editor, it also has an understanding of the code within your codebase.
Its biggest power comes from recognizing patterns in all that code, and anticipating what the next code a developer (and you in particular) might want to write. I’ve been using Copilot for a while, and I’m finding it both helpful and imperfect.
Scaffolding – writing vs. editing
When writing code for websites, we find ourselves repeating patterns. We create components for our sites, and in many cases the underlying code is structured very similarly. This is referred to as “scaffolding” – creating the outline for what will come next.
Copilot knows the scaffold that was used for previous components, and attempts to prepare the way for another one. In the example below, I start typing in the code to create a testimonial component, and copilot adds the gray text, anticipating how I would complete the work:
It recognizes patterns from when I and others have written similar code, and attempts to scaffold it out, adding expected fields, parameters, etc. This is an example of when using AI like copilot might shift my approach to the work – whereas before, I was the complete author of the code, typing every character except some basic autocomplete that my code editor provides, I’ve now turned more into an editing stance.
Copilot provides the code it thinks I want, and I need to step through it to make sure it’s actually correct. It’s a tradeoff – in my experience so far about half of the time editing Copilot’s output is more efficient than writing it myself, and the other half of the time it has enough incorrect assumptions and syntax errors that I’m better off writing it myself.
I’m used to dealing with my own mess code, but now I have to deal with my computer’s!
Help me with Syntax
Stack Overflow is a resource that many developers use when they need to remember the correct way to write things, and one specific syntax that is completely unintelligible to the human eye is that of regular expressions, which are used to match patterns within text.
Stack Overflow is an excellent place to get this information, but it requires moving from my code editor to the browser, performing a search, and finding the best answer. Using Copilot, I can write a comment in my codebase essentially asking for the proper syntax, and it will spit it out:
Again, Copilot isn’t 100% trustworthy yet, so you’ll need to test all of the code it generates, but this is a huge time saver.
Using computers to do help with basic tasks is not new
Artificial Intelligence is a step in the evolution of tools – a big step! We’ve had tools like autocomplete for a long time, and in a lot of ways this is like autocompletion on steroids. It’s also important to recognize its shortcomings. I mentioned wrong assumptions and syntax errors, but the tooling is getting better at those tasks every day.
A bigger inherent weakness, and potential danger, is that like any technology tool created by humans, AI tools are shaped completely by the inputs that they’re trained on. Any biases, mistakes, or worldviews brought in via those inputs will be perpetuated.
That’s at least a another full blog post (and already at least one book), for another time…
Have something to say?