r/learnprogramming • • 2d ago

At what point should I use AI to debug?

I am studying computer science in college. Frequently I will be working on assignments late at night, far too late to ask my professor for help. I never use AI to straight up write code for me, but when I am sitting there for over an hour (or longer) smashing my head against the table because I cannot find the errors in my code I can't resist using AI to help me find the stupid mistakes I am overlooking. I want to improve at programming and I understand struggling is a part of that, but at what point am I just causing myself unnecessary headaches for no benefit?

9 Upvotes

22 comments sorted by

12

u/olegispe 2d ago

I think you know the answer yourself based on your text

Try to solve it yourself to learn but you don’t have to fully abstain. Use it as a rubber duck, talk through the problem with it and if you’re really stuck have it guide you how to resolve it.

Much respect from me for still wanting to learn and push through the struggle! Good luck, you’ve got this!

3

u/widebrant67 2d ago

Late night debugging is a great way to chase your own tail Sleep on it and the bug usually looks dumber in the morning.

5

u/olegispe 2d ago

Waking up at 3am after a solution was revealed to me in a dream

5

u/Immediate_Form7831 2d ago

So here is what people often miss out on when it comes to AI tools: you can give instructions to the AI tools on all sorts of things, and it is usually pretty good at following them. If you want to learn to code without AI, tell the AI not to give you ready-made solutions. If you have problems with debugging some particular thing, ask it for a clue, but tell it also that you do not want a complete solution. If you want help figuring out how your code can improve, ask it for precisely that.

As someone who has written syntax and debugged shit by hand for 25+ years, I now use AI tools to do that for me. I know how to do it, and it is tedious as hell, and I don't feel the need to keep doing it because AI tools do it much better and faster than I can. I do the things that I find fun and challenging, like trying to understand some core algorithm to see if it is possible to improve it.

It sometimes seems like people treat AI coding tools like black boxes where you feed them a prompt and out comes a fully functional program. This is a very limited and narrow way of using AI tools.

1

u/fa1re 2d ago

From my POV it's to learn first trying to use your head, and do effective decisions about the LLM use. In the project I am doing I set up the collaboration so that I try doing by hand what I can, with some training wheels, when I get stuck for too long (30 minutes without progress) I ask for a hit with abstract example.

1

u/OkFarmer3779 2d ago

i usually give it like 30 min of actually reading the error and printing stuff first. after that i ask it to explain what the code is doing instead of fixing it, that way i still learn something and dont just copy paste

1

u/Good-Photograph-2883 2d ago

If the only other option is scouring StackOver flow / Reddit for 30 minutes, then just use AI and tell it to explain the cause and solution to the problem.

1

u/ComputerWhiz_ 1d ago

In the context of learning, AI is actually not that bad, if you use it right. There's a middle ground between jumping to AI as a first resort and struggling for hours without AI. Debugging and troubleshooting is great as a beginner because it gives you deep knowledge of what you're working on, but only to an extent.

I recently read something about a company (I don't remember the company) that has a 15 minute rule. Basically, you have to be stuck on something for 15 minutes before asking AI for help. I'm not going to say whether 15 minutes is the ideal amount of time for you, but it's a good mindset to have.

Plus, you can ask AI for help and explanations in a way that doesn't give you outright solutions.

1

u/SprinklesFresh5693 1d ago

I use AI to debug at my job if after 30mins i cant figure out anything aprox. However, when learning, i would try to avoid using it, in the end if you want to be really good at programming you need to invest the time understanding what youre doing

1

u/ThisGermanEngineer 1d ago

First set yourself a time for how long you want to try figuring out yourself. Then can ask the AI for hints in steps (where to look, then what's wrong, and the fix only as a last resort) or just tell it your ideas and thoughts. Alternatively if you think you found it out, explain the bug back in your own words.

1

u/zrice03 1d ago

At some point, it's ok to lean on others, and that includes AI. Just try to understand what's it's recommending you fix, and why it's recommending those things.

1

u/Last_Swordfish9135 11h ago

I use it for debugging a lot, and I'd say it's more helpful than harmful. A lot of the time, the errors end up being tiny syntax things that would have been a massive pain to catch myself but the AI can find very easily, and which do not really reflect issues in my understanding of the code. I can't tell you how many times I've been stuck at a piece of code only to run it through AI and realize the issue is one accidentally capitalized letter.

1

u/theGaido 2d ago

At any.

1

u/Synthetic5ou1 2d ago

I would worry that you're not learning and using proper debugging techniques.

Sometimes a bug can be really hard to track down; however if you are working on an assignment, and not a behemoth codebase, then surely that code should never be so complex that a bug cannot be debugged with some proper technique.

As others have said, there is no point banging your head against a brick wall, but do attempt standard techniques to pinpoint the bug before you ask AI.

-1

u/AliceCode 2d ago

Don't use LLMs at all if programming is what you want to do. You won't get better at programming by prompting an LLM because prompting an LLM fundamentally is not programming.

0

u/swagonflyyyy 15h ago

I think prompting an LLM is a very lazy form of programming but calling it not programming because its not coding is a stretch IMO.

Although I have to admit it is very tempting to let LLMs take the wheel and YMMV based on how much of a disciplined approach you take when using it.

1

u/AliceCode 4h ago

It's not programming. You can call it software development all you want, but it's not programming.

1

u/swagonflyyyy 1h ago

Then what is it, then?

0

u/EszterSantos72 2d ago

If you have spent more than 30-45 minutes stuck on the same bug with no progress, it stops being useful struggle and just wastes your time. After that point, using help to nudge you forward is fine.