声明式编程VS命令式编程

声明式编程关注于表达程序的目标,而命令式编程则着重于描述执行步骤。声明式编程让程序员更专注于业务逻辑,提高代码的抽象层次,而命令式编程提供了对程序状态的直接控制。理解这两种范式的差异有助于提升编程效率和代码质量。
摘要由CSDN通过智能技术生成

In computer science, declarative programming is a programming paradigm — a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow. This is in contrast with imperative programming, which implements algorithms in explicit steps.

声明式编程:告诉“机器”你想要的是什么(what),让机器想出如何去做(how)。

In computer science, imperative programming is a programming paradigm that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program consists of commands for the computer to perform. Imperative programming focuses on describing how a program operates. The term is often used in contrast to declarative programming, which focuses on what the program should accomplish without specifying how the program should achieve the result.

命令式编程:命令“机器”如何去做事情(how),这样不管你想要的是什么(what),它都会按照你的命令实现。

  • 声明式编程让我们去描述我们想要的是什么,让底层的软件、计算机去解决如何实现。

  • 在很多情况中,就像我们看到的一样,声明式编程能给我们的编程带来真正的提升,通过站在更高层面写代码,我们可以更多的专注于 what,而这正是我们开发软件真正的目标。

问题是,程序员习惯了去描述 how,这让我们感觉很好很安心能够控制程序的运行状态,不放走任何我们不能看见不能理解的处理过程。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值