# Haskell Chapter 1, Part I. Why are we doing this?  i-want-to-learn-haskell

## Presentation on theme: "Haskell Chapter 1, Part I. Why are we doing this?  i-want-to-learn-haskell"— Presentation transcript:

Why study functional languages? Without understanding functional programming, you can’t invent MapReduce, the algorithm that makes Google so massively scalable. —Joel Spolsky, The Perils of Java Schools

Perspective  http://www.defmacro.org/ramblings/fp.html http://www.defmacro.org/ramblings/fp.html  This is where the story would stop, I'd wrap up the article, and you'd navigate to another page, if not for the beginning of World War II. The world was in flames. The U.S. Army and Navy used artillery more often than ever. In attempts to improve accuracy the Army employed a large group of mathematicians to continuously calculate differential equations required for solving ballistic firing tables. It was becoming obvious that the task was too great for being solved manually and various equipment was developed in order to overcome this problem.

Theory of Computation  Independently of Alonzo Church, Alan Turing was performing similar work. He developed a different formalism (now referred to as the Turing machine), and used it to independently come to similar conclusions as Alonzo. Later it was shown that Turing machines and lambda calculus were equivalent in power. http://www.defmacro.org/ramblings/fp.html

Why FP? In general, use the language in which it's easiest to express the solution to a problem. For functional programming, this is when the solution to a problem is easily expressed in terms of functions, hence the name. Generally it's good for mathematical operations, AI, pattern matching; in general anything that can be broken down into a set of rules that must be applied to get an answer. You can only really determine the "best" language to use after you've analyzed your problem sufficiently. This is where pseudo-code comes in handy. If you find yourself writing pseudo-code that looks like FP, use FP.

Pattern Matching  Domain specific languages  Compilers  Data transformations  Today, pattern matching is found in almost all functional languages including OCaml, F#, Scala, Haskell, Clojure and Erlang. For example, I recently built a bespoke business rules engine for a client with a focus on mathematics. That is 1,000 lines of F# and is predominantly an interpreter. Lexing, parsing, type checking and interpreting input are all much easier thanks to pattern matching.  Lexing IS pattern matching… http://stackoverflow.com/questions/397425/when-to-use-a-functional-programming-language