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.
分享到:
相关推荐
However, functional programming may seem unfamiliar to developers who are used to using imperative and object-oriented techniques. The new additions to Java 8 offer the opportunity to develop more ...
If you’re new to functional programming, you’ll appreciate this guide’s many insightful comparisons to imperative or object-oriented programming that help you understand functional design....
Functional programming provides a differ- ent way to think about software design and a different way of programming, compared to the imperative, object-oriented styles commonly used with C++. Many ...
Functional Programming vs. Imperative Programming
From performance optimizations to concurrency, improved testability to code brevity, functional programming has a host of benefits when compared to traditional imperative programming.
Get to know the difference between imperative and functional approaches See the use of first-class functions and pure functions in a functional style Discover various techniques to apply immutable ...
shows how to apply basic theoretical concepts to produce succinct and elegant programs It demonstrates the role of functional programming in a wide spectrum of applications including databases and ...
Learn about first-class functions and how imperative-style patterns can be converted into functional code using some simple techniques The book will get you familiar with using functional programming ...
Chapter 1, Tasting Functional Style in C#, introduces the functional programming approach by discussing its concepts and the comparison between functional and imperative programming. We also try to ...
Programming.Scala_Tackle.Multi-Core.Complexity.on.the.Java.Virtual.Machine[2009][EN][PDF] Programming Scala: Tackle Multi-Core Complexity on the Java Virtual Machine by Venkat Subramaniam Scala is ...
Imperative_to_functional_programming_succinctly
paradigms abound: Some examples are imperative programming, structured (go to less) programming, object-oriented programming, aspect-oriented programming, and declarative programming. Lately, there ...
programming, aspect-oriented programming, and declarative programming. Lately, there has been renewed interest in a particular paradigm that can arguably be considered to be older than most (if not ...
Underscore.js is one of the most popular modern JavaScript libraries used for functional programming. It can be used as a base for building complex JavaScript applications in a sustainable manner and ...
pure FP often isn’t suitable for general-purpose programming. Because of this, FP languages have gradually embraced aspects of the imperative and OO paradigms, remaining true to the FP paradigm but ...
functional programmers, although it is a functional programming language itself.Erlang and Elixir for Imperative Programmers gives you a basis for deciding whether the effort is viable for your next ...
Learn from F#'s inventor to become an expert in the latest version of this powerful programming language so you can seamlessly integrate functional, imperative, object-oriented, and query programming ...
developers, are very much familiar with the imperative style of programming; however, now to tackle the essential complexity, reactive programming uses declarative and functional paradigms to build ...
Underscore.js is one of the most popular modern JavaScript libraries used for functional programming. It can be used as a base for building complex JavaScript applications in a sustainable manner and ...
Learn how to choose between imperative and functional approaches based on expressiveness, clarity, and performance Apply functional Python to common Exploratory Data Analysis (EDA) programming ...