Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Functional programming ideas have moved into mainstream Java over twenty years. Which of them have proven their value in large Java codebases, which have not, and what would you encourage or discourage in your organisation's standards?

The functional ideas that have proven their value in large Java codebases are immutable values, pure calculations, small higher-order utilities, stream transformations of collections, and, more recently, sealed types with pattern matching for modelling data and outcomes. The mixed ones are heavy monad stacks, point-free style and deep currying, which hurt readability for most Java developers. Standards should encourage the proven ideas with examples and discourage styles that need a specific library or training that most hires do not have.

Why this question is asked

Over twenty years, Java went from anonymous inner classes to lambdas, streams, records, sealed types and pattern matching, and many teams experimented with functional libraries along the way. That gives us enough history to judge ideas by results rather than enthusiasm. Interviewers ask this at a principal level because the answer shows whether we can separate what made codebases better from what merely felt modern, and turn that into standards. In this answer, we will recap how functional ideas entered Java, look at the ideas that proved themselves with examples, look at the ones with mixed results and why, and finish with what I would encourage and discourage.

1How Functional Ideas Entered Java

Functional programming treats computation as applying functions to values, prefers data that does not change, and keeps side effects, such as writing to a database, apart from calculations. Java took these ideas in steps. Libraries such as Guava brought immutable collections and function objects before Java 8. Java 8 added lambdas, streams and Optional. Records, compact immutable data classes, became final in Java 16, sealed types in Java 17, and pattern matching for switch together with record patterns in Java 21.

Along the way, libraries such as Vavr offered more: persistent collections, Try and Either types, and monadic composition. Some teams adopted them deeply. That variety is useful, because it lets us compare codebases that went far with codebases that stayed close to the language.

2Proven: Immutable Values and Pure Calculations

The clearest win is immutable data combined with pure calculations, functions whose result depends only on their arguments and which change nothing outside themselves. Immutable objects can be shared between threads without locks, used safely as map keys and cached without defensive copies. Pure calculations can be tested with a few lines and no mocks.

