Exploring The Use of ChatGPT For Resolving Programming Bugs
Exploring The Use of ChatGPT For Resolving Programming Bugs
net/publication/379001487
CITATIONS READS
0 314
3 authors, including:
SEE PROFILE
All content following this page was uploaded by Yakubu Bala Mohammed on 16 March 2024.
34
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
2. Theoretical Background
Recent advancements in artificial intelligence
(AI) have offers new opportunities for automating 2.1 ChatGPT as Debugging Tool
different software development tasks e.g., finding
and fixing programming bugs i.e., debugging In recent past, there has been a lot of focus on
(Nagwani & Suri, 2023). Jesse et al. (2023) in Large Language Models (LLMs) due to their
their work contended that nowadays, “developers robustness in processing programming languages
can use AI coding tools that get their strength for different Software Engineering (SE) tasks
from models trained on huge amounts of open- (Zhang et al., 2023). These LLMs usually go
source code to trace and fix programming bugs” through a pre-training-and-finetuning process [12,
such as Copilot and ChatGPT. Copilot is an AI- 49], meaning they're first trained with self-
powered coding assistant developed by GitHub supervised training on a big unlabelled collection
and OpenAI. It uses machine learning models to get general knowledge, and then adjusted with
trained on vast amounts of open-source code to supervised training on a smaller labelled
assist developers in writing code more efficiently collection to fit a particular task(Liu et al., 2024).
35
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
Among the various LLMs, ChatGPT is considered spot potential bugs based on the language used, ii)
by many as one of the most widely used language Comprehensive Knowledge Representation i.e.,
models, and it's being looked at by researchers in ChatGPT has undergone extensive training on a
various fields, such as code summarization, code wide array of text data, including details about
generation, and test generation(Sun et al., 2023). software development and programming
languages. Thus, enabling it to have a thorough
Tufano et al. (2019), claimed that ChatGPT is a understanding of the knowledge and principles
prompt-based LLM with reinforcement learning associated with software development, which can
from human feedback, allowing it to engage with be utilized to detect and rectify bugs in code, iii)
users through dialogues that mimic human Pattern Recognition Identification i.e., ChatGPT
interactions. Recently, ChatGPT has been getting excels in recognizing patterns within text data,
a lot of attention for its remarkable ability to which aids in bug detection in code, and pinpoint
understand and respond to human-initiated recurring patterns in code often linked to specific
conversations. In the context of Automated bug types, iv) Error Refinement i.e., With its
Program Repair (APR), ChatGPT has extensive training on large volumes of text data,
demonstrated exceptional performance in ChatGPT can propose corrections to code,
resolving issues in popular datasets such as including bug fixes, which streamlines the
“Defects4J” Plein et al. (2023) and “QuixBugs” debugging process, reducing the time and effort
Haque and Li (2023). needed to locate and resolve bugs, v) Adaptability
i.e., ChatGPT can generalize from its training
Sobania et al. (2023) in their work analyze how dataset to new onesand other unseen examples.
ChatGPT repairs programs by both making single Thus, making it a valuable tool for debugging
requests and engaging in further discussions with code as it enables the model to identify bugs in
it. Additionally, Cao et al. (2023) examined the fresh code based on its prior knowledge.
effectiveness of ChatGPTs in fixing deep learning
programs. The authors found that ChatGPT has 2.2 ChatGPT Versus Traditional Debugging
the ability to trace and fix bugs in various deep Methods
learning programs. Also, Xia and Zhang (2023) in
their study investigated the efficacy of Chatbot, ChatGPT is a model for natural language
specifically ChatGPT in tracing and fixing processing, which means it's trained to grasp
program bugs. The authors introduce an APR human language(Biswas, 2023). However, it can
method based on ChatGPT that maximizes also be trained on programming languages and the
conversations by providing immediate feedback syntax used in software code. For instance, when
on previous patches. Surameery and Shakor faced with a piece of code, ChatGPT can analyze
(2023) and Biswas (2023) in their studies argued it and spot potential problems(Liu et al., 2024).
that ChatGPT has the capability to identify bugs It’s capable of detecting various errors in code,
in programs, isolate the bugs, and fix them in a including syntax, logic, and semantics.Syntax
more robust and flexible manner compared to errors involve mistakes in the way code is written,
other traditional debugging approaches. The such as missing or extra punctuation, and
authors highlight some key features of ChatGPT incorrect syntax(Reiche & Leidner, 2023). While
that could be helpful in identifying and resolving logical errors occur when code doesn't perform as
bugs in computer programs. These features expected, even if it's written correctly(Liu et al.,
encompass; i) Natural Language Processing 2023). Semantic errors happen when the code is
(NLP) Skills. The authors claimed that ChatGPT technically accurate but doesn't produce the
has the ability to boast advanced NLP abilities, desired results(Yilmaz & Yilmaz, 2023).
such as understanding and generating text that
resembles human language, which may be ChatGPT can serve as a debugger in multiple
beneficial for code analysis as it enables the ways. It can aid in understanding code by
model to grasp the purpose behind the code and responding to queries about syntax, function
36
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
behaviour, or code structure. For instance, a proceed to apply a solution to address the
developer can ask ChatGPT about a specific problem. Making changes to the code, adjusting
function's definition or usage, and it can offer a settings, and/or making other modifications to the
detailed explanation to help the developer use the software are all steps involved in fixing bugs (Do
function correctly. It can assist in identifying and et al., 2018).Benton et al. (2021) and Ghosh and
rectifying syntax errors, such as missing brackets Singh (2020) in their works stressed that
or semicolons, by suggesting corrections or “traditional debugging often includes a significant
indicating where the error lies(Rahman & amount of trial and error, and it can be frustrating
Watanobe, 2023).Furthermore, ChatGPT can help and time-consuming”. The authors argued that in
pinpoint the underlying cause of issues by a typical debugging process (i.e., traditional
explaining error messages, providing context on methods), a successful debugging and bug-fixing
the code's operating environment, or proposing process “requires a combination of technical
potential solutions to a problem(Meyer et al., expertise, teamwork, and careful attention to
2023). details”. Thus, making the process cumbersome
as shown in Figure 1.
In the usual debugging process using traditional
methods, once the error is found, developers can
37
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
In contrast to the traditional debugging process, environment in which the code is running, and
Das et al. (2024) and Haque and Li (2023) argued even suggest potential solutions to the identified
that AI debugging tools, specifically ChatGPT problems". The authors highlight some general
have the skills to identify the main reasons for steps which ChatGPT might take to identify,
problems (i.e., bugs in programs) by “explaining analyze, and debug a piece of programming code
the error messages, providing context on the and fix it as shown in Figure 2.
As shown in Figure 2, the debugging process via suggestion for resolving the bug, usually in
ChatGPT consists of at least seven stages as per natural language. The suggestion might involve
(Haque & Li, 2023). i)The Input phase, in the altering the code itself, or it could propose
input phase, the programmer provides the code to changes to the environment or configuration
ChatGPT alongside a description of the problem settings, v) In the Feedback phase, here the
they're facing. ii) Analysis phase, in the second programmer assesses the suggestion and gives
stage, ChatGPT examines the code using natural feedback to ChatGPT. The coders might approve
language processing and machine learning the suggestion, tweak it, or reject it entirely. This
methods. It identifies all possible issues that are feedback helps enhance the accuracy of future
likely the cause of the bugs such as syntax errors suggestions, vi) Integration phase, in this stage, if
or logical discrepancies and creates a list of the programmer approves the suggestion given by
potential solutions, iii) Ranking phase, in the ChatGPT in the fifth step, they incorporate the
ranking stage, ChatGPT ranks the potential proposed fix into their codebase. Additionally,
solutions based on how relevant and likely they ChatGPT might also offer tools for automating
are to succeed. It might take into account factors the integration process, such as code restructuring
such as the programmer's past actions, code or testing frameworks that can enhance codes i.e.,
patterns, and the success rates of similar fixes, iv) the enhancement phase.
Suggestion phase, where ChatGPT generates a
38
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
Literature (Surameery & Shakor, 2023; Xia & significant expertise to fully utilize. On the flip
Zhang, 2023; Xin & Reiss, 2017) have shown that side, ChatGPT offers a more accessible and
both ChatGPT and traditional debugging tools intuitive method for solving programming bugs.
have their own strengths and weaknesses. The Its natural language processing and knowledge
best approach to solve a specific programming representation capabilities enable it to analyze
bug will depend on the particular circumstances code snippets and provide explanations for bugs
of the bug and the developer's experience and in a manner that developers can easily
preferences. Debugging tools like integrated comprehend. This can be especially helpful for
development environments (IDEs) and debuggers identifying and fixing more complex bugs. The
offer a variety of features to help developers strengths of ChatGPT as a debugging tool
identify and fix bugs, such as breakpoints, compared to other conventional debugging tools
variable inspection, and trace analysis. However, are offered in Table 1.
these tools can be complex to use and may require
Ability Explanation
Cost Traditional debugging tools and methods, like IDEs and debuggers, might come
with a high price tag, and difficult to use, whereas ChatGPT is commonly
available as a cloud-based service with a pricing model that offers more flexibility.
Speediness ChatGPT can offer speedy and effective bug explanations and predictions, while
traditional debugging tools may take longer to execute and deliver results.
Precision The precision of ChatGPT regarding bug predictions and explanations may be
influenced by the quality of its training data, whereas “traditional debugging tools
and techniques might provide a greater level of accuracy, but require a deeper
understanding of the codes”.
Flexibility Traditional debugging tools have the potential for extensive customization, while
ChatGPT is structured to function immediately and might not provide equivalent
customization options.
User- ChatGPT has the ability to generate natural language,which makes it simple for
friendliness developers to grasp its outcomes, while traditional debugging tools may be more
intricate and challenging to utilize.
Incorporation Conventional debugging tools can be merged with other tools and systems,
with other whereas ChatGPT might not provide an equivalent level of integration.
existing tools
Scalability ChatGPT have the ability to debug code on a large scale, whereas traditional
debugging tools might face challenges in handling extensive and intricate
codebases.
39
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
between code and bugs. This proves valuable in gain a deeper understanding of their code and
spotting bugs early in the development phase, effectively identify and rectify bugs. The
preventing them from becoming more challenging utilization of ChatGPT for addressing
and costly to rectify. This result is supported by programming bugs shows promise, yet further
the findings of Chen et al. (2024) who stressed research is required to fully assess its capabilities
that regarding bug prediction, ChatGPT can and limitations.
harness its skill to scrutinize and comprehend
code snippets. Thus, allowing the model to utilize References
its knowledge representation and pattern
recognition capacities to detect potential bugs in Benton, S., Li, X., Lou, Y., & Zhang, L. (2021).
new code, relying on its training data. Evaluating and improving unified
debugging. IEEE Transactions on
The review also discovered that the efficacy of Software Engineering, 48(11), 4692-4716.
ChatGPT in programming bug prediction is Bharadwaj, R., & Parker, I. (2023, June). Double-
contingent on the quality of the training data and edged sword of LLMs: mitigating security
system design. If the training data encompasses a risks of AI-generated code. In Disruptive
comprehensive array of code snippets and bugs, Technologies in Information Sciences VII
the model can cultivate a robust understanding of (Vol. 12542, pp. 141-146). SPIE.
the interplay between code and bugs. This, in Biswas, S. (2023). Role of ChatGPT in Computer
turn, results in precise predictions and aids in Programming.: ChatGPT in Computer
early bug identification during the development Programming. Mesopotamian Journal of
process (Hoq et al., 2023). Computer Science, 2023, 8-16.
Busch, D., Nolte, G., Bainczyk, A., & Steffen, B.
4. Conclusion (2023, October). ChatGPT in the loop: a
natural language extension for domain-
In conclusion, ChatGPT can contribute to specific modeling languages. In
resolving programming bugs by offering International Conference on Bridging the
debugging assistance, predicting bugs, and Gap between AI and Reality (pp. 375-
explaining their causes. Its capacity to analyze 390). Cham: Springer Nature Switzerland.
and comprehend code snippets, combined with its Cao, J., Li, M., Wen, M., & Cheung, S.-c. (2023).
knowledge representation and natural language A study on prompt design, advantages and
generation capabilities, renders it suitable for limitations of chatgpt for deep learning
these tasks. However, it's important to note that program repair. arXiv preprint
while ChatGPT can be helpful in addressing arXiv:2304.08191.
programming bugs, it's not flawless. Also, the Chen, M., Li, Y., & Xu, Q. (2024). HiBug: On
accuracy of its outcomes relies on the quality of Human-Interpretable Model Debug.
the training data and the system's design. Advances in Neural Information
Additionally, it's essential to employ other Processing Systems, 36.
debugging tools and methods to verify ChatGPT Dakhel, A. M., Majdinasab, V., Nikanjam, A.,
predictions and explanations, and to ensure bug- Khomh, F., Desmarais, M. C., & Jiang, Z.
free code. Thus, ChatGPT should be viewed as M. J. (2023). Github copilot ai pair
one component of a comprehensive debugging programmer: Asset or liability? Journal of
toolkit, that can be used alongside other tools and Systems and Software, 203, 111734.
techniques to achieve optimal results. By Das, J. K., Mondal, S., & Roy, C. K. (2024).
leveraging the strengths of ChatGPT alongside Investigating the Utility of ChatGPT in the
those of other debugging tools, developers can Issue Tracking System: An Exploratory
Study. arXiv preprint arXiv:2402.03735.
41
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
DeLiema, D., Kwon, Y. A., Chisholm, A., Liu, J., Xia, C. S., Wang, Y., & Zhang, L. (2024).
Williams, I., Dahn, M., Flood, V. J., Is your code generated by chatgpt really
Abrahamson, D., & Steen, F. F. (2023). A correct? rigorous evaluation of large
multi-dimensional framework for language models for code generation.
documenting students’ heterogeneous Advances in Neural Information
experiences with programming bugs. Processing Systems, 36.
Cognition and Instruction, 41(2), 158-200. Liu, Y., Le-Cong, T., Widyasari, R.,
Do, L. N. Q., Krüger, S., Hill, P., Ali, K., & Tantithamthavorn, C., Li, L., Le, X.-B. D.,
Bodden, E. (2018). Debugging static & Lo, D. (2023). Refining ChatGPT-
analysis. IEEE Transactions on Software generated code: Characterizing and
Engineering, 46(7), 697-709. mitigating code quality issues. ACM
Ghosh, D., & Singh, J. (2020). A systematic Transactions on Software Engineering
review on program debugging techniques. and Methodology1(4), 211-226.
Smart Computing Paradigms: New MacNeil, S., Denny, P., Tran, A., Leinonen, J.,
Progresses and Challenges: Proceedings Bernstein, S., Hellas, A., ... & Kim, J.
of ICACNI 2018, Volume 2, 193-199. (2024, January). Decoding Logic Errors:
Haque, M. A., & Li, S. (2023). The Potential Use A Comparative Study on Bug Detection
of ChatGPT for Debugging and Bug by Students and Large Language Models.
Fixing. EAI Endorsed Transactions on AI In Proceedings of the 26th Australasian
and Robotics, 2(1), e4-e4. Computing Education Conference (pp. 11-
Hoq, M., Shi, Y., Leinonen, J., Babalola, D., 18).
Lynch, C., & Akram, B. (2023). Detecting Meyer, J. G., Urbanowicz, R. J., Martin, P. C.,
chatgpt-generated code in a cs1 course. In O’Connor, K., Li, R., Peng, P.-C., Bright,
Workshop on empowering education with T. J., Tatonetti, N., Won, K. J., &
llms-the next-gen interface and content Gonzalez-Hernandez, G. (2023). ChatGPT
generation. 2(1), 221-238. and large language models in academia:
Jesse, K., Ahmed, T., Devanbu, P. T., & Morgan, opportunities and challenges. BioData
E. (2023). Large Language Models and Mining, 16(1), 20.
Simple, Stupid Bugs. arXiv preprint Modi, C., Patel, D., Borisaniya, B., Patel, H.,
arXiv:2303.11455. Patel, A., & Rajarajan, M. (2013). A
Kang, S., Yoon, J., & Yoo, S. (2023, May). Large survey of intrusion detection techniques in
language models are few-shot testers: cloud. Journal of network and computer
Exploring llm-based general bug applications, 36(1), 42-57.
reproduction. In 2023 IEEE/ACM 45th Morovati, M. M., Nikanjam, A., Khomh, F., &
International Conference on Software Jiang, Z. M. (2023). Bugs in machine
Engineering (ICSE), (pp. 2312-2323). learning-based systems: a faultload
IEEE. benchmark. Empirical Software
Lau, S., & Guo, P. (2023, August). From" Ban it Engineering, 28(3), 62.
till we understand it" to" Resistance is Nagwani, N. K., & Suri, J. S. (2023). An artificial
futile": How university programming intelligence framework on software bug
instructors plan to adapt as more students triaging, technological evolution, and
use AI code generation and explanation future challenges: A review. International
tools such as ChatGPT and GitHub Journal of Information Management Data
Copilot. In Proceedings of the 2023 ACM Insights, 3(1), 100153.
Conference on International Computing
Education Research-Volume 1 (pp. 106-
121).
42
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
Nathalia, N., Paulo, A., & Donald, C. (2023, Summarization via ChatGPT: How Far
September). Artificial intelligence vs. Are We? arXiv preprint
software engineers: An empirical study on arXiv:2305.12865.
performance and efficiency using chatgpt. Surameery, N. M. S., & Shakor, M. Y. (2023).
In Proceedings of the 33rd Annual Use chat gpt to solve programming bugs.
International Conference on Computer International Journal of Information
Science and Software Engineering (pp. Technology & Computer Engineering
24-33). (IJITC) ISSN: 2455-5290, 3(01), 17-22.
Nistor, A., Jiang, T., & Tan, L. (2013, May). Tufano, M., Watson, C., Bavota, G., Penta, M. D.,
Discovering, reporting, and fixing White, M., & Poshyvanyk, D. (2019). An
performance bugs. In 2013 10th working empirical study on learning bug-fixing
conference on mining software patches in the wild via neural machine
repositories (MSR) (pp. 237-246). IEEE. translation. ACM Transactions on
Perry, N., Srivastava, M., Kumar, D., & Boneh, Software Engineering and Methodology
D. (2023, November). Do users write (TOSEM), 28(4), 1-29.
more insecure code with AI assistants?. In Xia, C. S., & Zhang, L. (2023). Keep the
Proceedings of the 2023 ACM SIGSAC Conversation Going: Fixing 162 out of
Conference on Computer and 337 bugs for $0.42 each using ChatGPT.
Communications Security (pp. 2785- arXiv preprint arXiv:2304.00385.
2799). Xin, Q., & Reiss, S. P. (2017, October).
Plein, L., Ouédraogo, W. C., Klein, J., & Leveraging syntax-related code for
Bissyandé, T. F. (2023). Automatic automated program repair. In 2017 32nd
generation of test cases based on bug IEEE/ACM International Conference on
reports: a feasibility study with large Automated Software Engineering (ASE)
language models. arXiv preprint (pp. 660-670). IEEE.
arXiv:2310.06320. Xuan, J., Martinez, M., Demarco, F., Clement,
Rahman, M. M., & Watanobe, Y. (2023). M., Marcote, S. L., Durieux, T., Le Berre,
ChatGPT for education and research: D., & Monperrus, M. (2016). Nopol:
Opportunities, threats, and strategies. Automatic repair of conditional statement
Applied Sciences, 13(9), 5783. bugs in java programs. IEEE Transactions
Reiche, M., & Leidner, J. L. (2023, September). on Software Engineering, 43(1), 34-55.
Bridging the programming skill gap with Yilmaz, R., & Yilmaz, F. G. K. (2023).
ChatGPT: A machine learning project Augmented intelligence in programming
with business students. In European learning: Examining student views on the
Conference on Artificial Intelligence (pp. use of ChatGPT for programming
439-446). Cham: Springer Nature learning. Computers in Human Behavior:
Switzerland. Artificial Humans, 1(2), 100005.
Sobania, D., Briesch, M., Hanna, C., & Petke, J. Zhang, Q., Zhang, T., Zhai, J., Fang, C., Yu, B.,
(2023). An analysis of the automatic bug Sun, W., & Chen, Z. (2023). A critical
fixing performance of chatgpt. arXiv review of large language model on
preprint arXiv:2301.08653. software engineering: An example from
Sun, W., Fang, C., You, Y., Miao, Y., Liu, Y., Li, chatgpt and automated program repair.
Y., Deng, G., Huang, S., Chen, Y., & arXiv preprint arXiv:2310.08879.
Zhang, Q. (2023). Automatic Code
43
Int. J. Adv. Multidiscip. Res. (2024). 11(3): 34-44
Subject:
Software
Quick Response Code Engineering
DOI:10.22192/ijamr.2024.11.03.005
44