It is rare that I do longer form content on here since I tend to prefer to share amazing things I come across rather than share my opinions on things but today the mood struck me to write about a topic that has had a big impact on me lately. And that topic is the benefit of ChatGPT for software developers / engineers.
For those that don’t know, I am a software developer / engineer (I prefer the term developer since it sounds less pretentious but they mean the same thing). My 9-to-5 (or more accurately 7-3) is spent writing code in C#/.NET for regional sports networks and then when I’m not on the clock, I have various software projects of my own that I work on. And between the two, I have found ChatGPT (and GitHub Co-Pilot) to be an amazing resource for software development. So, I want to take some time to talk about why and how I use it as part of my developer inner-loop.
But before I get into that, I should probably say to check with your company’s policies regarding using services like ChatGPT or GitHub Co-Pilot to help you in your coding efforts. Some places embrace it and others ban it so just make sure you don’t do something that will get you fired or cause headaches for your company.
With that out of the way, lets talk about the benefits of ChatGPT for software developers!
#1. Refactoring made easy!
If there is one thing that I probably use ChatGPT the most for, it is probably going to be refactoring my code. I share my code with it (either paste it onto the chat box or give it a Pastebin link to my code) and tell it what I want it to refactor to and seconds later, my code is refactored to be much better code! Of course you always want to review the changes it makes to make sure it doesn’t leave something out or introduce new bugs but for the most part, it does a great job whether you want it to break down code into smaller methods or completely replace functionality in the code. For example, one of my projects was having major performance issues taking some JSON data and storing it in a SQLite database. So I decided to eliminate the SQLite database entirely and just work directly off the JSON so I gave it my few hundred lines of code and told it to get rid of SQLite and just operate on the JSON directly and in seconds it spit out a fully refactored class that I was able to copy and paste right into my existing file and the only changes I had to make was adding a library so that it would compile. Talk about a massive time saver!
#2. Unit tests galore!
Code that isn’t covered with unit tests is fragile and unmaintainable code that is going to cause you countless hours of regression headaches. However, writing endless number of unit tests is not exactly fun. Especially when it comes to setting things up and mocking out your architecture. This is one place that both GitHub Co-Pilot and ChatGPT for software developers really shines. Letting them handle setting up the boilerplate code and generate tests based on what it can come up with and cases that you tell it about can be a massive timesaver and headache reducer! Just make sure to tell it what unit testing and mocking frameworks you are using so it doesn’t assume the wrong one and leave you scratching your head why the code it gave you isn’t even close to working. I learned that lesson the hard way!
#3. Rubber duck debugging 2.0!
Who needs a rubber duck on their desk (or in my case a little SQL Server super hero figure) when you have GitHub Co-Pilot or ChatGPT to bounce ideas off of and explain what code is doing too you. One of the biggest problems that software developers have is not noticing issues in their own code (which is why code reviews are so valuable). You can stare at code for hours and still not see a bug but think you know exactly how the code is working. This is when the LLMs shine because they can explain to you exactly what the code is doing just in case you are missing something.
#4. Bug hunting!
Sometimes bugs can be a real pain in the butt to diagnose. Especially the ones that are hard to replicate! Having one of the LLMs take a look at your code and asking it if it can see why you are seeing certain behavior can be a huge help! Sometimes it will make suggestions that aren’t right but other times it can help spot issues that are next to impossible to spot yourself. For example, I was recently experiencing a bug that wouldn’t always show up which obviously makes it very hard to diagnose. Thanks to ChatGPT, it pointed out that there was a threading / race condition issue that could cause transient bugs. Talk about saving me time from staring at my code for hours! Those are the hardest kind of bugs to diagnose and it did it in seconds!
#5. StackOverflow on steroids!
Until now, a developers best friends were StackOverflow and Google (the best way to find what you are looking for on StackOverflow). And you could be in real trouble if you don’t find an answer on there and have to ask a question that may never get answered or simply closed as a “duplicate”. Well, now you are much less likely to have to sift through StackOverflow because Co-Pilot and ChatGPT likely have the answer you are looking for and can do a better job of fixing your code than some other person on the internet that doesn’t have the full context of what you are trying to do. StackOverflow can certainly still be a valuable resource for some issues, especially if its for a newer technology that the LLMs don’t know about, but they can give you the answer you seek in most cases.
But what about my job?! Is it safe?
Finally, I want to take a second to address the whole idea that ChatGPT is going to put software developers / engineers out of work. First of all, LOL! If you have used either ChatGPT or GitHub Co-Pilot or a similar LLM tool, you know that they are FAR from perfect. Sometimes they write good code but other times they write code that isn’t even close to compiling, its missing crucial things like library references or it writes code that is full of security holes, bugs and edge cases. Not to mention, it tends to reference libraries/packages that are often obsolete and no longer maintained which is something you never want in your code. Does it do an ok job sometimes? Sure. But experience will tell you that it rarely gives the best, most complete solution to a problem. So while they might make for a decent pair programmer, they are not reliable and can’t write good code on their own. Its up to experienced developers to distinguish what is good and what is bad code because ChatGPT and GitHub Co-Pilot tend to not know the difference.
So, for my fellow software devs out there, what has been your experience with using LLMs like GitHub Co-Pilot and ChatGPT for software development? Share your thoughts and experiences in the comments below!
Leave a Reply