Getting Cozy with GitHub Copilot

Github Copilot is definitely good – but is it “good”? And how does it fare for WordPress developers?

The first thing you’ll realize when using GitHub Copilot is that you sure as hell still need to know how to code. In fact, I assume that you need to be a better-than-average coder to use a tool like GitHub Copilot. If you haven’t heard of it, GitHub Copilot is a real AI coding partner that attempts to predictively autocomplete your code as you write it.

Having something else jump into your code editor and attempt to intelligently autocomplete your sentences is jarring to say the least. It’s a constant mental shift from ‘writing’ your code to ‘evaluating’ someone else’s code, which means you’re reading/editing at the same time that you’re also creating. This dual-mindset is not always intuitive, and it’s a skill that requires practice, especially the ability to quickly read code and determine if it’ll actually do what you want it to do. So, is it helpful?

Stepping back a moment, I’m a WordPress developer. Sort of. Writing code is about half of my time these days, the other half spent in meetings, running code reviews, writing, planning, training, and other managerial-type tasks.  I don’t code nearly as much as I used to, but I like to have a few projects on my plate. I mostly work in the WordPress arena, but I’ve also been working on a large, collaborative Laravel project recently, which has given me a slightly different vantage point to view it from. But first, let’s talk ethics.

I Choose ‘Business Ethics’

Before starting with Copilot, I was on team “anti-AI.” AI art generators (like Midjourney and DALL-E) bothered me and left me dubious about the entire AI wave. I didn’t (and still don’t) like the idea of actual visual artists being exploited and then supplanted by cheap AI. Similarly, ChatGPT is attempting to do the same thing with writing, and while it mostly sounds like a high schooler filling out a generic ‘five paragraph essay’ formula, it’s a high schooler that’s definitely heading to college in the near future. ChatGPT could be just a few beer bongs and hallucinogenic trips away from actually being able to write with a real personality and some basic intelligence. 

The thing about code is that while we may say “code is poetry,” I don’t really think code is “art.” Code is math, code is algebra. Maybe it’s a puzzle to be solved, like a crossword puzzle mating with a sudoko. It can be clever and beautiful, but reading code won’t help me understand my innate humanity. Most of the code I’m writing has surely been written before. I’m not the first person to reverse an array or add a box-shadow. I’m making something new, and yet the pieces are pretty commonplace.

Art, on the other hand, is about pushing boundaries, about taking references to something known and pushing it further into the realm of the unknown. Midjourney can do a great job making an image of Tiffani Amber Theissen eating a turkey leg beneath the Eiffel Tower in the artistic style of a Miyazaki film, but it’s probably not going to invent the next groundbreaking style of anime or have something new to say about gender issues. Code is merely a tool, like a paintbrush or an acrylic: the art is the product we’re making. So to use an AI to speed up the generation of code – to achieve my own goals – actually sounded more appealing, like using Photoshop or Adobe Illustrator to speed up and potentially reimagine the artistic process.

The ethics of GitHub scanning and scavenging their customer’s public repositories has rubbed me the wrong way. Most open source libraries have at least one rule: attribution. Credit given where credit is due. The fact that their code has become training data for AI means that I could be (very indirectly) using code that is ultimately unattributed. I’m not super happy about that. 

On the other hand, I’m a firm believer that once you put something “out there” on the internet, you can’t really be surprised when you don’t own it any more. We’ve learned that lesson the hard way, and it’s just a law of internet physics at this point – a rule we discovered rather than decided. So I put the ethics argument aside and began experimenting with Copilot. And my verdict? 

This is the future of web development. 

To be clear: I’m not sure I see it “replacing” web developers anytime soon. Instead I think it’s going to dramatically increase what a high-level developer can accomplish in a given amount of time. And because writing code is not harvesting a finite resource like grain or oil – there’s always more code to be written and more storypoints to pile onto this week’s scrum – I’m less concerned about it taking my job. But I do think it will start to demand a little more out of me and my colleagues. It will change our jobs for sure.

