# Functional Programming

## Functional Programming

### Introduction

New ideas are formed due to an intense reflection on the problems. Computer science, which seeks the answers to questions, has been formed as a result of finding solutions for a number of mathematical issues that required solutions. The tasks of the period of origin have largely been resolved, but they were the basis for various directions and approaches. One of such problems, i.e. the issue of solvability, or rather the question of possibility of creating an algorithm that could, based on given axioms, give an answer to whether a logical statement is true. It is a rather complex mathematical matter that captures the minds of many mathematicians of the time. It has made scientists think about the mechanisms for solving the issue as a whole. Several people had been working on this idea in parallel; and though they eventually came to the same thing, they were applying the radically different approaches. One of them is a basis of functional programming. This paper will discuss what functional programming is and how it differs from imperative programming along with its structure and main disadvantages.

Get Price Quote
Total price: 00.00

### Functional Programming along with the Imperative One

Functional programming is a branch of programming, in which programming is done by defining functions. According to its main principle, the computation consists of functions (Hinsen, 2009). It is well-known that any programmer has long programmed using functions, and not only these ones, but also procedures, loops, modules, and objects. However, there are no procedures, cycles, and even variables in functional programming. There are almost the only functions. Functional programming has a number of significant advantages that not only allow it to exist along with traditional programming, but also have its fans, task niche, and good prospects for the future.

Programs in traditional programming consist of their sequence of modifications of the values in the certain set of variables called a state. If a programmer does not consider input-output operations and also does not consider the fact that the program can work continuously, they can make the abstraction. Before the program starts, the state has a primary value. In it, the input data of the program are displayed. After finishing the program, the state has a new value. It involves the result of the program. During the process, each command is changing the state. Therefore, the state goes through the finite sequence of values. The state is modified with the help of assignment commands. These commands follow one another. Moreover, operators allow a programmer to change the order of execution of these commands depending on the current state value. This style of programming is called procedural or imperative. Functional programming represents a paradigm, which is radically different from the model presented above. A functional program is a certain expression in the mathematical sense. Its execution means the calculation of the value of this expression. Taking into account the above notation, if the result of the work of the imperative program is completely and uniquely determined by its input, it can be said as follows. The final state or any intermediate state is the function in the mathematical sense of the initial state.

Functional programming uses the following point of view. The program is an expression corresponding to the function. Functional programming languages approve of the formation of such expressions and provide a wide range of relevant language constructs. When comparing a functional and imperative approach to programming, it is necessary to note some properties of functional programs. The latter ones do not use variables in the sense that they are used in imperative programming. Specifically, functional programs do not utilize the assignment operator. As a consequence, there are no cycles in functional programs. The execution of the commands’ sequence in a functional program is meaningless, since one command cannot affect the execution of the next one. Functional programs employ functions in a considerably more complicated way. Functions can be passed to other roles as arguments and returned as a result, and even in the general case, perform calculations, the result of which will be a function. Instead of cycles, functional programs make an extensive use of recursive parts. At the first glance, a functional approach to programming may seem strange, unusual, and unhelpful, but the following considerations must be taken into account. First of all, imperative style in programming is not a rigidly prescribed necessity. Many characteristics of imperative programming languages are a result of abstraction from low-level details of computer implementation and machine codes to assembler languages, and then to such ones as Fortran, and so on. However, there is no reason to believe that such languages reflect the most natural way for a person to tell the machine of their intentions. Perhaps the approach is more correct, in which programming languages are born as abstract systems for recording algorithms. Then, they are translated into the imperative language of computer. Further, the functional approach has several advantages over the imperative one. First of all, functional programs more directly correspond to mathematical objects, and, therefore, allow the programmer to make exact reasoning. It can be quite difficult to set the value of the imperative program, which is the function, the calculation of which it realizes. On the contrary, the datum of a functional program can be derived almost directly.

### How it Works

7 simple Steps to get perfectly written custom essay

Place an Order

Make the payment

###### Step 3

We find the most qualified writer in your field

Writing Process

###### Step 5

Editors check for plagiarism & grammar mistakes

###### Step 7

Free revision within 48 hours after deadline expire

### Gluing Function

As the software is constantly becoming more complicated, a need to improve its structure is also increasing. Due to the fact that it is much easier to debug and write the well-structured software, it offers a set of reusable modules. Therefore, programmers can reduce the cost of programming in the future. Traditional languages have conceptual limitations on the organization of a modular structure. Functional languages remove these limitations. Modularity is a key to successful programming. That is why, languages, for which the runtime performance is a main goal, must support modular programming. But the new rules of visibility and the mechanisms of separate translation are not enough. Modularity does not have so many modules as opportunities. The ability to separate the matter into pieces is depending directly on the ability to connect solutions together. It has become possible to combine programs together with the help of a gluing function (Hughes, 1989). To maintain modular programming, the language should provide this role. Functional programming languages involve two new types of glue. They are higher-order functions and lazy calculations. When using these adhesives, programs can be modularized in new and exciting ways. Small and very common modules can be widely and repeatedly used, facilitating subsequent programming. If some part of the program is messy or complex, the programmer should try to break it into modules and generalize the parts. He or she must try to use higher-order functions and lazy calculations as the tools to accomplish this task.

Secure programming is implemented by avoiding states and changing data. Programming functionally, the programmer must create the functions in such a way where each of them solves only one task and does not produce side effects. Such a paradigm, placing emphasis on modularity and short functions, will help make the program easier to understand. Functional programming can also help to create code that is busy solving problems without introducing overhead to manage the calculation process. However, it is necessary to remember that some useful things from functional programming cannot be implemented in PHP, since this language was not originally designed for this purpose. Despite the fact that purely functional programming is one of the best methods of solving some problems it is necessary to note its weak point, namely low speed and clarity (Harrop, 2016). For example, pure functions are the excellent candidates for running parallel computations. However, PHP itself, unfortunately, is completely inappropriate for this issue. Moreover, it is not always easy to manage one recursion and lazy functions. They usually require additional resources, which leads to a significant decrease in the performance in individual cases. Sometimes, it is much more effective to develop programs in terms of variability. Another drawback of functional programming is the rather large amount of information that must be learned by the brain and accustomed to the imperative programming paradigm.

#### Conclusion

In many universities of developed countries, functional programming dominates as a basis of the laboratory practical work. It provides a docking of mathematical and computer science. This possibility is due to the weighted completeness of initial ideas of the functional approach. Functional programming languages are characterized by mathematical expressiveness. They are conceptual and laconic. On their basis, the ultimate commonality of constructions is attainable. Realizations of functional languages are inherent in the richness of the process models being studied. They support the traditional mathematical method of identifying the basic concepts. It makes it possible to most clearly reflect the nature of the problems being solved, naturally, up to the mnemonic-linguistic characteristics. Also, functional programming is extremely interesting. Therefore, by studying it, the programmer will have an opportunity to see the solution of some problems in a new light, which, in its turn, will help him or her continue growing in programming.

Free extras:
• Free plagiarism report (on request)
• Free revision (within 2 days)
• Free title page
• Free bibliography
• Free outline (on request)
• Free e-mail delivery
• Free formatting
We guarantee:
• Quality research and writing