ChatGPT: A Powerful Tool for Writing Code
ChatGPT is a powerful AI language model developed by OpenAI that can write code. However, using it to write complete applications is not recommended. ChatGPT can be used to help coders to build specific routines and complete specific tasks. In this article, we will explore how to use ChatGPT to write code and how to avoid its limitations.
One of the most intriguing discoveries about ChatGPT is that it can write pretty good code. In February, David Gewirtz of ZDNet tested ChatGPT by asking it to write a WordPress plugin for his wife’s website. ChatGPT did a fine job, but it was a very simple project.
ChatGPT can write code for specific tasks, such as writing resumes, Excel formulas, essays, and cover letters. However, it can get lost and produce unusable garbage. If you ask ChatGPT to deliver a complete application, it will fail. If you know nothing about coding and want ChatGPT to build you something, it will fail.
ChatGPT can help coders to build specific routines and complete specific tasks. For example, you can ask ChatGPT for a routine to put a menu on the menu bar, and then paste that into your project. ChatGPT can also help you break down a bigger project into chunks, and then you can ask it to help you code those chunks.
While ChatGPT appears to have a tremendous amount of domain-specific knowledge, it lacks wisdom. 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 require deep experience to understand.
To use ChatGPT to write code, the first step is to decide what you are going to ask of ChatGPT. Decide what you want your function or routine to do, or what you want to learn about to incorporate into your code. Decide on the parameters you’re going to pass into your code and what you want to get out. And then look at how you’re going to describe it.
When describing your code, imagine you’re paying a human programmer to do this. Are you giving that person enough information to be able to work on your assignment? Or are you too vague and the person you’re paying is more likely to either ask questions or turn in something entirely unrelated to what you want?
Let’s say you want to be able to summarize any web page. You want to feed it something like this article and get back a short summary that’s well-considered and appropriate. As your input, you’ll specify a web page URL. As your output, it’s a block of text with a summary.
With the rise of AI tools, it makes more sense to use an AI library to do an intelligent extract and summary. One of the places ChatGPT excels (and it’s also an area you can easily verify to avoid its authoritative-but-wrong behavior pattern) is finding libraries and resources.
OpenAI sells API access to the GPT-3 and GPT-4 engines that will do exactly what we want. But let’s assume we don’t want to pay transaction fees. So let’s look at interacting with ChatGPT to figure out how to use such a tool, for free, with a project that runs in PHP.
Start with a prompt that is designed to elicit information about what libraries would provide the functionality you want. A library is a body of code a programmer can access that does a lot of the heavy lifting for a specific purpose. A big part of modern programming is finding and choosing the right libraries.
In this case, you’re looking at blocks of code written by other people that will summarize text. Here’s an example prompt: “Describe ten different open source AI libraries (and the languages they work with) that I can use to generate a summary of the main core contents of a web page. I will be using PHP.”
In conclusion, ChatGPT is a powerful tool for writing code, but it has its limitations. It can help coders to build specific routines and complete specific tasks, but it cannot write complete applications. To use ChatGPT to write code, you need to be specific about what you want and provide enough information for ChatGPT to work on your assignment.