Skip to main content
QUICK REVIEW

[Paper Review] Leveraging LLMs for Legacy Code Modernization: Challenges and Opportunities for LLM-Generated Documentation

Colin Diggs, Michael W. Doyle|arXiv (Cornell University)|Nov 22, 2024
Artificial Intelligence in LawSocial Sciences3 citations
TL;DR

This paper evaluates large language models (LLMs) for generating line-by-line comments in legacy systems using MUMPS and IBM mainframe assembly code. It proposes a prompting strategy that avoids incomplete or modified outputs and finds LLM-generated comments are generally accurate, complete, and useful—though no automated metrics strongly correlate with human evaluation quality, highlighting a critical gap in evaluation tools for LLM-generated documentation in legacy software.

ABSTRACT

Legacy software systems, written in outdated languages like MUMPS and mainframe assembly, pose challenges in efficiency, maintenance, staffing, and security. While LLMs offer promise for modernizing these systems, their ability to understand legacy languages is largely unknown. This paper investigates the utilization of LLMs to generate documentation for legacy code using two datasets: an electronic health records (EHR) system in MUMPS and open-source applications in IBM mainframe Assembly Language Code (ALC). We propose a prompting strategy for generating line-wise code comments and a rubric to evaluate their completeness, readability, usefulness, and hallucination. Our study assesses the correlation between human evaluations and automated metrics, such as code complexity and reference-based metrics. We find that LLM-generated comments for MUMPS and ALC are generally hallucination-free, complete, readable, and useful compared to ground-truth comments, though ALC poses challenges. However, no automated metrics strongly correlate with comment quality to predict or measure LLM performance. Our findings highlight the limitations of current automated measures and the need for better evaluation metrics for LLM-generated documentation in legacy systems.

Motivation & Objective

  • To assess the feasibility and quality of LLM-generated documentation for legacy software written in niche, outdated languages like MUMPS and IBM mainframe assembly language (ALC).
  • To develop and validate a prompting strategy that reliably generates line-wise code comments without modifying the source code or producing incomplete output.
  • To evaluate the correlation between human-annotated comment quality and automated metrics, including code complexity and reference-based metrics like BLEU and ROUGE.
  • To identify limitations in current automated evaluation methods for LLM-generated documentation in legacy systems, where ground-truth comments are scarce and human evaluation is costly.

Proposed method

  • Proposed a structured prompting strategy to generate line-wise comments that avoids code modification and incomplete generation, ensuring fidelity to the original source.
  • Designed a human evaluation rubric scoring comments on completeness, readability, usefulness, and hallucination for both MUMPS and ALC code.
  • Collected and evaluated 1,000 comments across two real-world legacy codebases: an EHR system in MUMPS and open-source ALC applications.
  • Measured automated metrics including code complexity (Cyclomatic Complexity, Halstead), reference-based metrics (BLEU, ROUGE, CHRF), and LLM inference cost to correlate with human judgments.
  • Used statistical analysis (Spearman’s rho) to assess the strength of correlation between automated metrics and human evaluation scores across both codebases.
  • Applied a greedy chunking strategy to handle long code files within LLM context window limits, with no evidence of optimal chunking strategy in current literature.

Experimental results

Research questions

  • RQ1Can mainstream LLMs generate high-quality, line-level comments for legacy code in MUMPS and ALC that are comparable to human-written comments in completeness, readability, and usefulness?
  • RQ2Does the proposed prompting strategy prevent common LLM failures such as incomplete comment generation or unintended code modification?
  • RQ3To what extent do automated metrics—such as code complexity, BLEU, ROUGE, and CHRF—correlate with human-annotated comment quality in LLM-generated documentation?
  • RQ4Are there significant differences in LLM performance between MUMPS and ALC, and if so, what factors (e.g., language structure, similarity to modern languages) may explain these differences?
  • RQ5Can automated metrics reliably predict or measure the quality of LLM-generated documentation in legacy systems without requiring human-annotated ground truth?

Key findings

  • LLM-generated comments for MUMPS are generally hallucination-free, complete, readable, and useful, performing comparably to human-written comments.
  • LLM-generated comments for ALC are significantly more challenging to produce, with lower performance across all human evaluation dimensions, suggesting structural differences between ALC and modern languages hinder understanding.
  • No automated metric—including code complexity, BLEU, ROUGE, or CHRF—shows a strong correlation with human evaluations of comment quality, especially on ALC code.
  • The lack of strong correlation between automated metrics and human judgments indicates a critical limitation in current evaluation practices for LLM-generated documentation in legacy systems.
  • The performance of LLMs varies significantly across codebases, and results from this study do not guarantee similar outcomes on proprietary or unique legacy systems.
  • The study confirms that human evaluation remains the only reliable method for assessing LLM-generated documentation quality, underscoring the need for better automated evaluation tools.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.