Skip to main content

Debugging AI-Generated Code

ChatGPT generates code. 😎

It's buggy. 😭

What do you do?

If you're like me, you spend a whole day refining your prompt and testing the resultant code. Over and over. (Still better than spending days learning a new programming language.)

Tweak the language. Give more specific instructions. Describe the data in more detail.

Copy-paste. Run.

More bugs.

F$¢k.


Get desperate. Tell ChatGPT it sux.

👤Me: "Why is it producing more rows than expected?"

💻ChatGPT: "Oh, my bad. Didn't do the join operation properly. Here's a rework."

Hmm. Run it. Different error. But maybe we're onto something.

👤Me: "Why am I getting the error: <error>?"

💻ChatGPT: "Oh, my bad. Didn't properly instantiate and initialise the data structure. Here's a rework."

Hmm. Copy. Paste. Run. 

Mother of God, it works. 🤯

So what did we learn today, kids? 

ChatGPT doesn't just generate code (the easy bit). It also debugs compilation errors (the hard bit) and logic errors (the bash-your-head-on-the-desk bit). 

Programming this way changes from being instruction-focussed ("Do this, then that") to outcome-focussed ("Why are you giving me this, not that").

Is Generative AI going to take jobs? I don't know. It has, however, definitely saved work.

No Stack Overflow searches. No reading language references. No repurposing trivial examples. 

The AI does add another body into the coder-code-computer dance, but it would be a mistake to use it like a search engine with extra features, just as you wouldn't walk a plumber through fixing your tap. It's more like a conversation between customer (me) and coder (AI). Programming is still iterative, trial-and-error, but now driven as much by the AI as by you.

Comments

Popular posts from this blog

Transcode to PSP using Handbrake

Source: Handbrake 0.9.9.5530 64-bit edition Target: (Phat) Playstation Portable PSP-1000 , System Software: 6.60 Many internet articles on how to transcode video to PSP using Handbrake have not worked for me. Even the most helpful are incomplete. I hope this post will help fill in the blanks. There is no longer any PSP preset for Handbrake, but from what I can gather, the preset had only limited success as the x264 encoder would change syntax and settings between versions. Other presets that may have worked before, like 'iPod' and 'Apple-Universal' now do not. Here is what worked for me, step by step:

Scatterbox - build an Android Tor Socks Proxy Server

Cloak your location and create a firewall bypass device with a smartphone. 🕵Uses the Tor network . Does not require root. 1 - from Google Play, download and install: Orbot Orweb browser Socks Server Ultimate (Optional)

Dismissing Racism

Whenever white people kill people of colour, as in 2021's anti-Asian shootings in Atlanta Georgia , this sort of counter-commentary appears: "Since the killing of six Asian women who worked in massage parlors in Atlanta, the media has amplified the false narrative that “white supremacy” is to blame.  ... official crime stats show that white people are significantly underrepresented in terms of the violent crime threat they pose to Asians."  ... citing FBI statistics , whereas whites comprise 62% of the population, they committed 24% of crimes against Asians in 2018.  In comparison, blacks, who comprise 13% of the population, committed 27.5% of all violent crimes against Asian Americans in 2018.  So clearly, white people do not represent the biggest crime threat to Asian Americans." Not only is this an attack on the media and its imagined agenda, it also implies that Asians can't tell who's assaulting them.