{"id":1192567,"date":"2023-10-15T14:08:00","date_gmt":"2023-10-15T18:08:00","guid":{"rendered":"https:\/\/www.prime-wow.com\/?p=1192567"},"modified":"2023-10-15T14:08:00","modified_gmt":"2023-10-15T18:08:00","slug":"ok-so-chatgpt-just-debugged-my-code-for-real","status":"publish","type":"post","link":"https:\/\/www.prime-wow.com\/?p=1192567","title":{"rendered":"&#039;OK, So ChatGPT Just Debugged My Code. For Real&#039;"},"content":{"rendered":"<p>ZDNet&#8217;s senior contributing editor also maintains software, and recently tested ChatGPT on two fixes for bugs reported by users, and a new piece of code to add a new feature, It&#8217;s a &#8220;real-world&#8221; coding test, &#8220;about pulling another customer support ticket off the stack and working through what made the user&#8217;s experience go south.&#8221; First&#8230; <\/p>\n<p>please rewrite the following code to change it from allowing only integers to allowing dollars and cents (in other words, a decimal point and up to two digits after the decimal point).<\/p>\n<p>ChatGPT responded by explaining a two-step fix, posting the modified code, and then explaining the changes. &#8220;I dropped ChatGPT&#8217;s code into my function, and it worked. Instead of about two-to-four hours of hair-pulling, it took about five minutes to come up with the prompt and get an answer from ChatGPT.&#8221;<br \/>\nNext up was reformatting an array. I like doing array code, but it&#8217;s also tedious. So, I once again tried ChatGPT. This time the result was a total failure. By the time I was done, I probably fed it 10 different prompts. Some responses looked promising, but when I tried to run the code, it errored out. Some code crashed; some code generated error codes. And some code ran, but didn&#8217;t do what I wanted. After about an hour, I gave up and went back to my normal technique of digging through GitHub and StackExchange to see if there were any examples of what I was trying to do, and then writing my own code. <\/p>\n<p>Then he posted the code for a function handling a WordPress filter, along with the question: &#8220;I get the following error. Why?&#8221;<br \/>\nWithin seconds, ChatGPT responded&#8230; Just as it suggested, I updated the fourth parameter of the add_filter() function to 2, and it worked! <\/p>\n<p>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&#8217;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. I have to mark that achievement as incredible \u2014 undeniably &#8216;living in the future&#8217; incredible&#8230; <\/p>\n<p>As a test, I also tried asking ChatGPT to diagnose my problem in a prompt where I didn&#8217;t include the handler line, and it wasn&#8217;t able to help. So, there are very definite limitations to what ChatGPT can do for debugging right now, in 2023&#8230; <\/p>\n<p>Could I have fixed the bug on my own? Of course. I&#8217;ve never had a bug I couldn&#8217;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&#8217;s something I don&#8217;t know. I can tell you ChatGPT fixed it in minutes, saving me untold time and frustration.<\/p>\n<p>The article does include a warning. &#8220;AI is essentially a black box, you&#8217;re not able to see what process the AI undertakes to come to its conclusions. As such, you&#8217;re not really able to check its work&#8230; 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.&#8221; <\/p>\n<p>But it also ends with this prediction. &#8220;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&#8230; 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.&#8221;<\/p>\n<p \/>\n<div class=\"share_submission\" style=\"position:relative\">\n<a class=\"slashpop\" href=\"http:\/\/twitter.com\/home?status='OK%2C+So+ChatGPT+Just+Debugged+My+Code.+For+Real'%3A+https%3A%2F%2Fdevelopers.slashdot.org%2Fstory%2F23%2F10%2F15%2F185245%2F%3Futm_source%3Dtwitter%26utm_medium%3Dtwitter\"><img decoding=\"async\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2023\/10\/twitter_icon_large-569.png\" \/><\/a><br \/>\n<a class=\"slashpop\" href=\"http:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fdevelopers.slashdot.org%2Fstory%2F23%2F10%2F15%2F185245%2Fok-so-chatgpt-just-debugged-my-code-for-real%3Futm_source%3Dslashdot%26utm_medium%3Dfacebook\"><img decoding=\"async\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2023\/10\/facebook_icon_large-284.png\" \/><\/a><\/p>\n<\/div>\n<p><a href=\"https:\/\/developers.slashdot.org\/story\/23\/10\/15\/185245\/ok-so-chatgpt-just-debugged-my-code-for-real?utm_source=rss1.0moreanon&amp;utm_medium=feed\">Read more of this story<\/a> at Slashdot.<\/p>\n<p>&#013;<br \/>\n&#013;<br \/>\nSource: Slashdot &#8211; <a href=\"https:\/\/developers.slashdot.org\/story\/23\/10\/15\/185245\/ok-so-chatgpt-just-debugged-my-code-for-real?utm_source=rss1.0mainlinkanon&amp;utm_medium=feed\" target=\"_blank\" rel=\"noopener\">&#8216;OK, So ChatGPT Just Debugged My Code. For Real&#8217;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ZDNet&#8217;s senior contributing editor also maintains software, and recently tested ChatGPT on two fixes for bugs reported by users, and a new piece of code to add a new feature, It&#8217;s a &#8220;real-world&#8221; coding test, &#8220;about pulling another customer support &hellip; <a href=\"https:\/\/www.prime-wow.com\/?p=1192567\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1192568,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,110],"tags":[100],"class_list":["post-1192567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-slashdot","category-unfiltered-rss","tag-slashdot"],"_links":{"self":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts\/1192567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1192567"}],"version-history":[{"count":0,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts\/1192567\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/media\/1192568"}],"wp:attachment":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1192567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1192567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1192567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}