The Amount of Code is Too Damn High

Like many devs my generation, I’m nostalgic for the “simpler” times. Writing HTML and CSS by hand. Uploading it to my cheapo shared hosting via FTP. Never thinking once about node or Git or dockerized containers. Just me on my porch, sitting on a rocking chair, drinking a cold lemonade, and writing code in a simple text editor, the way the good lord intended. Well, times have changed, and one of those changes is the sheer amount of code we need to write. As our tools and frameworks become more complex, so too does the code we write. Compare the size of WordPress today to WordPress ten years ago. It’s a lot more code.

Where GitHub Copilot really excels for me, so far, is around the edges of writing code. It’s helpful in the boring places, the repetitive places. 

Perhaps I’m processing a form and I need to grab a bunch of values from $_GET or $_POST. Then I need to assign them to variables, sanitize them, and so forth. I can write something as simple as $post_id = $_G and not even finish my sentence, and Copilot is right there with a recommendation. And it’s good. It knows that my ID will be an integer and not a string. It knows I’ll want to check for its existence with an isset function. It knows that I don’t want to write the remaining 80% of this line of code that I’ve written a thousand times before. 

Of course there’s the cognitive switch of evaluating this suggested code, and to be fair, there are very often recommendations that simply distract and annoy me. But this is the early days, and as the AI trains us to use it more efficiently (the same way the Twitter algorithm trains us to post more outrage content), it’ll get better.

So at the end of the day, I’m writing less code. I’m done with this line much sooner than I would’ve been otherwise. But this sets up the ultimate paradox, of course. Because I just said I’m “writing less code.” But I’m not. Between the hours of nine to five, with GitHub Copilot in my utility belt, I’m writing even more code! Like I said, the expectations around developer productivity will ultimately increase. Any chance my boss will notice and increase my salary at the same rate? I’ll leave that answer up to the reader’s imagination.

What About WordPress?

I mentioned earlier that I’ve been half in Laravel and half in WordPress. Well it’s a night and day difference. The key distinction is that Laravel is a PHP framework for developers. WordPress is not.

Laravel is all about code. Laravel doesn’t care about your blocks, your content, your design language, your semantics, or your theme’s typography choices. Laravel cares about efficient coding based on very standard practices. It’s made for a tool like GitHub Copilot (and their forthcoming CLI). When using Copilot with Laravel I saw a lot more of that “write the name of a function and Copilot writes the entire function for you” potential.

WordPress, on the other hand, is consistenly moving developers away from writing code and toward designing and potentially building everything visually in the editor. Building a standard website in the block editor should theoretically mean that your theme has almost no code. And when it does have code, this code is generated by the block editor itself, as in the case of block patterns and templates. This is the paradox of Copilot, at least for me – because I’m a WordPress developer, I may ultimately need it less.

Of course, there are still plenty of use-cases for extending WordPress with custom PHP code, it’s mostly what I’m doing. And because there’s so much WordPress PHP code out there, there was clearly a lot of grist for the AI training mill. One example: Copilot is pretty handy around the $wpdb database class. And because it’s more than just a snippet generator, it does a great job of predicting which custom database table and which fields I plan on updating. It truly is impressive. Even if the code is only 60% correct, it still feels like a time-saver.

So can I recommend it? Sure. Maybe. It depends. My next plan is to jump back into the WordPress React.js world and see how Copilot holds up with a part of WordPress that is relatively unexplored and undocumented. If you’ve played around with Copilot while, say, building custom blocks or data layer interfaces, I’m curious what your experience was. 

At some point, developers who do not use tools like Copilot will be like graphic designers who are making magazine layouts with scissors and glue. Or construction workers forgoing the use of tractors. I’m still on the fence over whether it’s right, but it clearly is productive and impressive, and I’m pretty sure that’s all that’s going to matter in a few years.