4 ms·
Obviously you can't have truly pure functional code - I don't think anyone advocates that. But non-functional code is much harder to debug (spooky action at a
by smanek 17y ago
Obviously you can't have truly pure functional code - I don't think anyone advocates that.
But non-functional code is much harder to debug (spooky action at a distance, etc) so a little bit more work upfront to isolate the non-functional code from the functional will make the debugging/maintenance phase (which are considerably longer than the 'initial writing' phase), easier.
- scott_s 17y agoThat's exactly what the author is advocating.
- jrockway 17y agoHow is this obvious? It might make sense to say, "we can't build an effect-free computing machine", because we use transistors, and transistors get hot when they sink power, and things getting hot changes the entropy of the Universe... but it doesn't make sense to say, "we can't model an effect-free world, and program is if the world is effect-free". (In fact, without effects, there is no world.)
- ewjordan 17y agoWould you, then, agree with the statement: "There's no reason to write the sort of puritanically functional code that the article's author suggests we aspire to, because it would merely sit around and do nothing"? Because apart from nothing, I'm not entirely sure what the author really thinks 100% pure functional code should do, when even input and output states are too impure to be allowed inside his Sanctified Garden of Jesus-Code, despite the fact that it's that mapping that we're explicitly interested in whenever we run a program. As far as I can tell, it's the "run a program" step that the author has a real problem with, and while he's welcome to subvert that paradigm, I don't see any hint of a way forward from it...if your program is meant to be fully composable at a level more granular than "program", shouldn't you be writing a library instead? Is that the suggestion? From what I can tell, the author hasn't figured this out, either, he just thinks someone should.