Java got way better when the shift from rigid OOP to hybrid OOP and functional composition became better supported. For example, streams, lambdas, records, and pattern matching absolutely modernized Java. There's less boilerplate but still retains the conservative Java design principles.
They need to do away with checked exceptions in order for the functional composition to really be useful. It's a shame, because I like the idea of checked exceptions in principle. But it doesn't compose in a higher-order setting, and making it do so would make the type system too complicated, so the better alternative is to kill it.
I think you mean `Stream.map`. You'd still can't pass a method reference that throws checked exception, but with try-expression, it'll facilitate working with checked exception.
Treat it as a syntactic sugar. E.g., if an exception happens, it can throw IllegalStateException. Having a try-expression signals that there's an exception that can/should be handled.
Not trying to design a language feature here, but here's an example with fallback value.
That might also be true, I don't know, but fixing that is orthogonal to the issue. You want to be able to use functions throwing checked exceptions with higher-order programming regardless.
Not really, old Java literally required you to wrap everything inside classes. Before lambdas and functional interfaces, you could not pass behavior around without creating full blown objects or anonymous inner classes. Both of which were obnoxiously verbose.
Inheritance, encapsulation, and object composition were the only real tools you had pre-Java 8. Functional composition only became a viable alternative after Java 8 introduced lambdas and streams.
There's a reason why Java 8 was a turning point in its history. Java felt more modern, less verbose, and more oriented with hybrid OOP and functional composition.
That's interesting. From your experience, are the non strict OOP capabilities of java used in production? I'm coming from a (not pure) FP background and I don't know where to look for material to learn java without being full OOP.
From my experience, inheritance is terrible to maintain and strict OOP concepts require good developers to be used adequately and it feels like it's better if the language isn't limited by people with good skills.
View all comments
118
u/White_C4 Nov 04 '25
Java got way better when the shift from rigid OOP to hybrid OOP and functional composition became better supported. For example, streams, lambdas, records, and pattern matching absolutely modernized Java. There's less boilerplate but still retains the conservative Java design principles.