`
feixingfei
  • 浏览: 45321 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论
  • calosteward: 感谢分享,我还找到了另一个也是可以用于c#的代码,是一个英文网 ...
    PDF合并

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.

分享到:
评论

相关推荐

    Functional programming in Java.pdf

    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 ...

    Functional.Programming.in.JavaScript.2016.6.pdf

    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....

    Learning C++ Functional 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 ...

    Functional Programming Using F#

    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.docx

    在本文中,我们将深入探讨函数式编程(Functional Programming)的概念、优缺点、应用场景,以及与命令式编程(Imperative Programming)的区别。 一、什么是函数式编程? 函数式编程是一种编程范式(Programming ...

    Functional Programming for Java Developers

    Imperative Programming):声明式编程关注“做什么”,而命令式编程关注“怎么做”。函数式编程倾向于声明式编程,它描述了程序的逻辑而不描述实现逻辑的具体步骤。 3. 函数式编程的定义(What Is Functional ...

    Functional C#[January 2017].pdf

    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[2009][EN][PDF] Programming Scala: Tackle Multi-Core Complexity on the Java Virtual Machine by Venkat Subramaniam Scala is ...

    Purely Functional Data Structures.pdf

    函数式编程(Functional Programming, FP)是一种编程范式,其核心理念是使用数学函数来构建软件。与常见的命令式编程范式(Imperative Programming)不同,函数式编程强调不可变性(Immutability)和函数无副作用...

    Mastering+JavaScript+Functional+Programming-Packt+Publishing(2017).epub

    paradigms abound: Some examples are imperative programming, structured (go to less) programming, object-oriented programming, aspect-oriented programming, and declarative programming. Lately, there ...

    Mastering+JavaScript+Functional+Programming-Packt+Publishing(2017).pdf

    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 ...

    Learning Underscore.js(PACKT,2015)

    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 ...

    Erlang and Elixir for Imperative Programmers(Apress,2016)

    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 with Types — 关键知识点概览 #### 标题理解: - **Haskell**:一种纯函数式编程语言,强调简洁性、可读性和强大的类型系统。 - **Functional Programming**:编程范式之一,...

Global site tag (gtag.js) - Google Analytics