<story><title>Functional Programming Is Hard, That&apos;s Why It&apos;s Good</title><url>http://dave.fayr.am/posts/2011-08-19-lets-go-shopping.html</url></story><parent_chain><item><author>tptacek</author><text>I&apos;m not expert enough to call you out on this, but isn&apos;t &quot;function&quot;, the way it&apos;s used in &quot;functional programming&quot;, working from a different and more strict definition of the word &quot;function&quot; that (say) a C programmer is used to? I don&apos;t know that you&apos;re wrong about this summary of FP, but it doesn&apos;t smell right to me.</text></item><item><author>tumult</author><text>The title of this article, for example. The idea of this article is that functional programming is hard, because it forces you to think in a new way. But here, calling functional programming hard is just used to pat oneself on the back. Great, this article says you can map a function over a collection and then sum it. You don&apos;t need to think of yourself as some elite programmer that casts a shadow over procedural programmers. It&apos;s not true.&lt;p&gt;Functional programming is just the general notion of using more functions, and less computer-architectury things, to express your ideas. It&apos;s not necessarily about map/reduce, monads, or whatever. Encode your ideas mostly as functions where possible. That&apos;s it.&lt;p&gt;It&apos;s bad to say that functional programming is hard on purpose, or that it makes you a part of some elite cadre. Functional programming should be, and usually is, no harder than any other way to explicitly write down your ideas. The whole point is to make it more simple to express your ideas in a way that can be evaluated by a computer. Functional programming isn&apos;t hard. Programming is hard.</text></item><item><author>dustingetz</author><text>Care to elaborate?</text></item><item><author>tumult</author><text>FP is becoming the new OOP. People who don&apos;t understand its original meaning are misinterpreting it and incorrectly expounding its usefulness. Newcomers are not grasping how it fits into the bigger picture. Be cautious.</text></item></parent_chain><comment><author>profquail</author><text>That&apos;s about right. A &quot;function&quot; in functional programming is supposed to be just like the functions you remember from grade-school algebra class, e.g.,&lt;p&gt;&lt;pre&gt;&lt;code&gt;  f(x) = 2x + 5
&lt;/code&gt;&lt;/pre&gt;
If you look at that function, you&apos;ll notice that for any given value of &apos;x&apos;, the function always produces the same output value. For example, no matter how many times you try it, plugging in 3 for &apos;x&apos; &lt;i&gt;always&lt;/i&gt; returns 11. This means that f(x) is a &quot;pure&quot; function.&lt;p&gt;The only difference between the trivial example with f(x) above, and say, Haskell, is that the functions you&apos;re working with in Haskell are much more complicated. Boil it down though, and they&apos;re still pure, mathematical functions nonetheless.&lt;p&gt;Now, you can (should?) write purely functional programs in C if you follow the same principals. The main difference is that C doesn&apos;t &lt;i&gt;force&lt;/i&gt; you do write your code this way, and since writing purely functional code can be a bit tedious, most people don&apos;t.&lt;p&gt;This leads to impure functions in your code, like when you read a file from disk -- if the file is there, the function does one thing; if not, it may do something else (like crash). Since the output of an impure function can vary depending on when/where/why/how it&apos;s executed, it can be much harder to find bugs in it, since the code may compile and run just fine until the moment it doesn&apos;t.&lt;p&gt;Anyway, that&apos;s the basic rundown on FP. I&apos;m not an FP expert, so if I&apos;ve missed anything, someone please correct me.</text></comment>
<story><title>Functional Programming Is Hard, That&apos;s Why It&apos;s Good</title><url>http://dave.fayr.am/posts/2011-08-19-lets-go-shopping.html</url></story><parent_chain><item><author>tptacek</author><text>I&apos;m not expert enough to call you out on this, but isn&apos;t &quot;function&quot;, the way it&apos;s used in &quot;functional programming&quot;, working from a different and more strict definition of the word &quot;function&quot; that (say) a C programmer is used to? I don&apos;t know that you&apos;re wrong about this summary of FP, but it doesn&apos;t smell right to me.</text></item><item><author>tumult</author><text>The title of this article, for example. The idea of this article is that functional programming is hard, because it forces you to think in a new way. But here, calling functional programming hard is just used to pat oneself on the back. Great, this article says you can map a function over a collection and then sum it. You don&apos;t need to think of yourself as some elite programmer that casts a shadow over procedural programmers. It&apos;s not true.&lt;p&gt;Functional programming is just the general notion of using more functions, and less computer-architectury things, to express your ideas. It&apos;s not necessarily about map/reduce, monads, or whatever. Encode your ideas mostly as functions where possible. That&apos;s it.&lt;p&gt;It&apos;s bad to say that functional programming is hard on purpose, or that it makes you a part of some elite cadre. Functional programming should be, and usually is, no harder than any other way to explicitly write down your ideas. The whole point is to make it more simple to express your ideas in a way that can be evaluated by a computer. Functional programming isn&apos;t hard. Programming is hard.</text></item><item><author>dustingetz</author><text>Care to elaborate?</text></item><item><author>tumult</author><text>FP is becoming the new OOP. People who don&apos;t understand its original meaning are misinterpreting it and incorrectly expounding its usefulness. Newcomers are not grasping how it fits into the bigger picture. Be cautious.</text></item></parent_chain><comment><author>thurn</author><text>I agree. Minimizing state and side effects are at least as core to functional programming as &quot;you should use lots of functions.&quot;</text></comment>