Co-founder of Strumenta. Essays on software languages, legacy systems and the craft of building tools.

281 articles · since 2009

Rows of wooden barrels in a brewery storehouse
Legacy systems & modernization · 16 min · 3,153 words · 5 of 40 in this topic · by

Legacy Modernization with LLMs: what a well-done migration will look like in 2027

The world of software is changing, and the world of software migrations is changing with it, possibly more than other bits and niches. So the question I want to discuss in this article is how a well-done migration will look in 2027 and beyond.

Now, trying to predict the future in a period like this one is an exercise that requires a certain courage, or perhaps a certain shamelessness (but also sheer arrogance or stupidity can work). Having said that, I am going to give my opinion anyway, and it is an opinion based on the years we spent doing migrations, on many conversations with clients and with other people who do this job, on my own heavy daily use of LLMs, and on the experiments described in the first four articles of this series.

This series

  1. Article 1: the experiments, the costs and the answers in short
  2. Article 2: what changes when we translate the same code three times, and the decisions behind it
  3. Article 3: whether the translations behave like the original
  4. Article 4: whether a large translation is consistent with itself
  5. Article 5 (this one): how I would approach a migration now

The three phases of a migration we are going to look at

A migration is made of several phases, and I am going to concentrate on three of them: the design, the translation itself, and the testing. I’ll leave out the others, such as deployment and data migration, not because they are less important but because I think they remain closer to what they were before, while these three are the ones that LLMs are changing.

My position, in short, is the following:

  • Design. We must be careful not to neglect it, which today is very easy to do, with consequences that are not obvious at first, but eventually costly.
  • Translation. LLMs offer a great opportunity to improve this phase, but it is not yet clear how exactly to turn that promise into reality, and I see two ways of doing it.
  • Testing. This is where, in my opinion, most of the work is still to be done and most of the answers are still to be found.

The design phase, and the temptation to skip it

It is very easy to just abdicate our responsibilities and let the LLM choose the design of the new system (or anything else, for what matters). It is hard but, for the love of God, we need to resist this, as tempting as it is.

We can ask an LLM to translate an application for us and it will do it, taking every decision along the way without asking us anything, so we may think that it has relieved us of all the effort. It has. The problem is that we are still responsible for the consequences of these decisions, and, incidentally, for being able to defend them, to provide motivations for them. Which is hard to do when you did not make any of them.

In article 2 we saw what this means in practice. The same prompt, given three times, produced three applications with a different representation of the fields, a different way of accessing files, a different handling of transactions, and the decisions that were the same in all the runs (no framework, a runtime written by hand, CSV files or H2 as storage) were not the ones that our clients or we would have made. Nobody discussed any of them. They were just there, in the code, when the agent finished.

Why I do not expect LLMs to learn how to make these decisions

One could object that models are improving quickly and that sooner or later they will make good architectural decisions too. I am not convinced, and the reason has to do with how these models improve. LLMs have become enormously better in the areas where it is possible to give them an enormous amount of feedback: one can train a model to produce code that compiles, or code that passes a test, because the result is available in a few seconds and it is unambiguous. An architectural decision is a different kind of object. Some of its consequences appear after five or ten years, when we discover how much it costs to maintain the system or to find people who are able to work on it, and in many cases we do not even have the instruments to measure them. It is possible to do reinforcement learning on obtaining code that compiles, and I do not see how it would be possible to do it on obtaining the choices that, ten years later, will have maximized maintainability for one specific company.

If you do not believe me on this point, try talking with an LLM about other things for which quick and abundant feedback is not available; ask it about business strategy, for example.

An LLM offers certainties, and it is up to us to have the doubts

There is a second aspect, which concerns the way these tools behave. An LLM, by its nature, does not tend to raise doubts: it tends to provide certainties. It does not stop at each gap to say that there is something it does not know and that it would be better to ask. After all, what is selling is taking things off our plate.

A good consultant does the opposite:

  1. He asks all the questions he can think of during the planning phase,
  2. During execution, if a need to clarify more points comes up, he brings it up in conversation.

Of course, this is what a good consultant should do, not necessarily what all consultants do.

The consequence is that, if we are the ones driving the LLM, then we must know what should be evaluated, which doubts we should have, and which decisions have to be taken. If we do not know that a decision exists, the LLM will not tell us: it will take it.

The decisions to make, and what to weigh when making them

