Following up on the general guidance I offered Epi 554 last week, this week I tried to get specific about how to use AI assistance in debugging. I think there is room for improvement, but I’m going to get it out to you, and maybe you’ll tell me how to improve.
Debugging 1: When the code fails
Maybe I’ve told you that AI is BS. But that doesn’t make it useless.
Useful for debugging: use it so that you don’t stay stuck for long
example: error in code from Lab 2, shown below:

(if you know how to fix this… don’t worry you’ll have an error msg that is less obvi soon; and if you are above-average in debugging… this approach might make you worse!)
Teach an advanced AI technique called “Prompt Engineering“, example: paste error, type “why?” — aside: be polite in your prompts, for a better world and for better answers. Let’s not go through the details of the answer in detail — I want to focus on how and when to ask
- You can be more verbose, e.g. you can explain what you were trying to do, paste your error, and ask why you got this error and if it has ideas on how to fix the error that you got.
- You can also use the first precept of prompt engineering: tell AI who you want it to be. e.g. “You are a friendly and expert teaching assistant.” or “You are a busy and distracted professor.” (?)
- Customize as preferred, e.g. if appropriate, you can start with “you answer in English, but you know that I speak Spanish as a native and English is not my first language.”
You try: here is an error to work with [[I didn’t actually come up with this]], and an answer that still doesn’t fix it. What might you ask next?
Lauren Wilner (Epi 560 TA) says: For debugging, I have found that ChatGPT is mediocre. I give it the code I ran and the error I got, generally, but I find that often it gives me either (1) code that has the same error again or (2) new code that has a different error.
Summary: AI is BS, not useless; Useful for debugging; don’t stay stuck for long, prompt with code example, and polite request for help. Keep convo going if necess. It is just imitating the way words often hang together in online text, like stack overflow and cross validated, but if it gets your code to run… then you have running code!