- Hands-On Functional Programming with TypeScript
- Remo H. Jansen
- 235字
- 2021-07-02 14:03:09
The benefits of functional programming
Writing TypeScript code using a functional programming style has many benefits, among which we can highlight the following:
- Our code is testable: If we try to write our functions as pure functions, we will be able to write unit tests extremely easily. We will learn more about pure functions later in this chapter.
- Our code is easy to reason about: Functional programming can seem hard to understand for developers with a lack of experience in functional programming. However, when an application is implemented correctly using the functional programming paradigm, the results are very small functions (often one-line functions) and very declarative APIs that can be reasoned about with ease. Also, pure functions only work with their arguments, which means that when we want to understand what a function does, we only need to examine the function itself and we don't need to be concerned about any other external variables.
- Concurrency: Most of our functions are stateless, and our code is mostly stateless. We push state out of the core of our application, which makes our applications much more likely to be able to support many concurrent operations and it will be more scalable. We will learn more about stateless code later in this chapter.
- Simpler caching: Caching strategies to cache results become much simpler when we can predict the output of a function given its arguments.
推薦閱讀
- Building a Game with Unity and Blender
- PHP基礎案例教程
- Learning Linux Binary Analysis
- 薛定宇教授大講堂(卷Ⅳ):MATLAB最優化計算
- Python Data Analysis(Second Edition)
- Creating Mobile Apps with jQuery Mobile(Second Edition)
- RealSenseTM互動開發實戰
- AutoCAD 2009實訓指導
- SEO教程:搜索引擎優化入門與進階(第3版)
- INSTANT JQuery Flot Visual Data Analysis
- 3ds Max 2018從入門到精通
- Practical Linux Security Cookbook
- Python AI游戲編程入門:基于Pygame和PyTorch
- Instant SQL Server Analysis Services 2012 Cube Security
- Oracle API Management 12c Implementation