What is functional programming?

Functional programming is a programming paradigm where the calculation base is an assessment of expressions. Some features are the use of higher order functions, reference transparency and lazy evaluation. The advantages of programming style include that programs are easy to read, very reliable and can be divided into components. The disadvantages are that calculations can be slow and style and syntax differ completely from other common programming styles. Functional programming style is more often accepted by academics than computer science experts.

As the name suggests, the function is a basic part of this paradigm programming. Functions can be nested into other functions called higher order functions, and each higher -order function can be divided into building blocks that are easy to understand and tuning. Examples of some higher order functions are a map and a nest. The function map takes the function f and a sheet of variables, for example (x, y, z) and gives the result in the list: map [f, (x, y, z)] =(f (x), f (s), f (z)). NES will take Function F, variable x and number of iterations: Nest [f, x, 3] = f (f (f (f (f (x))).

Pure functional programming Get input and exhibition performance without changing the status of the variable. In other words, the function with the same input will always provide the same results no matter what happened in the program. This is called reference transparency. Since mathematical functions are reference transparent, functional programming is intuitive for many mathematicians, engineers and scientists.

Reference transparency of functions means that the order ranking is not important. The function may not be evaluated until their results are needed, which is called lazy assessment. This is in complete contrast with imperative programming, where the program begins with the first command and goes through the list until the last command. The lazy rating skips the part of the program that logiCKY do not follow or are unnecessary, which automatically optimizes the program and can shorten the computing time.

functional programming has many advantages over other paradigms of programming. Functions with clear inputs and outputs are easy to read and understand. Once the function is thoroughly tuning, it can be reliably used in other applications. Vícemstámní machines can be able to calculate functions that are evaluated independently in parallel, which drastically improves the performance of programs.

Unfortunately, not all programs are suitable for parallel calculation and computer functional programs can be quite slow. Functional programs are strongly relying on recursion, which is often less effective than the use of traditional loops or iteration methods. In fact, functional programming may be quineroma and difficult to learn because it is not discussed other common paradigms such as object -oriented programming.

Academics tend to prefer functional programming because PSKYet the clear and understandable way of programming complex problems of the real world. Some pure languages ​​are Hashell and Erlang. Mathematica specializes in symbolic mathematics, r specializes in statistics and J specializes in financial analysis. Multiparadigm languages ​​like Scala and F#

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?