A preliminary understanding of functional programming languages

For functional languages ​​do not quite understand, inquired Baidu, blog, etc. know almost made the following summary.

 

 

What

  Functional languages ​​(functional language) a class of programming languages, is a non-von Neumann-style programming language. Functional languages ​​is the main component of the original function, the function type and function definitions.

This language has a strong ability to organize data structure, can be a data structure (such as an array) as a single value processing; can function as a parameter, which may result as a function of such defined functions

Called higher-order functions, the program is the function, the program acts on structured data, generate structured results, changing the language of the von Neumann "word by word" work fundamentally.

  The purpose of functional programming languages ​​is possible emulated math functions.

  The core feature of functional languages:

   (1) the "function" head, as in imperative languages ​​"variable", the function can be assigned to other variables, as a function of other parameters,

      Or other functions as a return value.

   (2) does not modify the value of a variable

   (3) only expressions, not statements. Statement here refers not return worth some operations.

   (4) a transparent reference (Referential transparency), running the function does not rely on external variables or "state" simply means that,

      With an input (parameter), will always produce the same output (return value), which is consistent with the characteristics of the mathematical function.

      Imperative languages ​​because there is a global variables, you can not do this.

   (5) Comparative imperative languages, recursively circulating

 

Include

Functional programming languages ​​are the following:

  Haskell is a functional programming language in the late 1980s published, Haskell functional programming language is the basis of Miranda got on, it was standardized Miranda,

So this language collection of other relevant principles of functional programming developed it without spending too much repeat them to complete some data structures such as linked lists and matrices, is a functional programming language is currently the most widely used research .

  Another functional programming language Clean, Haskell, and it has a lot of different places. Currently the language is written in C, the responsibility of the University of Michigan Ni Zimei maintenance.

  There is also a functional programming language Meta Language, MetaLanguage University of Edinburgh and is developed in the last century by the late seventies, it was classified as non-pure functional programming language, it is the reason for this return

Category because it allows the use of side effects and imperative programming.

  Currently, there are functional programming language F #, which is a language for the .NET platform open-label study.

  There OCaml, Lisp, etc.

 

The characteristics of functional programming languages ​​include the following:

  1, parallel. In functional programming, programmers do not need to modify the program, the program can be run concurrently. During the program run, no deadlock.

  2, unit testing. In functional programming, since each symbol is the final program, so this function does not produce side effects.

  3, no additional action. In functional programming languages, all functions of the result is a return value, there is no other acts, including changes to external variables.

  4, does not modify the status. In functional programming, programming language will not change the variable, in use, it may be such a characteristic functional programming language from other programming languages. In other types of languages, variables are used to save the state.

  5, reference transparent. In functional programming, transparent refers to a reference run time function, did not implicate a step will not function to external variables or states of function, but the function depends only on the input parameters, the same parameter input always get the same function return value.

  6, the code deployment heat. Of the functional program, i.e., the state of all the parameters passed to the function are stored in the stack, making the heat easy to deploy.

 

Why popular

  First, a functional programming language code is very simple, to accelerate the speed of development. And in use since functional programming languages, the programmer can use a large number of functions, thereby reducing repetitive code, and thus the procedure is relatively short.

  Second, the functional programming language closer to natural language we use, programmers in learning and using it more quick and easy. Functional programming language degrees of freedom is high, very close to the code written in natural language. letter

The number of programming language code management more convenient. Functional Programming no dependency on external, can not modify the state of the outside world. Programmer only the designated parameter to the function, which returns the result of the same parameters must be the same.

In addition, functional programming languages ​​also support concurrent programming, which allows the programmer is no need to consider the issue of deadlock during functional programming, because it simply does not modify variables, so there is no problem locking thread.

  Finally, functional programming language code support hot code upgrades.

Guess you like

Origin www.cnblogs.com/ren9ie/p/10962470.html