AI-assisted Coding: What is it and Should You Use It
For years, the idea that you could automatically generate custom source code seemed like fiction. But it has become a reality thanks to new services like GitHub Copilot and Tabnine, which provide AI-assisted code generation.
Solutions like these have shifted the question from "how can we use AI to generate code?" to "should we use AI to generate code?" There's no clear answer, but there is plenty to say about the pros and cons of AI-assisted coding in today's development environment.
What Is AI-Assisted Coding?
AI-assisted coding is the use of machine learning models to generate code automatically. Most existing AI-assisted coding tools let developers describe in natural language what they want their code to do. Then, the tools automatically generate the code to do it, complete with custom variable names and the invocation of external modules or services, where necessary.
In the background, the tools are powered by algorithms trained using vast amounts of existing source code — usually from publicly available source code produced by open-source projects. Based on these examples, the algorithms generate custom code on demand.
How New Is AI-Assisted Code Generation?
The idea of automatically generating source code for applications isn't especially new. Low-code and no-code development tools have been around for decades. And IDEs have long offered autocomplete features, which you could consider a simple form of automated code generation.
However, AI-assisted code generation is different because, like low-code and no-code tools, it doesn't rely on prebuilt code modules to allow developers to construct applications without writing much (or any) code themselves. Instead, AI-assisted coding tools generate custom code entirely from scratch.
In theory, there's no limitation on what AI-assisted code generation tools can do. As long as the algorithms are good enough and the data they are trained on is comprehensive, AI-assisted coding tools could write highly complex applications based only on natural-language descriptions of how those applications should work.
Although developers have long talked — usually half-jokingly — about using AI to write code, AI-assisted coding solutions have only matured over the past couple of years. They represent perhaps the latest major innovation in the realm of software development.
Where to Find AI-Assisted Coding Tools
A variety of vendors now sell AI-assisted coding tools or services. The most famous is GitHub Copilot (based on OpenAI Codex) and Microsoft Intellicode. Smaller companies, including Kite and Tabnine, also offer production-ready tools for AI-assisted code generation.
Open source tools exist in this domain, too, although — like many open source solutions in newly established domains — they tend to be rougher around the edges than the commercial alternatives. To date, the leading open-source AI-assisted coding tool is PolyCoder.
The Pros and Cons of AI-Powered Coding
AI-assisted code generation offers one main benefit: It saves developers time by allowing them to write code without actually having to write code.
AI-powered coding tools are helpful in situations where developers want to implement certain code but don't know how. AI-assisted coding tools aren't sophisticated enough to generate complex code. Developers often have to be very specific about how they want their application to do something. They need to know how they would write the code.
On the other hand, there are clear drawbacks to AI-assisted coding:
Low accuracy: Advanced AI-assisted coding solutions, like OpenAI Codex, generate accurate code only 37% of the time, according to their developers. That falls far short of the performance necessary for programmers to let AI fully take the wheel (which, to be fair, is not what these solutions currently promise — there's a reason why Copilot is not named Autopilot).
Extensive code review: Developers have to accept (or reject) automatically generated code as they work. For some coders, the need to review code constantly could be distracting. They may work more efficiently if they just manually write out their code.
Legal and ethical issues: One stickier issue involving AI-assisted coding is that the tools are trained using open-source code, which raises questions. If your AI-assisted coding tool produces code that closely resembles code in another GitHub repo, does it make you a plagiarizer or license violator?
These challenges mean that AI-assisted coding tools may be handy for developers who want a fast way to generate relatively simple code and are willing to review — and, if necessary, tweak — it to ensure it's accurate. I also suspect we'll see AI-assisted coding used more often by programmers working on proprietary projects. In such cases, their source code won't be exposed to public scrutiny, and therefore are less likely to get caught up in accusations that they've stolen other projects' code through their AI-powered code generators.
It will probably take several more years before we know how good AI-assisted coding tools are and whether they expose users to complicated legal or ethical challenges.