Introduction

cover

Read it Online

For a best reading experience, read it online via Gitbook.

  • Quick-access side-bar

  • In-browser exercises

  • In-depth examples

About this book

This is a translation from JavaScript to Python. The original book can be found here.

This is a book on the functional paradigm in general. We'll use the world's most popular functional programming language: Python. Some may feel this is a poor choice as it's against the grain of the current culture which, at the moment, feels predominately imperative. However, I believe it is the best way to learn FP for several reasons:

  • You likely use it every day at work.

    This makes it possible to practice and apply your acquired knowledge each day on real world programs rather than pet projects on nights and weekends in an esoteric FP language.

  • We don't have to learn everything up front to start writing programs.

    In a pure functional language, you cannot log a variable without using monads. Here we can cheat a little as we learn to purify our codebase. It's also easier to get started in this language since it's mixed paradigm and you can fall back on your current practices while there are gaps in your knowledge.

  • The language is fully capable of writing top notch functional code.

    We have all the features we need to mimic a language like Scala or Haskell with the help of a tiny library or two. Object-oriented programming currently dominates the industry, but it's clearly awkward in python. It's akin to camping off of a highway or tap dancing in galoshes. To a lot of us, FP feels more natural anyways.

That said, typed functional languages will, without a doubt, be the best place to code in the style presented by this book. Python will be our means of learning a paradigm, where you apply it is up to you. Luckily, the interfaces are mathematical and, as such, ubiquitous. You'll find yourself at home with Swiftz, Scalaz, Haskell, PureScript, and other mathematically inclined environments.

Play Around with Code

To make the training efficient and not get too bored while I am telling you another story, make sure to play around with the concepts introduced in this book. Some can be tricky to catch at first and are better understood by getting your hand dirty. All functions and algebraic data-structures presented in the book are gathered in the appendixes. The corresponding code is also available as pip module:

$ pip install adequate

Creative Commons License This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.