GitHub Copilot vs OpenAI Codex. Which should you use?
Why should you care?
With the rise of more and more complex machine learning algorithms and models, comes fascinating new AI implementations. Ranging from automation of jobs in Amazon warehouses to predicting the stock market, AI is being trained to do tasks with more speed and accuracy than has ever been available to humans before.
Most notable to software development, the release of OpenAI Codex and GitHub Copilot has sent shock waves through the software development community, with many fearing their inevitable takeover of development jobs. Now while there’s not much reason to fear replacement by an AI like Codex or Copilot, there is an interesting question that has been posed to developers. Should I use a coding AI? And if so, which one should I use?
Should you use a coding AI?
Let’s talk about the first question, should you use a coding AI? Put simply, the answer is probably yes. First off, we have to ask ourselves why big tech businesses are investing so much in machine learning, with Microsoft investing billions of dollars in AI development firm OpenAI, the creator of Codex. Well, the biggest cost that most development firms face is the cost of developers.
Every hour that you have a developer working could cost between $20 and $200 dollars/hour. Multiply that by thousands of developers working for years and you can see a significant advantage to increasing the speed at which developers code. By introducing an assistant like GitHub Copilot, developers no longer have to worry about brainstorming an algorithm or a function to do a specific task (at least not as much as they used to), and can instead focus on the implementation of that function or algorithm.
By speeding up workflow, development firms can increase the productivity of their developers and spend less, while getting more. Therefore, it’s likely that coding alongside an AI will be the norm given a few years, and maybe even a requirement in some jobs. So not only does a coding AI speed up your own productivity and let you do and focus more on what you want to, but it also could be a necessity in the coming decade.
So which AI should You Use?
If you just want the short answer, you probably want to use GitHub Copilot. However, like most things, this is a little more complicated than it seems. GitHub Copilot and OpenAI Codex are both AIs that, when given a prompt, will output code in a variety of languages that is often very accurate to what you’re looking for. That being said, the main difference between the two comes with their respective scopes. OpenAI Codex and GitHub Copilot are both models trained on the GPT-3 language prediction model created by OpenAI. However, while Copilot writes code alongside you in your text editor (as the name suggests), Codex requires that you access it via their API, or Playground.
As you can see, all of that for a simple function that returns the square root of a product. OpenAI’s biggest caveat is it’s interface, it’s simply going to be a process to get good code completion from Codex, at least for now. That being said it’s still pretty cool that we can get a function, in a given language, by asking an AI to make it for us, using our own code. So how would we do this with GitHub Copilot? Here’s the same example with that:
Now that’s pretty nifty; Not only do we shorten the time that it takes to get a completion significantly, but we can use that directly in our code by pressing tab, or if we’re not really feeling the first suggestion it gives us, we can press ATL + ] and ATL + [ to shuffle between suggestions.
At this point the answer might seem obvious, GitHub Copilot can be used directly to autocomplete your code without having to go through a tedious process or interface with the engine on OpenAI’s website. However, there are a couple reasons why you might want to give OpenAI more of a chance.
First of all, GitHub Copilot is really only usable in Visual Studio Code, Microsoft’s IDE, or GitHub Codespaces if you’re into the whole Cloud IDE thing. This means that developers using PHPStorm, PyCharm, Sublime, or really any other development environment, aren’t going to have much access to this tool, at least not yet. Therefore, for the time being at least, those of you not using VSCode might accept the downsides of Codex’s interface to get those nifty code completions.
Second, Codex has something up it’s sleeve that is not readily available to GitHub Copilot users, training. That’s right, you can create your own fine-tuned OpenAI model by feeding it training data from files. If you do that, then it theoretically would be able to generate much more accurate and detailed responses than what Copilot might be capable of. Copilot can understand the context of a file and generate very accurate, but specific code completion based on that. However, if you were to train a Codex model on say a bunch of files and code from a big project you’re working on, then it’s completion is going to have a lot more context of the app you’re working on, because it’s not limited to the file that it’s in.
At the end of the day, what matters when choosing between the two of these is your use case. If you want to increase your productivity and write code faster with quick, accurate, and inline code completion, you’re probably looking at Copilot. To be honest, most developers are probably in this group and will make that decision. That being said, if you have a specific use case where you need either really accurate and detailed completions, an API to interface with for your application, or aren’t using a Microsoft IDE, then OpenAI has you covered with Codex.
It is important to note that both of these technologies are in private beta at the moment, and not yet in their true form. OpenAI might make an inline extension for your IDE and GitHub Copilot might let you train it given enough time. That being said, I will keep this post updated if anything of enough significance changes the accuracy of it.
Happy Coding Everyone!