Few days ago, OpenAI announced “major improvements” to ChatGPT 4.
This announcement really seemed like Apple Store’s apps release note :
- fixed bugs
- improved app
which can usually be translated by : “fixed bugs, went to meetings and worked on things no one cares about”
So I had very low expectations for this new version.
But I have to be honest : ChatGPT 4 got REALLY good at coding .
I’ve been using it for a while for pair-programming (debugging, refactoring or juste writing specific methods). The code provided often failed to meet the requirements, so I sometimes took some inspiration from it but rarely used it as it was. ChatGPT4 also regularly hallucinated even after I asked him to specify his reasoning step by step before providing the solution, which led me to insult him once - or twice (and I still feel sorry for that).
Since few days, not only it stopped delving deep into the tapestry of engineering but it also started to provide code snippets which are fully functional and well written. He seems to understand way better the specifications, the requirements and the constraints he is given.
Here are few prompts techniques I use to get better answers :
-
Start by explaining the situation and the problem you are encountering (if any) or what you want to achieve. Give details about your stack and any other info you consider as important (for example a code snippet / error messages…). Avoid sharing secret informations (api keys for example).
-
Ask it to rephrase : “First, I want you to rephrase the situation / problem / constraints / requirements to make sure you perfectly understand it”.
-
Define the ideal solution : “Think step by step and give me a solution which is simple / modern / robust / clean / performant / easy to maintain / which fully respects the requirements and the constraints / which doesn’t introduce regressions”
-
Once you get the answer, you still can improve it by providing clear feedback !