ChatGPT has created a lot of buzz since its launch. The speculations of generative AI being the next big thing in tech and its ability to impact lives of many people both positively and negatively is being debated extensively. As of now, it’s uncertain how things will turn out in the long run, but we can definitely see the benefits that it provides currently. In this post, I will discuss how ChatGPT can help us in coding. I will discuss some ways which you may find helpful and use it to code effectively.
Finding errors and debugging
Perhaps this is the most helpful feature. When we are coding, we often get stuck due to some pesky bugs which do not seem to fix. ChatGPT can help you in debugging. There are many ways in which you can perform this.
- Giving proper details of the error message and details of the program to ChatGPT.
- Copy and pasting the portion of the code into ChatGPT’s prompt where error is being shown.
I find the second way more effective as it helps ChatGPT to give us quick and proper results. ChatGPT will write the modified correct code and also provide an explanation. Here is a simple example:

I have provided a small piece of code with a very common mistake. Also, I didn’t provide any other data. ChatGPT was able to quickly detect the mistake and provide me the correct code with proper explanation.
This is obviously a very small example, but it holds true for large programs as well. There were many times during my college project that ChatGPT was able to help me in troubleshooting problems easily and also suggested me a better way of approaching the solution of the problem.

Making the code look good and more readable
Writing code which is easy to read and understand is a characteristic of a good programmer. It helps multiple people to work on parts of a single project and later integrate it easily. Even if we are working on a small project and we are the only people involved, cultivating good coding practices from the very beginning is always a good idea.
A good piece of code should have proper indentation and should have good amount of comments explaining what the code does. Although the modern IDEs automatically provide indentation to the programs, but even if you mess things up or you are writing a program in text editors that doesn’t have the feature, ChatGPT can easily understand the program and provide the necessary indentation and commenting. Here is an example:

Here is what ChatGPT provides us as a result:

Generate code based on provided information
ChatGPT is a generative AI, so obviously it can generate stuff based on the prompts we give to it. And it can generate pieces of code efficiently. Suppose I want a simple login/ signup form code in HTML. We can simply ask ChatGPT to generate code for it. Here’s an example:

Here’s the code that ChatGPT returned:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login/Signup Form</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 3px;
}
button {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h2>Login</h2>
<form action="login.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
</div>
<div class="container">
<h2>Signup</h2>
<form action="signup.php" method="post">
<label for="newUsername">Username:</label>
<input type="text" id="newUsername" name="newUsername" required>
<label for="newPassword">Password:</label>
<input type="password" id="newPassword" name="newPassword" required>
<button type="submit">Signup</button>
</form>
</div>
</body>
</html>
I tested the code using W3Schools try it editor and here’s the output:

Of course, it doesn’t look visually appealing, but you can further ask it to make visually appealing or do the designing yourself.
Not only HTML, it can generate code in almost any language. You can try out various approaches suitable for your project needs as and when required.
Pulling out information from official documentations
Official documentations are the most authentic source of information and while working on software projects, we are often required to visit official documentation and look out for the required information. Well, ChatGPT does that too for us. We just need to ask it to do it for us.
For example, suppose I am working on an android app development project and I need to pull out information regarding Constraint Layout. I can simply ask ChatGPT to fetch information from the Android documentation.

Providing statistical data
If we are involved in some research work, we often need statistical data. And surfing from site to site can be a cumbersome task. ChatGPT can provide us with statistical information. But we need to be careful because ChatGPT may have data till a particular point of time e.g. year 2021. In that case, the data provided may be outdated.

Conclusion
ChatGPT can prove to be an effective tool for us while coding, and it will be beneficial for us if we are able to use it to its full potential. Hope that this post will help you in some way. Keep reading iCuriousGeek!
You may like reading :What is ChatGPT? ChatGPT vs Google Bard