Introduction
Tags: functional, programming, tutorial, typescript
Published: 2021-09-10 15:55:54

Hello and welcome!

Today I'm introducing a new series about Functional Programming, or FP for short.

Functional Programming is an amazing world, but it can be quite challenging to walk on these lands and learn its concepts without feeling overwhelmed. At least that's how I felt when I discovered this paradigm.

When trying to learn FP, one of the first walls we bump into is the **vocabulary**. Functor, monad, algebraic data types, referential transparency, side-effects, higher-kinded types. All these buzzwords sounded mystical to me. It took some time (several years actually) to learn what they mean, how I could use them, and what were the relationships that tight them together.

Although there are quite a lot of articles about functors, monads, and the likes, I think there is still a lack of content regarding all the "surroundings". More specifically, there are _root concepts_ that are essential and used everywhere when doing FP.

In this series, I will try my best at introducing and explaining the following:
- What is FP, and why we should learn and use it
- Function composition and higher-order functions
- Declarative vs imperative
- Side-effects
- Function purity and referential transparency
- Data immutability
- Function currying, partial application and tacit programming
- Parametric polymorphism (aka "generics")
- Inversion of control
- Algebraic Data Types (ADTs)
- Kinds and higher-kinded types (HKTs)
- A word on category and set theories
- Algebraic structures and type classes
- Bonus (possibly): map filter reduce, tagless final, optics, transducers

I will not talk about (or maybe briefly) functors, monads, applicatives, etc. as I believe there is already a lot of great material out there explaining these great tools.

Hopefully by the end of this series, you will have all the means necessary to walk on these lands peacefully.

## Who am I?
Before diving into the subject, let me tell you about my experience with FP, and what you can expect from the quality and depth of this series.

My adventure began about 4 years ago, in 2017. I am still climbing the learning curve, I haven't mastered this paradigm. Though, I don't feel like I'm at the bottom anymore, which is nice.

I have been applying these concepts in TypeScript and Scala for the past years, as they are the main languages I have been using. I have seen the limitations of TypeScript compared to Scala or Haskell for example. Nonetheless, it is still possible to do FP in TypeScript, although it may feel less natural than with a language that has built-in FP concepts.

I have read a lot of articles and blog posts, and I still do. These are mainly the ones that helped me in this journey:
- [Composing Software](https://medium.com/javascript-scene/composing-software-the-book-f31c77fc3ddc) by Eric Elliott
- [Mostly Adequate Guide to Functional Programming](https://mostly-adequate.gitbook.io/mostly-adequate-guide/) by Brian Lonsdorf, aka DrBoolean
- [John De Goes' blog](https://degoes.net/articles/)
- [Fantas, Eel, and Specification](http://www.tomharding.me/fantasy-land/) by Tom Harding
- [James Sinclair's blog](https://jrsinclair.com/)

I started reading [Category Theory for Programmers (Scala Edition)](https://www.blurb.com/b/9603882-category-theory-for-programmers-scala-edition-pape) by Bartosz Milewski a few years ago, although I never finished the book. I stopped at around 30%. I would not advise reading this book at the beginning of the journey. As the book name suggests, there is a lot of theory in these pages! That being said, once you have grasped the main concepts, it is definitely a good book to dive deeper into the essential "components" that make FP possible.

Since my learning revolves mainly around TypeScript/JavaScript and Scala, the examples I will share will be written in these languages. However, this should not be an issue as the majority of these concepts are language-agnostic and can be implemented, or applied, in pretty much any language.

So, as you see, I am not some FP guru. I am still not able to write Haskell code like it's child's play. Some of my explanations may be incomplete, or partially wrong. If that is the case then please leave a comment so I can learn and fix these mistakes.

I may lack some formality in my explanations, though I think it is better to present these concepts in a more _informal way_, if one wants to convince people to learn and try FP.

I hope this series will help you dip a toe in the water, and convince you that Functional Programming is not that mystical after all!

---

Photo by <a href="https://unsplash.com/@xavi_cabrera?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Xavi Cabrera</a> on <a href="https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>.