编程术语

by Preethi Kasireddy

通过Preethi Kasireddy

伟大的编程术语烘烤 (The Great Programming Jargon Bake-off)

Imperative vs. Declarative. Pure vs. Impure. Static vs. Dynamic.

命令式与声明式。 纯与不纯。 静态与动态。

Terminology like this is sprinkled throughout programming blog posts, conference talks, papers, and text books.

这样的术语遍布编程博客文章,会议演讲,论文和教科书中。

But don’t be turned off by this jargon. Let’s jump right in and break some of these concepts down, so you can understand what all these developers around you are talking about.

但是,不要被这种术语关闭。 让我们直接进入其中,分解其中一些概念,以便您了解周围所有这些开发人员在谈论什么。

静态打字与动态打字 (Static vs. Dynamic Typing)

This is about when a type information is acquired — either at compile time or at runtime.

这与在编译时或运行时获取类型信息的时间有关。

You can use this type information to detect type errors. A type error is when a value is not of the expected type.

您可以使用此类型信息来检测类型错误。 类型错误是当值不是预期的类型时。

静态类型检查 (Static Type Checking)

The process of verifying the type safety of a program based on analysis of a program’s source code. In other words, type checking happens at compile time, allowing type errors to be detected sooner.

基于对程序源代码的分析来验证程序的类型安全性的过程。 换句话说,类型检查在编译时进行,从而可以更快地检测到类型错误。

动态类型检查 (Dynamic Type Checking)

The process of verifying the type safety of a program at runtime. With dynamic type checking, type errors occur at runtime.

在运行时验证程序的类型安全的过程。 使用动态类型检查,在运行时会发生类型错误。

强打字与弱打字 (Strong vs. Weak typing)

It’s important to note strong vs. weak typing doesn’t have a universally-agreed-upon technical meaning. For example, even though Java is statically typed, every time you use reflection or a cast, you’re deferring the type check to run time.

重要的是要注意强类型与弱类型没有统一的技术含义。 例如,即使Java是静态类型的,但每次使用反射或强制转换时,都将类型检查推迟到运行时。

Similarly, most strongly-typed languages will still automatically convert between integers and floats. Hence, you should avoid using these terms because calling a type system “strong” or “weak” by itself does not communicate very much.

同样,大多数强类型语言仍将在整数和浮点数之间自动转换。 因此,应避免使用这些术语,因为仅将类型系统称为“强”或“弱”就不能很好地沟通。

强类型 (Strongly Typed)

In a strongly typed language, the type of a construct does not change — an int is always an int, and trying to use it as a string will result in an error.

在强类型语言中,构造的类型不会更改int始终是int ,尝试将其用作string将导致错误。

弱打字 (Weakly typed)

Weak typing means that the type of a construct can change depending on context. For example, in a weakly-typed language, the string “123” may be treated as the number 123 if you add another number to it.

弱类型意味着构造的类型可以根据上下文而改变。 例如,在弱类型语言中,如果将字符串“ 123”添加到另一个数字,则可以将其视为数字123。

It generally means the type system can be subverted (invalidating any guarantees) because you can cast a value of one type to another.

通常,这意味着可以颠覆类型系统(使任何保证无效),因为您可以将一种类型的值转换为另一种类型。

可变与不可变数据 (Mutable vs. Immutable data)

不变的数据 (Immutable data)

When an object is not modifiable after it has been created, you can say it’s “immutable” which is a fancy word for “unchangable.” This means you’ll instead allocate a new value for every change.

当对象创建后不可修改时,您可以说它是“不可变的”,这是“不可更改”的奇特词。 这意味着您将为每个更改分配一个新值。

可变数据 (Mutable data)

When you can modify an object after its creation, it’s “mutable.” When you have a reference to a mutable object, for instance, the contents of the object can change.

创建对象后可以对其进行修改时,它就是“可变的”。 例如,当您引用可变对象时,对象的内容可能会更改。

纯函数与不纯函数 (Pure vs. Impure functions)

纯功能 (Pure functions)

A pure function has two qualities:

纯函数具有两种性质:

  1. It relies only on the input provided — and not on any external state that may change during its evaluation or in between calls.它仅依赖于提供的输入,而不依赖于评估期间或两次调用之间可能更改的任何外部状态。
  2. It doesn’t cause any semantically observable side effects, such as modifying a global object or a parameter passed by reference.它不会引起任何语义上可观察到的副作用,例如修改全局对象或通过引用传递的参数。

功能不纯 (Impure functions)

