本文主要是介绍【释义明晰】三种编程范式的概念和区别:imperative vs functional vs declarative(命令式编程 vs 函数式编程 vs 声明式编程),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 1. 前言
- 2. 区别总结
- 3. 具体探索
- 4. 小结
1. 前言
创作开始时间:2022年6月16日12:22:51
如题,简单探究一下三种编程范式的概念和区别。
2. 区别总结
在进行了一些探索(见下一节)之后,我大概知道了三者的区别:
- imperative programming,命令式编程 主要关注的是怎么做,是过程,是偏底层一点的编程实现。经常要用到:“顺序+分支+循环”
- declarative programming,声明式编程不关心怎么做,只关心做什么,是高层的抽象。不怎么用“顺序+分支+循环”
- functional programming 函数式编程:和声明式编程很相关。只关注做什么,不关注怎么做。有人认为声明式包含函数式和逻辑式编程 (函数式编程与声明式语言 我觉得还是有道理的)。
3. 具体探索
declarative programming:做什么。
imperative programming:怎么做。
Declarative programming is to program on a higher level of abstraction than imperative programming. Neither is better or worse, but both have their places.
The concept of functional and procedural programming paradigms are really just extensions of the concept of declarative and imperative programming paradigms. In fact, functional programming is a subset of declarative programming, and procedural programming is a subset of imperative programming.
命令式(imperative)对应过程式(Procedural programming)
声明式(declarative)丢应函数式(Functional programming)
参考:
- The Differences Between Procedural, Functional, Imperative, and Declarative Programming Paradigms https://amzotti.github.io/programming%20paradigms/2015/02/13/what-is-the-difference-between-procedural-function-imperative-and-declarative-programming-paradigms/
Both imperative and declarative programming are classified as the common programming paradigms (programming paradigms are a way to classify programming languages based on their features).
越接近现实的表达就叫越“声明式”(declarative),越接近计算机的执行过程就叫越“命令式”(imperative)
- https://learntocodetogether.com/imperative-vs-declarative-programming/
- https://wenku.baidu.com/view/59fa505a30687e21af45b307e87101f69e31fb82.html
- 编程风格之声明式与命令式的区别 - 没有50CM手臂的文章 https://zhuanlan.zhihu.com/p/58976871
参考:
- https://wenku.baidu.com/view/83c863cfe309581b6bd97f19227916888486b9e5.html
4. 小结
以上。
创作结束时间:2022年6月16日12:52:29
这篇关于【释义明晰】三种编程范式的概念和区别:imperative vs functional vs declarative(命令式编程 vs 函数式编程 vs 声明式编程)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!