COBOLAssist: Analyzing and Fixing Compilation Errors for LLM-Powered COBOL Code Generation
This paper introduces COBOLAssist, an iterative framework that leverages compilation feedback to significantly improve the syntax and functional correctness of LLM-generated COBOL code, raising compilation success rates from as low as 29.5% to over 95% for advanced models while highlighting persistent challenges in functional accuracy.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Problem: The "Ancient Library" and the "New Intern"
Imagine a massive, ancient library (the global banking and insurance systems) written entirely in a very old, strict language called COBOL. This language is like a formal, old-fashioned English where every sentence must follow a rigid structure, or the librarian (the computer compiler) gets confused and refuses to read the book.
The problem is that the people who know how to write this language are retiring, and there are very few new apprentices left. To keep the library running, companies are hiring a super-smart AI intern (a Large Language Model or LLM, like GPT-4) to write new code for them.
However, this AI intern has a big flaw: it has mostly read modern books (Python, Java) and hasn't studied the ancient COBOL grammar books enough. When it tries to write code, it makes mistakes. It might forget to put a period at the end of a sentence, use a word that doesn't exist, or mess up the order of chapters. When the librarian (the compiler) checks the work, it rejects it with a long list of errors.
The Solution: COBOLAssist (The "Editor's Red Pen")
The researchers created a tool called COBOLAssist. Think of this as a smart editor that sits between the AI intern and the librarian.
Here is how it works, step-by-step:
- The First Draft: The AI intern writes a piece of code.
- The Rejection: The librarian (compiler) says, "No! You forgot to close this paragraph," or "You can't use that word here." It sends a specific error message back.
- The Feedback Loop: Instead of giving up, COBOLAssist takes that error message, shows it to the AI intern, and says, "Hey, look at this note. You made a mistake here. Please rewrite the code to fix it."
- The Retry: The AI tries again. If it's still wrong, the editor sends the new error message back, and they try again. They keep doing this until the code is perfect or they run out of tries.
What They Discovered (The "Error Report")
The researchers looked at thousands of mistakes the AI made and found three main types of "bad habits":
- The "Incomplete Story" (Incomplete Code): The AI starts a story but forgets to write the "The End." In COBOL, every block of code needs a specific "stop" word. The AI often forgets these, leaving the code hanging.
- The "Grammar Police" (Syntax Errors): The AI puts things in the wrong order. For example, it might try to use a function like
MOD(math for remainders) the wrong way, or it might duplicate a section of the code that is only allowed to appear once. - The "Wrong Category" (Type Errors): The AI tries to put a word inside a box meant for numbers, or vice versa.
The Big Surprise: The AI makes a specific type of mistake that human experts rarely make: using built-in functions incorrectly. It's like the AI knows the word "calculator" but tries to use it as a verb instead of a noun. This shows the AI is guessing based on patterns from other languages rather than truly understanding COBOL.
The Results: From "Failing Grade" to "Honor Roll"
The researchers tested this "Editor" tool with five different AI models. The results were impressive:
- Before the Editor: The best AI (GPT-4o) could only get about 42% of its code to work on the first try. It was failing more than half the time.
- After the Editor: With COBOLAssist, that same AI got 96% of its code to work. It went from barely passing to an A+ student.
- The "Specialist" vs. The "Generalist": They also tested a model specifically trained on COBOL (mAInframer). It was great at getting the code to compile (98% success), but the code often didn't actually do the right thing (low functional score). The general AI (GPT-4o), with the help of the editor, was better at actually solving the problems correctly.
The Takeaway
This paper proves that while AI isn't perfect at writing ancient, strict languages like COBOL on its own, it can become extremely effective if we give it a way to learn from its mistakes.
Think of it like teaching a child to ride a bike. If you just let them go, they will fall. But if you have a parent (COBOLAssist) who points out exactly where they wobbled and tells them to try again, they quickly learn to ride perfectly.
In short: We can't rely on AI to fix our legacy systems alone, but if we give the AI a "compiler" to talk to and a chance to self-correct, it becomes a powerful tool for keeping the world's financial systems running.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.