Any function that does not meet those two requirements for a pure function is “impure.”

任何不满足纯功能的这两个要求的功能都是“不纯的”。

懒惰评估与急切评估 (Lazy Evaluation vs. Eager Evaluation)

懒惰评估 (Lazy evaluation)

Lazy evaluation does not evaluate function arguments unless their values are required to evaluate the function call itself.

延迟求值不会求值函数自变量,除非需要其值来求值函数调用本身。

In other words, expressions are only evaluated when evaluating another expression which are dependent on the current expression.

换句话说,仅在评估依赖于当前表达式的另一个表达式时才评估表达式。

Laziness allows programs to calculate data structures that are potentially infinite without crashing.

惰性允许程序计算可能无限的数据结构而不会崩溃。

渴望评估 (Eager evaluation)

Eager evaluation — also known as strict evaluation — always fully evaluates function arguments before invoking the function. In other words, an expression is evaluated as soon as it is bound to a variable.

急切的评估(也称为严格评估)始终在调用函数之前全面评估函数参数。 换句话说,将表达式绑定到变量后立即对其求值。

声明式与命令式 (Declarative vs. Imperative)

声明式编程 (Declarative programming)

Declarative programs express a set of operations without revealing how they’re implemented, or how data flows through them. They focus on “what” the program should accomplish (by using expressions to describe the logic) rather than “how” the program should achieve the result.

声明式程序表达了一组操作,而没有透露它们是如何实现的,或者数据如何流过它们。 他们专注于程序应完成的“工作”(通过使用表达式来描述逻辑),而不是程序应如何实现的结果。

One example of declarative programming is SQL. SQL queries are composed of statements that describe what the outcome of a query should look like, while abstracting over the internal process for how the data is retrieved:

声明式编程的一个示例是SQL。 SQL查询由描述查询结果外观的语句组成,同时抽象化内部过程以获取数据:

SELECT EMP_ID, FIRST_NAME, LAST_NAMEFROM EMPLOYEESWHERE CITY = ‘SAN FRANCISCO’ORDER BY EMP_ID;

Here’s an example of declarative code:

这是声明性代码的示例:

命令式编程 (Imperative programming)

Imperative programming focuses on describing how a program should achieve a result by using statements that specify control flow or state changes. It uses a sequence of statements to compute a result.

命令式编程着重于描述程序应如何通过使用指定控制流或状态更改的语句来获得结果。 它使用一系列语句来计算结果。

Here’s an example of imperative code:

这是命令式代码的示例:

有状态与无状态 (Stateful vs. Stateless)

A state is a sequence of values calculated progressively, which contains the intermediate results of a computation.

状态是逐步计算的值的序列,其中包含计算的中间结果。

有状态的 (Stateful)

Stateful programs have some mechanism to keep track of and update state. They have some memory of the past, and remember previous transactions that may affect the current transaction.

有状态程序具有某种机制来跟踪和更新状态。 他们具有过去的记忆,并记住可能影响当前交易的先前交易。

无状态 (Stateless)

Stateless programs, on the other hand, doesn’t keep track of state. There’s no memory of the past. Every transaction is performed as if it were being done for the very first time. Stateless programs will give the same response to the same request, function, or method call — every single time.

另一方面,无状态程序无法跟踪状态。 没有过去的记忆。 每笔交易都好像是第一次完成一样。 无状态程序每次都会对相同的请求,函数或方法调用给出相同的响应。

功能与面向对象 (Functional vs. Object-Oriented)

功能性 (Functional)

Functional programming is a paradigm that places a major emphasis on the use of functions. The goal of functional programming is to use functions to abstract control flows and operations on data, and to avoid side effects.

函数式编程是主要强调函数使用的范例。 函数式编程的目的是使用函数抽象化数据上的控制流和操作,并避免产生副作用。

So functional programming uses pure functions and avoids mutable data, which in turn provides referential transparency.

因此,函数式编程使用纯函数,并避免了可变数据,从而提供了参照透明性。

A function has referential transparency when you can freely replace an expression with its value and not change the behavior of the program. Said a bit differently: for a given input, it always returns the same results.

当您可以用表达式的值随意替换表达式而不更改程序的行为时,该函数具有引用透明性。 说的有点不同:对于给定的输入,它总是返回相同的结果。

Some examples languages that emphasize functional programming include Haskell, Lisp, Clojure, and Elm. But you can use functional programming concepts in most languages, including JavaScript.

强调函数式编程的一些示例语言包括Haskell,Lisp,Clojure和Elm。 但是您可以使用大多数语言(包括JavaScript)使用函数式编程概念。

