Haskell, Lambda Calculus and Functional Programming

Mar 23, 2015

After struggling with Functional Programming, finally I got into it. Some tips on how to start learning it.

I can remember it like five years ago when I started fantasizing about programming in a functional language. I knew very little about it, but everything I heard sounded awesome. Different way of thinking, elegant languages such as Lisp and Haskell, no side effects happening on code, less bugs, math-ish solutions and etecetera. That all sound so amazing to a enthusiast programmer who has always worked with imperative languages.

For some reason I picked Common Lisp to do my studies. Started trying to solve spoj problems, but I got a little lost. I read some papers. Even started reading some books such as Land of Lisp, Practical Common Lisp and the classic Structure and Interpretation of Computer Programs.

I don’t know exactly why, but I didn’t progress learning that. Soon I dropped the books and functional programming. Maybe I was too young and more focused on other things by the time. Since then I’ve been reading all the articles about functional programming and lambda calculus everytime I have an oportunity. I even bought the book An Introduction to Functional Programming Through Lambda Calculus, which I tried many times to understand the first pages, but I failed.

Recently decided to study functional programming again. Since Lisp is not really very used around (well, not entirely true, there is Clojure), so I went for Haskell. I don’t currently have any project in mind to write in a functional language, so it’s more a lab for me than any duty.

The first step I took was to solve some katas on Coderwars. Katas are little programming problems. I started with very simple problems, things like “your function accepts an array of integers and return an array of these numbers doubled”. Solving problems like that in a functional way is so much different from the regular way that it becomes a lot fun to do. Along with that I was reading Learn You a Haskell for a Great Good, the cutest programming book I’ve ever read.

Following the book and solving katas on Codewars made me understand the basic concepts of this new paradigm easier than anything else. Since then I’m trying to solve at least a kata a day in Haskell and I’m glad now I can even understand some code I find online.

The other day I went back to Lambda Calculus and then I realized how pure Haskell really is. All the basic about functions and evaluating I learned about Haskell is actually Lambda Calculus applied.

So if I may suggest a quick guide to learning functional programming, that would be reading Learn You a Haskell for a Great Good and working on exercises on Coderwars everyday. After a week or so start reading a bit about Lambda Calculus (this article is interesting).

I’m still at the very beginning and learning, but definetely enjoying every little piece of code I can write using only functional techniques. I’m proud that sometimes solving problems on my regular work with Unity3D and C# I think how to solve that in a functional way.

Headline photo was found here.