声明式和过程式编程范例之间有什么区别? [英] What is the difference between declarative and procedural programming paradigms?
问题描述
说明性编程范式和声明性编程范式之间有什么区别?您能提供一些例子吗?
What is the difference between the declarative and procedural programming paradigms? Could you please provide some examples?
还有哪些其他编程范例?
What other programming paradigms exist?
推荐答案
命令性
命令式编程范式有几个子范式,例如 procedural 或 object-oriented 编程范式.
在命令式编程范例中,您将以各种抽象程度逐步描述算法.
In the imperative programming paradigm, you describe the algorithm step-by-step, at various degrees of abstraction.
支持过程范例的编程语言示例:
Examples of programming languages which support the procedural paradigm:
- C(和大多数其他传统语言)
- 主要是PHP
- 从某种意义上说,所有主要语言
它通常是指表现出类型层次结构的语言,这些语言既可以继承从基本类型到派生类型的方法和状态,又可以包括基于原型的JavaScript.
It typically refers to languages that exhibit a hierarchy of types that inherit both methods and state from base types to derived types, but also includes the unusual prototype-based JavaScript.
支持OO范例的编程语言示例:
Examples of programming languages which support the OO paradigm:
- Java
声明性编程范例有几个子范例,例如功能或逻辑编程范例.
There are several sub-paradigms of the declarative programming paradigm, such as the functional or the logic programming paradigms.
在声明式编程范例中,您描述结果或目标,然后通过"黑色框".与命令相反.
In the declarative programming paradigm, you describe a result or a goal, and you get it via a "black box". The opposite of imperative.
支持声明性编程范例的编程语言示例:
Examples of programming languages which support the declarative programming paradigm:
- yacc
- 树梢
- SQL
- 正则表达式
- lex
- XSLT
- 标记,troff,CSS,VHDL
函数式编程强调函数的应用,且无副作用且无可变状态.上面的声明性系统展现了功能编程的某些方面.
Functional programming emphasizes the application of functions without side effects and without mutable state. The declarative systems above exhibit certain aspects of functional programming.
支持声明性功能范例的编程语言示例:
Examples of programming languages which support the declarative functional paradigm:
- Haskell
- OCaml
- 方案
- Erlang
- F#
- 斯卡拉
这篇关于声明式和过程式编程范例之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!