Any tips for asking ChatGPT coding questions?
These days I keep asking GPT when I'm writing code, but sometimes it spouts nonsense and it pisses me off lol
How do you all write your prompts? Can I just paste the whole error message?
8 answers
My conclusion is that it’s faster to read the official docs than to spend time hunting for prompt tips. After using it for six months, I’ve found that asking only about the parts where I’m truly stuck and handling the basics myself is less stressful. Especially for the latest library APIs, the docs are simply the answer.
Make sure to specify the language and version. For example, 'Python 3.11, pandas 2.0'. Otherwise, it'll respond with outdated syntax and spam import errors. Also, when providing code, reduce it to a minimal reproducible example, and include both the part that doesn't work and the expected result—then the nonsense drops significantly.
This is how I use it. Honestly, I haven't felt much of a difference from role assignments like 'You are a senior backend developer.' Instead, it worked better not to trust the answer right away and to run it again with something like 'Point out any edge cases or errors in this code.' Hope this helps!
This is right lol
Well, that's a bit... Isn't GPT spouting nonsense not a prompt issue but just a model limitation? No matter how well you ask, it doesn't know what it doesn't know lol
Any source?
It's better to just use it as a reviewer. When you ask it to write code, it mixes in nonsense, but when you have it review code you wrote, it's surprisingly good at pointing out issues.
Pasting the full error message is the baseline, but it's much better if you add one line before it about what you're trying to do.