Hacker News new | past | comments | ask | show | jobs | submit login

The article is not about FP.

> Languages like Java encourage patterns where you instantiate a half-baked object and then set the fields later.

Maybe it did before 2010. For many years everyone prefers immutable objects (so that object and its builder have different types, or in simpler case -- no setters, only constructor initialization). You can see it in pretty much all frameworks.

I'm ok with both functional and procedural languages, I just think this article is not about functionality. Come on, FP is all about monads!

Moreover, the "imperative" code example would be impossible anyway with immutable objects without side effects. So what I think the article is about is immutable data types. Everyone agrees that immutable are better, we have to do mutables only when we're optimizing for CPU/RAM.

And BTW concurrency is typically easily achieved if variables were not plain objects, but Future/Observable/Flow/Stream -- pick your poison. They all have passed the hype hill already, and became "just a tool" I think.




Define what you mean by "everyone" -- there are times where the cost of immutability can be overwhelming, such as in high traffic systems with overly complex data structures which you are required to use because someone who should have known better insisted upon writing.

(sorry, bitter personal experience) And yes, that is explicitly "modern" Java code written by a lead engineer and "java champion" in 2023.


Yes, I feel you. As I said, we often need to sacrifice immutability to performance, and that's ok. If they insisted using immutable structures in high-performance applications, then functional programming won't help anyway.


Hopefully we won't have to make that trade off for too long

https://www.microsoft.com/en-us/research/uploads/prod/2020/1...


Even reference counting needs memory management. Granted, allocations are very fast on the JVM heap, but cannot be faster than no allocations.


Came here to write this.

There's also a (research) language that uses the Perceus algorithm: https://koka-lang.github.io/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: