One of the more intriguing discoveries about ChatGPT is that it can write pretty good code. I tested this out in February when I asked it to write a WordPress plugin my wife could use on her website. It did a fine job, but it was a very simple project.
How to use ChatGPT to write: Resumes | Excel formulas | Essays | Cover letters
How can you use ChatGPT to write code as part of your daily coding practice? That’s what we’re going to explore here.
What types of coding can ChatGPT do well?
There are two important facts about ChatGPT and coding. The first is that it can, in fact, write useful code. The second is that it can get completely lost, fall down the rabbit hole, chase its own tail, and produce absolutely unusable garbage.
Also: I’m using ChatGPT to help me fix code faster, but at what cost?
I found this out the hard way. After I finished the WordPress plugin, I decided to see how far ChatGPT could go. I wrote out a very careful prompt for a Mac application, including detailed descriptions of user interface elements, interactions, what would be provided in settings, how they would work, and so on. Then I fed it to ChatGPT.
ChatGPT responded with just a flood of text and code. Then it stopped mid-code. When I asked it to continue, it vomited out even more code and text. I requested continue after continue and it dumped out more and more code. But… none of it was usable. It didn’t identify where the code should go, how to construct the project, and — when I looked carefully at the code produced — it left out major operations I requested, leaving in simple text descriptions stating “program logic goes here.”
Also: Okay, so ChatGPT just debugged my code. For real.
After a bunch of repeated tests, it became clear to me that if you ask ChatGPT to deliver a complete application, it will fail. A corollary to this observation is that if you know nothing of coding and want ChatGPT to build you something, it will fail.
Where ChatGPT succeeds, and does so very well, is helping someone who already knows how to code to build specific routines and get specific tasks done. Don’t ask for an app that runs on the menu bar. But if you ask ChatGPT for a routine to put a menu on the menu bar, and then paste that into your project, it will go quite well.
Also: How to use ChatGPT to create an app
Also keep in mind that while it appears ChatGPT has a tremendous amount of domain-specific knowledge (and it often does) it lacks wisdom. As such, it may be able to write code, but it won’t be able to write code containing the nuances for very specific or complex problems that requires deep experience to understand.
Use ChatGPT to demo techniques, write small algorithms, and write subroutines. You