面向(控制)执行 vs 面向描述

命令式编程面向算法vs声明式编程面向描述。

命令式编程面向:数据结构与算法;

算法 = 控制 + 逻辑;

命令式编程是行动导向(Action-Oriented)的,因而算法是显性而目标是隐性的;

声明式编程将描述与求解分离;

声明式编程面向描述:

面向逻辑、抽象、描述;

逻辑(数学)规则的表达;

计算规则;

结合规则;

处理规则;

特征规则;

描述为主,算法为辅。

声明式编程专注问题的分析和表达而不是算法实现,不用指明执行顺序,一般没有或极少副作用。同时也非常适合于并发式计算。

编程语言的流行程度与其擅长的领域密切相关。函数式语言和逻辑式语言擅长基于数理逻辑的应用,命令式语言擅长基于业务逻辑的、尤其是交互式或事件驱动型的应用。

命令式编程通过一系列改变程序状态的指令来完成计算,声明式编程只描述程序应该完成的任务。命令式编程模拟电脑运算,是行动导向的,关键在于定义解法,即“怎么做”,因而算法是显性而目标是隐性的;声明式编程模拟人脑思维,是目标驱动的,关键在于描述问题,即“做什么”,因而目标是显性而算法是隐性的。

http://www.nowamagic.net/academy/detail/1220528

imperative - expressions describe sequence of actions to perform (associative)

declarative - expressions are declarations that contribute to behavior of program (associative, commutative, idempotent, monotonic)

functional - expressions have value as only effect; semantics support equational reasoning

  • Declarative languages don't have looping control structures, e.g. for and while, because due to immutability, the loop condition would never change.
  • Declarative languages don't express control-flow other than nested function order (a.k.a logical dependencies), because due to immutability, other choices of evaluation order do not change the result (see below).

on the other hand, an imperative approach gives you more low level control - it's the "micromanager approach" to programming.

20

Imperative Programming means any style of programming where your program is structured out of instructions describing how the operations performed by a computer will happen.

Declarative Programming means any style of programming where your program is a description either of the problem or the solution - but doesn't explicitly state how the work will be done.

Functional Programming is programming by evaluating functions and functions of functions... As (strictly defined) functional programming means programming by defining side-effect free mathematical functions so it is a form of declarative programming but it isn't the only kind of declarative programming.

Logic Programming (for example in Prolog) is another form of declarative programming. It involves computing by deciding whether a logical statement is true (or whether it can be satisfied). The program is typically a series of facts and rules - i.e. a description rather than a series of instructions.

https://stackoverflow.com/questions/1784664/what-is-the-difference-between-declarative-and-imperative-programming

命令式编程面向算法vs声明式编程面向描述相关推荐

  1. 功能性,声明式和命令式编程[关闭]

    功能,声明和命令式编程这两个术语是什么意思? #1楼 命令式 - 表达式描述要执行的动作序列(关联) 声明性 - 表达式是有助于程序行为的声明(关联,交换,幂等,单调) 功能 -词汇具有值作为唯一的影 ...

  2. 函数式编程和面向对象式编程_比较函数式编程,命令式编程和面向对象的编程

    函数式编程和面向对象式编程 As Oracle Corporation has introduced some Functional constructs in Java SE 8, now-a-da ...

  3. 编程语言的主要类型,声明式编程,命令式编程()和函数式编程的区别

    编程语言的主要类型 Common programming paradigms include imperative which allows side effects, functional whic ...

  4. 声明式和命令式编程_命令式与声明式编程

    声明式和命令式编程 At this point you've undoubtedly heard about imperative programming vs declarative program ...

  5. Imperative vs Declarative声明式编程和命令式编程的比较

    先统一一下概念,我们有两种编程方式:命令式和声明式. 我们可以像下面这样定义它们之间的不同: 命令式编程:命令"机器"如何去做事情(how),这样不管你想要的是什么(what),它 ...

  6. 高阶函数||编程范式: 命令式编程/声明式编程 || 编程范式: 面向对象编程(第一公民:对象)/函数式编程(第一公民:函数)

    编程范式: 命令式编程/声明式编程 编程范式: 面向对象编程(第一公民:对象)/函数式编程(第一公民:函数) 高阶函数 filter/map/reduce filter中的回调函数有一个要求: 必须返 ...

  7. 编程思想:面向对象和面向过程

    何谓面向对象?何谓面向过程?对于这编程界的两大思想,一直贯穿在我们学习和工作当中.我们知道面向过程和面向对象,但要让我们讲出来个所以然,又感觉是不知从何说起,最后可能也只会说出一句就是那样啦,你知道啦 ...

  8. Atitit 面向对象编程(OOP)、面向组件编程(COP)、面向方面编程(AOP)和面向服务编程(SOP)的区别和联系...

    Atitit 面向对象编程(OOP).面向组件编程(COP).面向方面编程(AOP)和面向服务编程(SOP)的区别和联系 1. 面向组件编程(COP) 所以,组件比起对象来的进步就在于通用的规范的引入 ...

  9. 放心!没人在意你使用的是命令式编程还是声明式编程

    作者 | Sunil Sandhu 译者 | 弯月,责编 | 屠敏 头图 | CSDN 下载自东方 IC 出品 | CSDN(ID:CSDNnews) 以下为译文: 最初我想写一篇文章详细介绍命令式编 ...

最新文章

  1. mysql 普通索引和唯一索引_MySQL 普通索引和唯一索引的区别
  2. 利用python安装opencv_OpenCV Python安装教程
  3. MATLAB数值计算与符号运算
  4. thinkphp三级分销小程序源码_山东谷道微信小程序商城源码带后台 公众号平台三级分销系统...
  5. scipy中稀疏矩阵coo_matrix, csr_matrix 的使用
  6. MySQL 安装 [mysql-5.6.37]
  7. 如何在windows10系统将用户名改为英文
  8. C# winform实现系统托盘NotifyIcon控件右键菜单
  9. 2017年总结与展望
  10. 计算机程序设计c++ 5-1:函数的调用格式
  11. 电影文件的合并与分割
  12. pyecharts之参透神剧人物关系
  13. ckplayer播放线上视频问题
  14. Ubuntu主机合盖子不休眠
  15. CDS (W2) -- Features, Data, Text Processing
  16. Python带你面向对象爬取网易云音乐
  17. 编码修养系列---提升性能必学篇
  18. 从数字化过渡到智能制造
  19. 分享一道蚂蚁金服笔试题
  20. STM32应用(八)数字温度传感器DS18B20、数字温湿度传感器DHT11(软件模拟I2C)

热门文章

  1. mysql insert 性能_MySQL 提高Insert性能
  2. 安阳7中计算机绘画知识,安阳工学院绘画专业主修课程有哪些
  3. python封装sql脚本_pymysql的简单封装代码实例
  4. ps人像精修照片步骤_15天零基础自学PS!送你整套PS教程297集+视频+素材+源文件模板6...
  5. SpringBoot2入门笔记
  6. 一台电脑上安装5台tomcat 与 项目部署 probe
  7. c++ 海战棋_编程入门须知:都说零基础不好学编程,那么什么是编程基础?
  8. sql和mysql同时配置_jfinal同时配置mssql和mysql混动数据源
  9. matlab实验符号计算答案,2014秋实验四_MATLAB的符号计算二答案
  10. qgis 图片_QGIS教程09QGIS中如何制作萤火虫地图?