9 mins
You have 0 further articles remaining this month. Join LeadDev.com for free to read unlimited articles.

Generative AI tools like ChatGPT and GitHub Copilot are already providing software developers with a handy productivity boost, but the risks have to be carefully managed.

In just a few short months, OpenAI's ChatGPT and other coding assistants which leverage large language models (LLMs) have already shown the potential to make software developers’ lives easier.

Not only can these generative AI tools already write code, but they can do it almost instantly, as well as handle other boring or painful tasks. Make no mistake, these assistants still need obvious supervision, but they can also help you be more productive in the right context.

Here are seven ways developers are already leveraging these tools to make their lives easier:

1. Generate simple code in languages you don’t know well

Piyush Tripathi is a lead engineer at fintech company Square. His team is already using ChatGPT, another GPT-based tool called Auto-GPT, and GitHub Copilot to help with various programming tasks.

Tripathi says his team used ChatGPT to write code in a language they weren’t already familiar with. His team had mostly used Ruby in the past but needed to use Python for a recent project: creating a contact form that could upload documents to AWS S3 storage.

Instead of having to dig deep into the various docs, they were able to get ChatGPT to write the necessary function, in a way that was consistent with object-oriented programming, using the prompt: “Generate S3 code in Python language that can connect to AWS S3 and store a file. Constraints: make code according to OOP rules.”

All he had to do to make it usable was add the relevant application programming interface (API) keys and file details.

To get the best results from ChatGPT, Tripathi suggests using detailed prompts and adding constraints and context around your request. The more specific you can be about the code you need, the more likely it is to be usable.

Similarly, in a recent episode of The Tim Ferriss Show podcast, Kevin Rose, the founder of the news aggregator Digg, describes how he uses ChatGPT to code. “I can come in and as I start to have little hiccups or I want to think through a problem, I can just ask it to figure it out for me and it writes code that is like 99% ready to go," he said.

Unfortunately, Tripathi says, “Sometimes the code produced by it doesn’t work. I love to call it a confident liar, because it’s going to spit out things and it’s going to sound so confident that you wouldn’t think it’s not correct. But a lot of the time when we actually run these functions or classes, they outright don’t work and you have to spend some time fixing it.”

So, while ChatGPT can help you write some simple code in a language you don’t know well, it might make your job more difficult if you rely on it for complex projects.

2. Speed up coding and suggest complex algorithms with GitHub Copilot

While ChatGPT can code surprisingly competently for a chatbot, GitHub Copilot was designed specifically for the task.

It uses OpenAI Codex, a programming-specific AI model that was trained on billions of lines of publicly accessible code and can access your entire project codebase. This means that Copilot can make intelligent and relevant suggestions for what classes, variables, and functions you’re trying to call in any situation, and suggest solutions to complex programming tasks.

Giancarlo Erra, CEO of Words.tel, uses Copilot daily, both to produce boilerplate code and as a form of advanced auto-complete. “I know what I need to write and how,” he explains, “but it’s much quicker if I just make a detailed comment about the function, class, and method I need, and I can let the AI write it for me. I just need to check it.”

Similarly, if Erra doesn’t remember the precise syntax or all the relevant commands, he’s found that the AI can normally help. “It’s much quicker than going on Google or StackOverflow.”

The downside to Copilot is that it is trained on publicly accessible code – which may include copyrighted materials. Tripathi says that for corporations that care about IP, this can be a big issue. “I’ve had cases where the use case was so narrow that you can only point to a few repositories that had this kind of code.” He felt that allowing Copilot to put it in a project would be a really big risk, because if someone took a legal case, “it’s so easy to prove that you just took the code from one of those repositories.”

While there’s an option in Copilot to exclude code that matches public repositories on Github, Tripathi said he wasn’t confident the filters would be effective enough for his team to use it freely in these situations.

3. Refactor and convert code

While writing novel code might be hit and miss with ChatGPT, it’s pretty good at refactoring and converting code between languages.

