News for hackers. Stuff that matters.
Re:Functional Programming Is Not Popular Because It Is Weird by chriswarbo on Saturday February 27, 2016 @06:27PM (#11188978)
There are many styles of functional programming; the thing they have in common is that they all use first-class, high-level functions to implement features which other languages might implement via special-purpose syntax, bytecode, compiler passes, etc.

The "lambda the ultimate" papers are the classic example of using functions to implement a variety of language features, including jumps. Hence the author's claim that functional programming is an "inside-out" approach is more of a question of style than of paradigm.

For example, even simple function composition can approach the clarity of imperative code for following a step-by-step process. The result tends to look like UNIX pipes, although traditionally they're read "right to left" (but you can trivially define your own composition function which goes the other way).

Here's an example of the author's task, written in a compositional style rather than an "inside out" style:

    heatedOven = preheat 175 oven

    preparedPans = grease . flour $ pans

    flourMixture = whisk . add flour . add bakingSoda . add salt $ smallBowl

    creamedMixture = until (all [light, fluffy]) . cream . add butter . add whiteSugar . add brownSugar $ largeBowl

    bananaMixture = mix . add bananas . repeat eggCount (beat . add egg) $ creamedMixture

    batter = stir . add (chop walnuts) . repeat (size / spoonful) (add (spoonful flourMixture) . add (spoonful buttermilk)) $ bananaMixture

    baked = take . wait 30 . add (add batter preparedPans) $ heatedOven

    cake = take . wait 10 . add baked $ dampen teaTowel
Re:Functional Programming Is Not Popular Because It Is Weird by greydius on Saturday February 27, 2016 @07:21PM (#11189130)
If you create a Kitchen monad, you could write it imperatively. Then you can have your functional cake and eat it too. (I couldn't stop myself.)
Re:Functional Programming Is Not Popular Because It Is Weird by tmptmp on Saturday February 27, 2016 @08:59PM (#11189417)
a "kitchen monad" may seem to be a overkill for doing what you (or your mom) may need to bake a small number of cakes for you to consume

but

bakery monads are what is needed if you want to bake hundreds of thousands of cakes of hundreds of different variations (types) in a manageable manner.

FP starts to make (more and obvious) sense there not in the small household kitchen. But even then that is not to say that FP doesn't make sense in a small household kitchen. Only, it is very difficult to make sense of that sense at the smaller scales.

Re:Functional Programming Is Not Popular Because It Is Weird by greydius on Sunday February 28, 2016 @12:48AM (#11190027)
I was just attempting to inject a little humor into the situation while bringing attention to the fact functional and imperative are not necessarily mutually exclusive. In fact, I'm of the opinion that Haskell is the best imperative programming language. It's just really hard to explain why that is the case when the popular sentiment is that monads are scary and impossible to understand. In any case, these threads always devolve into ideological bickering which I try to avoid.
Re:Functional Programming Is Not Popular Because It Is Weird by cwyers on Saturday February 27, 2016 @06:33PM (#11188992)
Ugh, I am sorry, I tried to upvote but I fatfingered it and downvoted instead.
Re:Functional Programming Is Not Popular Because It Is Weird by paulddraper on Saturday February 27, 2016 @09:58PM (#11189606)
It's a shame you can't fix it.
Re:Functional Programming Is Not Popular Because It Is Weird by krotton on Sunday February 28, 2016 @07:08AM (#11190732)
It's a shame you can't fix.