r/functionalprogramming • u/jfmengels • Sep 21 '24
Question Non-obvious benefits of pure code
Like probably a lot of you, I really like writing code without side-effects (at least as much as possible), because it has plenty of benefits, such as easier to predict and to maintain, etc.
What are some benefits of writing code in a pure way (completely or partially) that are not obvious to newcomers or - even better - to more experienced programmers?
21
Upvotes
View all comments
Show parent comment
7
u/a3th3rus Sep 21 '24
Besides, immutability makes creating cyclic references impossible. This makes implementing garbage collectors a little bit easier, but on the other hand, certain kinds of data structures like doubly linked lists red-black trees, and Fibonacci heaps can't be implemented in pure FP languages.