Chapter 4
- For this book, side effects are defined as modifications and interactions with the environment outside the scope of the current unit of logic (function).
- It is a data that can be changed by the program.
- They cause extra mental load on your mind, which may lead to bugs. There are much more things to keep in mind with side effects and mutable state. The scope of your attention must extend much further than the piece of logic that you are working on at the moment.
- It is a function that does not produce any side effects.
- The ability to substitute a call to a function with the result of that call in code without changing the semantics of that code.
- Decrease the mental load you face. Hence decrease the possibility of bugs.
- Errors, an absence of a result, delayed competition, logging, input-output operations.
- Yes, it is. Programming in the purely functional style is just a matter of understanding the concepts of side effects, understanding how they are harmful, being able to see the side effects and their harm in code, and knowledge on how to abstract them away. It is possible to write abstractions for side effects in modern imperative programming languages.
- It is the presence of the infrastructure to support you. Most of the abstractions you may need are already present in the language. Most of the libraries are functional. The community is also likely to be oriented to the functional style.