4 ms·
I've been using the openai apis to write and edit code for 3-4 months now. So I think that makes me an old timer (ha!). I have also been building tooling for im
by anotherpaulg 3y ago
I've been using the openai apis to write and edit code for 3-4 months now. So I think that makes me an old timer (ha!). I have also been building tooling for improving the chat based coding experience [0]. All of this work has given me an opportunity to think about how to work best with GPTs on coding, and I've shared some thoughts about this in the past [1].
Here are some of my thoughts on how to code with chatgpt. Many overlap with topics covered in the Nature article.
- It really does help to think of chatgpt as a junior coder. I mentioned this in the writeup about my first AI coding project [2]. A bunch of things in this list would also be helpful when working with a junior dev.
- GPT isn't good at code architecture. It will repeat code and take the shortest, laziest path to coding up your request. You need to walk it through changes like you might with a junior dev. Ask for a refactor to prepare, then ask for the actual change. Spend the time to ask for code quality/structure improvements.
- Don't copy-and-paste between a chat session and your files. Use a tool like Copilot [3] or aider [0] that will give GPT your code to edit and apply its changes automatically. This is critical as it removes friction and lets you iterate quickly on code with GPT.
- GPT is amazing at generating fresh new self-contained code. It takes more skill and better tools to work with it to edit existing code.
- Break down a big change and ask for a series of smaller, self contained steps. This is a smart way to code solo, but really helps GPT succeed at more complex code modifications.
- GPT has a wide breadth of coding knowledge, and impeccable command of syntax... but it is sometimes overconfident about details. So it will usually choose the right library for a task, but sometimes make an error about the details of the api/method/params. Paste doc snippets or error messages into the chat and it will fix those bugs.
- GPT is really strong at churning out good boilerplate and roughing in a solution. This reduces the activation energy required to start larger changes or changes which will require unfamiliar libraries/packages/languages. GPT can can quickly prepare the ground for you to do the interesting work.
- If you can, use gpt-4 (not gpt-3.5-turbo) since it can successfully generate larger, more complicated code changes.
[0] https://github.com/paul-gauthier/aider https://github.com/paul-gauthier/aider
[1] https://news.ycombinator.com/item?id=36020809 https://news.ycombinator.com/item?id=36020809
[2] https://github.com/paul-gauthier/easy-chat https://github.com/paul-gauthier/easy-chat
[3] https://github.com/features/copilot https://github.com/features/copilot
- SOLAR_FIELDS 3y agoI’ve been using aider since last week when I got GPT4 api access and it has easily quadrupled my coding productivity. I didn’t realize how slow it was to constantly be pasting and copying in the browser until I started using it
- anotherpaulg 3y agoGlad to hear aider is working well for you!
- agentcoops 3y agoReally fantastic advice. The only corollary that I'll over-emphasize to those reading: do not rely on ChatGPT and learn to work with the APIs directly -- or tools built explicitly for your purpose. I've also been working with the APIs directly for about that time and I only get more depressed daily reading the horrible takes about GPT's problems based only off of ChatGPT (and hearing about how even many companies try to use the product). GPT has forever changed how I interact with computers.
- james-revisoai 3y agoGreat tooling. I was using CodeGPT but this looks better. And it's exciting to have those command line options to easily insert other contextual input like command outputs. Can I ask about your plans? CodeGPT planned to add semantic embeddings of code, but I haven't seen any updates for quite a time. The idea being that, like walking an Abstract Syntax Tree of the code, you could include relevant functions and function definitions(/classes/constants/etc), to help improve output quality. Alongside what you note with module/library versions and pasting in doc snippets, I have often found is necessary to include package.json files to nudge the results towards the right API calls. I think semantic code search might push it finally to being able to work even on comprehensive, multi-service style repos. For MVC or services architected solutions, I think this could be more helpful than including whole files - though it may be overkill - do you have any thoughts on doing this?
- anotherpaulg 3y ago