Java
record Money(BigDecimal amount, Currency currency) {}
record Line(Sku sku, int quantity, Money unitPrice) {}
static Money subtotal(List<Line> lines, Currency currency) { // pure: same input, same output
BigDecimal total = lines.stream()
.map(l -> l.unitPrice().amount().multiply(BigDecimal.valueOf(l.quantity())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
return new Money(total, currency);
}
// The test needs no database, no mocks and no framework
var lines = List.of(new Line(sku1, 2, eur("4.50")), new Line(sku2, 1, eur("1.00")));
subtotal(lines, EUR); // Money[amount=10.00, currency=EUR]
subtotal(lines, EUR); // Money[amount=10.00, currency=EUR]: always the same answer

Notice that subtotal reads nothing from outside its arguments and writes nothing anywhere, so calling it twice with the same lines always gives the same answer, and the test is two lines. Whole categories of bugs, such as a shared list modified by another thread or a cached object changed after caching, simply disappear when values are immutable. In codebases that adopted records and pure domain functions widely, these benefits showed up quickly and nobody asked to go back.

3Proven: Small Higher-Order Utilities and Stream Transformations

Small functions that take or return functions have earned their place: Comparator.comparing(Order::date).thenComparing(Order::id), a retrying(Supplier, attempts) helper, a cache's computeIfAbsent(key, loader). Each hides a small, reusable piece of control flow behind a clear name.

Streams for transforming collections, filtering, mapping, grouping and summing, have also proven themselves, as long as pipelines stay short and named. Collectors.groupingBy(Order::region, Collectors.summingLong(Order::cents)) says in one line what used to take a loop, a map and several null checks, and readers understand it once they know a handful of operations.

4Proven: Sealed Types With Pattern Matching

The newest proven idea is modelling data and outcomes as closed sets of types, which functional languages call algebraic data types. Java's sealed interfaces with record implementations, handled by an exhaustive switch, let us represent "a payment either succeeded, was declined, or needs review" so that the compiler checks every case is handled.

Java
sealed interface PaymentOutcome {
record Approved(String reference) implements PaymentOutcome {}
record Declined(String reason) implements PaymentOutcome {}
record NeedsReview(int riskScore) implements PaymentOutcome {}
}
String status = switch (outcome) {
case PaymentOutcome.Approved a -> "paid " + a.reference();
case PaymentOutcome.Declined d -> "declined: " + d.reason();
case PaymentOutcome.NeedsReview(int s) when s > 80 -> "manual review, high risk";
case PaymentOutcome.NeedsReview n -> "manual review";
}; // adding a new outcome makes this switch fail to compile until it is handled

This gives the main benefit people sought from Either and similar types, explicit and typed outcomes, using only standard Java that every developer can look up. It is why I count it among the proven ideas even though it is recent.

5Mixed Results: Monad Stacks, Point-Free Style and Deep Currying

Other ideas have a mixed record in Java. Heavy monad stacks, such as Future of Either of Option composed with flatMap chains, work well in languages designed for them, but in Java they produce long generic types, nested lambdas and confusing compiler errors. Point-free style, composing functions without naming their arguments, becomes andThen and compose chains that a reader has to decode. Deep currying, Function<A, Function<B, Function<C, R>>>, is precise but hard to read, and every value is boxed.

The pattern is the same in each case: the idea is sound, but Java's syntax makes it verbose, its type inference and error messages make it hard, and most Java developers have not been trained in it. In codebases that used these heavily, the code was often correct but expensive to review, hard to debug and frequently rewritten when ownership changed.

Functional ideas in large Java codebases
IdeaRecordStandard says
Immutable values (records)ProvenEncourage, default for data
Pure domain calculationsProvenEncourage, keep I/O outside
Small higher-order utilitiesProvenEncourage with clear names
Stream transformationsProvenEncourage, short and named
Sealed types + pattern matchingProvenEncourage for outcomes
Monad stacks (Either, Try chains)MixedDiscourage in shared code
Point-free compositionMixedDiscourage beyond two steps
Deep curryingMixedPrefer a small class or record

6What the Standards Should Say

I would write the encouraged ideas into the standards with examples from our own code: records as the default for data, pure functions for domain calculations with I/O kept in an outer layer, streams for collection transformations, and sealed types with switch for outcomes. Examples matter more than rules, because developers copy what they see in the codebase.

For the mixed ideas, I would discourage rather than ban. The test is simple: does this style need a specific library, or training that most of the people we hire do not have? If it does, it does not belong in shared code. Teams may still use it inside modules they own, but the cost of that choice stays with them. And I would revisit the list as Java evolves, since today's verbose idea may become natural when the language supports it directly.

7Follow-up questions

Why do you count streams as proven when many teams complain about them?

The complaints are almost always about long, clever pipelines, not about streams themselves. Short pipelines of filter, map and collect have replaced a great deal of error-prone loop code. The standard should encourage the short, named form and discourage the long one.

Is immutability always worth it?

For domain data and anything shared between threads, yes. For large, frequently updated structures in hot paths, such as a buffer being filled, mutable objects confined to one method or one thread are fine and often faster. The rule is immutable by default, mutable by deliberate choice.

What about checked exceptions with lambdas?

That friction is real and pushed some teams toward Try types. The proven answer in most codebases is either a sealed result type for expected failures or wrapping checked exceptions in unchecked ones at the lambda boundary when failure should stop the pipeline.

8Conclusion

In this answer, we saw that functional ideas entered Java through libraries and then through the language itself. Immutable values, pure calculations, small higher-order utilities, stream transformations and sealed types with pattern matching have proven their value in large codebases, while heavy monad stacks, point-free style and deep currying have mixed results because Java's syntax and most developers' training work against them. Standards should encourage the first group with examples and discourage styles that need a particular library or uncommon training.

What to say in the interviewAbout 90 seconds aloud

Open with

Looking back, the ideas that clearly paid off are the simple ones. Immutable values, which today means records, removed whole classes of bugs around shared state and caching.

Then, if they want more

Pure calculations, where the result depends only on the inputs, made domain logic testable with a few lines and no mocks. Small higher-order utilities like Comparator.comparing or a retry helper, and short stream pipelines for filtering, grouping and summing collections, replaced a lot of error-prone loops.

And the newest one, sealed interfaces with records and pattern matching in switch, gives us typed, exhaustively checked outcomes, which is most of what people wanted from Either, but in standard Java. The ideas with mixed results are heavy monad stacks, point-free composition and deep currying.

They're sound ideas, but in Java the syntax is verbose, type inference and error messages get hard, and most hires haven't been trained in them, so that code was often correct but slow to review and frequently rewritten when it changed hands.

In our standards I'd encourage the proven ideas with examples from our own code: records by default for data, pure domain functions with I/O at the edges, short named pipelines, sealed results.

I'd discourage, not ban, anything that needs a specific library or training most of our hires don't have, especially in shared code, and I'd revisit that list as the language evolves.

About this answer

Last updated
12 November 2026
Versions it names
Java 8, Java 16, Java 17, Java 21
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Functional programming ideas have moved into mainstream Java over twenty years. Which of...": https://scrivio-interview-library.netlify.app/java/functional-design/a4483478bd/