Trying to learn functional programming approach I was faced with both lambda calculus and Category theory terms.
Could you please explain in layman's terms what are the differences between them, in the scope of FP.
What do they mean for FP?
Thank you!
It's hard to fully answer such a broad question. Below, I tried to provide some insights, but I can not describe these vast topics in only a few paragraphs.
The lambda calculus is the mathematical core of any functional programming language. It can be seen as a very minimalistic programming language, where the key properties of FP can be studied without being distracted by an heavy syntax.
Any programmer, especially if they are FP programmers, should be able to learn the basics of lambda calculus within a few hours of study. Note that, even if the basics are rather simple, the underlying theory is incredibly vast: there's a huge amount of scientific literature dedicated to the lambda calculus. One does not need to know all of this for everyday FP, but reading a few results here and there once in a while can provide some insights on FP. For instance, reading about Church encodings can make one realize how powerful can be a lambda abstraction.
Category theory is one of the most abstract parts of mathematics. Compared with the lambda calculus, it is much harder to study. It can be very challenging.
CT is connected with the lambda calculus mostly because it provides a nice way to understand types. Types in FP have an underlying algebraic structure which can be best understood by categorical means. For instance, in Haskell the types (A, Either B C)
and Either (A,B) (A,C)
are isomorphic (ignoring bottoms, at least; because a*(b+c) = (a*b)+(a*c) ), roughly meaning that they carry the same amount of information. As another example, currying and uncurrying form the fundamental idea of cartesian closed categories, the "standard" way to interpret simple types.
If you have a programmer's background, you can try Bartosz Milewski's online book Category Theory for Programmers. Still, I would recommend to start from learning some FP and the lambda calculus first.