Why using AI to modernize legacy mainframe hairballs is harder than you think

Jason Bloomberg, Managing Director, Intellyx BV

Generative AI (genAI) is a legacy code modernization magic wand. Put that mainframe hairball in one end and out pops well-architected modern code out of the other, ready for deployment in the cloud of your choice, right?

Not so fast.

It’s true that there are now several genAI-based legacy code modernization tools on the market that can do a reasonable job of translating, say, COBOL or PL/I code into Java or Python, etc.

As a rule, however, these tools cannot scale. Feed them large codebases – the ‘hairballs’ that most mainframe-dependent organizations struggle with on a daily basis – and they fall over.

Sage AI Technologies, however, is the exception. Why does genAI fall short when modernizing such codebases? And how does Sage solve this hairball of a problem?

Challenge #1: Maintaining context at scale

Every genAI large language model (LLM) has a limitation on how much information it can accept in a prompt. This context window constrains the level of understanding any modernization tool can bring to a legacy codebase.

Furthermore, the more code fed into the tool, the more tokens it consumes, which means the more expensive it becomes to run. The result: more money for poorer results.

Many legacy mainframe codebases run at millions of lines of code across thousands of programs, as well as numerous copybooks, JCL jobs, and data definitions.

As a result, most AI-based modernization tools have a global context problem that limits whole-system understanding of legacy codebases.

In addition, legacy mainframe code written in languages like COBOL, PL/I, and REXX typically ties business logic to core operations. GenAI struggles to interpret such logic especially at scale, as it often misses critical edge cases or other functionality.

LLMs may do a good job of understanding code locally at the program or file level but fail at making sense of code at the global, end-to-end business flow level.

Challenge #2: Understanding the semantics of business logic

LLMs generally understand syntax patterns, giving modernization tools at least the appearance of code understanding.

Where genAI struggles, however, is understanding the semantics of mainframe logic.

After all, the original programmers of mainframe applications had no idea that decades later, AI would need to make sense of their code.

They had no qualms, therefore, about incorporating numeric flags, implicit sequencing assumptions, data-driven control flow, or ‘magic’ values like hardcoded maximum values or error codes – implicit semantic signifiers that present booby traps for any LLM.

Sometimes these semantic signifiers represent logical edge cases – edge cases that the AI may miss entirely. In other situations, the modernization tool may generate financial logic errors: errors that mainframe-centric organizations simply cannot tolerate.

Without an understanding of such code modernization traps, AI-based modernization tools struggle to uncover the business intent in the code they are modernizing. They end up generating results that may look correct but include subtle logic errors that testers find difficult to uncover.

Challenge #3: Modernizing architecture vs. modernizing code

Many legacy modernization tools purport to offer some level of architectural modernization. For example, it’s common for such tools to be able to identify subroutines in the mainframe code and translate them into shared objects or microservices in Java.

Modernizing legacy procedural hairballs into efficient cloud native applications, however, is far more difficult.

Simply creating microservices isn’t enough: a modernization tool must also understand the bounded contexts that properly separate microservice functionality so that it can offer the scale and flexibility that cloud native architectures promise.

Instead, legacy modernization tools are more likely to preserve monolithic code structure by wrapping legacy logic, rather than rearchitecting it to follow modern architectural best practices.

A better approach to AI-based modernization: Sage AI Technologies

The modernization tooling from Sage represents a next-generation approach to applying genAI to the challenge of legacy codebase modernization at scale.

Rather than limiting input code to a particular context window, Sage ingests the entire codebase. As a result, it is able to produce high-level architectural models and insights that give engineers a system-wide map of components, data flows, and dependencies.

In other words, Sage anchors AI outputs in the structure of the entire application, rather than separate parts of it, thus maintaining context at scale.

Sage then leverages the architectural models it produces plus auto-generated documentation to train domain-aware LLM agents, essentially tailoring them for each specific codebase.

As a result, Sage’s reasoning leverages context that it grounds in each particular legacy system, reducing the chances of hallucinations and increasing semantic correctness, even for the hairiest of legacy mainframe hairballs.

The Intellyx Take

Today, no modernization tool – including Sage’s – is fully autonomous, especially at scale. All such tools help engineers with modernization rather than replacing them.

While Sage offers a measure of autonomy, what it provides, more so than competing modernization tools, is context and explainability.

Sage understands the functionality of even the most complex legacy hairballs. It tailors AI agents to each system, reducing the risk of hallucinations and incorrect refactoring and gives engineers a common shared understanding of the codebase in question.

Because Sage can understand the entire codebase, it can provide better architectural results than competing tools, even when the original code contains semantic booby traps and dense monolithic control flows.

There’s more to the Sage story. This article is the first in a series. Stay tuned for additional pieces by myself and my colleague Eric Newcomer.

Copyright © Intellyx BV. Sage AI Technologies is an Intellyx customer.

Intellyx retains final editorial control of this article.

No AI was used to write this article.

Next
Next

Tell your Coding Assistant What you Expect