

 Functional Programming is Dead, Long Live Expression-Oriented Programming - Rickasaurus
http://richardminerich.com/2012/07/functional-programming-is-dead-long-live-expression-oriented-programming/

======
jerf
I would also accept "Compositional Programming". Just as the secret to deeply
understanding Erlang is to understand that it is primarily about reliability
and not about "functional", the secret to understanding where the bulk of the
Haskell community is going (except the ones strictly studying theory for
theory's sake) is that they are primarily working on composition. Purity and
functional and lazy are just some of the buzzwords being turned in that
direction. Just as aping Erlang's message passing in $YOUR_FAVORITE_LANGUAGE
while missing everything it does for reliability is really missing the point,
dropping a map and a fold into your language (and eyeing Monads, then
skittering away, though I suspect this is often _not_ because they're too
complicated but because the languages are too weak to make them syntactically
palatable) is also really missing the point.

(Also, mocking Haskell and/or its community for being too theoretical is
really missing the point. It's one of the few places where progress is being
made on the topic of practical compositional programming. No, the work's not
done yet, but, then, that's sort of my point, work is in fact being done.
Almost everybody else is just shuffling the same handful of 25-year-old
primitives around.)

~~~
monkeyfacebag
I think the real reason Monads haven't been widely adopted is that there isn't
a compelling need for them. Laziness, purity and referential transparency are
nice-to-haves in most languages, whereas in Haskell, they're need-to-haves.

Computers are imperative by nature. They have state. That Haskell has the
capability to shield us from that is really, really cool, but that doesn't
mean it's necessary to write good software.

~~~
Locke1689
Monads have already been adapted into C# via LINQ. That's as mainstream as it
gets. Your premise is false.

~~~
olavk
I think this is somewhat misleading. If I understand correctly, only the
SelectMany method in Linq is monadic. This is only a minor part of Linq, and
not at all comparable to how monads are used in Haskell.

------
Locke1689
No offense, but I think you may be pandering to people who don't know what
they're talking about.

Guido adds first class functions and functools to the standard library and
people suddenly start calling Python "functional." The same is probably going
to start happening to Java once λ expressions get added.

I think functional programming has been most clearly defined as those
languages whose base model of computation is the λ-calculus (or F_ω, etc.).
Python is not functional because, despite having functional features, the
idiomatic way of writing Python mirrors Turing machine computation.

If you restricted yourself to only the functional features of Python, well,
that would be Python in name, but is that really how people write Python?

~~~
Rickasaurus
The problem is that the vast majority of programmers don't know what they're
talking about. Scott Hanselman calls them then silent 99%. They don't blog or
comment and they do real work everywhere.

The point is terminology matters, especially in how those who can't be
bothered to dig deeply come to understand things.

~~~
Locke1689
Yet your post simply concedes the point--would you not rather explain why
people are wrong rather than walk the line yourself to make a point?

~~~
Rickasaurus
As someone who has regularly given tech talks on functional programming to
audiences completely foreign with the ideas involved for almost five years I'm
completely sick of explaining it. It takes up far too much of my time when I
could be teaching other cool stuff.

Calling it Expression Oriented programming is something I've taken to recently
and it get people on the right track off the bat. They're focusing on the
expressions and not just trying to understand how everything relates to
functions.

------
lmkg
Being a functional language is different than supporting functional
programming. A functional _program_ is one that fits the mold he describes:
high-order functions as the primary abstraction, pure wherever possible, heavy
emphasis on transformation of values rather than updating state. A _language_
that supports functional programming is one where such a program is possible
(without too much trouble). A _functional language_ is one where programs that
don't fit that mold are difficult or discouraged.

To the author's point, supporting functional programming is not hard and most
languages do it. Basically all languages, except Java and maybe like Pascal or
something. I'm ok with that, though. I'm fine that I can write my own
JavaScript functionally, even though other people may not. (Though it's
annoying when I interface with less-than-functional third-party libraries.)
After all, part of the reason to learn Lisp or Haskell is to make you better
at Blub, right? Merely supporting functional programming means that I can
still put those lessons to decent use.

~~~
Rickasaurus
> After all, part of the reason to learn Lisp or Haskell is to make you better
> at Blub, right?

What's forcing you to stay in Blub to begin with? There's great same-platform
alternatives to everything except for Javascript.

------
monkeyfacebag
I will freely admit to thinking I knew something about functional programming
after learning about lambdas, map, filter and reduce in Python (and lamenting
the language's lack of tail call optimization). Three days with Haskell set me
straight.

~~~
Ixiaus
Haskell, Scheme (a LISP), Erlang, Clojure will all set you straight. What's
great is, once you grok one; the others are much easier to get a handle on.

------
gruseom
I highly recommend Backus' "Can Programming Be Liberated from the von Neumann
Style?" as a classic critique of the expression-statement dichotomy (which
Backus calls "the von Neumann bottleneck" and then immediately blames himself
for rather than von Neumann - Backus of course having led the creation of
FORTRAN).

www.cs.cmu.edu/~crary/819-f09/Backus78.pdf

~~~
Xcelerate
That critique led to the creation of some function-level languages like FP and
FL (nobody's ever heard of them):

<http://en.wikipedia.org/wiki/Function-level_programming>

Most languages nowadays are value-level. The difference between the two is
that function-level programs combine "sub-programs" into one giant new
program. Value-level takes primitive types and transforms them into more
complex types (I believe this is the same sort of complexity that Rich Hickey
disparages).

~~~
doublec
There's an implementation of FP here: <http://www.call-with-current-
continuation.org/fp/>

------
ozataman
I have to say, I'm not very fond of hyperbole-laden posts such as this one.
People who devote the time and enthusiasm learn the details and hopefully
enlighten themselves. People who lack that kind of enthusiasm will likely be
confused throughout their lives across many of fronts. What is so surprising,
interesting or new about this?

Things are often called what they are called for continuity and for legacy
reasons. What does it matter if we call it "Functional" vs. "Expression-
Oriented"? Will Haskell, ML, Clojure, etc. or their impression on people
change overnight because we have a new cool name? I guess a bunch of
new/experimental library now claim to be Functional, but so what if they do?

Maybe it's a bit too late here, but I don't see the point in this kind of
sentiment.

------
sherwin
I think Ruby does a pretty good job with this, as far as an object oriented
main stream language goes. For example, the switch case example from the
article can be implemented in ruby as case n: when 1: "one" when 2: "two"

etc, and the entire construct can be assigned to a variable because it is an
expression.

As an aside, ruby 1.9 also supports generic predicates for case statements
through lambdas, which is very concise and powerful. Example:
<https://gist.github.com/838163>, source: <http://flazz.me/predicates-in-ruby-
case-statements>

------
cantankerous
I don't get the jump between talking about how "functional" doesn't evoke
purity, yet "expression-oriented", does. To be fair, most (probably all)
functional languages aren't fully pure. Haskell is probably more pure than
most of them, but eventually you have to get things done and dive into the sin
bin.

The term "functional" really evokes "first class" invokable function symbols
that can be passed around in a higher-order kind of way. Everything else is
secondary.

~~~
Rickasaurus
Expression-Oriented evokes purity in that expressions have external facing
properties which can be understood and even kept in the type system. If you
use global mutation and you don't keep track of it in the type system you
can't say much about those properties anymore. You can however use mutation
locally and maintain your referential transparency which is a nice way to get
around the limits of some not-so-functional-friendly algorithms.

I'm planning on writing about that next time around because my tracking shows
barely anyone gets to the end of an article beyond a certain length.

------
kenbot
Making things like if/else/switch statements true expressions is a great
feature, but I'm not sure it deserves a new foo-oriented programming buzzword.

~~~
Rickasaurus
The reason I suggested it is because functional has been so badly perverted.
We need a term that evokes the actual spirit/philosophy of the language, not
just the heritage.

------
BadassFractal
Hm.. should I stop learning Clojure right this instant? I can't take the "you
GOT to learn Erlang/Haskell/Scala/Node/[...] right NOW!" any longer.

~~~
Locke1689
No. Clojure is fine. I actually think that everyone's first functional
language should be scheme, but Clojure is not too different.

Erlang, Haskell, and Scala all want to sell you on some broader paradigm of
functional programming, but they're all still functional at their core and
understanding the fundamentals is far more important.

Node.js isn't a language, it's just some libraries added on to Javascript.

~~~
Ixiaus
I highly support the idea of learning Scheme first too - particularly with the
Little Schemer books!

------
jroseattle
Really, the volume of discussion ad nauseum around what normally amounts to
syntactic sugar is over the top. I'm not disparaging the functional
programming paradigm, but conversation seems to eventually gravitate toward
measurements of _how functional_ something is, which seems pointless.

------
sohn10
No.

~~~
Rickasaurus
Care to elaborate?

