News for hackers. Stuff that matters.
Re:Why functional programming matters by mpweiher on Tuesday April 18, 2017 @09:48AM (#14138751)
> Why compose classes, abstract base classes, etc. when you can compose simple functions!

Because they allow you to compose higher level entities?

(Incidentally, one would generally compose objects).

"When programming a component, the right computation model for the component is the least expressive model that results in a natural program." -- Concepts Techniques and Models of Computer Programming

So when a less expressive model (such as FP) is sufficient for a "natural" program, definitely use that. And of course that has been the general recommendation. Switch to a more expressive model once this is no longer the case. In my experience, FP tends to be good for "computation", at least if performance isn't a primary concern. However, most of what "computers" (badly named) do today isn't computation, and modeling communication and storage over time tend to get awkward (though obviously possible).

Re:Why functional programming matters by louthy on Tuesday April 18, 2017 @10:20AM (#14138993)
> Because they allow you to compose higher level entities?

That isn't true. FP still uses data records, they're just not tightly coupled to the functionality like OO. Pure functions + immutable types is a more powerful programming paradigm than data and functionality encapsulation via classes and methods.

Also more advanced techniques like combinators can encode more complex and extensible patterns in a significantly more robust way than any OO class hierarchy (see 'parser combinators' for an example).

Re:Why functional programming matters by mpweiher on Tuesday April 18, 2017 @10:28AM (#14139067)
> (see 'parser combinators' for an example).

Lots of parser-combinator libraries in OO languages.

Re:Why functional programming matters by louthy on Tuesday April 18, 2017 @10:33AM (#14139105)
Your point being?
Re:Why functional programming matters by haskellandchill on Tuesday April 18, 2017 @10:14AM (#14138958)
> So when a less expressive model (such as FP)

You can express object models in FP so what you are saying is very confusing to me.

Re:Why functional programming matters by mpweiher on Tuesday April 18, 2017 @10:23AM (#14139023)
Models in "Concepts Techniques and Models of Computer Programming"

Note that they are talking about general models of computation, in particular including at least:

- Declarative sequential model (strict functional programming, deterministic logic programming, dataflow/logic variables, higher-order procedures). Component behavior is independent of rest of program.

- Declarative concurrent model (explicit threads, by-need/lazy computation, data-driven concurrency, demand-driven concurrency). Almost as simple as declarative sequential. Declarative model with exceptions: allows nondeterminism to be visible.

- Message-passing concurrent model (declarative plus ports/communication channels). Allows nondeterminism, and allows nondeterminism to be restricted to particular components.

- Stateful model (declarative model extended with explicit state). Allows components to keep history. Typical of sequential OO programming.

- Shared-state concurrent model (declarative extended with both explicit state and threads). Typical of concurrent OO programming.

- Relational model (declarative extended with search). Search space explored by testing choices until result is satisfactory. Encompasses Prolog-style logic programming.

- Constraint programming and still other models are discussed elsewhere in the book.

http://wiki.c2.com/?PrincipleOfLeastPower

Re:Why functional programming matters by novembermike on Tuesday April 18, 2017 @03:04PM (#14141852)
You do realize that the object model is just data bundled with functions, right? If I'm using Erlang I can pass in a map that has something like #{ data => [(data)], methods => [(functions)] }. The object style approach is orthogonal to FP.

EDIT: Just to be clear, I don't think this is a good idea. It's usually better to pass in one or more data structures and one or more first class functions separately. I'm just saying that it's not too different.