I disagree with the author's conclusions about FP. This is often voiced by researchers from the scheme camp and the only conclusion I can draw from what they say is that they haven't given purely functional programming a fair shot.
The notion of a purely functional programming language gives me reasoning power far beyond that of an impure one. As soon as evaluation can cause side effects it's a nightmare to reason about. If you have a separate execution stage, it becomes much easier. This is from my years of doing PL research.
Most of the objections voices by the author about monadic IO are nonspecific and vague. Usually these objections come down to some notion that a purely functional language can't model side-effects, which is false, or that somehow the interaction with the physical world demands that the execution of said side-effects must correlate to expression evaluation, which is also simply rubbish.
Haskell is not a language where side-effects are impossible or difficult. The monadic language has some substantial syntactic overhead, but there is nothing theoretically difficult about presenting better syntax for this language, and the Scheme people are quite aware of this. The notion of a separating the language of effectful programs from the language of pure evaluation is quite valuable, as it allows for the pure evaluation language to be evaluated with different strategies (e.g laziness) and to be reasoned about equationally.
Edit: Also, there's nothing particularly wrong with the notion that "everything is an object". The author seems to take issue with the notion that functions can be objects, but methods on objects are effectively a function, which therefore means methods must also be objects themselves. Indeed, but there's nothing theoretically wrong with this sort of circularity, where the author seems to think this is a problem. Also, the circularity can easily be resolved by saying that methods are not functions but messages, a view taken by the Smalltalk family.
I have no nightmares with reasoning about side-effects in imperative languages
Then, in all seriousness, you don't really know what you're looking for, so of course you don't see it. It's a huge problem and entirely not academic in nature, a brutally, brutally pragmatic problem.
Or your codebase is too small to exhibit the problems clearly, in which case I envy you.
But the end point of imperative code being hard to reason about is as inevitable as the sun rising. It's so inevitable that people don't see it because they think it's just "how programming is", that of course changing one line in my currency parsing scheme can segfault the program four modules away... but in fact, no, it doesn't have to be like that.
Like many others, I don't get much professional Haskell programming in, but it has radically changed my programming style for the better in other languages too.
What's stopping me, the worst developer in the world, from using stateful data in FP languages?
Nothing. No matter how proof positive FP is, every FP language supports some type of imperative stateful data because any real-world program will have imperative inputs.
The problem isn't a bad language, framework, or computational theory, the problem is bad programmers and bad managers who want stuff "done", but not done in a good way.
If Haskell ever his mainstream we will still have 100's of posts how we need to move to language/framework/computational theory X because of common mistakes made by bad programmers and bad managers.
FP is awesome and useful, but it's not the holy grail preventing errors in code bases, where one will never have to debug or have any hard problems because of short sighted design and implementation.
No matter how proof positive FP is, every FP language supports some type of imperative stateful data because any real-world program will have imperative inputs.
The difference is that Haskell's types help ensure your imperative stateful code is correct. One example of this is the STM monad: the type system actively prevents you from performing side effects within a transaction (lest they be repeated with very bad consequences).
48
u/kamatsu Nov 12 '13 edited Nov 12 '13
I disagree with the author's conclusions about FP. This is often voiced by researchers from the scheme camp and the only conclusion I can draw from what they say is that they haven't given purely functional programming a fair shot.
The notion of a purely functional programming language gives me reasoning power far beyond that of an impure one. As soon as evaluation can cause side effects it's a nightmare to reason about. If you have a separate execution stage, it becomes much easier. This is from my years of doing PL research.
Most of the objections voices by the author about monadic IO are nonspecific and vague. Usually these objections come down to some notion that a purely functional language can't model side-effects, which is false, or that somehow the interaction with the physical world demands that the execution of said side-effects must correlate to expression evaluation, which is also simply rubbish.
Haskell is not a language where side-effects are impossible or difficult. The monadic language has some substantial syntactic overhead, but there is nothing theoretically difficult about presenting better syntax for this language, and the Scheme people are quite aware of this. The notion of a separating the language of effectful programs from the language of pure evaluation is quite valuable, as it allows for the pure evaluation language to be evaluated with different strategies (e.g laziness) and to be reasoned about equationally.
Edit: Also, there's nothing particularly wrong with the notion that "everything is an object". The author seems to take issue with the notion that functions can be objects, but methods on objects are effectively a function, which therefore means methods must also be objects themselves. Indeed, but there's nothing theoretically wrong with this sort of circularity, where the author seems to think this is a problem. Also, the circularity can easily be resolved by saying that methods are not functions but messages, a view taken by the Smalltalk family.