0% found this document useful (0 votes)
8 views5 pages

Functional 7

Functional programming is a programming paradigm that constructs programs by applying and composing functions, emphasizing immutability and pure functions. It has roots in lambda calculus and has evolved through various languages such as LISP, Scheme, and Haskell, gaining traction in areas like web development, data analysis, and cloud-native applications. Key characteristics include first-class functions, higher-order functions, and a focus on avoiding mutable state and side effects.

Uploaded by

65763888a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Functional 7

Functional programming is a programming paradigm that constructs programs by applying and composing functions, emphasizing immutability and pure functions. It has roots in lambda calculus and has evolved through various languages such as LISP, Scheme, and Haskell, gaining traction in areas like web development, data analysis, and cloud-native applications. Key characteristics include first-class functions, higher-order functions, and a focus on avoiding mutable state and side effects.

Uploaded by

65763888a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

History and development of Functional paradigm of


programming
In computer science, functional programming is a programming paradigm where
programs are constructed by applying and composing functions. It is a declarative
programming paradigm in which function definitions are trees of expressions that each
returns a value, rather than a sequence of imperative statements which change the
state of the program.

Functional programming is sometimes treated as synonymous with purely functional


programming, a subset of functional programming which treats all functions as
deterministic mathematical functions, or pure functions. When a pure function is called
with some given arguments, it will always return the same result and cannot be
affected by any mutable state or other side effects. This is in contrast with impure
procedures, common in imperative programming, which can have side effects (such as
modifying the program's state or taking input from a user). Proponents of purely
functional programming claim that by restricting side effects, programs can have fewer
bugs,be easier to debug and test, and be more suited to formal verification.

Functional programming has its roots in academia, evolving from the lambda calculus, a
formal system of computation based only on functions. Functional programming has
historically been less popular than imperative programming, but many functional
languages are seeing use today in industry and education, including Common Lisp,
Scheme, Clojure, Wolfram Language, Racket, Erlang, OCaml, Haskell, and F#. Functional
programming is also key to some languages that have found success in specific
domains.

The lambda calculus: developed in the 1930s by Alonzo Church, is a formal system
of computation built from function application. In 1937 Alan Turing proved that the
lambda calculus and Turing machines are equivalent models of computation, showing
that the lambda calculus is Turing complete. Lambda calculus forms the basis of all
functional programming languages. An equivalent theoretical formulation, combinatory
logic, was developed by Moses Schönfinkel and Haskell Curry in the 1920s and 1930s.
Church later developed a weaker system, the simply - typed lambda calculus, which
extended the lambda calculus by assigning a type to all terms. This forms the basis for
statically - typed functional programming.

The first functional programming language, LISP, was developed in the late 1950s for
the IBM 700/7000 series of scientific computers by John McCarthy while at
Massachusetts Institute of Technology (MIT). LISP functions were defined using
Church's lambda notation, extended with a label construct to allow recursive functions.
Lisp first introduced many paradigmatic features of functional programming, though
early Lisps were multi-paradigm languages, and incorporated support for numerous
programming styles as new paradigms evolved. Later dialects, such as Scheme and
Clojure, and offshoots such as Dylan and Julia, sought to simplify and rationalize Lisp
around a cleanly functional core, while Common Lisp was designed to preserve and
update the paradigmatic features of the numerous older dialects it replaced.
Information Processing Language (IPL), 1956, is sometimes cited as the first computer
based functional programming language. It is an assembly-style language for
manipulating lists of symbols. It does have a notion of generator, which amounts to a
function that accepts a function as an argument, and, since it is an assembly-level
language, code can be data, so IPL can be regarded as having higher-order functions.
However, it relies heavily on mutating list structure and similar imperative features.

In the 1977s, John Backus defined functional programs as being built up in a hierarchical
way by means of "combining forms" that allow an "algebra of programs"; in modern
language, this means that functional programs follow the principle of compositionality.
Backus's paper popularized research into functional programming, though it
emphasized function-level programming rather than the lambda-calculus style now
associated with functional programming.

In the 1970s, Guy L. Steele and Gerald Jay Sussman developed Scheme, as described in
the Lambda Papers and the 1985 textbook Structure and Interpretation of Computer
Programs. Scheme was the first dialect of lisp to use lexical scoping and to require tail
call optimization, features that encourage functional programming.

In the 1980s, Per Martin-Löf developed intuitionistic type theory (also called
constructive type theory), which associated functional programs with constructive
proofs expressed as dependent types. This led to new approaches to interactive
theorem proving and has influenced the development of subsequent functional
programming languages.

The lazy functional language, Miranda, developed by David Turner, initially appeared in
1985 and had a strong influence on Haskell. With Miranda being proprietary, Haskell
began with a consensus in 1987 to form an open standard for functional programming
research; implementation releases have been ongoing since 1990.

More recently it has found use in niches such as parametric CAD courtesy of the
OpenSCAD language built on the CSG geometry framework, although its restriction on
reassigning values (all values are treated as constants) has led to confusion among users
who are unfamiliar with functional programming as a concept. Functional programming
continues to be used in commercial settings.

2. Definition
Functional programming is a paradigm that treats computation as the evaluation of pure
mathematical functions, avoiding changing states and mutable data. It focuses on
declarative programming, meaning developers describe what should happen rather than
how it should happen.

Key Characteristics:

 Immutability – Data cannot be changed after creation.


 Pure Functions – Functions return the same output for the same input.
 Referential Transparency – A function call can be replaced with its
output without changing the program’s behavior.
 First-Class & Higher-Order Functions – Functions can be stored in
variables, passed as arguments, and returned from other functions.

In this paradigm treating functions as first-class citizens means that functions can be used
like any other variable. This means you can:

1. Assign functions to variables


2. Pass functions as arguments to other functions
3. Return functions from other functions

This makes functional programming more flexible and powerful because functions can
be used dynamically, just like numbers, strings, or objects.

3. Types of functions
Pure Functions
This function will always return the same output when given the same inputs. The result
is the same output for a mathematical function without side effects.
Pure functions rely on the following:
 The concept of immutability
 Referential transparency

Higher-Order Functions
A higher-order function takes in one or more functions as inputs. Then, it returns a
function as an output. For example, an online store has a database of all its product’s
prices. There’s a pure function designed to take 10% of a product’s price. The higher-
order function applies the pure function to every product’s price. That way, it can
produce a discounted pricing list. This is used for mapping, filtering and reducing data.

Anonymous Functions
These lambda functions are ideal for one-off situations. They are short, unnamed
functions for quick use. You could create the shuffle feature in Apple Music using an
anonymous function. Once activated, it will rearrange the songs in random order. This
function wouldn’t need to be named or saved because it only serves a one-time
purpose. You can keep randomly shuffling the songs using the anonymous function.
There is no need to remember any given shuffle for later use.

Recursive Functions
Recursive function is a function that calls itself to solve a problem. One of the most
common recursive functions is calculating disk space. This function is common in a
computer operating system. For example, do you want to know the size of your video
folder? A recursive function would repeatedly execute its command in all subfolders. In
other words, it would individually calculate the size of each subfolder. Each calculation
is one use of the recursive function to give you the overall size of the video folder.
Partial Functions
Partial functions are functions that pre-fill some arguments before execution. They only
return data for specific inputs and not for others. Developers use partial functions to
ensure apps and programs work as they should. How? These functions return errors or
“invalid input” when inputs fall outside valid ranges. For example, Uber will display a
fare cost if someone travels a distance greater than 0 km. If the distance is 0 km or
negative, the fare would be $0 or result in an error.

Generator Functions
Generator functions yields value easily instead of computing all at once. They used in
large scale data processing. Take the example of any social media application. When
you open the app, you don’t see every post on your feed simultaneously. That would
break the app. Instead, you see, say, 20 posts at a time with more loading as you scroll.

4. Uses of functional programming paradigm


Functional programming has many uses. But the top four arguably are the following:

1. Web Development (react and UI design) : React is based on functional


programming principles. Component-based architecture ensures reusability and
scalability and declarative views make UI predictable and easier to bug.

2. Data Analysis and Machine Learning : Immutability and pure functions are
crucial in data analysis because they promote code clarity, predictability, and easier
debugging. They do this by ensuring that data is not accidentally modified and that
functions always produce the same output for a given input. This makes it simpler to
reason about complex data transformations and analysis pipelines.

3. Concurrent and Distributed Systems: concurrency refers to a computer’s


ability to run multiple systems or parts of a program simultaneously while managing
total system memory and resources. A distributed system is a computer system where
the components are located on different networked computers and communicate with
each other by passing messages modern computer systems require both concurrent
and distributed systems. And this paradigm is well suited for both systems because of
its characteristics. It enables safe parallel execution.

4. Cloud-Native Applications: Cloud-native applications are designed to be


scalable, resilient, and efficiently deployed on cloud platforms. The functional
programming paradigm plays a crucial role in building such applications due to its
principles like immutability, statelessness, and high concurrency.

You might also like