For another project, Tripathi had to add a new payment option for Square’s smart payment terminal. Unfortunately, the old infrastructure and new infrastructure didn’t mesh well, so there needed to be a lot of refactoring. “Let’s say we have a Ruby file with jumbled code that’s like 12 years old. If I feed that into ChatGPT and write a prompt that says something like, ‘Optimize this so it’s easy to create unit tests,’ which would make it more robust for our team to test it out. It just does it flawlessly.”

Similarly, ChatGPT is able to take working code in one language and convert it into another. “It’s really handy for smaller chunks of code,” says Tripathi. And by getting ChatGPT to write tests and translate your code, he explains, “you can slowly transition your codebase from one type of code to another type of code.”

And, of course, Copilot, which has an understanding of your codebase, is even more powerful for these kinds of tasks.

4. Create basic documentation from code samples

One of the most interesting uses for ChatGPT and Copilot is to create documentation for undocumented code.

Tripathi explains that when his team has new hires, they are often placed on customer support projects so they can learn Square’s workflows. Unfortunately, these projects often have older code with no documentation – and existing engineers don’t have the time to go and write it. But because GPT can understand computer code, it can create documentation from a simple prompt.

According to Tripathi, Copilot is even better at it. “It’s really handy when you feed the entire project into Copilot. Then it’s going to generate documentation, and it’s also going to tell the new hires that this class is being used in another library somewhere, and give them a link to it.” Before, this was the kind of thing that they could only figure out by talking to a human.

And this doesn’t just have to be used for new hires. If you are facing a poorly maintained codebase, you can use ChatGPT or Copilot to help parse what the different functions actually do.

5. Find information on and solve errors

Another Copilot feature that Tripathi flagged was its ability to help solve errors like service outages.

“We have a centralized database of all our error logs,” he explains. Since Copilot has access to it, when they have an error like an outage, they can ask Copilot if it’s got any information on the error. “It’s really great at pattern matching and then telling us, ‘OK, three months back we had this error. We had this resolution and these were the people involved in that discussion.’” That way, the team can follow up and find out how the previous issue was resolved

Similarly, Tripathi says that they’ve used ChatGPT and Copilot to suggest fixes for errors and that they have come up with relevant solutions.

6. Write proposals, minutes, blog posts, and other documents

While these tools can all help out with coding, they can also speed up plenty of engineering-adjacent tasks, such as writing system design documents and proposals for new projects.

Similarly, you can throw in a meeting transcript and ask for minutes or a summary, or use ChatGPT to outline or even draft a blog post announcing a new feature or describing the build process.

Hila Shitrit-Nissim, CMO of Blend localization, says her team uses ChatGPT to do just that. Apparently, having the AI create the initial draft can cut the content creation time by 30-50%. While it doesn’t quite nail the brand voice, even with a bit of extra editing, it can still be faster than writing from scratch.

7. Let Auto-GPT take the reins

Another tool the Square team has had some success with is Auto-GPT, which basically uses a second GPT-instance as an agent that talks to the first GPT-instance.

“It’s like ChatGPT on steroids,” Tripathi says. “ChatGPT is only going to tell you, ‘OK, you need to do X, Y, Z,’ but it’s not going to do it. But Auto-GPT is going to log into the system, create files, connect to your server, do Google searches, and all of the other stuff it can do. We’re using it a lot these days.”

While Auto-GPT is open-source and requires some setting up, AgentGPT is a version that works as a web app.

Lastly: be careful with generative AI

With all that said, there are plenty of reasons to be cautious about relying on the confident liar that is generative AI technology in the workplace. Apple, JP Morgan, Verizon, Amazon, and other companies have all currently banned employees from using ChatGPT, Copilot, and similar tools, over fears about how private data is handled, for one. If your team handles sensitive customer data, putting it into ChatGPT might not be the best option.

Still, these technologies are just getting started and the guardrails are still being built. Each organization will differ in its appetite to leverage these tools for certain tasks, but it's already clear that they're only going to be more relevant to engineering leaders over the next few years.