Friend or foe: Can computer coders trust ChatGPT?

  • Published
Pietro Schirano, design lead at business finance company BrexImage source, Justin Johnson
Image caption,

Pietro Schirano asked ChatGPT to create Pong, Asteroids and Breakout for him

"It felt like magic to me," says Pietro Schirano. "It scared me a little bit because it was so good."

He's talking about the latest version of ChatGPT, an artificial intelligence (AI) tool. You type something in, and it makes up a reply for you.

It's uncanny how human, friendly and intelligent the responses seem. Underneath it is an AI model called GPT-4.

Mr Schirano, design lead at business finance company Brex, has been using ChatGPT to make computer programs.

"I want to build a Pong-like game," he typed, referencing Atari's table tennis game of the 1970s. "What's the best language to [use] so that lots of people can try?"

ChatGPT not only recommended a programming language that runs in the browser (JavaScript), but also generated the code for a simple version of the game.

What would have taken an experienced developer half an hour to write took ChatGPT 40 seconds. It worked equally well for classic arcade games Breakout and Asteroids.

Image source, Getty Images
Image caption,

Pong, seen here being played at a trade fair in Cologne in 2019. ChatGPT quickly created a simple version of the game

There are lots of code examples for these games online, but ChatGPT isn't searching the internet for a ready-made answer.

Although it's been built using huge amounts of web content, ChatGPT generates new text just for you by predicting the right answer.

"ChatGPT was able to understand my question about how I make this game more popular," says Mr Schirano. "It has a lot of contextual understanding that somebody who's never developed couldn't get from Google."

Using a search engine, you'd have to figure out which coding language to use, how to use it, and how to finish any incomplete examples online. ChatGPT can give you all the game code, together with instructions tailored to your needs.

"Now, even somebody who has no idea of what they're doing can create a simple web app," says Mr Schirano.

Some say that recreating these old games was too easy because there are so many examples online.

So Mr Schirano's colleague Ammaar Reshi, design manager at Brex, pushed ChatGPT further. He asked it to recreate an old PC game for which there is no example code online. It's a 3D game called Skyroads where you guide a car along a road, jumping over barriers.

ChatGPT knew about the game from its Wikipedia page and Mr Reshi elaborated on how the game works. "There was so much back and forth with this one," says Mr Reshi. "Literally an hour of tweak this, tweak that." He had to test the game, tell ChatGPT how to change the game behaviour, and repeat.

Even so, Mr Reshi was able to build an online 3D game, despite not knowing any of the JavaScript language used to build it, and without ChatGPT having access to code examples for that game.

These are small games, and nobody's suggesting ChatGPT will be making modern console games. But it could be used to make parts of a major game, or to help create any other software.

But even with the productivity improvements, some hesitate to adopt AI for coding.

"The risks of ChatGPT for software development still outweigh the benefits," says Tony Smith, chief technology officer at Rightly, an organisation that helps people get their data deleted from company databases. "The code these AIs generate is often flawed or inefficient."

Mr Smith asked ChatGPT to create some code to work out how many days are in a given month. "The code looks great, however there's a problem with the shift to British Summer Time, so it thinks March has 30 days," he says. "There's a subtle bug that will show up once a year."

Others have found that AI-generated code can include security flaws. ChatGPT may model bad behaviour it's seen online, overlook vulnerabilities or use outdated techniques. Also, ChatGPT has limited knowledge of events after 2021.

The Italian data-protection authority has blocked ChatGPT while it investigates whether it complied with General Data Protection Regulation.

Image source, Alex Bartok
Image caption,

Kevin Bocek says developers must be accountable for AI-generated code

Business risk increases, too, if people are tempted to use code they don't understand.

Kevin Bocek is vice president, security strategy and threat intelligence, at Venafi, a company that makes security software for authenticating machines. He used ChatGPT to create Excel macros and PowerShell scripts, which are two different ways to give a computer repeatable instructions. Hackers often use them to launch an attack.

"Now I've got code that's come from 'out there' and I'm going to run it, and I've got no idea what it does," he says. "The opportunity has now increased for more code to come in that might be harmful."

While AI can be used to create code, it will always be the developer's responsibility to check it at Venafi. "That's something we take very seriously," he says. "Code is reviewed multiple times by humans. Ultimately, it's the professional developers that are responsible and accountable."

Image source, Herd
Image caption,

Matthew Hunt (second from left) asks whether ChatGPT might stop him growing his skills

Herd, a performance marketing and web agency, makes slideshow-style elements on some of its websites. "Writing the JavaScript code individually for each section can be painful, so ChatGPT really speeds that process up," says Matthew Hunt, a junior web developer at Herd.

He's concerned, though, that ChatGPT could take away some of the satisfying work, too. "Part of the joy of developing is learning exactly what a file does and how it all works," he says. "If ChatGPT is doing this for us, we aren't really growing as developers."

Dan Ciruli, vice president of technology at cloud management company D2iQ, has a different take. He previously worked at Google.

Google's application programming interfaces (APIs) enable developers to connect their software to Google services. There were 200 APIs and seven supported programming languages, including Python. To provide instructions for every API in each language, Google would have to create 1,400 code examples.

"That's something we struggled with," he says. "We just couldn't create samples in every [programming] language. But when I got access to ChatGPT, the first thing I did was ask it to show me how to call the Google Translate API in Python. Boom - there it was."

The future of software development is likely to be a partnership between the developer and the AI assistant, which is reflected in the name of one popular AI tool. GitHub Copilot is a commercial tool that automatically completes code as developers work. The code completion uses a faster but less accurate model than ChatGPT.

"Given you're typing code, ideally every time you input a character, you get a new response," says GitHub CEO Thomas Dohmke.

Although Copilot has been upgraded with features to detect and block insecure code, humans remain an essential safeguard. "Like any other coding tool, you should always use GitHub Copilot together with human code review, testing practices and security tools," says Mr Dohmke.

Will AI code generation lead to job losses? Mr Schirano and Mr Reshi can both foresee that junior roles could be replaced if AI takes on repetitive coding work.

Manuel Doc is a front-end developer at user experience agency Illustrate Digital. "I was so amazed by ChatGPT's code-level responses that I was scared my job would be in jeopardy soon," he says.

"However, during my 1-2-1 with our head developer, he helped me understand that I'm not just hired to write code, but to analyse problems and provide solutions that ChatGPT can't give. It was very reassuring."