0% found this document useful (0 votes)
20 views1 page

Functional Programming vs. Imperative Programming

This document compares functional programming and imperative (procedural) programming. Functional programming focuses on what information is desired and transformations required rather than algorithms and state changes. It treats functions as objects and has low importance on order of execution. In contrast, imperative programming focuses on algorithms and tracking state changes, with important order of execution and manipulation of structures. While most languages support a specific paradigm, many are flexible enough to also support aspects of the other paradigm.

Uploaded by

Sanjay Khajure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Functional Programming vs. Imperative Programming

This document compares functional programming and imperative (procedural) programming. Functional programming focuses on what information is desired and transformations required rather than algorithms and state changes. It treats functions as objects and has low importance on order of execution. In contrast, imperative programming focuses on algorithms and tracking state changes, with important order of execution and manipulation of structures. While most languages support a specific paradigm, many are flexible enough to also support aspects of the other paradigm.

Uploaded by

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

This topic compares and contrasts functional programming with more traditional imperative

(procedural) programming.

Functional Programming vs. Imperative


Programming
The functional programming paradigm was explicitly created to support a pure functional
approach to problem solving. Functional programming is a form of declarative programming.
In contrast, most mainstream languages, including object-oriented programming (OOP)
languages such as C#, Visual Basic, C++, and Java , were designed to primarily
support imperative (procedural) programming.
With an imperative approach, a developer writes code that describes in exacting detail the
steps that the computer must take to accomplish the goal. This is sometimes referred to
as algorithmic programming. In contrast, a functional approach involves composing the
problem as a set of functions to be executed. You define carefully the input to each function,
and what each function returns. The following table describes some of the general
differences between these two approaches.

Characteristic

Imperative approach

Functional approach

Programmer focus

How to perform tasks (algorithms)


and how to track changes in state.

What information is desired and what


transformations are required.

State changes

Important.

Non-existent.

Order of execution Important.

Low importance.

Primary flow
control

Loops, conditionals, and function


(method) calls.

Function calls, including recursion.

Primary
manipulation unit

Instances of structures or classes.

Functions as first-class objects and


data collections.

Although most languages were designed to support a specific programming paradigm, many
general languages are flexible enough to support multiple paradigms. For example, most
languages that contain function pointers can be used to credibly support functional
programming. Furthermore, in C# 3.0 and Visual Basic 9.0, explicit language extensions
have been added to support functional programming, including lambda expressions and
type inference. LINQ technology is a form of declarative, functional programming.

You might also like