Why should you learn Haskell?

Posted on November 22, 2019

Before discovering Functional Programming, I thought my programming language experience was quite diverse. I mean the languages I knew could do front-end and backend, what more do you need?! I had used languages like PHP, Python, C++, VB, Java, etc, which I have heard described as “C-style languages”, and I didn’t really know much different. I saw programming languages as tools to get the job done, with a preference for typed languages as I thought I could refactor, understand, and test these more easily.

I started going to The Leeds Code Dojo, and met lots of cool people using non-mainstream languages. This idea seemed alien to me, why spend time learning a language that nobody was using in industry much, “you won’t get a job with Racket or APL!” I smugly thought to myself. Thinking back to my time at university, I recall regularly discussing the most used languages in industry with fellow students, which at the time this was C++ and Java, so I ensured I knew both well enough to land a job when I finished. Anyway - at the end of the Leeds Code Dojo sessions, you get to show off your solutions. So to my surprise not only were the niche language users solving the solutions, they were solving them rather simply, elegantly. Even though I didn’t know these obscure languages, the code looked like the algorithm it was implementing! Boy was I ashamed to show off my bowl of if-then-else-soup followed up by a plate of nested-for-loop-spaghetti!

So I started looking into functional programming around the languages I knew at the time, and I found things like RxJava, Java 8 Streams, Scala, and Kotlin. But I initially struggled because I had spent so long thinking imperatively I couldn’t get myself out of that mindset, I would always cheat a bit. A side-effect here, a mutable-data structure there, and those languages were sitting there like “this is fine!” But it wasn’t fine. I wanted to try something stricter, that prevented me being able to do those things in order to curb my old habits and essentially to force me to think differently, or rather to think functionally. I stumbled on Haskell and had been recommended “Learn you a Haskell for Great Good”, and prompty got to reading it!

In my mind I thought “I’ll learn haskell so that I can think functionally, and then put it into practice and carry on with my life like before, just more functionally.” Little did I know that once you learn Haskell, you don’t look at things the same way again… I’ve learnt why those people learnt non-mainstream languages, there’s many great things about them, and it’s not all about getting and/or staying employed!

Pros of learning haskell

Cons

Summary

Learning Haskell is great fun, and I continue to learn things from it. If you like functional programming and want to know more, or get better at thinking functionally, I can highly recommend learning it.

My tip for learning haskell is to find a good book and stick with it (I recommend Haskell Book!), don’t worry about giving up on a book or course if it’s really not working out for you, there’s many more :)