Javatpoint Logo
Javatpoint Logo

Functional Programming

Functional programming is designed to handle the symbolic computation and application processing list, and it is based on mathematical work. The most popular functional programming languages are Python, Lisp, Haskell, Clojure, Erlang etc.

Functional Programming has two types; those are shown as below:

  • Pure Functional Languages: Pure functional language supports only the functional pattern. An example of the pure functional language is Haskell.
  • Impure Functional Language: Impure Functional language supports the prototype of functions and the programming's imperative style. An example of an impure functional language is LISP.

Characteristics of the Functional Programming Language

Characteristics of the functional programming languages are like as shown below:

  • Functional programming languages are designed to perform the functions of mathematical functions. These functions use conditional expressions and recursion to perform the computation.
  • Functional programming supports functions in higher-orderand features of lazy evaluation.
  • Functional Programming language directly uses the functions and function calls. It does not support the flow of the controls like statements of the loop, and statements are like the conditional statements such as If-Else and Switch Statements.
  • Object-Oriented Programming supports the Abstraction, Encapsulation, and Polymorphism, just like functional programming languages support OOPS concepts.

Advantages of the Functional Programming

Advantages of the functional programming languages are as shown below:

  • Bugs-Free code: Functional Programming language does not support state, so there is no side effect of the functional programming; hence we can write the error-free code.
  • Efficient Programming Language: Functional Programming language has no mutable state, so there is no state change issue. We can do the program "Functions" to work parallel to "Instruction". This type of code supports reusability and testability easily.
  • Efficiency- Functional Program contains the Independent Units. Independent units run concurrently. Hence these functional programs are more efficient.
  • Supports Nested Functions- Nested functions are supported by functional programming.
  • Lazy Evaluation- Lazy Functional Constructions are also supported by functional programming such as Lazy Lists, Lazy Maps, etc.

Functional programming does not have any state, so all the time, there is a need to create new objects to perform the actions. That's why functional programming needs a large memory space.

Functional programming is used to perform the different operations on the same data set.

The LISP supports artificial intelligence applications such as language processing, Machine learning, Modelling of speech and vision.

Differences between the Functional Programming and Object-Oriented Programming are:

Sr.No. Functional Programming Object-Oriented Programming
1. The functional programming language supports immutable data. OOP uses mutable data.
2. Functional Programming supports the Declarative Programming Model. OOP supports the imperative Programming Model.
3. Functional Programming focuses on the "What we are doing". OOP focuses on the "How we are doing".
4. The methods of Functional Programming will not produce any side-effects. Methods of the OOP can produce the side-effects.
5. Functional Programming follows parallel programming. OOP does not work on parallel programming.
6. For the flow control, we do function calls & function calls with recursion. Object-Oriented Programming supports the use of the loops and conditional statements for the flow control.
7. For the iteration of the data collection, functional programming uses the"Recursion" concept. Object-Oriented Programming uses the "Loop" concept for the iteration of Data collection. For example, For-each loop in Java
8. For functional programming, the execution of statements in the order is not so important. It is essential for the oop programming to execute the statements in order is very important.
9. Functional Programming supports "Abstraction over Data" and "Abstraction over Behavior". OOP supports only "Abstraction over Data".

Efficiency of Program

The program's code is directly proportional to the efficiency of the algorithm and the execution speed of the program. If the efficiency is good, that means the performance will be high in the program.

The efficiency of the program is affected by the below factors:

  • The machine's speed affects the efficiency of the program.
  • The compiler's speed also affects the efficiency of the program.
  • The operating system also plays a crucial role in the efficiency of the programming code.
  • The choice of the right Programming language affects the efficiency of the programming.
  • Data organization is also affecting the efficiency of the program.
  • The use of the algorithm in the program affects the efficiency of the programs. An algorithm in the Functional Programming solves the problem.

We can increase the efficiency of the programming language with the help of the below tasks -

  • To increase the program's efficiency, we have to remove the program's unusable code or the code that is having redundant processing.
  • The use of optimal memory and non-volatile storage helps to improve the efficiency of the programming language.
  • We can reuse the components. This will also help to increase the efficiency of the program.
  • By using the error & exception handling on all the layers of the program.
  • During the program's coding, the program should have to be ensured about the data's integrity and consistency.
  • By using the programming code, we can do design logic and flow.

Efficient programming code can reduce the consumption of the resources and time taken by the completion programs.

Prerequisite

Before learning Data Structure, you must have the basic knowledge of C++.

Audience

Our Functional Programming Tutorial is designed to help beginners and professionals.

Problem

We assure you that you will not find any difficulty while learning through our Functional Programming Tutorial. But if you find any mistake in this tutorial, we request you to kindly post the problem in the contact form so that we can improve it.






Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA