3 ms·
Yeah. Functional programming happened to be trending again and our lead service bus developers decided to write Java like it’s Haskell. Now their garbage keeps
by wredue 3y ago
Yeah. Functional programming happened to be trending again and our lead service bus developers decided to write Java like it’s Haskell.
Now their garbage keeps crashing with stack overflows, and they complain when files are bigger than a few hundred lines.
We accidentally pushed a 10,000 line file once and it brought the entire bus to a crawl for an hour. TEN THOUSAND LINES.
One day, these twerps pushing this stupidity of “copy everything always cause ‘it’s easier to reason about dawg’” are gonna get theirs.
- taberiand 3y agoYeah that's not the fault of a functional approach, that's just bad code.
- solraph 3y ago> decided to write Java like it’s Haskell. I have no love for Haskell or functional programming, but the problem here isn't FP per se, it's that they tried to jam it into Java. Don't fight the language or framework. If you are using Java, write idiomatic OOP code. If you want to write FP on the JVM, then start writing Clojure or Scala. If the business won't let you write Clojure or Scala, then do it on your own time and/or change jobs.
- throwawayqqq11 3y agoPassing arguments as read-only references does impact the purity of functions from a fundamentalistic view point but, as you experienced first hand, is sometimes more or less required for performance. Looks like your FP zealots didnt learn how to compromise on that point or how to work with constness in general.
- mrkeen 3y agoOnce more, a Java programmer has a bad time writing Java and scapegoats Haskell. > One day, these twerps pushing this stupidity of “copy everything always cause ‘it’s easier to reason about dawg’” are gonna get theirs. Making defensive copies is literally item 39 of Effective Java by Josh Bloch. The Haskell way is to not bother with that shit, because you don't have to.
- Tainnor 3y agoThe semantics of Java aren't really optimised for FP the way they are in Haskell (e.g. no TCO, no guaranteed immutability prevents certain optimisations), but if you write FP code in Java that leads to stack overflow, you're still just doing it wrong. You need to be careful about stack overflows when you use manual recursion, but in most cases (even in Haskell) you don't write explicitly recursive functions, you call higher-order functions like map, reduce, etc. instead that are written so they don't run into those problems (those are implemented with tail recursion in Haskell, which is eliminated, but in Java, I assume they're implemented with iteration).