
上QQ阅读APP看书,第一时间看更新
Why FP is the best fit for RP
When we conflate RP with FP, we will get the following benefits:
- Composability—we can compose multiple data streams using functional operations so that we can solve even complex problems easily
- Thread safety
- Readability
- Simple, concise, clear, and easy-to-understand code
- Easy-to-write asynchronous, concurrent, and parallel code
- Supports very flexible and easy-to-use operations
- Supports Declarative programming
- Easy to write, more Scalable, highly available, and robust code
In FP, we concentrate on what to do to fulfill a job, whereas in other programming paradigms, such as OOP or imperative programming (IP), we concentrate on how to do.
Declarative programming gives us the following benefits:
- No side effects
- Enforces to use immutability
- Easy to write concise and understandable code
The main property of RP is real-time data streaming, and the main property of FP is composability. If we combine these two paradigms, we will get more benefits and can develop better solutions easily.
In RP, everything is a stream, while everything is a function in FP. We can use these functions to perform operations on data streams.