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

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.

主站蜘蛛池模板: 永丰县| 丹巴县| 尉犁县| 于都县| 宜丰县| 肇州县| 绥化市| 巢湖市| 赤峰市| 博客| 湟中县| 固安县| 精河县| 堆龙德庆县| 江山市| 建瓯市| 桃园市| 安龙县| 侯马市| 雅安市| 七台河市| 通州区| 荥阳市| 涿鹿县| 鹤岗市| 曲靖市| 清流县| 扎囊县| 义乌市| 新田县| 贡嘎县| 德兴市| 阳谷县| 哈巴河县| 遂昌县| 绩溪县| 江永县| 盐边县| 亚东县| 平度市| 信阳市|