DEV Community

GageHarmon
GageHarmon

Posted on

ChatGPT & Beginner Programmers

In the following article, I will talk about ChatGPT and individuals who are learning to code for the first time. I do not endorse copying every bit of code from ChatGPT when you need it, however, I do believe it has other benefits, specifically for those that are new to the field. As a beginner programmer knowing how to Google search for solutions efficiently. Usually, the answer to your coding problem is just a Google search away on StackOverflow or a similar site, but finding the right information can be frustrating and a time-consuming process. Fortunately for us, ChatGPT, developed by OpenAI, can make this process easier and more efficient.

To understand this, here is a quick explanation (hopefully accurate) of what ChatGPT is in case you don’t already know. ChatGPT is an artificial intelligence program that uses machine learning to understand user input and generate responses. It has been given vast amounts of text data from the internet, such as books, news articles, and many other sources. This means that it has a huge amount of data, which it can use to assist beginner programmers to find the information they need.

One of the ways that ChatGPT can be helpful is by acting as a more efficient Google search. When you search for something using Google, the results can be quite a lot. You may get hundreds of links to web pages, many of which are not relevant to your specific problem. You then have to sort through those websites to not only find relevant sites but also sort through the information on those sites to find what you need. This can be frustrating and very time-consuming.

A great example of this is if you are looking for information on how to write a function in JavaScript, you might search for something like "JavaScript function tutorial." However, then you need to sort through all the forums and videos to find the example of what you are looking for. ChatGPT can analyze your question and generate a much more specific answer (usually). You could ask it "How to (insert function needed)” and receive instructions plus an example of how to write the function you requested. This may not always give you the exact answer you need, but it will likely have something relevant or at least a skeleton of some code that you can work off of.

Another way that ChatGPT can be helpful for beginner programmers is by helping with fixing bad code. This can be controversial since ChatGPT isn’t perfect of course, and its code should be taken with a grain of salt. That being said, as a beginner you may make mistakes in your code that are not immediately obvious. For example, you might forget to close the parenthesis or use the wrong variable name. These mistakes can cause your code to fail, and it can be difficult to figure out what went wrong.

It is still important to learn how to find these mistakes yourself, but ChatGPT can help by analyzing your code and providing suggestions for corrections when in a pinch. For example, if you have a syntax error in your code, ChatGPT can point it out and suggest the correct syntax. This can save you a lot of time and frustration, as you won't have to spend too much time trying to figure out what went wrong.

Here is a simple example of how ChatGPT can help.

Bad code:

let toggleButton = document.querySelector("#checkbox");

toggleButton.addEventListener('click', funtion () {
document.body.classList.toggle("dark-mode")
);

This code has syntax errors and misspellings in a few places. If you tried to run this code, you would receive some sort of syntax error. This can be frustrating, especially if you are a beginner or have a time constraint with bigger issues to focus on.

Corrected code using ChatGPT:

let toggleButton = document.querySelector("#checkbox");

toggleButton.addEventListener('click', function () {
document.body.classList.toggle("dark-mode");
});

In this corrected snippet, ChatGPT has suggested adding a semicolon after the ("dark-mode"); along with the misspelling in ('click', function () {. This simple correction can save you a lot of time and frustration, which I think we all could enjoy.

It is easily understood how ChatGPT can harm newcomers to the coding community as well. Once again specifically with beginners, ChatGPT can lead to bad practices, and sloppy code, and even have an impact on how well an individual ends up absorbing some of this information. An example of this is having the AI essentially write an entire block of code or a majority of their project, while not learning what they are programming and why.

In conclusion, I believe that ChatGPT can be beneficial if used properly. Just like anything else it has its drawbacks, and those that will abuse it. However, it can also be a powerful tool if understood and used efficiently.

Top comments (0)