Writing Backend APIs in a Functional Programming Style
May 04, 2023
31 min
Free
kotlin
backend-apis
io-separation
functional-programming
api-design
coroutines
structured-concurrency
error-handling
grpc
developer-productivity
Description
This talk covers a pattern for writing backend APIs in a functional programming style, with a focus on separating business logic from I/O. The presenter showcases how Kotlin's structured concurrency features make separating business logic from I/O easier. By decoupling I/O and business logic, the aim is to robustly handle errors while making it easy to modify code in response to changing product requirements. The talk walks through the code for a gRPC endpoint that calls three services using the functional-core, imperative-shell pattern, and then builds on that example by adding new product requirements to demonstrate how structured concurrency and lazy loading help keep business logic and I/O separate.