When to use AI for coding

jasonleow • 15 Oct 2024 •
I’m convinced devs have difficulties using LLMs for coding because many don’t know WHEN to use it. There’s 3 options at any one time:
- Code without AI - Code it yourself entirely
- Code with AI - Code it yourself but with AI as assistant
- Code by AI - Code it entirely using AI
When to use which?
1. Code without AI:
- when it’s an obscure library or package
- when it’s too niche and unique to your code
- when training data, resources, documentation on the internet is scarce
- when you know the solution and can already see the code in your head
2. Code with AI:
- when you’re half sure or unsure and need some ideas or help
- when you don’t trust AI to do this 100%
- when you’ve been going in circles with AI
- when you want to learn fast
3. Code by AI:
- when it’s boilerplate part of the code
- when it’s common and popular, lots of resources and conventions
- when you know what good looks like and can vet the AI’s outputs
I think most of the issues devs face when using AI for code is when they do #3 for something that should be #1.
On flip side, the argument for not using AI by skeptics because you’ll get worse at coding is silly because they think #1 when a situation just calls for #3.
So why the all-or-nothing thinking?
For #1 situations, just code it yourself because AI will be slower. If it’s boring boilerplate part of the codebase, use #3, it’s faster.
You can mix, you know.
Comments
Yes! I spend most of my coding time now on #2! I like it, it’s the best of both worlds - I get to learn, still maintain skill, but code faster and more productive.

Great approach! I might need #2, plus asking AI to explain stuff to me so I can get better at #1 (when AI implementing the code fails me because it’s not understanding my requirements properly)