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

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.

主站蜘蛛池模板: 黄梅县| 吉木乃县| 安平县| 兴安县| 汕尾市| 佛教| 共和县| 璧山县| 南雄市| 扬中市| 南皮县| 资中县| 玉山县| 奎屯市| 九龙县| 东宁县| 武城县| 康马县| 抚州市| 文成县| 南涧| 扬州市| 永新县| 达州市| 凤翔县| 合作市| 维西| 临泽县| 吉木萨尔县| 浦江县| 二连浩特市| 新闻| 泰顺县| 普安县| 文山县| 礼泉县| 太原市| 射阳县| 陇南市| 芜湖县| 修文县|