3 ms·
As you say, you cannot make a 100% side-effect free program, unless it doesn't do anything at all. But I do think it's valuable to aim for as side-effect-free
by diggan 3y ago
As you say, you cannot make a 100% side-effect free program, unless it doesn't do anything at all.
But I do think it's valuable to aim for as side-effect-free as possible, and concentrate the statefulness into certain part(s), rather than spread out all over the place, which is the typical way typical.
- btreecat 3y agoPracticing software architecture should generally lead you to minimize side effects and efficiently manage sections of state small enough to fit into your working memory IMO. FP can be used to get you there, but it strongly optimizes for readability of experts in most cases which harms readability in general, as there are always fewer experts. At least that's been my experience with FP languages in the professional space. People often underestimate the benefits of good tooling, a large community, and deep candidate pool.
- epgui 3y ago> it strongly optimizes for readability of experts in most cases which harms readability in general Strongly disagree. In the way you speak of "readability", you're confusing simplicity and familiarity, which are really two different things. If FP if not "familiar" to you, then it will require some effort on your part, sure. But you can teach FP to an absolute beginner, and they will likely find it just as simple, if not simpler, than an imperative mode of reasoning. It's basically just a social and cultural issue at this point.
- sodapopcan 3y agoVery much so to all of this. When I started programming I was just messing around and doing so as more of a curiosity than anything. What I came up with on my own was much closer to FP. When I started to really learn and was presented with OO, it took me what felt like a really embarrassingly long time to under how classes worked and why I'd want them. Once I grokked it I had a grand ol' time, but then I learned a functional language and it felt so good to learn an actual well-designed version of how I initially imagined programming should be :)
- lupire 3y agoNo programming languages have side effects. Side effects are introduced by the runtime. All programming languages have side effects. The question is what logical constraints limit them.
- garethrowlands 3y agoAbsolutely. It's often helpful to distinguish between effects and side-effects. The idea is that an effect is deliberate and explicit, such as, say, sending an email or moving a robot's arm. Whereas a side-effect is one that happens but wasn't your explicit objective - heating the CPU, say, or silently caching a value in thread-local storage. Haskell programs often use the type system to make these kinds of distinction.