–> <!–>
Screenshot by David Gewirtz/ZDNETJust as it suggested, I updated the fourth parameter of the add_filter() function to 2, and it worked!
ChatGPT took segments of code, analyzed those segments, and provided me with a diagnosis. To be clear, in order for it to make its recommendation, it needed to understand the internals of how WordPress handles hooks (that’s what the add_filter function does), and how that functionality translates to the behavior of the calling and the execution of lines of code.
Also: I asked ChatGPT to write a WordPress plugin I needed. It did it in less than 5 minutes
I have to mark that achievement as incredible – undeniably ‘living in the future’ incredible.
What does it all mean?
As I mentioned earlier, debugging is a bit of art and a bit of science. Most good development environments include powerful debugging tools that let you look at the flow of data through the program as it runs, and this does help when trying to track down bugs.
But when you’re stuck, it’s often difficult to get help. That’s because even a close colleague may not be familiar with the full scope of the code you’re debugging. The program I’m working on consists of 153,259 lines of code across 563 files – and as programs go, that’s small.
Also: These experts are racing to protect AI from hackers
So, if I had wanted to get help from a colleague, I might have had to construct a request almost identical to the one I sent to ChatGPT.
But here’s something to consider: I remembered to include the handler line even though I didn’t realize that’s where the error was. As a test, I also tried asking ChatGPT to diagnose my problem in a prompt where I didn’t include the handler line, and it wasn’t able to help. So, there are very definite limitations to what ChatGPT can do for debugging right now, in 2023.
Also: The best AI chatbots to try
Essentially, you have to know how to ask the right questions in the right way, and those questions need to be concise enough for ChatGPT to handle the whole thing in one query. That’s something that takes actual programming knowledge and experience to know how to do.
The potential cost of AI-assisted debugging
Keep in mind that the AI doesn’t replace all your other debugging tools. You’ll still need to step through code, examine variable values, and understand how your code works. I found that ChatGPT can help identify areas to look at and provide some simple code blocks. In a way, it’s a lot like using coding templates, except you don’t have to pre-build those templates to incorporate them into your code. It’s a helper, but it’s not a coding replacement.
Also: Can AI code? In baby steps only
Could I have fixed the bug on my own? Of course. I’ve never had a bug I couldn’t fix. But whether it would have taken two hours or two days (plus pizza, profanity, and lots of caffeine), while enduring many interruptions, that’s something I don’t know. I can tell you ChatGPT fixed it in minutes, saving me untold time and frustration.
ZDNET’s Tiernan Ray recently published a fascinating article that cites a Texas Tech University study showing that AI performance in coding is still highly unreliable. Keep this in mind, because if AI is struggling to write complex code, it will have even more difficulty debugging complex code.
Most programmers have a range of debugging tools at their disposal and choose the tools they’re going to use based on whatever problem they’re currently trying to diagnose. There is no doubt that AI tools can be added to that toolbox. But be careful about overusing them. Because AI is essentially a black box, you’re not able to see what process the AI undertakes to come to its conclusions. As such, you’re not really able to check its work.
The potential cost of this is enormous. For traditional debugging tasks, the programmer is always able to see exactly what changes are being incorporated into the code. Even if those changes don’t always work, the programmer is certainly aware of why those changes were attempted. But when relying on AI-based debugging -even in part – the programmer is separated farther from the code, and that makes the resulting work product far harder to maintain. If it turns out there is a problem in the AI-generated code, the cost and time it takes to fix may prove to be far greater than if a human coder had done the full task by hand.
As I showed above in my examples, AI coding tools can help (at least two times out of three). But they don’t always work and they should never be relied on as a substitute for real understanding. Failure to remember that could be costly, indeed.
Looking toward the (possibly dystopian) future
I see a very interesting future, where it will be possible to feed ChatGPT all 153,000 lines of code and ask it to tell you what to fix. Microsoft (which owns GitHub) already has a public beta release of a Copilot tool for GitHub to help programmers build code. Microsoft has also invested billions of dollars in OpenAI, the makers of ChatGPT.
While the service might be limited to Microsoft’s own development environments, I can see a future where the AI has access to all the code in GitHub, and therefore all the code in any project you post to GitHub.
Also: I asked ChatGPT to write a short Star Trek episode. It actually succeeded
Given how well ChatGPT identified my error from the code I provided, I can definitely see a future where programmers can simply ask ChatGPT (or a Microsoft-branded equivalent) to find and fix bugs in entire projects.
And here’s where I take this conversation to a very dark place.
Imagine that you can ask ChatGPT to look at your GitHub repository for a given project, and have it find and fix bugs. One way could be for it to present each bug it finds to you for approval, so you can make the fixes.
But what about the situation where you ask ChatGPT to just fix the bugs, and you let it do so without bothering to look at all the code yourself? Could it embed something nasty in your code?
Also: Bard vs. ChatGPT: Can Bard help you code?
And what about the situation where an incredibly capable AI has access to almost all the world’s code in GitHub repositories? What could it hide in all that code? What nefarious evil could that AI do to the world’s infrastructure if it can access all our code?
Let’s play a simple thought game. What if the AI was given Asimov’s first rule as a key instruction. That’s a “robot shall not harm a human, or by inaction allow a human to come to harm”. Could it not decide that all our infrastructure was causing us harm? By having access to all our code, it could simply decide to save us from ourselves by inserting back doors that allowed it to, say, shut off the power grid, ground planes, and gridlock highways.
I am fully aware the scenario above is hyperbolic and alarmist. But it’s also possible. After all, while programmers do look at their code in GitHub, it’s not possible for anyone to look at all the lines in all their code.
Also: How to use ChatGPT to write Excel formulas
As for me, I’m going to try not to think about it too much. I don’t want to spend the rest of the 2020s in the fetal position rocking back and forth on the floor. Instead, I’ll use ChatGPT to occasionally help me write and debug little routines, keep my head down, and hope future AIs don’t kill us all in their effort to “not allow a human to come to harm.”
Do you find the fact that ChatGPT can debug code helpful or terrifying? Do you think AIs will murder us in our sleep, or do you think we’ll be watching our doom with our eyes wide open? Or are you, like me, going to try not to think about it too much because it makes your head hurt? Talk to me in the comments below. While you still can.
You can follow my day-to-day project updates on social media. Be sure to follow me on Twitter at @DavidGewirtz, on Facebook at Facebook.com/DavidGewirtz, on Instagram at Instagram.com/DavidGewirtz, and on YouTube at YouTube.com/DavidGewirtzTV.
–>
Source: Information Technologies - zdnet.com