So what are these decisions? The most visible ones are the target language, the framework, and the database. In our experience, most of the companies migrating to Java want (excuse the expression) boring enterprise applications, which typically means Spring Boot, even if this is not always the case. For the database, some clients want to remain on Db2, others want to move to PostgreSQL, and others still want to stay where they are for now while isolating the parts that are specific to the database, so that moving later remains possible.

Then there is the question of who will maintain the code. If it is the original team, perhaps after some training, it can make sense to produce code that resembles the RPG it comes from, with types for fixed-length strings and packed decimals that represent the original semantics directly. If it is a team of Java developers, we probably want String, BigDecimal, and int, with the rules of the original language confined in a runtime library or made explicit where they matter. Both are legitimate, and they lead to two very different applications.

To choose, we have to consider things that are not written in the code we are migrating:

  • The skills that are already in the company, and the ones that can realistically be found or built.
  • The other technologies in use in the company or in the group it belongs to, especially if there is the intention to converge on a single stack, or if the company has just been acquired.
  • The prospects of those technologies over the years in which the migrated system will have to live.
  • Which factors matter most for us: performance, maintainability, ease of finding talent, infrastructure costs.

Making these decisions well takes work, for the client and for whoever is helping them. Many companies look for external help exactly here, because they spent decades working with one technology and, in front of a decision that will have consequences for the next ten or fifteen years, they want somebody who has kept a wider view of the alternatives. Others have those skills internally. In both cases, a well-done migration in 2027 starts from a design that somebody decided, and not what the machine that can’t be held accountable threw at us.

The translation phase: turning the design into a system

Once we have a design, we have to turn it into something that applies those decisions to the existing code and produces the new code. For very small applications, I think that giving the design decisions to an LLM, asking it to translate the code, and then hammering on the result until it works is a strategy that can succeed. If I had a 50,000-line or so application, this is what I would try first.

It is not a strategy that works for large applications, and the reasons are the ones we saw in the previous articles. Each run takes different decisions, so we cannot translate a part again without risking that it no longer fits with the rest. In a large translation, which necessarily happens across many sessions, the style drifts from the first sessions to the last ones, the same utility is written again in dozens of programs instead of being shared, and nobody goes back to align the code written earlier when the runtime improves (article 4). And we found errors in every translation we examined (article 3).

This does not mean that large applications cannot be migrated with LLMs. It means that it takes an engineered approach, and I see two of them:

  1. Create an engineered process around LLMs, ergo, defining a migration software factory,
  2. Keep writing transpilers but doing it better and more rapidly using LLMs.

A migration software factory

The first one is to build a specific harness around the LLM, something I would call a migration software factory. Instead of a series of prompts, we would have a process: a plan derived from an analysis of the whole codebase, as the one we used for the large system we migrated; the design decisions written down as instructions and as examples of the code we expect; a runtime defined before the translation starts, and not grown session after session; steps in which the work done earlier is revisited to keep it aligned; automatic checks on duplication and on the conventions; and a verification loop around all of this. I believe it is possible, and several people are working in this direction, us included.

A software factory that produces a transpiler

The alternative is to use the LLM to build a transpiler, and then to use the transpiler to translate the application. This is surprisingly close to what we observed in the experiment: when we asked an LLM to translate a large application, what it did, without being asked, was to write seven small scripts acting as transpilers for different kinds of source. Apparently, even the LLM thinks that transpilers are a good idea. And maybe this is a hint that choosing between LLMs and transpilers is the wrong way to frame the question.

The advantages of this strategy are the ones we would expect from a deterministic tool:

  • Consistency. A decision written in a transpiler is applied in the same way to every program, whatever the day on which it is translated. In the large system we migrated using a transpiler, the generated parts were the most uniform ones.
  • Errors that are predictable and localized. When a rule is wrong, it is wrong everywhere in the same way, and correcting the rule corrects all the cases.
  • A smaller thing to verify. Verifying a transpiler, rule by rule, can be simpler than verifying an entire migration, program by program.

The main disadvantage is that it requires skills and reusable components to start from, such as a parser for RPG and a framework for defining transpilers. We saw the consequence of not having them: the generators that the agent wrote covered the file definitions, the screens, the queries, and CL, which are the easy parts, while RPG, which is where the logic of the application lives and which mixes fixed and free format in the same program, was translated by hand, one program at a time. Without those foundations, this is the harder road. With them, I think it is the one that gives more control.

I expect that these two strategies will be the ones that will drive the translation phase in the next years.

