Which is the best FP language to quickly internalize FP concepts?

Without doubt the language you are looking for is Haskell. Haskell is static typed, is a pure functional language (it supports impure/imperative code through monads), it uses lazy evaluation by default and has data immutability.

Some useful observations: not all functional programming languages are equal and there is no consensual definition of what is exactly a FP language. Here some examples:

  • Haskell uses lazy evaluation by default (equivalent to python generators) / has static typing.

  • Scala uses eager evaluation, has OO support and has support to imperative features like for loops.

  • OCaml and F#(F sharp) also uses eager evaluation and has OO support and imperative features.

  • Scheme uses eager evaluation, it is a MIT FP lisp dialect. It has dynamic typing, allows higher order functions. However doens't have algebraic data types, curring and pattern matching.

I think the most import thing in Functional Programming is learn the "Functional Programming style" and apply it to whatever language supports it.

The most important things of FP independent of the language used is:

  • Pure Functions / Referential Transparency / Side effects
  • Currying --> Allows you to create composable and many reusable functions from the same function:
  • Function Composition
  • High Order Functions
  • High Order Functions idioms: map, flodl, foldr, reduce, filter, zipWith, last, head, take, takeWhile ...
  • Lazy Evaluation / Eager(aka Strict) Evaluation / Infinite lists
  • Recursion
  • Loops: In FP loops are implemented generally with lazy lists, map, reduce(folds), filter and recursion.
  • A 100% pure code does nothing, is not useful, since write a file, print to screen are side effects for example. The main idea of FP is to have the minimum of side effect code surrounded by a set of pure functions.

Not all FP languages are has all features listed below like Javascript or Scheme.

  • Algebraic/ Abstract data type
  • Pattern Matching
  • Built-in support to monads (Haskell Only)
  • Not all FP languages has static typing. It is possible to use FP style in dynamic typed languages like Python and Javascript.
  • Data immutability

Another interesting code is: http://underscorejs.org/ that is a functional programming library for Javascript that has many useful FP idioms and also some FP idioms that can be useful with OO.

I am writing a tutorial Functional Programming by examples Haskell, available at: FP by examples in Haskell

/r/functionalprogramming Thread