Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's no community consensus on what are the essential concepts in functional programming. In <a href="http://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf" rel="nofollow noreferrer">Why Functional Programming Matters (PDF)</a>, John Hughes argues that they are higher-order functions and lazy evaluation. In <a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/haskell-retrospective/" rel="nofollow noreferrer">Wearing the Hair Shirt: A Retrospective on Haskell</a>, Simon Peyton Jones says the real essential is not laziness but purity. Richard Bird would agree. But there's a whole crowd of Scheme and ML programmers who are perfectly happy to write programs with side effects.</p> <p>As someone who has practiced and taught functional programming for twenty years, I can give you a few ideas that are widely believed to be at the core of functional programming:</p> <ul> <li><p><strong>Nested, first-class functions</strong> with proper lexical scoping are at the core. This means you can create an anonymous function at run time, whose free variables may be parameters or local variables of an <em>enclosing</em> function, and you get a value you can return, put into data structures, and so on. (This is the most important form of higher-order functions, but some higher-order functions (like <code>qsort</code>!) can be written in&nbsp;C, which is not a functional language.)</p></li> <li><p>Means of composing functions with other functions to solve problems. Nobody does this better than John Hughes.</p></li> <li><p>Many functional programmers believe purity (freedom from effects, including mutation, I/O, and exceptions) is at the core of functional programming. Many functional programmers do not.</p></li> <li><p><strong>Polymorphism</strong>, whether it is enforced by the compiler or not, is a core value of functional programmers. Confusingly, C++ programmers call this concept "generic programming." When polymorphism is enforced by the compiler it is generally a variant of <a href="https://stackoverflow.com/questions/399312/what-is-hindley-milner">Hindley-Milner</a>, but the more powerful <a href="http://en.wikipedia.org/wiki/System_F" rel="nofollow noreferrer">System&nbsp;F</a> is also a powerful basis for functional languages. And with languages like Scheme, Erlang, and Lua, you can do functional programming without a static type system.</p></li> <li><p>Finally, a large majority of functional programmers believe in the value of <strong>inductively defined data types</strong>, sometimes called "recursive types". In languages with static type systems these are generally known as "algebraic data types", but you will find inductively defined data types even in <a href="http://www.htdp.org" rel="nofollow noreferrer">material written for beginning Scheme programmers</a>. Inductively defined types usually ship with a language feature called <strong>pattern matching</strong>, which supports a very general form of case analysis. Often the compiler can tell you if you have forgotten a case. I wouldn't want to program without this language feature (a luxury once sampled becomes a necessity).</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload