Functional Programming

Functional programming is the process of constructing programs by applying and composing pure functions, avoiding shared state, mutable data, and side effects. It is a declarative programming paradigm, meaning it’s focused on what to solve. It contrasts with the imperative programming style, such as object oriented programming, in which the focus is on how to solve. Functional programming uses expressions instead of statements, meaning that an expression is evaluated to produce a value.

Functional code is more concise, predictable, and easier to test than imperative code because functions are treated as values and passed to functions as parameters. Programming languages that support functional programming include JavaScript, Scala, Lisp, Erlang, and Haskell.

Concepts of Functional programming

Many concepts are specific to functional programming. Some include:

Pure functions

Pure functions have two main properties: They always produce the same output given the same input, and they have no side effects. Because of these properties, there are many benefits of pure functions. If the result of a pure expression is not used, it can be removed without affecting other expressions. If there is no data dependency between two pure expressions, their order can be reversed, or they can be performed in parallel so they do not interfere with each other.

Pure functions are easy to understand because they don’t change any states and depend only on the input given to them. 

Recursion

Iteration, also known as looping, in functional languages is implemented through recursion. There are no “for” or “while” loops in functional languages. Recursive functions invoke themselves, meaning an operation can be repeated until it reaches the base case.

First-class and higher-order

First-class functions are treated as first-class variables, which can be passed to functions as parameters, returned from functions, or stored in data structures. Higher-order functions are functions that can either take other functions as arguments or return them as results. Higher-order functions are related to first-class functions because both allow functions as arguments and results of other functions.

Webopedia Staff
Webopedia Staff
Since 1995, more than 100 tech experts and researchers have kept Webopedia’s definitions, articles, and study guides up to date. For more information on current editorial staff, please visit our About page.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.

Related Articles

Embedded Analytics

Embedded analytics brings self-service business intelligence to everyday application users.

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their workforce operations. They provide a central platform for human resources professionals...

Complete List of Cybersecurity Acronyms

Cybersecurity news and best practices are full of acronyms and abbreviations. Without understanding what each one means, it's difficult to comprehend the significance of...

Human Resources Management System

A Human Resources Management System (HRMS) is a software application that supports many functions of a company's Human Resources department, including benefits administration, payroll,...

ScalaHosting

ScalaHosting is a leading managed hosting provider that offers secure, scalable, and affordable...

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their...

Best Managed Service Providers...

In today's business world, managed services are more critical than ever. They can...