AI for Developers: GPT-3 is Changing Software Development

Kenny Hall
March 7, 2023

The article looks at how GPT-3 is changing how software engineers work.

AI can help developers with code generation, documentation, writing software tests, explaining complex code, and debugging. Although AI has its limitations and can sometimes produce imperfect results, it can speed up the development process and makes engineers more efficient.

Let's have a look at four different real-world examples of developers using AI tools at work.

Graphic design for software developers

Thomas Ricouard is a developer who found himself working on a new app he was calling Ice Cubes. He was building a chat client for the decentralized social network Mastodon. Partway through the development process, he was struck by an inevitability that had yet to occur to him—his app would need an icon.

Now, for many developers, graphic design isn’t exactly a specialty. This meant that Thomas would have to either whip up a less-than-ideal design himself or pay a potentially expensive graphic designer to do the work for him. Or, what if, he used an AI?

Thomas decided to check out Midjourney—a discord-operated AI image generation tool—to see if he could get an app icon from it.

His first prompt was simple.

“4 ice cubes, in a glass of water, the glass is floating in the deep space”

And the results he got were almost exactly what he had asked for. Impressive to say the least.

4 ice cubes, in a glass of water, the glass is floating in the deep space
Image Credit: Thomas Ricoaurd (and Midjourney, I guess)

Though, what he asked for, it turns out, wasn’t exactly what he wanted. These initial images were a bit noisy and detailed for an app icon. They lacked the subtle simplicity that the best icons all go for. So, he put in a second prompt.

“An iOS app icon with ice cubes in a glass floating in space”

This time, he got almost exactly what he was looking for. This second offering was clean and detailed and perfectly captured what he was after.

An iOS app icon with ice cubes in a glass floating in space
Image Credit: Thomas Ricoaurd

This design was later refined into the final product but by using Midjourney, Thomas was able to approach an artist with a very specific idea to work from and sped up the entire process.

Final App icon for the ice cubes app
Image Credit: Thomas Ricoaurd

Moving forward, giving the developers—or anyone—the power to just make an image out of nothing with only a few prompts is a real game-changer.

Write code with artificial intelligence

Fernando Doglio, a freelance tech journalist, found himself wondering just how far he could push ChatGPT. Recently, he asked the chatbot to create a simple to-do app. The prompt he provided was simple:

“Can you give me the code to create a to-do app that allows me to edit the items and store them in a database? Please use React for the front end and next js for the back end.”

This is the kind of straightforward language that any human would be able to understand and that any entry-level developer should be able to bust out by lunch. So, how did the AI handle the task? Honestly? Surprisingly well; but far from perfect.

The code spit out by ChatGPT was largely functional but it missed a few key points from the prompt. Most notably, the app produced didn’t actually allow for tasks to be edited and it used in-memory storage instead of the database storage that was asked for. Overall, an OK start, though.

Fernando then prompted the bot further asking it:

“Can you modify that code to add support for a cloud database?”

Notice the intentionally vague phrasing. This is, again, the same kind of natural language that humans easily understand but has long eluded AIs. The new code made the necessary edits. It selected Firebase as the database and even wrote the placeholders for Thomas to enter his credentials! Sort of.

There were two main issues with the final code.

  1. It lacked the import of the “useEffect” hook. Minor and easily fixable.

  2. It didn’t specify which version of the Firebase npm package to use.

This second issue was a serious problem for the functionality of the app. An “npm install firebase” input returned a version that wasn’t compatible with the code that was there. Fernando followed up by asking the bot:

“What version of the firebase npm package should I use for that example?”

Again, being intentionally vague. The response he got? Well, it turns out that the AI was only trained on data up until 2019 and the release of Firebase 7.0. However, the most recent version at the time was 9.0.

ChatGPT screenshot
Image Credit: Fernando Doglio

Another issue that was easily fixed but it just highlights the shortcoming of AI at the moment. After a little more troubleshooting, Fernando was able to get a barebone, but functional, app.

screenshot of todo app
Image Credit: Fernando Doglio

While this app isn’t about to become our next huge productivity hack, it shows just how far the still-early AI can be pushed.

Machine learning to document all the things

You’ve just inherited a bunch of code for a project and it’s an absolute mess. What’s even worse? There’s almost zero documentation. Figuring out what it all does and how typically takes hours—assuming that it all actually works. Whether it’s a little more clarification or a completely unintelligible section, going through everything line-by-line is always a nightmare. Well, Lakindu Hewawasam over at Syncfusion discovered a few tips.

It looks like ChatGPT is just as good at turning code into language as it is at turning language into code. Just pump in the code and ask ChatGPT how it works. You’ll get back a plain-English explanation. Now, there are always limits and the explanations tend to break down once you start putting in larger blocks of code. Further, ChatGPT is trained on slightly outdated data and it may not understand certain up-to-date references.

debugging with gpt-3
Image Credit: Lakindu Hewawasam

But all things considered, this response was better than I thought it would be. I think there's room to calibrate the prompt to the right expertise level. For example, by specifying there's no need to explain what a hook is and how useEffect works to an expert, the response could just focus on explaining the function's purpose. Still, not bad for a first pass.

We all know that getting code without notes is a pain. And documenting your own code is just tedious. Well, the same trick can be used to streamline your workflow. You can plug code into the AI interface and simply ask it to “document this code”. You get back new in-line documentation as well as a plain-text explanation.

AI documentation example
Image Credit: Lakindu Hewawasam

While this kind of use isn’t flashy or headline-making, it’s these little conveniences and timesavers that will lead the way toward mass AI adoption.

Debugging with artificial intelligence

Guillermo Martínez Espina, a software engineer at Google, conducted several experiments with ChatGPT, using a variety of prompts to see just how well it could integrate into his daily workflow.

He started with prompts such as "Create a function to check if a number is prime," and "Can you explain the concept of recursion?" to see how the AI  would respond. Overall, the results generated were largely accurate and relevant.

One of the main benefits that Guillermo points out for software engineers is its ability to generate code snippets. When he prompted it with "Create a function that reverses a string," the chatbot was actually able to generate functional code. While that’s a small example, the time saved by these little steps adds up.

Another tool he discovered was ChatGPT’s ability to accurately debug code. This exchange was particularly illuminating.

Guillermo: I’m having trouble with a TypeError in my React code. Can you help me debug it?

ChatGPT: Sure, can you provide more details on the error message and the relevant code snippet?

Guillermo: The error message says “Cannot read property ‘map’ of undefined.”

He also included the code. Within a matter of seconds, the AI spotted the error

ChatGPT: The error message is indicating that data is undefined and

you’re trying to call the map method on it. To fix this, you can add a

check to make sure that data is not undefined before calling the map

Method.

It even supplied modified, working code.

debugging with AI
Image Credit: Guillermo Martínez Espina

In conclusion, it's exciting to see how AI tools like GPT-3 are revolutionizing the way software engineers work. AI is not here to replace us, but to augment our abilities and help us work more efficiently. As things advance, we are likely to see even more innovative tools that will help developers streamline their workflows and handle projects in more complex and sophisticated ways.

Further Reading for AI developers