官术网_书友最值得收藏!

Functional programming

Functional programming is a sub-paradigm of declarative programming. As opposed to imperative programming, functional programming does not change the internal state of the program.

In imperative programming, the functions can be regarded more as sequences of instructions, routines, or procedures. They not only depend on the state stored in the memory but can also change that state. This way, invoking an imperative function with the same arguments can produce different results depending on the current program's state, and at the same time, the executed function can change the program's variables.

In functional programming terminology, functions are similar to mathematical functions, and the output of a function depends only on its arguments, regardless of the program's state, which, at the same time, remains unaffected by the execution of the function.

Paradoxically, while imperative programming has existed since computers were first created, the basic concepts of functional programming dates back before that. Most functional languages are based on lambda calculus, a formal system of mathematical logic created in the 1930s by mathematician Alonzo Church.

One of the reasons why functional languages become so popular in those days is the fact that they can easily run in parallel environments. This should not be confused with multithreading. The main feature that allows functional languages to run in parallel is the basic principle on which they reside: the functions rely only on the input arguments and not on the program's state. That is, they can be run anywhere, and the results of the multiple parallel executions are then joined and used further.

主站蜘蛛池模板: 长岛县| 顺昌县| 华亭县| 固安县| 如皋市| 日土县| 娄底市| 自贡市| 时尚| 怀远县| 奉贤区| 抚州市| 湘乡市| 夏津县| 利辛县| 陕西省| 绵竹市| 阳江市| 永吉县| 上思县| 濮阳市| 哈密市| 津南区| 桃江县| 余干县| 庆城县| 靖江市| 永靖县| 天峨县| 辽阳市| 康定县| 潜江市| 淅川县| 霍邱县| 黔江区| 靖边县| 阿坝| 苗栗县| 玛纳斯县| 拜泉县| 耿马|