面向对象 (Object Oriented)

The Object Oriented programming paradigm places major emphasis on the use of objects. This results in programs that are made out of objects that interact with one another. These objects can contain data (in the form of fields or attributes) and behavior (in the form of methods).

面向对象编程范例主要强调对象的使用。 这将导致程序由相互交互的对象组成。 这些对象可以包含数据(以字段或属性的形式)和行为(以方法的形式)。

It’s a style of partitioning (or encapsulating) the state of a program via objects to make analyzing the effect of changes tractable [1].

这是一种通过对象对程序状态进行分区(或封装)的样式,以使分析变更的结果变得容易处理[1]。

Moreoever, object-oriented programs uses inheritance and/or composition as their main mechanisms for code reuse. Inheritance means that a new class can be defined in terms of existing classes by specifying just how the new class is different. It represents an “is-a” relationship (e.g. a Bird class which extends an Animal class). Composition, on the other hand, is when classes contain instances of other classes that implement the desired functionality. It represents a “has a” relationship (e.g. a Bird class has an instance of a Wing class as it’s member).

此外,面向对象的程序使用继承和/或组合作为代码重用的主要机制。 继承意味着可以通过指定新类的不同之处来根据现有类定义新类。 它表示“是”关系(例如,扩展动物类的Bird类)。 另一方面,组合是当类包含实现所需功能的其他类的实例时。 它表示“具有”关系(例如Bird类作为其成员具有Wing类的实例)。

Polymorphism is also an important mechanism for code reuse in object oriented programming. It’s when a language can process objects differently depending on their data type or class.

多态性也是面向对象编程中代码重用的重要机制。 这是一种语言可以根据对象的数据类型或类对对象进行不同处理的时候。

Some examples languages that emphasize object oriented programming include Java, C++, Ruby. Again, you can apply these concepts in most languages, including JavaScript.

强调面向对象编程的一些示例语言包括Java,C ++,Ruby。 同样,您可以将这些概念应用于大多数语言,包括JavaScript。

确定性与非确定性 (Deterministic vs. Nondeterministic)

确定性 (Deterministic)

Deterministic programs always return the same result any time they’re called with a specific set of input values and the same given state.

确定性程序每次以一组特定的输入值和相同的给定状态调用时,总是返回相同的结果。

不确定的 (Nondeterministic)

Nondeterministic programs may return different results each time they’re called, even with the same specific set of input values and initial state.

不确定性程序每次调用时都可能返回不同的结果,即使使用相同的特定输入值集和初始状态也是如此。

Nondeterminism is a property of any concurrent system — that is, any system where multiple tasks can happen at the same time by running on different threads. A concurrent algorithm that is mutating state might perform differently on each time, depending upon which thread the scheduler decides to execute.

非确定性是任何并发系统(即,在不同线程上运行可以同时发生多个任务的系统)的属性。 根据调度程序决定执行哪个线程,正在改变状态的并发算法在每次执行时可能会有所不同。

For example:

例如:

declare Xthread X=1 endthread X=2 end

The execution order of the two threads is not fixed. We don’t know whether X will be bound to 1 or 2. The system will choose during the program’s execution, and it’s free to choose which thread to execute first.

两个线程的执行顺序不固定。 我们不知道X是绑定到1还是2。系统将在程序执行期间进行选择,并且可以自由选择首先执行哪个线程。

Another example of non-determinism:

非确定性的另一个示例:

! 大功告成 (Phew! We’re done.)

As always, your feedback and input is really important to me. I read and consider every single comment, so please don’t shy away from responding!

与往常一样,您的反馈和意见对我来说非常重要。 我阅读并考虑了每条评论,因此请不要回避!

Finally, you can also check out the Prezi presentation I built for this article.

最后,您还可以查看我为本文构建的Prezi演示文稿 。

[1] Thank you to Kent Beck for his input on this.

[1] 谢谢肯特·贝克在这方面的投入。

翻译自: https://www.freecodecamp.org/news/programming-mental-models-47ccc65eb334/

编程术语

