
What makes Functional and OO programming equal - bkovacev
http://codinghelmet.com/articles/what-makes-functional-and-object-oriented-programming-equal
======
tutfbhuf
This reminds me of chain (dot syntax composition with objects) vs. actual
function composition & currying:

[https://medium.com/making-internets/why-using-chain-is-a-
mis...](https://medium.com/making-internets/why-using-chain-is-a-
mistake-9bc1f80d51ba)

------
hhas01
Nonsense on stilts. What matters is the __“Why”s __; not the “How”s. Any other
discussion is just implementation crap.

OO is imperative; functional (caveat impure pollution) is declarative.

The goal of declarative coding is to tell the machine what you want, rather
than how to do it. The state of any program is inherently time-dependent;
transferring responsibility over state from the programmer to the software
gives the system the hard guarantees it needs to reason _mathematically_ about
a program and thus make its own decisions on how best to perform it: deferring
a task here, parallelizing an operation there, reliably converting
nondeterministic input into predictable output without fear of locking or
races or different answers every time, and so on.

Not a different way of doing; a different way of _thinking_. Both human _and_
machine.

In contrast, the imperative system _cannot_ reason reliably about state over
time as it lacks the complete control needed to enforce such guarantees. Any
internal/external actor might affect that state in any way at any time; the
system has no way of knowing for sure. Stuck with the Hobson’s choice of being
reliably dumb or unreliably wrong, it can only do exactly what you tell it to
do in the exact order you tell it; it cannot do anything more. Lacking the
deeper insights that a declarative system possesses, the imperative machine
simply isn’t competent to make any higher-level decisions for itself.

Much like a lot of today’s programmers, really: wetware Turing Machine
implementations of Plato’s cave. Why expand their understanding outwards when
they can so easily drag everything down to fit neatly inside their existing
level of ignorance, squished to uselessness by a mindless fixation on the
micromanaging mechanical minutiae of it all?

And still we wonder why so many systems nowadays are absolute garbage. But
hey, you just keep on banging those rocks together, guys…

.

Obligatory:

[https://en.wikipedia.org/wiki/Referential_transparency](https://en.wikipedia.org/wiki/Referential_transparency)

[http://calteches.library.caltech.edu/51/2/CargoCult.htm](http://calteches.library.caltech.edu/51/2/CargoCult.htm)

~~~
ncmncm
I wonder why Edsger Dijkstra didn't agree with you, or, rather, with what you
insist.

Fact is, it's all ultimately about getting a machine to do the operations
needed. What varies is how much effort you have to waste, on top of actually
telling the machine what it should be doing, and how much wasted activity the
machine has to do because you couldn't direct it more precisely.

Every program, in any language, strikes a balance. Some languages force the
balance toward one side, others the opposite. Better languages minimize the
total.

Functional languages, as Dijkstra complained, tend to force wasting time by
copying unnecessarily. Mutating languages make program transformations by the
compiler -- optimizations -- harder, but most potential optimizations are to
make the machine do more mutating and less copying.

The machines keep getting faster (less so, lately), but the problems grow to
match. At all times, over 70 years, the mutating languages have got more
useful computation out of the machines where it mattered most.

When the machines get too complicated to understand, the balance might change.
Nobody knows when that might happen, if it ever does before the whole topic
becomes moot.

In the meantime, programmers sort themselves out neatly between those who
prefer to waste machine cycles for what amounts to esthetics, and those who
find ways not to, without actually suffering for their choice. That is where
we have been for decades, and may still be when civilization collapses.

~~~
hhas01
“Functional languages, as Dijkstra complained, tend to force wasting time by
copying unnecessarily.”

Citation required for your suspect AF appeal to authority/deathbed conversion
story. ’Cos even dead and rotted, the corpse of EWD doesn’t give a flying shit
how fast your program is if you cannot __prove __it right first. The man spent
his whole career trying to hammer the rigor of science and mathematics onto
the mess that was, and still is, computer programming.

Here’s some of EWD’s actual words:

[https://www.cs.utexas.edu/users/EWD/transcriptions/OtherDocs...](https://www.cs.utexas.edu/users/EWD/transcriptions/OtherDocs/Haskell.html)

[http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EW...](http://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1284.html)

Not exactly the reckless racer boy, he. Perhaps you were thinking of Dennis
Ritchie?

.

“When the machines get too complicated to understand, the balance might
change. Nobody knows when that might happen, if it ever does”

Um, that balance already tipped on its side a half-century ago, skippy. Try to
keep up.

[https://en.wikipedia.org/wiki/Fred_Brooks](https://en.wikipedia.org/wiki/Fred_Brooks)

~~~
ncmncm
Gee, you sound bitter.

There was a reason I mentioned Dijkstra, but it wasn't an argument, so "appeal
to authority" doesn't apply. Common mistake, though.

Dijkstra is relevant specifically because he advocated a mathematical
approach.

If you're actually curious, you can read up on the famous feud with Backus,
where Backus was promoting functional programming, and Dijkstra wouldn't give
him the time of day. It's pretty amusing, at this remove.

My guess is you're bitter because nobody controls important equipment with FP
languages; or publicly regrets it when they did. I might be bitter too. But
I'm not.

