How Do I Learn Some Functional Programming?

I am sure you have heard about functional programming already. Otherwise, you would never find this article :)

If you are still unsure what is it all about, I’d propose you to stop reading this article and switch to Uncle Bob’s article Functional Programming Basics.

You know what, just go and read it anyway!

The first step is the most controversial. Yet, I personally think it is the most useful one anyway.

Grab Practical Object-Oriented Design in Ruby (POODR) by Sandi Metz and read it.
Yes, you read it correctly: Object-Oriented Design.

“Why?! How… How does it relate to Functional Programming?!” you may wonder.

The thing is — you really need to experience a good, nice OOD to see the immediate value of Functional Programming and make the transition from OOP to FP smooth and easy.

Ah, and do not be afraid of Ruby. The examples are nice and easy, you will understand everything, I promise!

Ok, now when you are back from Ruby Land, let’s talk about some nice stuff we have in the JavaScript Land.

And yes, we have some goodies. But I won’t show you everything right away so that you do not get overwhelmed.

I would suggest you the thing I keep repeating all the time:

Get this book first: Functional Javascript by Michael Fogus.

I think this is the most pragmatic book you can find to actually start writing some functional code in JS. That’s it!

You will learn how to use underscore library (or lodash, if you will) right away.
It will lead you through applicative programming and some basic combinators, showing how it differs from the OOP and Class-oriented approaches you get used to.

Ah, such a nice journey!

Ok, you have played with underscore or lodash already, and all of those .map and .pluck are not scary and useless anymore?

Watch this then: Hey Underscore, You’re Doing It Wrong!.

Brian Lonsdorf will show you the idea behind tacit programming technique.
You may find it quite similar to unix tools philosophy of putting the arguments in a specific order: from less often changed to most often changed, target object last, like in git checkout branch. See the similarity?

This is not the coincidence! This style pushes composability further.

What’s the next step?

I’d propose to read JavaScript Allongé, the “Six” Edition by Reg Braithwaite.

You will learn some SKI combinator calculus and high-caliber combinators and decorators with a nice and pleasant ES6 syntax.

This is kestrel, or “K-combinator”

Also, you will learn about all those mixins and delegation based on prototypes in JS. It will make you a better programmer already!

Ok, now you have tried some low-hanging fruits and maybe get a habit of simplifying things.

It’s time to tread on a more abstract ground and learn some Theory™!

Go read Professor Frisby’s Mostly Adequate Guide to Functional Programming.

It will lead you through the path of Real-Deal Functional Programming: currying, Hindley-Milner type system, functors, applicatives, monads… Oh, my!

Don’t be afraid, the book is written in a comprehensible language and all examples are written in a digestible javascript using ramda.

I think, this is the time you can start using elm and fully appreciate all the powers it gives you.

But, if you want to proceed the journey from here, I would suggest you fighting the real dragon: Functional Programming in Scala
by Paul Chiusano and Rúnar Bjarnason.

They say it is one of the best books on FP today.The Real Deal™. Not the toys.

Also, I would personally suggest you reading both Clojure for the Brave and True
and Learn You a Haskell for Great Good!.

Not only will you learn other flavours of Functional Programming, but also you will experience a type of books you have never seen before!

And this is the time where I will leave you on your own.

After spending the time with all those FP, you are a completely new programmer right now!

I would love to hear back from you!

  • Do you still use JavaScript, or have you switched to ClojureScript, Elm or PureScript?
  • Have you conquered the quirks of Category Theory?
  • Have you mastered the DataFlow programming? Or maybe Algebraic Effects? Or even Dependent Types?

Originally published at blog on June 18, 2016.

Software Engineer by day, Founder at ( by night.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store