Do's and Don'ts of Coding with ChatGPT
While it’s true that considerable uncertainty swirls around how AI will affect the software industry, I say it’s never been a better time to be a programmer. In terms of building and accomplishing things, there’s never been an easier, less frustrating, and more productive time to program. While genAI’s utility may have some skeptics in other fields, its usefulness and application for coding tasks is unambiguous and transformative.
Having myself been experimenting with and using ChatGPT as a coding tool almost since the day it came out, and having been coding professionally long before that, I have about as much experience with the technology as anyone alive. I believe something of an art and science of working with AI is taking shape. In my mind’s eye I can to see the outline of a “textbook” on how to integrate AI into coding efforts begin to formulate. There really are best practices for getting the most out of the tech and it’s possible to tell power users apart from regular or inexperienced users. While unfortunately I don’t quite have the time to write a fully blossomed treatise on said topic, I can share some of the quintessential findings that would go into it.
So here are some dos and don’ts of AI assisted coding, along with some general observations and commentary.
DO: Use ChatGPT as an analytic tool to break down and explain code . ChatGPT is excellent at deconstructing chunks of code and theorizing about what it does and how it works. If you encounter code that you have a hard time understanding, it’s worthwhile to run it through ChatGPT and get its take on it.
DO: Use it to quickly yield boilerplate you understand through and through and can quickly validate at a glance to thereby free up mental space to work on more novel, complex tasks. ChatGPT excels at doing the repetitive, boring chore work that you know how to do but don’t want to do. Whereas previously coders might write a script to handle these tasks, and such scripting may still be necessary at scale, much of it can now be handled by delegating the busywork to ChatGPT. The important thing about these tasks is that you already know how to do them, so you can quickly glance at what the bot has produced to confirm its validity.
DO: Use it to validate and proofread syntax. One of the most frustrating, time-consuming parts of coding is having the right idea for something, but struggling to get some of the more complicated syntax formations right or overlooking some other seemingly minor but significant detail. Often, it’s possible to come up with conceptually correct pseudo-code, but to have things off only slightly in terms of syntactic correctness. ChatGPT can help get you over that hump and allow you to proceed free of the cognitive load of having to remember inessential details. By “inessential” I mean details which are not integral to your goals, but are merely part of the cognitive cost of implementing them with the tools available. This capacity to rapidly unblock you by catching tiny discrepancies is of enormous time-saving value.
DO: Still maintain curated libraries and repositories of code you take pride in and claim ownership of.
One way genAI appears to be changing the culture in general is a shift from persistent, revisited public information to transient, one-time-use, on-the-fly, generated private information. Instead of searching for a website with info, such as stack overflow, where a piece of code has had many eyes on it and many visitors and has been thoroughly discussed and crowd sourced, it’s now becoming increasingly more common to go to ChatGPT and ask it to cough up code ad hoc, in a private, isolated session that is not connected to the public internet. As a result, how we circulate code and information has become less communal and more disconnected. Churn code is on the rise, because rather than refining and maintaining thoughtful, gradually extended codebase with consistent design patterns, lazy devs are just rushing to ChatGPT and copying over its disjointed code snippets that have not been systematically absorbed into an well thought out overall architectural plan.
I suspect we will soon feel the loss of communally sourced, contributed and maintained code as the proportion of AI generated code to human made code grows. This overall loss of community context will prove disempowering in time, as we tend to value code less as the labor cost of obtaining workable code decreases.
DO: Ask yourself what you contribute to the overall value package. Lately I have observed people getting into programming for the first time, and I find it almost disturbing how this new generation operates. They serve essentially as no more than handmaidens or midwives to the AI, passively delivering and handing off what it generates with whatever prompts they can cobble together with minimal insight and comprehension. If these admittedly anecdotal observations are a sign of things to come, I worry that we are going to eventually find ourselves with a knowledge collapse, as lose deep expertise and hard-won skills.
Such a generation of quasi-coders might get good enough to cheat on their homework, but it becomes immediately obvious how less far someone can go when it’s not their programming knowledge that guides the activity. This “AI-driven workflow” rather than AI-integrated workflow, is going to get less milage on it. When those who are not knowledgable about programming use ChatGPT to code, they’re not drawing from a structured, organized mental model that determines what they ask for and how everything falls in place with respect to the overall picture. As soon as human knowledge and guidance takes a backseat to the AI, we’ve disenfranchised ourselves.
The bottom line is you should still be writing the essential, project-specific code that only you could write, because only you have a grasp of the business requirements and contextual nuances of the problem, and only you see how it should all fit together.
DO: Keep experimenting. People are constantly discovering new capabilities for these amazing technologies. One of the first rules of genAI usage is that the limit of imagination should not be taken as a limit of the technology. It’s possible to reach a state of stagnancy with genAI, where you’re no longer blown away by what it can do so your curiosity dwindles and you get diminishing returns from it. Don’t let this cold spell freeze you. What you put in really influences what you get out, so go wild and see what you can invent.
DON’T: Use it in place of official documentation. It’s always better to take it from the horse’s mouth when dealing with a specific library or software component. Documentation that is intentionally and specifically written to address a certain software entity should always be consulted and deferred to as a more definitive source of truth. Furthermore, exercise caution when asking it to explain the latest updates or newest releases. ChatGPT lags behind the expanding frontier of software development. If you’re having a hard time finding out about something on the internet, then you will probably have a hard time finding out about it though ChatGPT.
DON’T: Get lazy or too complacent. GenAI coding tools have made it so that almost anyone can produce more and get done with code. I anticipate that employer expectations will adjust accordingly. If you are using genAI to get about as much done as you used to with less effort, I’d start getting a little uncomfortable. GenAI should embolden and enable you to be more ambitious, and to take on projects that perhaps once scared you away. The bottom line is ChatGPT will tempt you to get lazy, but you must instead let its existence encourage you to raise the bar for yourself.
DON’T: Assume it understands the context in which your problem or goal exists. Much of what defines skillful chatbot use is problem formulation: the ability to describe your problem so as to set the bot up for success. As when dealing with other people, it’s possible to fall for the “curse of knowledge”, the cognitive bias whereby one assumes that the person being engaged with is equally as informed as you. Chatbots aren’t doing any thinking, and they don’t share the context you have on your problem. One of the several reasons human programmers will continue to be necessary is that they are way better at integrating information cross-functionally across domains.
Translation: people can put separate things together and move between boundaries much better than AI. We can deal with fuzzy, multimodal and horizontal environments that span varied socio-technical domains. A human developer is pushing to github, posting to slack, writing code in an editor, attending meetings, and updating the status on Jira tickets, all in a days work. A bot is stuck in its box, and can only see what we go there to show it.
DON’T: Use it blindly in a rush to generate code that’s beyond your capacity to understand. This is a significant one, because a lot of non-coders are going to venture into AI-assisted coding not knowing what they’re doing. But if you can’t understand what ChatGPT has produced, you are wandering blindfolded. For all but the most modest of projects this is a recipe for disaster. It’s called CoPilot, not AutoPilot!
DON’T: Stop learning. Related to the previous point, the use of AI to generate code can either be an excuse to skip thinking for yourself, or it can be an opportunity to learn something new. Developers are accustomed to working in information rich environments thanks to search engines and the internet. For a long time, developer’s own memorized knowledge has only been part of their value-add. Their minds also serve as integration centers, where they find and bring together information from across the web to one location and render it usable for the mission at hand. While doing this gathering, however, developers often learn a lot. ChatGPT can be a great teacher also, so make sure that while using it, your mind becomes an imprint and record of all corrections, reminders, and lessons it has to offer.
Conclusion
ChatGPT and similar AI tools have enormous potential for software development. We’ve only scratched the surface as to what’s possible. When human developers bring context and a plan to shape and guide the bot’s activity, the result is more and better code. ChatGPT has far from made software development effortless. What it has done is offered developers a challenge to push their skills to the limit and do more in a shorter amount of time.
To my thinking, generative AI is more than a new set of tech tricks. It heralds a new paradigm of computing that will change how people interact with computers and do knowledge work across the board. This new way of computing is more verbal, conversational, and contextual, and will reward those with the linguistic and ideational skills to communicate and manage bots while maintaining a bigger picture in mind. Coding itself will be affected by this revolution, and as coders it behooves us to evolve with the times.