Harrop is known in the Haskell community for being a hater. Most of his remarks here are opinion, which is fine. Lots of people don't like Haskell - that's also fine, but pieces like these hurt the community because it will both push away newcomers and make industrial use more difficult. Also, I've never needed an unsorted dictionary, and parallelism is actually great in Haskell. http://chimera.labs.oreilly.com/books…
Disadvantages of purely functional programming
21–30 of 70 posts
Re: Disadvantages of purely functional programming
#22I don't get why people would use functional programming for anything. It's both more difficult and slower.
First, functional programming is an umbrella term. This paper talks about strict FP, which is basically "no mutation", so I'll talk about that. It's clear that some other aspects of FP, such as first-order functions, closures, etc are very useful in practice. Immutability does have its advantages in that it supplies strong guarantees about what your code does. It avoids spaghetti code where everything can and does mu…
Re: Disadvantages of purely functional programming
#23I have settled on a style of doing "functional-like" programming in Python and C++. It's more about the high level architecture than low level coding details.
It means being very paranoid and rigorous about state -- but still having great tools to express it! For example: Using ZERO mutable globals, and passing state in as a parameter to functions. Using immutable/persistent data structures. These techniques are done very naturally and effectively in Python and C++. You just have to be disciplined.
To me there's no real advantage to expressing something like "split a string by a delimiter" in a purely functional style. Either way, you have a trivial referentially transparent function you can reuse without causing complexity in your program. You might as well do the obvious imperative thing.
However there IS a benefit to threading state explicitly throughout the application, and encapsulating it in OBJECTS (yes objects).
For me, the thing that sealed the deal against functional languages for "real work" was trying to write a production quality sh parser.
I went down a long path of trying to do this first in OCaml and then in Lisp. The VERY first thing that hits you over the head -- lexing -- is heavily and inherently stateful. ocamllex and ocamlyacc to me are evidence of this paucity and poverty of purely functional solutions. They're just transliterating solutions from C. Well I might as well use C then.
Actually, I decided to use C++, which was like my 5th choice as language. Aside from headers and compile times, it's a good choice. I use "functions and data" (a la Rich Hickey).
Except my functions and data are both CLASSES. Data objects are basically structs, except they can do things like print themselves and answer simple queries based on their values, which helps readability (e.g. 1 liners, like word.AsFuncName() ).
Function objects are simply classes with configuration passed to constructors. That usually have a single method, but multiple methods are also often useful. Calling this method is basically equivalent to calling a curried function. But this is supremely useful for both compilers and servers, because often you have config/params that is constant once you reach main(), and then you have params that vary per request or per file processed. Many functions depend on both, and it's cleaner to separate the two kinds of params.
So both "functions and data" are effectively and usefully implemented as classes. The key is to make some classes like functions, and some classes like data. And have more of a bipartite dependency graph, where functions depend on data, and data depends on functions.
When all your classes are an equal mix of data and behavior, that's when they start getting "hard-coded" weird-shaped dependencies, and your program turns into fragile spaghetti. Functions and data are a useful architectural technique, and to me it doesn't have that much to do with Clojure or Lisp, although Hickey is certainly a great advocate.
Re: Disadvantages of purely functional programming
#24Earlier quoted context omitted.
First, functional programming is an umbrella term. This paper talks about strict FP, which is basically "no mutation", so I'll talk about that. It's clear that some other aspects of FP, such as first-order functions, closures, etc are very useful in practice. Immutability does have its advantages in that it supplies strong guarantees about what your code does. It avoids spaghetti code where everything can and does mu…
I agree that immutability is very useful, but you don't really need any kind of FP to use immutability, do you?
Re: Disadvantages of purely functional programming
#25Harrop is known in the Haskell community for being a hater. Most of his remarks here are opinion, which is fine. Lots of people don't like Haskell - that's also fine, but pieces like these hurt the community because it will both push away newcomers and make industrial use more difficult. Also, I've never needed an unsorted dictionary, and parallelism is actually great in Haskell. http://chimera.labs.oreilly.com/books…
This is an ad hominem attack, and a fallacy. He may hate Haskell - so what? Are any of his critiques incorrect?
Re: Disadvantages of purely functional programming
#26I don't get why people would use functional programming for anything. It's both more difficult and slower.
I think the concept of immutability confuses people bit. It really clicked for me when I stopped thinking of it in terms of things not being able to change and instead in terms of every version of things having different names.
Functional programming from that perspective is like version control for your variables. It makes explicit, not only which variable you are accessing but which version of it.
The reason it seems like you need to copy a variable each time you modify is just to give each particular mutation a different name. Note that the compiler can optimize things. It doesn't need to keep every version in memory. If it sees that you are not going to reference a particular mutation, it might just physically overwrite it with the next mutation so that in the background "var a=i, var b=a+j", might run as something like "var b = i; b+=j";
Re: Disadvantages of purely functional programming
#27Harrop is known in the Haskell community for being a hater. Most of his remarks here are opinion, which is fine. Lots of people don't like Haskell - that's also fine, but pieces like these hurt the community because it will both push away newcomers and make industrial use more difficult. Also, I've never needed an unsorted dictionary, and parallelism is actually great in Haskell. http://chimera.labs.oreilly.com/books…
This is an ad hominem attack, and a fallacy. He may hate Haskell - so what? Are any of his critiques incorrect?
Re: Disadvantages of purely functional programming
#28This post lists 9 points, but the first 7 are all variations of "mutable data structures suck in a pure language!" and the other 2 are "look at all these fucking idiots who talk about purely functional programming!" So the first 7 points are true because pure functional programming, by definition does not support mutable data structures very well. It is what it says on the tin. If you go on stack overflow you'll find…
At least point 4 seems to be about algorithms, not data structures? That is, there's nothing up front that says graph algorithms must be faster using mutable data structures, but that is apparently the case, so far.
Re: Disadvantages of purely functional programming
#29Earlier quoted context omitted.
I use functional style in C++ with lambdas and iterators. It is nothing but slow. I use functional style in Rust. It's blazing fast. Huge body of problems can be handled by simple recursion but I've yet to see non-functional programmers use it. I don't know why. Functional style is simply better and is applicable in many languages. Modern C++ is a great example. Throw away much of OOP clunkiness, use simple functions…
> Huge body of problems can be handled by simple recursion but I've yet to see non-functional programmers use it. I don't know why. Stack overflows.
http://stackoverflow.com/questions/32164370/does-elixir-infi...
Re: Disadvantages of purely functional programming
#30Sadly, the author's chosen style is a rant and it is counterproductive. There's plenty of words and claims are made but benchmarks or code are nowhere to be seen. Why should anyone take these claims at face value? > Furthermore, most functional programming languages (OCaml, Haskell, Scala) are incapable of expressing a fast generic mutable hash table because they lack the killer combo of: reified generics, value type…
> The author [...] links to code that other people have written