Insights From The Blog

How ChatGPT Can Help Programmers and How it is Starting to be Used for Software Development

It seems, over the last few weeks, that it is impossible to open a newspaper or magazine, or listen to the TV or radio without there being something about ChatGPT, the artificial-intelligence (AI) chatbot developed by OpenAI. While we have had AI-driven software before, this new system marks a huge leap forward in capability, and the use of natural language. While it is still in its infancy, ChatGPT has shown an affinity for language and is fast becoming a powerful tool in written work and many other spheres of language-based development work.

It is not hard to understand why ChatGPT has become so popular recently all across the world. The ground-breaking artificial intelligence known as a chatbot is capable of an astounding number of activities, ranging from carrying on a conversation to composing a full technical paper. In addition to this, Microsoft has started incorporating the GPT language model that is the foundation of ChatGPT into services and products such as Bing, Edge, and Teams. In point of fact, due to the level of intelligence possessed by the ChatGPT chatbot, Google has hurriedly developed a competitor to ChatGPT known as Google Bard. And moreover, Opera has declared that it will incorporate ChatGPT into its web browser, in addition to other products that it offers. Even Snapchat is getting in on the fun with its very own artificial intelligence chatbot, which is known as My AI and is powered by ChatGPT.

The number of people using ChatGPT has increased at an exponential rate over the past several months due to the fact that OpenAI’s most well-known project has been on the minds of people all over the world, including those who are in charge of Google, Microsoft, and Meta. The AI language model quickly became the app with the highest rate of growth, even outpacing the popularity of TikTok. “The quality of ChatGPT is terrifying. We are getting dangerously close to having powerful AI,” remarked Elon Musk, who, prior to his departure from OpenAI, had been one of the company’s founders.

While ChatGPT is being used extensively for the creation of content, and as a conversational chatbot source, it has also shown an aptitude in other areas, and is becoming a major force in software development. A recent communication from OpenAI describes how ChatGPT has been able to sort an issue with a section of code that was causing problems. This exchange is shown below.  

The section of code in question was given as:

resultWorkerErr := make(chan error)

defer close(resultWorkerErr)

go func() {

defer cancel()

resultWorkerErr <- b.resultWorker(ctx)

}()

err := b.worker(ctx)

cancel()

if err == nil {return <-resultWorkerErr}

return multierror.Append(err, <-resultWorkerErr)

There appeared to be a problem with this part of the code and the programmer turned to ChatGPT for help. The programmer asked the software to examine the code, and the conversation between ChatGPT and the developer went:

  • ChatGPT: It’s difficult to say what’s wrong with the code without more context. Can you provide more information about what the code is supposed to do and what isn’t working as expected? Also, is this the entire code or just a part of it?
  • Programmer: just part of it — the error never surfaces. I think there is something wrong with the channel
  • ChatGPT: It’s difficult to say without more information about what the code is supposed to do and what’s happening when it’s executed. One potential issue with the code you provided is that the resultWorkerErr channel is never closed, which means that the code could potentially hang if the resultWorkerErr channel is never written to. This could happen if b.resultWorker never returns an error or if it’s cancelled before it has a chance to return an error

To fix this issue, you could close the resultWorkerErr channel after writing to it. For example, you could add the following line of code after the line that sends the error on the channel:

close(resultworkerErr)

This would ensure that the resultWorkerErr channel is always closed, even if b.resultWorker never returns an error. Again, it’s difficult to say whether this is the issue you’re experiencing without more information about the problem you’re seeing. Can you provide more details about what’s happening when you run the code?

This exchange demonstrates that the ChatGPT not only understands the code contextually, but can see potential problems with it on a line-by-line basis, and from that point can suggest modifications to it to prevent failure. Make no mistake, this is a massive leap forward in AI and represents a situation where the AI is becoming sufficiently sentient to begin to understand how something as software coding needs to be constructed, analyse how it is actually built-up, and determine the possible difference between these two states. This is just the start, and AI is going to become increasingly powerful in this area. However, not everyone is happy about it, and many feel a genuine fear for their jobs, but the vast majority of developers and programmers see the use of ChatGPT as a viable tool to assist with software development, and one to speed up processing and bug-finding rather than as a full development tool. Hugely intelligent tools of this nature have a number of different advantages within software development, such as:

  • Improved accuracy. The deep learning techniques utilised by ChatGPT guarantee that the code it generates is syntactically sound, hence lowering the probability that it will contain errors or flaws.
  • Increased productivity. ChatGPT is able to generate code in a quick and effective manner, freeing up the time of developers to focus on more difficult tasks.
  • Personalisation. It is possible to fine-tune ChatGPT for certain use cases, which enables it to generate code that is tailored specifically to the requirements of the user.
  • Easier collaboration. Developers are able to collaborate more effectively with one another and share code snippets while also having real-time discussions on questions relating to coding when they use ChatGPT.

The fundamental way in which ChatGPT selects and investigates written structure is the strength behind its use as a coding tool. It is able to construct a skeleton of the code that is normally required for any specified frameworks, technologies, and versions by simply requiring the user to respond to a few prompts. In addition to this, it helps keep the documentation focused, which in turn helps keep the development of each programme bug free and clear. In addition, ChatGPT will work on the drafting of an initial code structure for the development of the project if it is going to make use of an external API. It is now possible to ask the programme directly for its expert opinion on which library or choice is ideal for the code development, and ChatGPT will react to the question. This not only helps save time and effort when making judgements, but it also ensures that only the best tools are employed. In addition, ChatGPT may be of assistance in improving the quality as well as the maintainability of the code. It is feasible to guarantee that the code has the appropriate documentation before the product is shipped by requesting that the programme add comments line by line.

Let’s not overplay this; ChatGPT isn’t perfect and has a number of foibles that can limit its use.  It tends to reuse phrases in a way that is not considered good English, and it exhibits a certain verboseness with its content. If you ask it to create standard kinds of text like a letter, it will do well, and the latest indications are that it understands highly ordered and specific constructs such as software coding, because it has well-defined rules. However, those of us who are creating technically-based conversational and opinion-piece articles don’t have too much to fear at present…however, in five years’ time, even we journalists could be rendered redundant. This is the potential power of AI writing.