3 ms·
I disagree with the notion that functional programs must never contain side effects. I think we should just be reasonable and only produce side effects when exp
by kyleperik 8y ago
I disagree with the notion that functional programs must never contain side effects. I think we should just be reasonable and only produce side effects when explicit, and never mix side effect code with data processing.
We shouldn't have to rely on loopholes to satisfy any hard and fast rules. A lot of writing good code is just being reasonable and explicit.
If you call a function to launch a missile, you'd expect that it's just going to launch a missile and do nothing else. So why are we so concerned that it contains side effects? What other option do we have?
Logging is a bit different. For many, logging is probably a necessity to allowing you to look back and and understand context when things go wrong. But when you're programming functionally, I find that it's much easier to get a grasp on things compared to procedural code, which can become spaghetti much quicker. I also find that bugs are much less common, or otherwise much more obvious in functional code, negating the need for logging in the first place (for functional code).