Functional programming isn't just academic — it makes code more predictable, testable, and maintainable. Here's how we apply FP principles at Google.
Core Principles
- Pure Functions: Same input → same output, no side effects
- Immutability: Never mutate data, create new copies
- Function Composition: Build complex operations from simple functions
Higher-Order Functions
Composition
Currying
Immutable Updates
When NOT to Use FP
- Performance-critical loops (for loop > reduce for large datasets)
- When mutation is clearer (sorting in place)
- When the team isn't familiar with FP concepts