AI
Researchers Use AI to Extract Hidden Logic from Legacy Code for Smoother Language Migration
A new technique treats outdated programs as implementations of hidden declarative descriptions, using language models to make them explicit and guide automatic translation to modern languages.
Modernizing old software repositories remains a major challenge in software engineering: decades of accumulated logic live in undocumented code that's hard to understand and convert to contemporary languages. Researchers have developed a novel approach that treats legacy programs as implementations of an implicit declarative specification—and works to surface that specification to aid automatic porting.
The Core Insight#
The key assumption behind the work is that every program encodes an underlying, unstated description of what it computes. By making this latent representation explicit, the authors hypothesize, it becomes possible to guide code migration more effectively. Rather than translating code line-by-line, their method reconstructs the intent of the original system first.
How ADFD-Migrate Works#
The technique, called ADFD-Migrate, approximates this hidden specification using an annotated data-flow diagram (ADFD)—a structured representation that captures processes, data stores, external systems, information flows, and behavioral contracts. Here's the workflow:
- A large language model infers the source ADFD by examining bounded portions of the repository
- Static-analysis checks guide and validate coverage of the inferred model
- A dependency-aware chunking strategy orders process groups for translation to the target language
- Differences between the source ADFD and a statically recovered target ADFD inform iterative regeneration
Putting It to the Test#
The team evaluated ADFD-Migrate on a new benchmark called f2x50, comprising 50 Fortran repositories ranging from 1,500 to 1.6 million lines of code across three complexity levels. Results suggest the approach makes a meaningful difference:
- Generated Python translations passed 327 out of 382 oracle tests (85.6%), with 40 repositories achieving perfect scores
- The method exposed all 382 targeted behaviors as runnable code, versus only 99 and 98 for simpler baselines
- It achieved a 93.1% mean migration outcome index and outperformed direct translation by 17–59 percentage points on 47 repositories
- Ablation studies showed that both static-profile analysis and dependency-aware chunking contributed measurably to success

