


(We will discuss later in more detail how these concepts help us write better and cleaner code.) Out of all the concepts in FP, the following three contribute the most to the benefits of adopting FP in our day-to-day programming. Together, these implications and rules are what make FP a great paradigm to consider. This might seem trivial, but it has a lot of implications and rules behind how the functions are constructed and what is the scope of changes that can be affected by these functions. A typical program in FP works like this: Given some input, apply a series of functions (can be both big and small) on the input to get the desired output. In a nutshell, FP is a programming paradigm in which programs are constructed by applying and composing functions.


In this post, we are going to talk about what functional programming is, what the benefits and potential downsides of it are, how it compares to the alternative paradigm imperative programming (IP), what Kotlin provides for developers to leverage FP, and examples of how we at DoorDash write FP-style code in Kotlin. As a multi-paradigm general-purpose programming language, Kotlin provides a lot of the necessary toolkits we need to leverage FP in our day-to-day coding. While there are many ways we can improve our engineering metrics via optimized hardware and suitable system designs, one direct lever we can pull as developers to contribute to the overall engineering excellence is to write better and cleaner code on a daily basis.Īnd one way for developers to write cleaner code is to adopt the paradigm of functional programming (FP) using Kotlin. As DoorDash transitioned from Python monolith to Kotlin microservices, our engineering team was presented with a lot of opportunities to improve operational excellence and continue our obsession with reliability.
