问题描述
我试图理解命令式和声明式范式之间的区别,因为我必须对Visual Basic进行分类. NET中的不同范例.除了面向对象之外,我认为它也是命令性或声明性的.如果有人可以帮助我解释我的实现方式,我会感激
I'm trying to understand the difference between imperative and declarative paradigms, because I have to classify Visual Basic. NET in the different paradigms. Beyond object-oriented, I guess it's also imperative or declarative. If someone could help me explaining how I realized I would appreciate
推荐答案
操作性代码是过程性的:先执行此操作,然后再执行该操作,然后执行该操作,然后执行该操作,然后执行其他操作.您想要的内容非常精确和具体.我们用于构建最终用户应用程序的大多数语言都是命令性语言,包括VB.Net.指示命令性语言的语言结构包括if
块,循环和变量分配.
Imperative code is procedural: do this, then this, then that, then the other, in that order. It's very precise and specific in what you want. Most languages that we use for building end-user applications are imperative languages, including VB.Net. Language structures that indicate an imperative language include if
blocks, loops, and variable assignments.
说明性代码仅描述了您希望系统提供的结果,但可以将一些实际的实现细节留给系统.声明性语言的典型示例是SQL(尽管它也具有一些命令性功能).您也可以将文档标记语言视为声明性的.指示性语言的语言结构包括基于集合的操作和标记模板.
Declarative code just describes the result you want the system to provide, but can leave some actual implementation details up to the system. The canonical example of a declarative language is SQL (though it has some imperative features as well). You could also consider document markup languages to be declarative. Language structures that indicate a declarative language include set-based operations and markup templates.
这就是诀窍:虽然传统上将VB.Net视为当务之急,但自2008年LINQ推出以来,VB.Net还具有重要的声明性功能,聪明的程序员可以利用.这些功能使您可以编写看起来像SQL的 lot 的VB.Net代码.
Here's the trick: while VB.Net would traditionally be considered imperative, as of the introduction of LINQ back in 2008, VB.Net also has significant declarative features that a smart programmer will take advantage of. These features allow you to write VB.Net code that looks a lot like SQL.
这篇关于命令式与声明式代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!