Why functional programming is important-1

Source: Internet
Author: User
Tags mathematical functions

Statement: This translation aims to improve the individual's English Reading Ability and provides more excellent translations on the Internet. it is very painful for me to understand English. for the original article, see pai_^.

Why functional programming matters

The data in this article came from 1984, which has been widely used as a memorandum for Chalmers for many years. A slightly changed version is available in 1989 and 1990. this version is based on the original Chalmers memorandum and is slightly changed with latex to make it closer to the release version.

Summary

As a software becomes more and more complex, it becomes more and more important to organize it well. A good structure makes it easier to write programs, debug programs, and provide a set of Reusable Modules to reduce future coding payments. traditional languages have conceptual limitations on modularity. (conventional versions Ages place concetual limits on theway problems can be modularised .) functional languages do not have these limitations, so they can achieve greater modularization. for example, we process linked lists and trees, write several numerical algorithms, and process alpha-beta heuristic algorithms (one artificial algorithm is used in game programming ). since modularization has become the key to programming, functional languages are important to the real world.

Introduction

The purpose of this article is to prove that functional programming is important to the real world and help functional programming programmers explore all of its advantages by clearly pointing out the advantages of functional language.

Function programming is called because a program is composed of all functions. The main program is written as a function that accepts program input as its parameters and transmits program output as its result.

Typically, the main function is defined by another function, and other functions are defined by another function in turn until the bottom function is the original language. these functions are more like original mathematical functions, and will be defined through the original equations in this article. our symbols Mark Miranda (TM) from Turner's language, but are also readable to readers without functional language basics.

The special and advantages of function programming are often summarized as follows: function programming does not have a value assignment statement. Therefore, once a value is given, it will not be changed. more often, functional programming has no side effects. A function call has no function other than calculating its value. this eliminates the root cause of the main bugs, and changes the expression value without any side effects also make the execution of the program irrelevant to the sequence, because it can be computed at any time. this reduces the burden on the control flow specified by programming. because the expression can be evaluated at any time, we can freely replace the variable with the value of the variable, and vice versa. the program reference is transparent. This free energy helps functional programs more easily control mathematics than other traditional languages.

These advantages are good, but we will not be surprised if outsiders do not care about them. it sounds like a lot of functional programming is something that he doesn't have (no assignment, no side effects, no control flow), but there's no more about him. functional programmers may sound like monks who have no fun and hope they will become noble. for those who are pursuing superficial exploitation, these "advantages" seem to be unconvincing.

Functional programmers argue that functional programming brings a lot of benefits. Functional programmers are more productive than programmers of other types of languages, because functional programs are shorter. Why is this correct? One reason seems to be that the traditional program has a value assignment statement of 90%, but in functional programs, these values can be omitted. this is obviously ridiculous. if the value assignment statement is omitted, the Fortran programmer did this 20 years ago. logically, it is impossible to let a language omit the value assignment statement to make it powerful, no matter how bad the design is.

Even a functional programmer should be dissatisfied with these advantages, because it is not helpful to help them explore functional languages. we cannot write a program that completely lacks the value assignment statement or completely references transparent. this is not a measure of the quality of a program, so it is useless to put the goal here.

Obviously, this descriptive functional programming feature is insufficient. we must find something that not only explains the power of functional programming, but also points out the effort of functional programming.

Analogy with Structured Programming

The comparison between functional programming and structured programming is very helpful. in the past, the features and advantages of structured programming were summarized as follows: structured programs do not have a GOTO statement. the statement block does not have more entrances and exits. structured programs are easier to perform mathematical operations (more tractable mathematically) than unstructured programs ). we found in the Early Days that these features have great similarities with functional programming. these are essentially negative, resulting in too many "Goto is indispensable" and so on.

Obviously, although these attributes of structured programming are helpful, they cannot solve the core issue. the biggest difference between structured and unstructured programming is that structured programs are designed to be modular. modularization improves productivity. first, small modules can be quickly and easily written. second, the general target module can be reused, so that we can produce subprograms more quickly. third, the program module can be tested independently, helping to spend time debugging.

The absence of "Goto" and so on is almost useless, and the key role is Modularization. languages such as modula-II, Ada, and ML (not make love) all include improved modular functions. however, the key points are ignored all the time. when writing a modular program, you must first break down the problem into sub-problems, then solve the sub-problems and combine the solutions. the decomposition method directly affects the bonding solution. therefore, to improve modularity, new bonding methods must be provided in programming languages. complex scope rules and support for block compilation are only a little help, and they do not provide new-concept tools to break down the problem.

By analogy with craftsman, we understand the importance of bonding. A chair can be easily made through a cushion, foot, back, and so on and through the correct combination. however, this is determined by the connection capability of the board and plug. without this capability, it can only be carved with solid wood blocks. this is very difficult. this example demonstrates the great capabilities of modularity and the importance of correct adhesives.

Now let's go back to functional programming. in the remaining articles, we will discuss two very important new adhesives provided by function programming. we will provide many program examples to prove that functional programming can be modularized and simpler with new methods. this is the key to functional programming. he gave us great modularity. this is also the goal of functional programming-smaller, more concise, and more modular. It is combined with the new binder we will describe.

Why functional programming is important-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.