2 ms·
The 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 i
by Tainnor 3y ago
The 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).