How I use ChatGPT as a coder (in 2024)

How I use ChatGPT as a coder (in 2024)

·

4 min read

OK this short blog is just to share how I use ChatGPT so far (up until this point, maybe that can change in the future) in the way I find the most effective.

And this is with ChatGPT 3.5, not 4.0, cuz I have not found any use case that I can benefit significantly to upgrade to Plus. And if I upgraded in that state of mind, I would be likely to keep that subscription and live in denial "Just keep the subscription, I'm sure one day I can find the benefit that worth it," then waste more time and money than necessary with it.

Ask it like a lawyer interviewing a witness

Do you know a rule of a lawyer when interviewing a witness? Ask questions that you know the answers.

The LLM at this stage still acts as a BBR - Big Boring Repeater. Whatever question you ask it, it acts like it is Googling fast, but not hard, and pick a random answer it finds. In the case of a coder, it is like searching on StackOverflow, but kind of more efficient.

So, if there is a question that you know even searching the Internet would not give you the answer, don't waste time asking ChatGPT. It's just a repeater of the most likely and closest answers, not an oracle.

Converse with it like with an instructor, not with a worker

ChatGPT is good at explaining things, especially the basic ones. And it will not judge you "Why do you ask such a stupid question?" Make use of that. E.g. I encounter a Power-shell script that I don't want to waste time looking up the parameters, so I paste it to ChatGPT and ask its help to explain:

Explain 7zip x "-o$deployTarget" $deploySource -r -aoa

Don't ask it to write codes to solve your problems. Ask it to give examples of how to solve a problem that is close to the one you need to solve, the more basic and simpler the better. Learn from these code examples to then actually do your job.

(So, for a colleague student, it is a good tutor, but don't expect it to do your homework)

Give it the signatures

I tend to ask ChatGPT to help write code examples to solve a certain problem, e.g. how to open a camera stream with JavaScript. If I just ask it like that, I will get a random implementation, each time significantly different from each other. And sometimes the examples will be way too different from my coding style, that it would take time for me to shape it to the way consistent with my code base.

So, one way to solve that is to give the signature of the method along the way to narrow down the scope, like this:

Write the JavaScript method to open the camera stream in the interop file. The method should start with this:

window.startCameraStream = async function (videoElementId, deviceId) {

Shotgun the questions

More than often, ChatGPT will give you the answer that does not work at first (sometimes due to hallucination), which you will have to either report what's not working for it to correct, or like me, you can ask it again but in a new conversation.

So, sometimes I find it more effective to just copy the same question and shotgun it in 1, 2, 3 conversations, and see which one provides the solution that works or that I like. I can also learn on all of them to conclude the optimal answer.

This is no different from when you read the answers on StackOverflow: You jump from answer to answer until you find one that works for you.


Overall, the role that I can expect from ChatGPT is to help me burden trivial mental labor, which I can save to resolve the tricky matters. That's why you can see I usually ask it questions on the tech stacks I'm not familiar with in the way that I can slowly learn them.