3 ms·
>> Why is making it "not possible to call the function from other places" a benefit? When it's a pure function that's not a problem. When it changes state then
by phkahler 10y ago
>> Why is making it "not possible to call the function from other places" a benefit?
When it's a pure function that's not a problem. When it changes state then you lose track of ordering and such. That's his point, state changes need to be kept in the one big function so you can keep track of them easily.
And of course, almost all interesting software has mutable state. Otherwise you're just doing a computation and looking for a single output.
- apeace 10y ago>> When it's a pure function that's not a problem. That was my point. He's conflating two different things. I understand why inlining mutation has benefits. Just not inlining functional code. >> And of course, almost all interesting software has mutable state. Of course, but I think most programmers overestimate how prevalent state needs to be throughout a program. I once wrote an RSS aggregator as an eight-stage pipeline. It checked about 40k feeds, each every 60 seconds. Every stage had a 'main' file where the vast majority of state was kept. The rest was functional libraries. I suppose that would be a demonstration of what Carmack is proposing, with the difference being that my pure functions (the majority of the code) had clear names and were unit-tested. It worked so well that almost every large program I've written since has been designed the same way!