07/12/2020 (Sun) 17:12:39
Nah, I'm not much into functional programming, I just see it as powerful and neat.
But pure functional programming is pure autism.
Take a quick think about how would a purely functional (pure functions, immutable variables) algo for finding a biggest element in an array would look like. We would call a binary pure function returning the bigger of the two and then do it recursively on a subarray or something. Each return value would have to be stored separately or, less naively, we would have to assign a new pointer to the old data (after all, it's immutable), but still, the algo takes O(N) memory (or even more, I didn't big brain it enough, there should be arrangements for subarrays). And that's why GHC takes like 1GB of space for no good reason.
>b-but memory be cheap, buy more
Dereferencing more memory affects performance, paging out and a lot of other things. In short, your programs are slower when they take more memory. The only reason functional languages seem viable is that contemporary software is so bloat that imperative languages struggle with the infrastructure. Functional programming indeed scales better. Kinda seems like a social issue.