Tram Ho

What is Functional Programming?

Functional Programming has been around for a long time, it’s the main programming platform. As technology has evolved, other programming languages, such as SML, OCaml, APL and Clean, have left FP lagging behind, although still being developed but used only for academic purposes and The research is mainly. This raises the question of why FP has been present for a long time and still maintained its development, but FP has not achieved as much success as, Imperative or OO …

FP is a fairly popular and important programming method in computer science. FP’s job is to see the program as a collection of functions that take arguments and return values. Unlike imperative and OO, FP does not produce side effects and uses recursion instead of loops. The function of FP is very similar to the function in mathematics because it does not change the state of the program.

For example: f (x) = y, then x will always be equal to y, the quantity when it is assigned the value never changes that value.

The mathematical basis of FP is very transparent, so because it is not flexible in state changes, FE provides a logical and concise solution to computational problems. Therefore makes people prefer other paradigm to handle common computing operations. With F #, the above barrier is solved because it allows to use multiple paradigm and mix them together to solve the problem in the most convenient way.

The terms in FP are as simple and clear as they are. To gain an overview of this industry, we must first understand the concepts of it.

Pure function

A pure function of FP that consists of the same inputs, always produces the same output and certainly has no side effects.

Function composition

This is the act of performing a process that combines two or more functions to create a new function or perform a task. If you can use the function composition smoothly, it will be an important step to understand how the software is built using Functional Programming.

Shared state (Shared variable)

A shared state is generally understood as whether any variables, objects, or memory spaces exist within a shared scope. A shared scope includes the global scope and the scope closure. They are shared in so many places and it’s hard to know which function changed that variable. Functions should not be shared between variables and data. The results may vary if we change the order of the functions with shared variables.