Yunus Emre Vurgun's Blog

ChatGPT for Finding Syntax Errors in Your Code

June 9, 2023
Hello everyone,

I just recorded and uploaded a new video to my YouTube channel. As you may have heard, ChatGPT is becoming widely recognized because of its advanced capabilities. It has a good NLP capacity and, of course, for us developers, it is an amazing syntax corrector and debugger to some extent.

I recorded a video where I feed the assistant some basic Java and JavaScript code with syntax errors and let it find the bugs. It is amazing that it found the errors and fixed them too.

In another section of their tool, which is focused on writing JavaScript from scratch (not included in the video), the bot actually writes JavaScript based on your plain English explanations.

It makes errors when details get intense, but I can't imagine what it will be able to do in the future.


It can easily generate the desired JavaScript code from an explanation like this:

"Write me a program where the user has to input a number, and if the user has entered a letter or not a number, the program will turn the background color red."

This sort of instruction will be instantly turned into plain JavaScript, and to be honest, it is amazing.
I noticed some errors in more detailed requests, though. I tried explaining a similar concept but also requested it to have functionalities such as ".....will turn the background color red only if the user clicks on the screen afterward or if the user hasn't responded for more than 10 seconds at that stage."

These sorts of details confused the bot, and it generated some JavaScript that was constructed wrong. It was still correct in terms of syntax, but it mixed up the order of events and when the functions get triggered. As a result, it wrote a program where it instantly outputs the red color and bypasses the if condition.

It is still amazing for an early technology, and don't forget that these tools are not only for programmers and can also be used (the Assistant version) for other things such as music composition, lyrics, poem writing according to a concept or emotion, rhymes, etc.