AI 能否化解 COBOL 代码危机?
英文标题:Can AI help solve the COBOL code crisis?
全球银行、航空及政府机构的核心系统仍高度依赖数十年前编写的 COBOL 等古老编程语言,其维护与迁移成本极其高昂。近期 OpenAI 与 Anthropic 竞相展示利用大语言模型(如 GPT 系列与 Claude Code)将遗留代码迁移至现代语言的能力,OpenAI 更宣称在特定测试中模型迁移的行为保持准确率最高可达 98%。然而多位计算机科学家与业内专家指出,“重写代码”并不等于“替换系统”,遗留系统背后的复杂架构拆解、多语言多格式集成以及业务逻辑黑盒才是核心痛点,99% 的自动化率仍可能因剩下 1% 的潜在错误带来毁灭性后果。
306.9 KB
573.4 KB
996.6 KB
3.4 KB
84.5 KB
177.2 KB
82.9 KB
572.3 KB
139.0 KB
45.2 KB
93.0 KB
164.4 KB
63.0 KB
527.4 KB
160.2 KB
34.3 KB
91.0 KB
中文
美国国税局(IRS)、银行、航空公司以及全球各地的政府基础设施有什么共同点?它们都在依赖极其古老的计算机代码支撑的系统上运行,而几乎没人敢触碰这些代码,生怕整个系统分崩离析。
OpenAI 认为自己或许有了解决方案。10 月 19 日,该公司宣称其最新 AI 模型在将用老旧编程语言编写的老化软件迁移为现代代码方面取得了“实质性进展”,并称这有助于组织机构“维护和现代化改造旧系统”。
这可能是一件大事。OpenAI 重点提及的语言之一是 COBOL,它仍然根深蒂固地嵌入在世界上绝大多数关键基础设施中。尽管数十年来人们一直在努力将其淘汰进历史档案,但这种语言却始终苟延残喘、绝不退场。
“任何理智清醒的人都不会在新的开发项目中使用 COBOL。”
COBOL 的无处不在无论怎样强调都不为过。COBOL 是“通用面向商业语言”(common business-oriented language)的缩写,诞生于 1959 年。近七十年后的今天,它依然无处不在。据 IBM 统计,COBOL 构成了超过 40% 的在线银行系统的基础,支持着 80% 的面对面信用卡交易,并处理着 95% 的 ATM 自动取款机交易。它还支撑着众多政府系统,从社会保障署(Social Security)、美国国税局(IRS),到绝大多数州运行的各项服务。据粗略估计,COBOL 的低效每年给美国 GDP 造成约 1050 亿美元的损失。
但替换 COBOL 的难度极其恐怖。其他传统遗留编程语言也是如此,例如 Fortran 如今仍在使用,应用范围涵盖科学计算、天气预报、大气和海洋研究,以及对核安全至关重要的代码。这些系统通常重要到绝不能冒任何崩溃的风险,而且许多真正理解它们的程序员早已退休或离世。
尽管 AI 编程工具在现代软件开发领域取得了令人瞩目的进展,但在处理这些遗留系统方面却始终步履维艰。不过,近期的动态表明情况可能正在改变。
在其最新发布的博文中,OpenAI 报告了将 COBOL 代码迁移到更现代编程语言(包括 C++、Java、Kotlin、Python 和 Rust)且不改变原始软件功能的令人欣喜的成果。对于希望彻底摆脱 COBOL 等老旧代码的机构而言,最后一点至关重要,OpenAI 也坦言,“唯有所有测试均通过,迁移才被视作成功。”
在 OpenAI 的自身测试中,GPT-6.1 Sol 在较低推理算力消耗(low reasoning effort,即模型在给出答案前用于分析问题的计算步骤量)下实现了 87% 的行为保持准确率;而在提高推理算力后,该准确率攀升至 98%。相比之下,在低推理算力下,GPT-6 Astra 得分约为 86%,GPT-6 Sol 仅为 21%,而 GPT-5.6 Sol 仅有微不足道的 5%。
“重写代码不等于替换系统。”
OpenAI 写道:“这些评估结果表明,在为那些依赖老旧软件开展业务的团队提供更准确、更经济的代码迁移方案方面,我们取得了进展。”
该公司还报告称,其模型在用包括 COBOL 在内的多种编程语言构建数据库软件方面的能力有所提升。
Anthropic 同样在遗留系统中看到了机遇。今年 2 月,该公司发布了一份分步指导的“代码现代化手册”(code modernization playbook),并推介其编程 Agent Claude Code 作为将 COBOL 代码迁移到 Java 或 Python 等现代语言的途径。尽管它没有提供展示 Claude Code 执行此类迁移效果的性能基准,但它宣称“COBOL 现代化的经济模型已发生转变”。在 Anthropic 宣布此消息后,部分收入来自协助企业维护遗留系统的 IBM 股价遭遇暴跌。
接受《The Verge》采访的专家们一致认为,AI 工具近年来在处理遗留代码方面确实取得了长足进步。但他们同时警告,OpenAI 本周大肆宣扬的这些进展,距离真正能够安全替换以此为基础构建的关键遗留系统,还有非常漫长的道路要走。
OpenAI 发言人奥斯卡·海因斯(Oscar Haines)在发给《The Verge》的电子邮件中承认,遗留代码“仍远非一个已经解决的问题”,并表示公司正在听取开发者和企业的反馈,探索构建更完善的测试方法,并持续改进模型对编程语言的理解。Anthropic 未能在发稿前提供置评。
“OpenAI 展示的评估并没有解决关键难点:将复杂的遗留系统拆解为可以单独替换的小型单元。”
荷兰特温特大学(University of Twente)软件演化副教授瓦季姆·扎伊采夫(Vadim Zaytsev)表示:“重写代码不等于替换系统。”系统的代码量确实庞大——扎伊采夫称他见过最大的系统包含 2.5 亿行 COBOL 代码,“且绝对不是全球最大的”——但这仅仅是问题的一部分。他指出,代码可能是由多种语言编写的,还需要考虑可能以各种格式存储的数据。此外,还有与其他系统的技术集成,以及相关人员和组织的预期需要考量。
扎伊采夫表示,所有这些复杂性意味着“AI 目前在替换或迁移传统 COBOL 系统方面并未扮演主要角色”。
荷兰代尔夫特理工大学(Delft University of Technology)软件工程教授阿里·范·德尔森(Arie van Deursen)在接受《The Verge》采访时表示,OpenAI 的评估同样未能反映出这种复杂的现实。他形容该公司的博文“浮于表面”,指出其对迁移任务本身提供的细节极少,而其语言基准测试所考核的任务相对简单且边界清晰,涉及的系统也与模型在训练中见过的类似。他还强调了维护老化系统与实现系统现代化之间的巨大鸿沟。“维护当然比现代化容易得多,”范·德尔森说,并称 OpenAI 用于评估其模型的任务距离实际的现代化“相差十万八千里”。“OpenAI 展示的评估并没有解决关键难点:将复杂的遗留系统拆解为可以单独替换的小型单元。”
最大的挑战其实未必是重写代码。伦敦帝国理工学院(Imperial College London)编程语言教授阿拉斯泰尔·唐纳森(Alastair Donaldson)指出:“主要的挑战实际上是没人理解系统是如何运作的。”他表示,对于使用 COBOL 等语言的遗留系统来说,这种理解的缺失是“非常普遍”的问题,并补充说现在几乎没人懂怎么用这些语言编程了。而且,尽管它无处不在,唐纳森直言“任何理智清醒的人都不会在新的开发项目中使用 COBOL”。
“在很多情况下,迁移前后系统行为哪怕出现微小的差异,都是不可接受的。”
唐纳森表示,这使得稳健的测试变得至关重要。一种方法是通过旧系统和新系统运行相同的工作流,以检查它们的行为是否完全一致。AI 也可以对其代码转换过程进行文档记录,理想情况下可以让熟悉遗留语言的人类专家来审查这些工作。南丹麦大学(University of Southern Denmark)数学与计算机科学教授亚科波·毛罗(Jacopo Mauro)提出,形式化验证(formal verification,利用数学技术通过计算验证代码行为是否正确)是另一种选择。
毛罗表示,此类方法已经被用于验证 AI 生成的数学结果,但要将其应用于遗留代码将需要“巨大的工作量”。毛罗指出,使用这些方法意味着代码可以得到自动检查,“拥有这一手段将优于依靠人工来检查代码转换是否正确”。但在那之前,他表示“人工验证依然必不可少”。
当涉及的系统像基于 COBOL 运行的系统那样关键时,专家们表示,你必须绝对确保替代方案万无一失。扎伊采夫说:“在很多情况下,迁移前后系统行为哪怕出现微小的差异,都是不可接受的。”虽然 AI 确实能够降低成本并加快进度,但遗留系统的复杂性意味着仅靠部分自动化是远远不够的。
扎伊采夫说:“假设你有一根神奇的 AI 魔法棒,能够搞定 99% 的代码。但剩下的 1% 怎么办?那 1% 可能就意味着 100 万行代码,分散在系统的各个角落,并在你有生之年以超乎你想象的隐蔽方式引发故障。”
English / 原文
What do the IRS, banks, airlines, and government infrastructure around the world have in common? They’re all running on systems propped up by antique computer code that nobody dares touch, lest everything come crashing down.
OpenAI thinks it may have a solution. On October 19th, the company touted “substantial improvements” in its latest AI models’ ability to migrate aging software written in older programming languages into modern code, which it claims could help organizations with “maintaining and modernizing older systems.”
That’s a potentially massive deal. COBOL, one of the languages highlighted by OpenAI, remains stubbornly embedded in vast portions of the world’s critical infrastructure. And despite decades of efforts to banish it to history, the language has limped on, simply refusing to die.
“Nobody in their right mind would use COBOL for a new development project.”
It is hard to overstate COBOL’s ubiquity. Short for “common business-oriented language,” COBOL came into being in 1959. Nearly seven decades later, it is still everywhere. According to IBM, COBOL is the foundation for more than 40 percent of online banking systems, supports 80 percent of in-person credit card transactions, and handles 95 percent of ATM transactions. It also underpins many government systems, from Social Security to the IRS to services run by most states. One rough estimate puts the annual cost of COBOL’s inefficiencies to the US GDP at around $105 billion.
But replacing COBOL is fiendishly difficult. The same goes for other legacy programming languages, like Fortran, still in use today for everything from scientific computing and weather forecasting to atmospheric and ocean studies and codes critical to nuclear security. These systems are often too important to risk breaking, and many of the programmers who understand them have long since retired or died.
For all their impressive advances in modern software development, AI coding tools have struggled to make much headway with these legacy systems. But recent developments suggest that may be changing.
In its latest blog post, OpenAI reported promising results migrating COBOL code to more modern programming languages, including C++, Java, Kotlin, Python, and Rust, without changing what the original software does. That last bit is crucial for organizations looking to ditch code like COBOL, and OpenAI acknowledges that “a migration is considered successful only if all tests pass.”
In OpenAI’s own tests, GPT-6.1 Sol achieved 87 percent behavior preservation accuracy at low reasoning effort — how many computational steps the model spends analyzing a problem before giving an answer — climbing to 98 percent at higher reasoning. By comparison, at low reasoning effort, GPT-6 Astra scored around 86 percent, GPT-6 Sol just 21 percent, and GPT-5.6 Sol a mere 5 percent.
“Rewriting code is not the same as replacing a system.”
“These evaluation results demonstrate progress toward more accurate, affordable code migration for teams modernizing the software their businesses depend on,” OpenAI wrote.
The company also reported improvements on its models’ ability to build database software in various programming languages, including COBOL.
Anthropic also sees an opportunity in legacy systems. In February, it published a step-by-step “code modernization playbook” and pitched its coding agent, Claude Code, as a way to migrate COBOL code into modern languages like Java or Python. It offered no performance benchmarks showing how well Claude Code could perform such migrations, but declared that “the economics of COBOL modernization have shifted.” Shares in IBM, which derives part of its revenue helping companies maintain legacy systems, nosedived following Anthropic’s announcement.
Experts who spoke to The Verge agreed that AI tools have made strides in tackling legacy code in recent years. But they cautioned that advances trumpeted by OpenAI this week are a very long way from making it possible to safely replace critical legacy systems built around it.
OpenAI spokesperson Oscar Haines acknowledged in an email to The Verge that legacy code “is still far from a solved problem” and said the company is listening to feedback from developers and enterprises and exploring ways to build better tests and continue improving its models’ understanding of coding languages. Anthropic did not provide comment in time for publication.
“The evaluations shown by OpenAI don’t address the key difficulty: Breaking up a complex legacy system into smaller units that can be replaced individually.”
“Rewriting code is not the same as replacing a system,” said Vadim Zaytsev, an associate professor of software evolution at the University of Twente in the Netherlands. Systems do have a lot of code — Zaytsev said the largest system he’d seen had 250 million lines of COBOL, “definitely not the world’s largest” — but that’s only part of the problem. Code may be written in multiple languages and there’s data, potentially stored in various formats, to consider, he said. There are also technical integrations with other systems and the expectations of the people and organizations to bear in mind.
All that complexity means “AI is not playing a major role at the moment in replacing or migrating legacy COBOL systems,” Zaytsev said.
OpenAI’s evaluations don’t capture this complex reality either, Arie van Deursen, a software engineering professor at Delft University of Technology in the Netherlands, told The Verge. He described the company’s blog as “superficial,” noting it offered few details about the migration task, while its language benchmark tested models on a relatively simple and well-defined task involving systems similar to those they would have encountered in training. He also stressed the huge gap between maintaining an aging system and modernizing it. “Maintaining is of course a lot easier than modernizing,” van Deursen said, calling the tasks OpenAI used to assess its models “lightyears” away from actual modernization. “The evaluations shown by OpenAI don’t address the key difficulty: Breaking up a complex legacy system into smaller units that can be replaced individually.”
The biggest challenge isn’t necessarily rewriting code. “The main challenge is indeed not understanding how the system works,” said Alastair Donaldson, a professor of programming languages at Imperial College London. Such a lack of understanding is a “very common” problem for legacy systems using languages like COBOL, he said, adding that very few people know how to program in them anymore. And while it is everywhere, Donaldson said “nobody in their right mind would use COBOL for a new development project.”
“In many cases even minor differences in system behaviour before and after migration are unacceptable.”
That makes robust testing crucial, Donaldson said. One approach could be to run the same workflows through the old and new systems to check they behave identically. AI could also document its code translation, ideally allowing humans familiar with the legacy language to review the work. Formal verification, which uses mathematical techniques to computationally verify that code behaves correctly, is another option, said Jacopo Mauro, a mathematics and computer science professor at the University of Southern Denmark.
Such methods are already used to verify AI-generated mathematical results, but applying them to legacy code would require a “huge amount of work,” Mauro said. Using those methods would mean code could be checked automatically, Mauro said, adding that “having this will be better than having a human check that the translation is correct.” Until then, he said, “human verification remains essential.”
And when the systems involved are as critical as those running on COBOL, experts say you need to be absolutely certain the replacement works. “In many cases even minor differences in system behaviour before and after migration are unacceptable,” Zaytsev said. While AI can definitely deliver savings and speed things up, the complexity of legacy systems means partial automation isn’t enough.
“Suppose you have a magic AI wand that handles 99 percent of your code,” Zaytsev said. “What do you do with the remaining 1 percent? That 1 percent can be a million lines of code, spread all over the place and subtly failing in more ways you can imagine within your lifetime.”
Follow topics and authors from this story to see more like this in your personalized homepage feed and to receive email updates.
-
Robert Hart
-
AI
-
Anthropic
-
OpenAI
-
Report
-
Tech