Closing Thoughts

Congratulations! You’ve covered the basics of functional programming with TypeScript. Give yourself a pat on your back.

We'll cover the following

What we learned

Functional programming (FP) is a programming paradigm that focuses on the use of functions as the primary building blocks for creating applications, as opposed to object-oriented programming (OOP), which focuses on classes that encapsulate both state and behavior. FP has a strong mathematical background, is popular in academic circles, and has been growing in popularity among professional programmers.

However, as a paradigm, object-oriented programming still reigns supreme, with many widely used languages geared toward OOP, including C++, C#, and Java. Hybrid languages like Kotlin and Swift make functional programming an option, but they still only represent a minority of use cases in the industry. Meanwhile, JavaScript, despite shortcomings, treats functions as first-class citizens, which enables us to write code with a very functional flavor. With TypeScript, we get a useful and powerful compiler with no runtime overhead.

Still, the basic language constructs of JavaScript are insufficient to enable real functional programming by themselves. So, we have to turn to a library. The library we mainly considered in this course is fp-ts. It’s powerful and feature rich, well maintained, and accompanied by multiple helper libraries. Documentation is more than adequate, with blog posts going into more depth for some topics. However, fp-ts isn’t exactly beginner friendly. That’s a shame because it provides an excellent framework for writing production-worthy functional code. That’s why this course is set out to help beginners understand the basic concepts of FP and use fp-ts for writing projects.

We started with a discussion of the basics of functional programming. They include the preference for pure functions, immutability, and recursiveness. The basics also cover the way we can use composition to create functionality, making our code cleaner, simpler, and more reusable. Next, we turned our attention to monads and the important role they play in building applications. In the subsequent chapters, we used our functional techniques to build example projects, starting simple and moving to somewhat more complex. Along the way, bit by bit, we expanded our knowledge of FP and the monads from fp-ts. We also showed how to rewrite an existing application in a more functional style and briefly discussed some more advanced material like DSLs, tagless final, and free monads. We hope the material contained in the previous chapters will help you use fp-ts in your spare time and professional projects.

Get hands-on with 1200+ tech skills courses.