a feature
1. Scalable programming language
2. Pure object-oriented language
3. Functional languages
4. Seamless java interoperability
Two functional programming ideas
1. What is functional programming
"It's just writing programs with pure functions"
Pure functions, or the purity of functions, have no side effects.
A side effect is a change in state.
For example: global variables are modified, exceptions are thrown, IO read and write, and functions with side effects are called.
![](http://dl2.iteye.com/upload/attachment/0126/5963/c6bfd1ff-3a09-3807-8563-200f44aa36a6.png)
In the above example XplusY_V1 has no side effect on X, it is a pure function.
XplusY_V2 has side effects on X.
2. Referential transparency
Always get the same output for the same input.
3. Pure function
A function f is pure if both the parameter x of f(x) and the function body are referentially transparent.
4. Example: Violation of referential transparency.
![](http://dl2.iteye.com/upload/attachment/0126/5965/2655c628-f00e-39f4-845c-42e71f2ff318.png)
The append function violates referential transparency.
5. Immutability
For referential transparency, no value can change.
6. Functions are first-class citizens
Everything is computation, in functional programming there are only expressions, variables and functions are expressions.
7. Expression evaluation strategies: strict evaluation and non-strict evaluation.
8. Lazy evaluation.
It is not evaluated when it is defined, it is evaluated only when it is used for the first time.
9. Recursive function
Recursion implements looping and tail recursion.
Three functional programming advantages.
1. High production efficiency: For programs with the same function, the length of Lisp code is only one-seventh to one-tenth that of C language.
2. Easy to reason about.
3. Parallel programming
4. Multi-core computing, cloud computing.
The Rise of Four Functional Programming
Moore's Law
multi-core processor
Cloud computing era