编程术语_伟大的编程术语烘烤相关推荐

  1. ab plc编程软件_三菱PLC编程程序PLC的软件编程

    三菱PLC编程程序-PLC的软件编程 BL2 RACKMOUNT 4U系列工控机 - 搭载Intel第六代core i系列CPU, I3-6100, I5-6500, I7-6700 CPU可选 - ...

  2. 快速理解编程结构_为什么系统编程全都用英文而不用中文?听完专家的解释恍然大悟!...

    全球博弈(quanqiuboyi)--不一样的观点,不一样的解读,8000万人订阅的超级微信大号.不关注时事,你将会被这个世界抛弃,点击标题下蓝字"全球博弈"关注,我们将为您提供有 ...

  3. 新代数控系统编程说明书_数控加工中心编程快速入门教程

    一.编程入门 本文章来自公众号<加工中心>.关注领取资料! 概念一.指令分组:将功能类似的指令分成一组,同一组的G代码不能同时出现在同一行程序段里. 概念二.程序段程序段是程序的基本组成部 ...

  4. 扇贝python编程课_【扇贝编程python安卓手机下载】扇贝编程app v1.1.47 破解版-趣致软件园...

    扇贝编程python是运行于安卓平台的一款专业Python课程学习应用,该应用内置了专业强大的教研团队与交互式学习方法,同时还能够支持电脑.手机进度同步,自动保存学习进度,让用户能够使用扇贝编程轻松精 ...

  5. 中达优控触摸屏编程视频教程_触摸屏组态编程软件|中达优控触摸屏编程软件(YKBuilder)1.0 官方版_ - 极光下载站...

    YKBuilder是一个中达优控触摸屏编程软件!触摸屏组态编程软件在电脑的开始菜单,打开运行对话框,输入"dcslic"->确定启动"Licenses 管理工具. ...

  6. python只有idle 1种编程环境_《Python编程初学者指南》——1.5 IDLE简介

    本节书摘来自异步社区<Python编程初学者指南>一书中的第1章,第1.5节,作者[美]Michael Dawson,王金兰 译,更多章节内容可以访问云栖社区"异步社区" ...

  7. 数据结构面试题编程题_您下次编程面试时应该了解的顶级数据结构

    数据结构面试题编程题 by Fahim ul Haq 通过Fahim ul Haq Niklaus Wirth, a Swiss computer scientist, wrote a book in ...

  8. python优雅编程视频_日常 Python 编程优雅之道

    3 个可以使你的 Python 代码更优雅.可读.直观和易于维护的工具. Python 提供了一组独特的工具和语言特性来使你的代码更加优雅.可读和直观.为正确的问题选择合适的工具,你的代码将更易于维护 ...

  9. python编程方块_趣味Python编程之经典俄罗斯方块

    本帖最后由 柠檬守护 于 2016-10-23 14:14 编辑 转载:http://www.linuxidc.com/Linux/2016-10/136205.htm 用python把经典俄罗斯方块 ...

最新文章

  1. 近似与精确——《狂人C》习题解答15(第三章习题5)
  2. 【转】ABP源码分析二十七:ABP.Entity Framework
  3. oracle存储过程季度方法,Oracle存储过程、触发器实现获取时间段内周、月、季度的具体时间...
  4. 周末生活日记|我们和楠哥
  5. 简单的beego分页功能代码
  6. Django模板系统 运算
  7. 华为云推UGO:一手抓结构迁移,一手抓SQL转换
  8. jquery中prop()和attr()的使用
  9. Graphviz样例之集群流程图
  10. 150330之软件测试
  11. 内存对齐、内存对齐规则解释、内存对齐原理
  12. 批处理一键创建局域网共享文件夹或文件共享轻松访问Win系统其他电脑的共享文件命令行(纯bat代码)实用便携~
  13. 编程实现对率回归,并给出西瓜数据集 3.0α 上的结果.
  14. 直播 编解码、 协议、网络传输
  15. wsl 1 ubuntu 安装图像化界面
  16. 肾有多好,人就有多年轻。男女通用
  17. android 本地lrc 歌词同步,android 音乐播放器-------歌词同步 lrc
  18. Instruments 调试
  19. 一键修改分辨率bat_BAT批量处理一键修改设置IP(亲测有效)
  20. python开发网页视频播放器_暴风影音没了,我们就用Python做个播放器吧

热门文章

  1. 小程序使用富文本完整代码及示例图
  2. flutter报错Could not connect to lockdownd, error code -
  3. 04-dispatch_group
  4. 利用jQuery实现用户名片小动画
  5. 排序(一)归并、快排、优先队列等(图文具体解释)
  6. 如何更快速加载你的JS页面
  7. java 反射 动态代理
  8. SMS2003 SP3+SQL Server2000 SP4部署(下)
  9. Visual Studio 2017 - Windows应用程序打包成exe文件(1)- 工具简单总结
  10. hive2.3.2安装使用