The testing phase, where the answers are still missing

This phase has been taking longer and has been more costly than anybody wanted for quite some time. Now, with the translation phase accelerating, this is becoming even more of a pain. The fact is that I hardly saw any progress in this area. The approaches at our disposal are the ones we had before:

  • Record and replay. We execute the original application on a set of inputs, we capture the results, we do the same on the translated application, and we check that they match.
  • Parallel run. We keep the two systems, the original and the translated one, running side by side; we send the same inputs to both, and we record the discrepancies.
  • Manual testing. Call me old-fashioned, but I think some of it should remain. Doing all of it manually, however, becomes very expensive.

None of these is a brilliant solution. The first two also share a limit, which is that some operations do not happen often: the closing of the year or of the quarter, or the routine that is executed when a new shop or a new branch is opened, may never run during the period of observation, and so those paths remain untested.

Asking the LLM to write the tests is not the answer

The idea that comes naturally is to ask the LLM to generate the tests. We saw that it does not work. When we asked for the same application to be translated three times, each run also wrote its tests, and each suite passed, while the three translations disagreed with each other: the tests simply adhere to what that translation does. The translation of the large system passes all its 1,150 tests, and not one of the errors we found was caught by them. When a migration involves modern code, we can often bring the existing tests across, but legacy systems typically do not give us that starting point, because the tests just aren’t there.

Somebody will suggest using a different model, or the same model in a separate context, to write the tests starting from the original code. It may reduce the problem, and I think it is a direction worth reasoning about, but an agreement between two models does not guarantee that the new system behaves like the old one, as we saw with the errors that all the translations had in common.

To be certain, we need the original system

If we want to be certain of the results, we need to be able to run the original system, with its specific hardware and software, be it an IBM i, a mainframe, or a SAS installation. The client does not always have this possibility, or not in a form that allows us to run thousands of scenarios and compare the outputs. In our own experiments, we did not have an IBM i, and everything we said about the behavior of the original comes from reading the source and the documentation. This is a problem for the testing phase and, in my opinion, it remains open.

The cost of testing is going to weigh even more

In our experience, in the projects done before LLMs, the testing phase often cost more than the translation phase. If LLMs keep their promise of making the translation simpler and cheaper, this disproportion can only increase: a phase that was already the most expensive one will be even more so, and I think it will become the real battlefield of migrations. We had a small confirmation in the experiment, where generating test scenarios for five programs cost about four times as much as translating them.

There is also a reason why testing is becoming more vital, and not just relatively more expensive. After a phase of enthusiasm, we are starting to see the bill for the acceleration in the way software is developed. The DORA report of 2024 found that an increase in the adoption of AI was associated with a decrease in the stability of software delivery, and in the months in which I am writing, there have been several cases of serious outages that the press connected to changes made with AI tools, even if the companies involved do not always agree on the cause.

Now consider who migrates. We are talking about companies that remained on old technology for decades, and they typically did so because they are conservative companies, for which the system that runs the business must keep working above all. If in the translation we involve new approaches such as the ones based on LLMs, we are adding uncertainty exactly where these companies least want it, if anything else, because LLM-powered migrations are the new thing and not something proven for 10 or more years. Testing was not a phase to skip before, and now it is the one that has to give them the confidence to go to production.

Conclusions

So how will a well-done migration look in 2027? This is my bet:

  • It starts with a design that people decide, considering the context of the company, and for which somebody takes responsibility. The LLM can help us explore available alternatives, and it should not be the one choosing among them.
  • The translation is performed by an engineered system, be it a migration software factory or a transpiler built with the help of LLMs, and not by a prompt. Mechanical translation becomes cheaper than before, but not that cheap, as the cost of mistakes is still high.
  • Most of the effort and of the budget goes into verification, more than before, and whoever finds a better answer to the testing problem will have solved the most valuable part of the job.

In 2018, at the end of an article on migrating PL/SQL to Java, I closed the part on testing by saying that there was probably some more work to do. Eight years and one revolution later, I find myself writing the same sentence.

And you? If you are migrating a system, who is taking the design decisions, and how are you establishing what the original really does?

If these are questions you are facing right now and you would like to reason about them with somebody who has been through a few migrations, get in touch with us: this is the kind of conversation we enjoy having. You can also take a look at how we approach migrations in general and the modernization of RPG applications in particular.

One letter when there is something worth sending.

Written by Federico · Torino

Scroll to Top