For decades, one of the safest decisions in software has often been to leave working legacy systems alone. The reasoning was understandable.
Rewriting a large application could take years. It required developers to understand undocumented business logic, recreate thousands of edge cases, build new tests, migrate data, and somehow keep the existing system running at the same time.
Even when everyone agreed that the old system was difficult to maintain, the business case for replacing it was often hard to make.
AI-assisted development is starting to change that equation.
AI can help developers understand unfamiliar code, generate documentation, create tests, translate implementations, identify dependencies, and produce new code dramatically faster than before.
Tasks that previously made modernization prohibitively expensive are becoming easier to automate or accelerate. That creates an interesting question for organizations with large legacy systems:
If rewriting software is becoming significantly cheaper, should we simply recreate the same architecture — or use the opportunity to build something better?
We believe this creates a particularly strong case for Functional Programming.
The Economics of Rewriting are Changing
Historically, the cost of replacing a legacy system was dominated by human development effort. A developer first had to understand what the existing code was doing. Then document it. Then design the replacement. Then implement it. Then write tests. Then compare the old and new behavior.
AI can assist with every one of these steps.
An AI coding agent can analyze existing code and explain what a module does. It can help identify dependencies and business rules. It can generate characterization tests around existing behavior. It can create documentation for previously undocumented code.
And once the required behavior is understood, AI can assist in implementing the replacement. This does not mean that AI can automatically rewrite a complex production system. Architecture, domain understanding, verification, security, performance, and migration strategy still require experienced engineers.
But AI can remove a significant amount of the repetitive work surrounding those decisions. That matters because it changes the calculation. A modernization project that previously required too much time and too many developers may suddenly become economically realistic.
But Faster Code Generation Isn’t Enough
There is an important catch, AI makes it easier to generate code, it does not automatically make the resulting system simpler. In fact, organizations could easily end up doing the opposite: using AI to generate enormous amounts of conventional code faster than ever before. That might solve today’s modernization problem while creating tomorrow’s legacy system.
The objective therefore shouldn’t be: How can we use AI to rewrite our old code faster?
It should be: How can we use AI to replace our old system with something simpler, safer, and easier to change?
This is where Functional Programming becomes particularly interesting.
Legacy Systems Often Suffer From Complexity, Not Age
There is nothing inherently wrong with old software. A 20-year-old application that is stable, understandable, and inexpensive to maintain may be extremely valuable. The problem is usually accumulated complexity. Over many years, systems acquire mutable state, shared dependencies, special cases, patches, side effects, duplicated logic, and interactions that nobody fully understands anymore. Changing one thing can unexpectedly affect something somewhere else.
That is ultimately what makes legacy software expensive.
Functional Programming attacks many of these problems at their architectural roots. Instead of organizing software around objects whose state continuously changes, FP encourages developers to model transformations explicitly: Input → Function → Output
Pure functions make behavior predictable. Immutable data reduces hidden changes. Strong type systems can make invalid states difficult — or sometimes impossible — to represent. The result is software that can be easier to reason about locally.
And that becomes particularly valuable when both humans and AI agents are writing and modifying the system.
AI Makes Predictable Code More Valuable
There is a slightly paradoxical effect happening in software development. As AI becomes better at producing code, the ability to produce code becomes less scarce. The ability to verify that code is correct becomes more important. Imagine an AI agent modifying a function. If that function depends on mutable global state, hidden side effects, complex inheritance, and interactions spread throughout the application, determining whether the modification is safe can be difficult.
Now consider a pure function: calculatePrice : Order -> Customer -> Price
Given the same Order and Customer, it always produces the same result. It doesn’t unexpectedly update a database. It doesn’t modify the customer. It doesn’t depend on some global variable changed elsewhere in the application. That function is comparatively easy for a human to understand, it is easy to test, and importantly, it is also easier for an AI system to reason about.
Functional Programming therefore provides something increasingly valuable in AI-assisted development: constraints.
AI can generate implementations quickly, while the language, type system, tests, and architecture constrain what constitutes a valid implementation.
Strong Types Become Guardrails for Generated Code
This is particularly powerful in strongly typed Functional Programming languages such as F#, Haskell, Scala, and OCaml.
Consider a financial application. Instead of passing strings, integers, decimals, and nullable values throughout the application, the domain can be represented explicitly:
- CustomerId
- AccountId
- Currency
- Money
- Payment
- PaymentStatus
The type system can then encode rules about how these concepts are allowed to interact, and the compiler becomes part of the verification process, this has always been useful.
But when AI can generate hundreds or thousands of lines of code very quickly, compiler-enforced constraints become even more valuable. Rather than relying entirely on an AI agent to remember every architectural rule, some of those rules can be expressed directly in the software.
The AI is free to generate code — but within a much tighter set of boundaries.
Don’t Rewrite Everything
Moving from legacy software to Functional Programming does not have to mean launching a five-year “big bang” rewrite. In most organizations, that would still be unnecessarily risky. AI makes a more incremental strategy increasingly attractive.
Start by identifying a component that is:
- business-critical,
- difficult to change,
- reasonably well bounded,
- expensive to maintain, and
- possible to verify against existing behavior.
A pricing engine could be a good example. So could a rules engine, calculation module, workflow, reporting component, financial model, or data-processing pipeline.
The existing implementation becomes the specification and tests can capture its current behavior, and AI can assist engineers in understanding and documenting the old implementation. The new component can then be implemented using Functional Programming and run against the same inputs as the existing system.
Instead of arguing theoretically that the new approach will be better, you can measure it:
- How much code was required?
- How comprehensive are the tests?
- How easy is the new implementation to understand?
- How many invalid states are prevented by the type system?
- How easy is it to introduce a new business rule?
- And how much AI assistance could safely be used during development?
From Rewrite to Continuous Modernization
This also changes how organizations can think about legacy modernization. Rather than treating modernization as one enormous project every 15 years, it can become an ongoing process.
Take one bounded component:
- Understand it.
- Test its existing behavior.
- Redesign the domain.
- Implement the replacement.
- Verify it.
- Move traffic to the new component.
- Then choose the next one.
Over time, the architecture gradually moves away from the most problematic parts of the legacy system without requiring the organization to bet everything on a single rewrite. AI can accelerate each iteration, and Functional Programming can help ensure that each iteration leaves the system simpler than before.
The Goal Should Be Less Code, Not More Generated Code
There is another important point. AI makes generating code cheap, however that doesn’t make maintaining code free. Every new abstraction, dependency, class, service, configuration file, and integration becomes something that eventually has to be understood and maintained. Organizations should therefore resist measuring AI development productivity primarily by how much code can be produced.
The better question is how little code is necessary to express the required business behavior clearly and safely. Functional Programming often lends itself well to this objective because composition, higher-order functions, pattern matching, algebraic data types, and immutable transformations can express sophisticated behavior with relatively little ceremony.
In the AI era, that characteristic becomes more — not less — important.
If AI helps us write software faster, we should use that productivity gain to build smaller and better systems, rather than simply generating larger ones.
A Rare Modernization Window
Major changes in software development occasionally create opportunities to revisit assumptions that previously seemed fixed. AI-assisted development may be one of those moments. Organizations have spent decades accumulating legacy applications because replacing them simply wasn’t economically attractive.
That constraint is beginning to weaken. AI can help us understand old systems faster, document them, create tests around them, and accelerate the implementation of their replacements. But the real opportunity isn’t simply to recreate yesterday’s software faster. It is to reconsider how tomorrow’s software should be built.
Functional Programming offers many of the properties that become increasingly valuable as AI writes a larger share of our code: predictable behavior, immutable data, explicit effects, strong types, composability, testability, and architectures that are easier to reason about.
The combination is powerful.
AI can reduce the cost of moving away from legacy systems. Functional Programming can reduce the risk of creating the next generation of them.
For organizations that have spent years saying “we should replace that system someday,” someday may finally be getting considerably closer.
