How I use AI for Software Development
I admit it, I have asked ChatGPT at least 17 times how to center a div!
I admit it, I have asked ChatGPT at least 17 times how to center a div!
The internet is full of tips and tricks for How To Use ChatGPT, Prompt Engineering 101, How To Become a 10X Developer Using AI and so on and I thought I would add to all that noise and write a bit about how I use AI in my daily life as a Software Developer. ’Cause why not? I’m sure the world needs this post!
To be clear I’m not talking about how I use AI in my projects to add awesome functionality that would have taken a team of developers months or years to build just a few years ago (and that’s not a flex, that’s just a reflection on the current state of the world), but about the tools I use during software development to make stuff faster and help me avoid destroying my computer in frustration.
The tools I use
ChatGPT
I most often use the very shitty web version of ChatGPT (seriously how can it still be that shitty? We’re talking about a multibillion company having a chat UI that’s worse than what a few CS students can hack together in a month), I’m a premium subscriber and by now I always default to GPT-4 and only use GPT-3.5 when my credits run out (you only get 20 questions every 3 hours).Copilot
I only use the autocomplete functionality, I’ve tried the other features but all results I got were worse than GPT-4 in the browser where I have full control over what information I give it and how I prompt, still the idea of Copilot X is promising and I’ll for sure try it again in the future.
You might be wondering: Hey, why don’t you use <insert some new AI thing>? The thing is there is a tradeoff between what newer tools can offer you and the time it takes to learn a new tool. So while I believe it’s always worthwhile to learn new things, tools and frameworks, I also think you have to be careful not to always just do that. By now I’m pretty good at knowing a) what ChatGPT can help me with and b) how to get that help as fast as possible. That wouldn’t be the case if I start using something else, I would need some time to get used to that and reach those same productivity gains.
What I use those tools for
Bugfixing
Chad is actually pretty good at fixing more or less obscure bugs. Whenever I find a bug I usually describe it to Chad in one to three sentences and then copy and paste all the code I think can be potentially useful for fixing that bug, including:
1. the error message I get
2. the whole file I think contains the bug
3. important type definitions
4. the most important one to three files that “interact” with that file (meaning either stuff is imported into my buggy code from there or they import and use my buggy code)
5. if I have them a file with tests that fail (I also add which tests fail and how)
It happens quite often that I go over the length limit and have to trim it down, which I do by deleting parts that I think won’t matter from my prompt. In about a third of the cases Chad gives me a great solution right away, another third I have to specify some more stuff or tell Chad to give it another try (which I usually do a maximum of three times before I give up) and another third Chad is as lost as me or acts completely stupid in which case I bang my head against the table a few times and then go to Google and Stackoverflow.Isolated code parts
If I need a function that is pretty much isolated from everything around it, you just call it with some parameters and get something out (I guess most code should look like this, but sadly it often doesn’t), I often ask Chad to write it for me, by just giving it a very short description of what I want, specifying inputs and outputs.
If I have some tests already, I’ll also add those, though in my experience the first version of code Chad writes still tends to fail some of the tests anyway. If that is the case I usually just paste the test that fails with the corresponding error message (like expected null but got 5 at line 17 I also tell Chad what line 17 actually consists of, as Chad is very bad at counting to any number above two or three). If I don’t have any tests I copy and paste what Chad gave me and tell it to write me some tests for that function in a new chat. These kind of tasks Chad is really good at and succeeds in about 80% (in my experience and only after a few kind remarks from me like You didn’t do that right, test X still fails with Y)Code improvements and documentation
After I (meaning mostly Chad) have written some code that works, I often copy paste it into a new Chad and ask for ideas for improvements. I usually do about half (the easy half) of the five to seven ideas Chad gives me. Also asking Chad to document code (I make sure to tell Chad to only document stuff that isn’t obvious when you read the code, otherwise it’s often very verbose) is a great way to improve readability without any extra effort (though you should always at least skim over anything Chad writes).Tests
If I already have some code, asking Chad to write me some tests for that code often works like a charm, sometimes I specify what inputs should return what outputs, but often just the code I want tested is enough.Code structure
When starting a new project it’s often interesting to ask Chad what my code/class/file/database structure should look like, though the results should always be thought about carefully. I don’t think I actually used exactly the structure Chad recommends in any project, but it’s often a good starting point.Mock Data
When testing and demoing often times I need some mock data (to fill a table for example) and sure I could just copy and paste one row with XXXXX for all fields but generating some kinda realistic mock data as a json only takes a few seconds, so why not? (This is the only thing I still let GPT-3.5 do for me)
What I don’t use AI for
As important as knowing when to use it, is knowing when you’re just wasting time.
There’s lots of stuff that AI is great at, but there are some fields it still fails at. In my experience the three main areas are:
Integration
When you have a medium to big codebase and you want to change, remove or add something that’s influenced by lots of other components, Chad will probably not be a big help. It’s just that not everything needed will fit into it’s context window and I often feel that even if everything fits, Chat kinda “forgets” stuff that I told him a while ago. Of course you can try to break everything down so that only the stuff that Chad will need is in your prompt but by then you often only need few minutes to do it yourself and then you can skip having to go over what Chad did.Design
I create a lot of websites and webapps and though I’m in no way a designer, I do have some opinions on what looks good and what doesn’t and almost every time Chad creates a simple website for me, I think: this looks pretty shitty. Telling Chad to try again doesn’t work either and if I have to say: Hey Chad, add some more padding to this button, change the hover color, make that text smaller, and so on, it’s faster to do it myself.Not widely used language
I also heard that using a language or framework that is very new or pretty unknown will lead to worse Chad results, but as I haven’t really tried that yet and can’t confirm nor deny that (I only tried Chad with Javascript, Typescript, Python, C, C# and Swift and for frameworks mostly React, React Native, Svelte, NestJS and NextJS which are all pretty widely adopted).
My tips and tricks
Don’t use GPT-3.5!
GPT-3.5 sucks!
When people say they don’t think Chad is really good enough to help them with coding, they almost always talk about GPT-3.5. GPT-4 is just in another league entirely. I recommend either getting a Plus subscription or getting a OpenAI API key (don’t forget to set a monthly limit) and using one of the thousands of Chad clones out there.Learn to prompt
It takes a while to see what you can use Chad for, start with trying lots of tasks and see which ones work well for you.Test a lot
Testing all code “you” write is often recommended even without using AI, with AI it just gets that much more important but also that much easier! Even so I also don’t always write tests (some stuff is still just very hard to write tests for) but in that case I make sure to double and triple check it by doing lots of manual testing. Great for game development, where you’re not playing your game for hours, but testing your game for hours 😉Understand “your” code
It’s almost never the case that Chad write all the code for me, usually I have to fix something, get different components to work together or do a small change somewhere. That’s why it’s crucial to understand all “your” code whether you wrote it or Chad wrote it for you! I also recommend doing that in small bits, because if you save a few hours by letting Chad write your complete codebase but then lose a few hours having to read and understand it, you haven’t gained anything.Know when to try something else
Yes, Chad is great, but it’s not the end-all be-all of software engineering, you should be able to read and understand documentation, google for clues or copy-paste from stackoverflow, even just as a fallback.
That’s it from me, I hope you found this overview of how I use AI interesting, AI is completely changing the way I create software, making it faster but also more fun, so personally it’s really exciting to be a part of this coding revolution.
Disclaimer: This text is actually 100 % human written, I tried to let Chad write the first paragraph but I couldn’t get it to stop being so overly formal and verbose.