Features of functional programming
1. Everything is a function and there is no object concept.
2. The same input is given to produce the same output.
3. The function has no internal status and has no side effects.
In Erlang, It inherits the features of functional programming and adds one. elang function variables can only be assigned once.
Erlang inherits the idea of PROLOG. in Prolog language, there are three elements: Atom, variable, list, And Erlang,
It also inherits its syntax and powerful pattern matching functions. These features come from
If Erlang has its own characteristics, it mainly includes the following:
1. No threads. All are lightweight processes.
No thread means no resource sharing, which greatly simplifies concurrent programming and increases the efficiency of concurrent execution. For concurrent implementation, it mainly creates a lightweight process. I'm curious about the relationship between the Process and the operating system itself.
In itself, the operating system provides processes. The process between the Lightweight Process Erlang and the operating system does not know what the relationship is, is it implemented by itself?
2. Dynamic hot plugging and high stability
Dynamic languages all have hot plug-in functions, which is the biggest advantage of dynamic languages. But Erlang seems to be compiled and executed. Can the systems that reference this module be aware of it in a timely manner?
For stability, the language core may be relatively small and the microkernel, so it is highly stable.
3. Error Handling Mechanism and Automatic Restart of processes
When an error occurs, many Java languages throw an exception through display definition or during runtime.ProgramErlang does not handle the issue. The process crashes directly and then restarts the process. It is mainly because functional programming is stateless and the retry results are the same.
As for the powerful concurrency programming model, which is the actor model, it is very similar to Scala. The sender sends messages asynchronously, and the receiver receives messages through pattern matching.