Legacy Modernization with LLMs: Cost and Results

Legacy modernization with LLMs: RPG code translated into Java with cost and error results

Legacy modernization with LLMs got a rare dose of data this month. A team ran controlled experiments translating two real RPG applications from IBM i into Java with Claude Code and Opus 5.5. The headline cost was about $1,100 at API prices to translate more than half a million lines, and every translation compiled. Every translation the team examined also behaved differently from the original in places.

The applications and the setup

Both systems are real ERP software that has evolved over decades. “Small” covers production planning inside a furniture maker’s ERP: roughly 15,100 lines of RPG plus 208 DDS files and 4 CL programs. “Large” is an ERP for clothing manufacturing and retail, with some 552,000 lines in the migration plan and another 51,000 or so of queries and CL.

The prompt was short: translate the application to Java, put the code in a directory and organize the project as you see fit. Small was translated three times from scratch. Five programs from Large were also translated three times. Large itself was translated once.

The agent didn’t plan Large alone. Deterministic tooling parsed the codebase and ordered its 2,777 files by dependency. A script cut the plan into 43 phases, each comparable to Small, and further phases handled queries (two) and CL programs, commands and menus (four). Each phase ran as a separate session.

Rows of wooden barrels in a brewery storehouse
Image: Federico Tomassetti

What it cost

  • Five programs: about $2 and 8 minutes.
  • Small: about $24 and one hour.
  • Large: about $1,100, with 48 hours of agent working time spread over eight days.

That works out to about $1.60 per thousand lines for Small and $1.80 for Large. Large was roughly 35 times Small’s size, yet it cost around 45 times as much. Single phases ran from $1.22 to $37.73 and didn’t get steadily pricier as the Java project grew, which suggests the approach might scale without cost per line exploding.

Output varied for the same price. Small came back as 14,500 lines in one run and 26,300 in another. The Large translation yielded 5,737 Java files and some 1,053,000 lines, and used 11.8 million output tokens and 3.14 billion cache-read tokens. Every phase finished on its first attempt, though “finished” only means the session ended and the project compiled.

These figures cover only the first translation. Generating test scenarios for the five programs cost $7.56 with another model, about four times the translation cost. Human work, correction cycles and verification aren’t counted.

Console screen for entering a new record, with its program identifier masked.
Image: Federico Tomassetti

Same logic, different applications

Repeated translations of the same code kept recognizable logic but produced different Java. The packages, field types, data access, public interfaces and launchers all differed. On normal input they behaved alike: all three runs passed 35 predefined tests, and one program matched across 102 million valid inputs. Away from the normal path, overflow, negative values, mid-update errors and missing source each got different treatment.

The strategic choices were the same every time: no application framework such as Spring Boot, a hand-built runtime, and CSV files or H2 for storage instead of something like PostgreSQL. The agent also wrote seven Python generators on its own for DDS, display files, print specifications, SQL tables, queries, CL and menus.

Console list showing the added record, with its program identifier masked.
Image: Federico Tomassetti

The errors found

Looking at about a tenth of the programs turned up errors in every translation, and they weren’t cosmetic:

  • One program’s records were read in the wrong order in all four translations.
  • A lost sign that put a date in another century.
  • Errors raised by the original but ignored by the translation, so a nightly job continues when it should stop.
  • Three different answers to one overflowing calculation, and two programs that loop forever.
  • Transactions rolled back or committed opposite to the original, and no record locking.
  • 17 programs counted as translated that throw an exception when run.

The team had no IBM i machine, so its expectations of the original come from reading the source and the RPG manual.

What it means for anyone planning a migration

Large did start: the H2 database initialized and the main menu came up. They added a record on a maintenance screen and it survived a restart. A report ran but produced headings with no data rows, and database setup skipped 27 logical files.

The authors’ conclusion is that these applications can’t be trusted with the business before serious testing. A rounded $2 per thousand lines gives a rough first-generation cost, but it isn’t a migration budget. The costly part, proving the new system matches the old one, is still unsolved.

Source: Federico Tomassetti

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.