3 ms·
I think a lot of people missed the article that this one is replying to: http://prog21.dadgum.com/54.html http://prog21.dadgum.com/54.html That article's main
by nostrademons 17y ago
I think a lot of people missed the article that this one is replying to:
http://prog21.dadgum.com/54.html http://prog21.dadgum.com/54.html
That article's main point was that functional programming doesn't work because deep in the bowels of two otherwise-pure leaf functions, you might want to make their behavior interdependent. In an imperative language, you can do this through adding a simple global variable. In a functional language, you have to change the signatures of all the callers to add this new parameter.
A lot of people pointed out that in a real program, you're asking for massive maintenance headaches if you connect two independent leaf functions through a global variable and make their behavior interdependent. In that context, this isn't a strawman, because somebody actually did suggest structuring programs this way.
Make a silly suggestion, get a silly reply.
I think both authors would do well to focus less on individual languages or programming paradigms and more on writing actual large-scale software systems. Because the imperative, OO, and functional worlds basically converge on that point: don't do that. You don't want the behavior of apparently-pure functions to change based on hidden, undocumented state. And once you document it, you might as well add it to the function signature, which is your "executable documentation" anyway.
- cemerick 17y agoI wasn't replying to that article -- at best, I was going off on a tangent prompted by a comment to that article.
- nostrademons 17y agoWell, then it's a strawman. ;-) Nobody decent actually writes imperative programs where every function depends upon the global state of the whole program.
- jrockway 17y agoThe problem is that you can't know for sure until you read every line of code in the program, or at least read every function in a given call chain. In languages like Haskell, the type system ensures that there are functions whose effects can be understood by only reading that one function.
- kelnos 17y agoTrue, but you're essentially arguing for a "nanny" language model that doesn't let you do things that someone decided is "unsafe" or "bad design." While I'd agree that writing a program in an imperative language where everything depends on hidden global state is a very poor choice, I'd rather use a language that trusts me to design my application as I see fit.
- jrockway 17y agoNo I'm not. I'm arguing for safety as the default, and un-safety as an option. Haskell gives me this. The usual imperative languages don't even make safety an option. You just have to try hard and hope for the best.
- jimbokun 17y ago'True, but you're essentially arguing for a "nanny" language model that doesn't let you do things that someone decided is "unsafe" or "bad design."' Isn't the same true for, say, garbage collection? Higher level languages are often defined by the things they don't let you do, compared to lower level languages, in order to make your life easier. Of course, if you're a C++ programmer, you probably agree that both mandatory garbage collection and immutable state are equally nanny-language features.
- kelnos 17y ago"Of course, if you're a C++ programmer..." Ugh, no. C programmer. I don't have an intrinsic problem with GC (as it allows me to be lazy), though admittedly there are quite a few bad GC implementations out there that can cause noticeable performance issues. Immutable state has its uses, but, again, it's a question of whether or not it's mandatory.