/ Java

Double Rainbow Man

Last night I had a dream. It was like my brain tried to tell me something in order to protect itself from taking serious damage.

The days before, I hadn't slept much. I'm on vacation, spend the day with my family and read the DOOM novels. By night, I luminate my retina with blue light and solve VAVR issues that dangled for months, maybe years. The environment here in Spain is hot. The sun is burning while my main water supply seems to be coffee.

Last night, I decided to stay offline and go to bed early. I was exhausted. It was a refreshing and long sleep. I did not even notice the ants crawling over my body. These little bastards seem to be everywhere, you can't kill them, whether you like it or not. I think they will survive us, especially climate change.

I always embraced my dreams. They have a meaning. I understand them as a feedback loop of my brain that realigns my synapses during regeneration. This dream was deep to the core. It brought me back to my home village. I met locals that showed me secret paths I did not recognize before in the deep woods.

All of a sudden something happened. In my dream, I had a clear vision.

Object-oriented programming and functional programming are basically the same.

I felt pretty much like the Double Rainbow Man that moment.

What does that mean? In the context of a statically typed language, both paradigms technically use higher order functions and encapsulation with objects. Types are used to model a domain. Builders help us creating a context in the form of instances that we work with. We call this an internal domain-specific language (DSL).

 * Search and destroy that 🐜

interface Ant {
    // properties omitted

interface Poison {
    Ant apply(Ant ant);

final class Search {

    // omitted private constructors and instance vars

    static Search of(Criteria criteria) {
        return ...;

    Ant destroy(Poison poison) {
        return poison.apply(ant);

Most of the known Java, Scala and Kotlin libraries work this way, especially hardcore specialized libraries like Cats, ZIO and Arrow. Some call their library functional, few call their library object-oriented, others call it object-functional. It is a fancy name that simply does not matter. What really counts are the API and the features.

To bring the world forward, we should think about the problem that is solved by a particular library and, much more important, the problem we need to solve. Pick what works for you, do not get dragged in a tabs vs spaces discussion. Most likely, someone is trying to manipulate you.

Keep it simple and solve real world problems.


Holiday greets from Yours Truly.

P.S. Soon, you will read something about the upcoming VAVR 1.0 release again ;)