Working with AI is here and it's skill. Just like google-fu became important in the mid 2000's. A few things I've learned.
I started properly integrating AI into my coding workflow a few weeks ago after I got in trouble for "wasting thousands of dollars of company time" by manually doing things computers can do. 😅
It's not perfect yet but it's pretty good! On net I think it saves time, or at least effort. But yesterday I spent an hour debugging when my editor hallucinated the wrong URL for a config. ¯\_(ツ)_/¯
What AI is good for
Like I've said before AI won't take your job, it's going to make your job easier. You can move up the value chain while computers do more of the grunt work.
Current AI is pretty good at writing atoms or S-programs – code with a tightly scoped spec where you can quickly validate the solution. It cannot engineer a solution to a business problem.
LLMs are fantastic at "I have inputs A, B, C and need them translated to outputs 1, 2, 3" problems however. This is awesome!
Based on what I've seen, I doubt large language models will ever get to a place where they can sit down with a stakeholder, figure out what they need, and engineer solutions to business problems. And that's fine.
Defining the inputs, outputs, and constraints – contracts – of your system is the fun part. If AI can write the code, sweet.
Two ways I use AI
These days I use AI in two primary ways depending on context:
- Cursor is my editor at work. It's a fork of VSCode with AI (Claude I think) integrated into the editor. It kinda understands the whole project and can pull relevant files into context
- ChatGPT Canvas when I need to develop one-off scripts that solve a problem and I don't care to know how
Coaching ChatGPT
Using ChatGPT feels like coaching a less experienced developer. It won't read your mind or magically write good code the first time.
But if you take the code, run your validation, and iterate with feedback, you'll get a solution to your problem. The code will be strictly okay. It won't blow you away with elegance but it works.
And that's all you need when you are, for example, writing a script to count words in your book, or a script to collect wordcount stats from git history, or even a script to package your book for feedback.
That last one was fun because ChatGPT made a dumb choice – parsing markdown with regex – and I asked it to use a library. Then we couldn't get that to work and eventually we reverted back to regex. You can see the full chat here.
The whole thing felt like a collaborative pair programming session. I could keep high level context, steer direction, and validate the code, while AI fiddled with the details.
Mentally this felt easier than jumping up and down levels of abstraction. Not sure it saved time.
Advanced auto-complete with Cursor
No screenshots because they're full of work code. Sorry.
Cursor has saved me time with boilerplate code. It's really good at figuring out "Oh you're spelunking this variable through 5 layers of indirection, lemme help" or "You recently looked at code about Foodazzlers, are you trying to add a GenerateTheFoodazler function here?".
This has been fantastic. It's super nice when you establish clear patterns in your project and your editor can follow them for you.
- Add new prop
- Yes thank you editor, add this same thing in 5 other places
👌 chef's kiss
Why do I have so much boilerplate? We're working on it okay [name|].
Another nice thing I've tried with cursor is to highlight a method, open the chat, and say "Hey add so and so to this function". And it does.
Again this works great when the problem is tightly scoped and easy for you to verify. It won't work if you don't know what you're doing or can't quickly validate the result.
Generating tests
It can even generate tests!
Yes I've said in the past that you shouldn't use AI to generate you tests because tests should describe your code, not derive from your code. This is an important distinction.
Here's where I think it's okay: You have a basic function and need Beyonce Rule testing. You know the code works because you've manually tested it, but you need to put a ring on it and make sure it keeps working in different situations.
Cursor is great at taking a function and saying "Ah looks like you need these 4 different cases and to return blah". Then it generates an integration test and you can run to make sure it works. Great.
Again because you're using it on a tightly scoped function with clear inputs and outputs :)
tl;dr
AI can help you write the code you used to copypaste from StackOverlow. Tightly scoped with a clear input/output.
You have to do the engineering part.
Think iterative collaboration, not one-shot do my work requests.
Cheers,
~Swizec
Continue reading about Coaching AI to write your code
Semantically similar articles hand-picked by GPT-4
- Why you shouldn't use AI to write your tests
- Yes, AI will "take" your job. No, you won't mind
- Why a coding AI like Github Copilot won't take your job
- The programming tutorial SEO industry is dead
- How to start playing with generative AI
Become a *true* Senior Engineer
Get promoted, earn a bigger salary, work for top companies
Getting that senior title is easy. Just stick around. Being a true senior takes a new way of thinking. Do you have it?
The Senior Minset email crash course
Get a free chapter from the Senior Engineer Mindset book and a sample audiobook chapter, followed by a Senior Mindset 101 email course.
You'll get insights to apply at your work right away.
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️