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....
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 ...
在本文中,我们将深入探讨函数式编程(Functional Programming)的概念、优缺点、应用场景,以及与命令式编程(Imperative Programming)的区别。 一、什么是函数式编程? 函数式编程是一种编程范式(Programming ...
Imperative Programming):声明式编程关注“做什么”,而命令式编程关注“怎么做”。函数式编程倾向于声明式编程,它描述了程序的逻辑而不描述实现逻辑的具体步骤。 3. 函数式编程的定义(What Is Functional ...
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 ...
函数式编程(Functional Programming, FP)是一种编程范式,其核心理念是使用数学函数来构建软件。与常见的命令式编程范式(Imperative Programming)不同,函数式编程强调不可变性(Immutability)和函数无副作用...
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 ...
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 ...
### Haskell:Functional Programming with Types — 关键知识点概览 #### 标题理解: - **Haskell**:一种纯函数式编程语言,强调简洁性、可读性和强大的类型系统。 - **Functional Programming**:编程范式之一,...