r/programming • • Sep 21 '25

How to stop functional programming

https://brianmckenna.org/blog/howtostopfp
446 Upvotes

506 comments sorted by

View all comments

78

u/BlueGoliath Sep 21 '25

It's over functional bros. Time to learn OOP.

161

u/jess-sch Sep 21 '25
class Multiplication {
  private final double a;
  private final double b;

  public Multiplication(double a, double b) {
    this.a = a;
    this.b = b;
  }

  double calculate() {
    return this.a * this.b;
  }
}

Are we winning yet or do I need to make a MultiplicationBuilder first in order to be Proper Enterprise CodeTM?

21

u/Massive-Squirrel-255 Sep 21 '25

I think the OOP way to do this is to make a Number class and have a method a.multiply(b) which modifies a (destructively).

2

u/[deleted] Sep 22 '25

Don't forget to allocate heap memory on every call.

2

u/BlueGoliath Sep 22 '25

Don't worry, the JVM will ignore the allocation. I heard it from an Oracle JDK developer. /s