Most coverage of AI coding tools presents two extremes. On one side, breathless articles claim AI tools eliminate the need to learn coding. On the other side, dismissive articles claim AI tools are unnecessary novelties. Here is a more pragmatic look at these tools.
Where AI tools work best
First and foremost, AI tools automate the most tedious and repetitive coding task – writing “boilerplate” code. This is the coding that every developer performs, but is predictable and can be written without much thinking. Registering a new function, writing a canned API call, or writing a test function for a new function are tasks that AI coding tools can do faster and with less risk than a developer. Misuses in AI tool coding will be detected when the developer reviews the code.
AI tools can also get a developer out of a coding jam where they’ve lost their train of thought. AI tools can also present explanations of a given coding function to a developer when a developer is stuck in a coding jam and needs a push to get unstuck. Explaining a piece of code that is foreign to the developer can be time consuming. AI tools can provide quick explanations and, in many circumstances, be more useful than a developer’s documentation.
Where they need closer supervision
The business logic pertaining to your unique construction is the biggest blind spot. An AI assistant can’t derive the specific rules your application needs to follow, so code it generates for anything involving your unique business rules needs to be vetted carefully, as opposed to accepted blindly. The same applies to anything security related — authentication, permissions, user data — since a not so correctly formulated suggestion can be rational looking, and potentially very dangerous.
A good rule of thumb that’s helpful to remember is the more standard and generic a task is, the more code an AI can safely generate. The more specific and consequential it is, the more it needs to be verified.
Setting up coding assistants
We can now integrate AI helpers directly into most coding platforms. Many developers use GitHub Copilot, integrated into VS Code. It suggests code and provides a chat interface to clear code-related queries. The default Copilot installation process is an extension and a sign in. An investment of a few additional minutes is worthwhile to set up the preferences. Many developers enable suggestions, to prompt automatically. The suggestion feature can become very productive, once you build trust in the tool. However, suggestive code can be distracting, and should be avoided until you learn to evaluate code suggestions.
Avoiding extra work from AI assistants
Writing code with AI has the same effect in the end as writing it yourself. The ultimate goal should be to gain confidence in the AI. However, we must read and validate every line of code written by AI. We also need to explain to the AI, why we would choose that line of code, as opposed to others. In the long run, writing and validating every line of code reduces development time.
Being specific instead of vague helps when prompting. When I say, “Write a function,” the results returned are usually of no help and almost always vague. When I say, “Write a function that validates a UK postcode format and returns a clear error message when it’s invalid,” the results returned are almost always a step in the correct direction.
A good starting point for most
Most starting out users usually have the following setup: Editor with integrated AI suggestions that become helpful when set to manual instead of fully automatic. Until then, make a personal rule to never commit any changes until you have personally reviewed them making sure no change was made without your knowledge or understanding. This particular setup mitigates the risks of losing control over the codebase and increases the overall reading benefit it provides.