|
|
|
|
|
by KingMob
5172 days ago
|
|
While it's true that the output/observable behavior is what we want out of a program, whether the internals rely on side effects, strictly speaking, isn't relevant to producing useful things for the users. I won't deny that sometimes, a lack of side effects results in weird contortions, but there are ways around it and benefits that make up for it. Since side-effect-free functions are way easier to predict, debugging time is much shorter in FP, I find. Monads, while difficult to grok at first, are elegant ways to get around side effects in pure FP languages. Or, just go with my personal favorite solution, use an FP language that's not pure (e.g., most Lisps). They tend to encourage side-effect-free and/or state-free programs, but do not strictly require it. This gives you the best of both (IMNSHO); 80-90% of your code is side-effect-free and easier to debug, and the side-effect code is relatively contained and straightforward (in an imperative sense). |
|