A.I. coding assistants have not been out in the wild for too long, but definitely long enough that you either use them in your professional work or you completely ignore them because they'll just slow you down. I'm currently stuck somewhere in the middle.
But I personally use ChatGPT whenever I need a function to handle some edge case scenario that I don't have time to figure out. Or if I do know how to implement it, I also don't want to spend the 15-20 minutes typing it out and debugging it. And for these situations, ChatGPT does a great job.
The code isn't perfect by any means, and definitely requires a few modifications, but it still saves me some amount of time. And the better my prompts get, the more time I end up saving in the end.
And this got me thinking about the times in my career where I wish I had some artificial robot to help me answer my coding questions. The days where the sun was gone for the day, but the office was still lit brightly and coffee was still being consumed and the project was due the following day.
Those days are long gone for me, but the memories remain. So in this article I'll break down how I personally use A.I. coding assistants in my daily work currently and how potentially, this could save you a few brain cells in the grand scheme of life.
What really causes burnout
Most people associate burnout with doing something for extended periods of time and eventually just running out of steam. If you've been coding from 8am, when you walked into work and sat down in your cubicle, and it's now 11pm, then some might argue that there's burnout.
For me, personally, that's not burnout. That's just a rough day at work. Burnout happens when it's month 3, and you're still going home at 11pm. When the coffee starts to taste stale and old and when the code in front of you makes less sense each time you stare at it. When sleep starts to get in the way of you finishing your project, that's burning out. At least, those are the symptoms for burning out.
Here's a more specific list of what potentially could cause burnout, as a developer:
- Missed deadlines
- Short deadlines (really short)
- Working on outdated codebases
- Working on poorly written code
- Company culture of overtime work
- Working on very complex logic
- Traffic
And the more you combine from that list the above, the faster you're going to be running on the aforementioned steam.
A.I. (currently) can't help you with company culture or with traffic, but it can help you with a few of the other scenarios.
Creating utilities
This is where 80% of my A.I. usage is spent when it comes to coding. ChatGPT is very good at creating things from scratch. Typically small things, such as widgets or functions that do 'so and so'.
A quick example would be something like the following:
// Import any necessary libraries
import React from 'react';
// Function to sanitize and validate phone number input
const sanitizeAndValidatePhoneNumber = (input) => {
// Step 1: Remove any non-numeric characters except '+' for country code
const sanitizedInput = input.replace(/[^0-9+]/g, '');
// Step 2: Validate the phone number (you can adapt the validation according to your needs)
const isValid = /^\+?\d{10,15}$/.test(sanitizedInput);
if (!isValid) {
return {
isValid: false,
sanitized: sanitizedInput,
errorMessage: 'Invalid phone number. Please enter a valid phone number with 10-15 digits.',
};
}
return {
isValid: true,
sanitized: sanitizedInput,
errorMessage: '',
};
};
// Example usage
const PhoneNumberInput = () => {
const [phoneNumber, setPhoneNumber] = React.useState('');
const [error, setError] = React.useState('');
const handleInputChange = (e) => {
const input = e.target.value;
const { isValid, sanitized, errorMessage } = sanitizeAndValidatePhoneNumber(input);
setPhoneNumber(sanitized);
setError(isValid ? '' : errorMessage);
};
return (
<div>
<input
type="text"
value={phoneNumber}
onChange={handleInputChange}
placeholder="Enter phone number"
/>
{error && <div style={{ color: 'red' }}>{error}</div>}
</div>
);
};
export default PhoneNumberInput;
This function sanitizes and validates a user's input to match a phone number. And it's a function that I've probably written dozens of times for dozens of websites and in various different languages spanning over a decade. And truthfully, it's not one of my favorite parts of the job.
For one, it takes time to type out and to test and debug. But more importantly, it isn't very complex in any way. It's typically going to look exactly the same regardless of programming language or decade that we are in (assuming phone number standards don't change).
But ChatGPT (or whichever assistant), can save me a few minutes here or there with these type of tasks.
Debugging
When that red error message appears, 9 out of 10 times you're fine. You can probably resolve it within milliseconds in your mind, and a few seconds physically. It's that singular 1 out 10 that's the problem. The error that makes no sense (and that might be wrong truthfully) that you've spent half an hour trying to locate and are about ready to change careers.
Usually these errors happen when there's some critical flaw that breaks the compiler and interpreter. And if the compiler doesn't know what's wrong, then its going to be a challenge for an A.I. assistant as well.
ChatGPT can sort of help in this regard. It probably won't actually just tell you what's wrong, because just like you, it won't know. But it can give you suggestions and point you in a different direction.
Generating templates
Much of coding professionally is doing the same thing over and over again. Your components will import the same libraries, load the same tracking scripts, pull data from a database in the same fashion over and over again.
For the most part, this isn't an overly complex or burnout inducing thing. But, it is annoying sometimes. It takes time, even if you are copy and pasting a component and then renaming certain variables to accomplish a slightly new thing.
Technically, there are probably only a handful of things that you personally need in a component. For example, maybe it's just a component that pulls data and loads a table to the user. Or it's a component with an entry form, that validates the data and pushes it to a database.
ChatGPT is great when it comes to this, because you can reference one of your current components and have it spin up variations as you need them. For example, you could have it create a new entry form, based on one of your current components, with the fields that you specifically need.
And at the end of the day, it's these time-saving hacks that really help to prevent burning out, because it means that you're less likely to miss deadlines and if anything, it could leave you with a few days to spare.
Keyword lookup
Despite popular belief, most professional programmer's don't have entire programming languages completely memorized. There are 1000's of keywords per language and each one can have multiple pages of documentation breaking down what they are and how they work.
Websites like MDN are still a great resource for looking up JavaScript keywords and functions, but sometimes even after reading their thorough documentation, you're still left somewhat confused.
This is where ChatGPT (or your favorite A.I.) comes in handy. Because not only will you get a relatively thorough breakdown, you can also generate example after example in order to see it in action. And that's huge, because in the past many developers would essentially have to have their own sandboxes in order to test these things out. And that takes time and energy.
And once again, saving you time and getting things done quicker is the name of the game here.
Are robots eventually going to take every programming job in the world? Maybe. It's a possibility at least. But for right now, I personally still have to write for loops and create database tables and I still get paid to do so. And many others do as well.
So before the paradigm shift hits society, we should use the resources that we have available to save ourselves a few minutes a day and a few extra hours per month.