当前位置: 首页 > 编程日记 > 正文

编程术语_伟大的编程术语烘烤

编程术语

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/

编程术语

相关文章:

Swift 圆环进度条

Swift 圆环进度条 import UICircularProgressRing import UIKit import UICircularProgressRing class ViewController: UIViewController {var progress:UICircularProgressRing!;override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading …

Linux文件系统构成(第二版)

Linux文件系统构成/boot目录:内核文件、系统自举程序文件保存位置,存放了系统当前的内核【一般128M即可】如:引导文件grub的配置文件等/etc目录:系统常用的配置文件,所以备份系统时一定要备份此目录如:系统管理员经常需要修改的文…

include_once 问题

最近在做微信小程序,在include_once 微信文件后,该方法return 前面会用特殊字符,导致我return 给前端的本来是json串变成了字符 解决方法 : ob_clean(); return json_encode(array);转载于:https://www.cnblogs.com/zouzhe0/p/630…

babel6 babel7_当您已经准备好Babel时设置Flow

babel6 babel7by Jamie Kyle杰米凯尔(Jamie Kyle) 当您已经准备好Babel时设置Flow (Setting up Flow when you’ve already got Babel in place) Flow is a static type checker for JavaScript. It makes you more productive by providing feedback as you write code. Flow…

如何为Android上的产品设计一款合适的图标

如 果你已经完成了你的app,你一定会马上向其它人宣布这件事情。但是你需要注意一个很重要的问题,那就是app的图标。你的图标可能在项目启动之 前就已经设计好了,但我不喜欢这样,如果app没有完成实际上图标也没什么用了。如果你不是…

得到windows聚焦图片(windows 10)

有些Windows聚焦图片确实很漂亮,很希望保留下来,但是Windows聚焦图片总更好,网上有得到聚焦图片的方法,每次都手动去弄真麻烦,于是自己编了一个小程序,自动得到Windows聚焦图片,下面是运行这个小…

swift 加载gif 框架图片

swift 加载gif 框架图片 SwiftGifOrigin 以下代码 轻松搞定 let imgView UIImageView(frame: CGRect(x: 50, y: 100, width: 280, height: 200));imgView.loadGif(name: "gfff");self.view.addSubview(imgView);

devops_最低可行DevOps

devopsby Michael Shilman通过迈克尔希尔曼(Michael Shilman) 最低可行DevOps (Minimum Viable DevOps) 快速而肮脏的指南,用于扩展您的发布并拥抱互联网的死亡 (A quick and dirty guide to scaling your launch and embracing the Internet hug of death) Startu…

java基础之——类的初始化顺序(转载)

原文地址:http://www.cnblogs.com/chrischennx/p/3612295.html 由浅入深,首先,我们来看一下,一个类初始化有关的都有些啥米: 静态成员变量、静态代码块、普通成员变量、普通代码块、构造器。(成员方法&…

如何用CSS快速布局(一)—— 布局元素详细

要快速进行网页排版布局,则必须对布局的元素有清晰的了解,才不会总是在细节处出错。这一篇先详解有关布局的因素作为布局基础:块级元素and内联元素、盒模型、准确定位、元素对齐、样式继承。下一篇则重点描述快速布局思路。 一、什么是块级元…

iOS 改变字符串中数字的颜色

匹配中文字符 [\u4e00-\u9fa5] 匹配双字节字符(包括汉字在内) [^\x00-\xff] 匹配网址:[a-zA-z]://[^\s]* 匹配国内电话 \d{3}-\d{8}|\d{4}-\{7,8} 匹配腾讯QQ号 [1-9][0-9]{4,} 匹配18位身份证号^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$ Swift String…

jpg在线合并jpg_JPG如何运作

jpg在线合并jpgby Colt McAnlis通过Colt McAnlis JPG如何运作 (How JPG Works) The JPG file format was one of the most technologically impressive advancements to image compression to come on the scene in 1992. Since then, it’s been a dominant force in represe…

革命就是请客吃饭(案例分析吧)

前不久路过南京, 拜会了本科同学. 刚好他要见个青年才俊谈些事情, 于是就神神秘秘地把我拉了过去. 一路高谈阔论, 指点江山, 忆往昔峥嵘岁月之后, 此次"拜访"的目的也渐渐清晰起来. 我们所要见的人是位年轻的创业者, 他有些移动互联网的点子, 想和我们分享下, 并尝试…

TextView-- 测量文字宽度

https://my.oschina.net/lengwei/blog/637380; http://blog.csdn.net/mare_blue/article/details/51388403; http://blog.csdn.net/baidu_31093133/article/details/52413893; --1,Android中调用Paint的measureText()方法取得字符串显示的宽度值: public static float GetTextW…

swift 简单风格的Toaster

简单风格的Toaster Toaster //1 弹出文本 "Hello World" 延迟时间 2 展示时间 1 Toast(text: "Hello World", delay: 2, duration: 1).show();//2 初始化toast 方法 let toast Toast(text: "你好世界"); toast.show(); toast.cancel();// 3 …

工业革命前数千年人口经济_我们已经进行了数千年的编程

工业革命前数千年人口经济by Tautvilas Mečinskas由TautvilasMečinskas 我们已经进行了数千年的编程 (We have been programming for thousands of years) Computer programs are all around us. We interact with them every day. It looks as if software is becoming mor…

1-flutter 安装步骤

flutter 安装步骤 1 下载SDK SDK 下载地址 2 解压压缩包 将sdk 文件夹丢进系统的应用程序(Application)的目录 3 配置环境变量 命令行 open ~/.bash_profile ,然后在bash 文件中写入下面配置 export PATH$PATH:/Applications/flutter/bi…

codevs1258 关路灯(☆区间dp)

1258 关路灯 时间限制: 1 s空间限制: 128000 KB题目等级 : 大师 Master题目描述 Description多瑞卡得到了一份有趣而高薪的工作。每天早晨他必须关掉他所在村庄的街灯。所有的街灯都被设置在一条直路的同一侧。 多瑞卡每晚到早晨5点钟都在晚会上,然后他开始关灯。开…

BroadcastReceiver自学笔记

1. 使用步骤: 1.1 声明Intent Intent intent new Intent("name");------静态常用 IntentFilter filter new IntentFilter("name");--------动态常用 1.2 注册 1.3 接收:利用action或者Bundle 在OnReceive()中,接收信息…

小狗钱钱_小狗设计

小狗钱钱by Patryk Adaś通过PatrykAdaś 小狗设计 (Design for doggies) Education should be universal and free for everyone.教育应该是普及的,对所有人来说都是免费的。 When I first entered the field, designers were patient with me. They gave me fee…

层化(stratification)的方法

有时候我们会遇到调整后的模型反而不如调整前表现好的情况,这可能和数据的随机分割有关系。在这个不平衡的数据情况下,最好用层化(stratification)的方法,比如: from sklearn.cross_validation import Stra…

零基础入门jQuery视频教程

零基础入门jQuery最新版开发.NET富客户端应用(选择器、DOM操作、事件和动画、Ajax应用、插件、Mobile)课程分类:.NETJquery适合人群:初级课时数量:35课时用到技术:javascript,ajax,jquery,handler涉及项目:各知识点的项…

2-flutter 之HelloWorld

widget 在flutter 中,几乎所有的东西都是widget,本身是用户界面的基本构建快,将widget组成一个层次结构, 调用widget树。每一个窗口widget都嵌套在父窗口widget中,并且从其父窗口中继承属性。甚至应用程序对象本身也…

浏览器获取浏览历史_浏览器历史的未来

浏览器获取浏览历史by Patryk Adaś通过PatrykAdaś 浏览器历史的未来 (The Future of Browser History) I am really unsatisfied with the current state of Browser History. I think that this is the most underestimated feature of every modern web browser. Let’s t…

【水】JSOI完美的对称

完美的对称 题目描述 在峰会期间,必须使用许多保镖保卫北约组织的各国代表。代表们除了由他自己的随身保镖保护外,组委会还指派了一些其他的特工和阻击手保护他们。为了使他们的工作卓有成效,使被保卫的人的安全尽可能得到保障,保…

3-flutter 项目结构 资源 依赖

1 项目的名称 android 安卓相关工程文件 build 项目的构建输出目录 ios ios 相关的部分工程文件 lib 项目中的dart 源文件 src 包含其他的源文件main.dart 自动生成的项目入口文件 test 测试相关的文件 pubspec.ymal 项目依赖配置文件 3 归档图片资源和处理不同的分辨率…

python简史_命令行简史

python简史by Gitter通过吉特 命令行简史 (A Brief History of the Command Line) This post by Andy Trevorah, Engineer at Gitter, has been adapted from a talk that he originally gave at codebar, a non-profit initiative that facilitates the growth of a diverse …

4- flutter - Widget

Widget Flutter 中的view 就是widget 1 无状态和有状态的Widget StateslessWidgets 适用于用户界面不依赖于用户的信息的时候 StatesfulWidgets 有状态的,例如HTTP 网络请求或者用户交互之后收到数据动态表更新UI 这就是一个无状态的Widget Text("we like…

第一讲SQL命令的DDL和DML操作讲解

知识点: 一、sql命令DDL(结构化操作) 二、sql命令DML操作(增删改查) 1.sql命令DDL(结构化操作) 1.1表添加字段: alter table 表名 add 列定义 如: alter table Student add email varchar(128); 1.2 修改字段&#xff…

基于Tkinter利用python实现颜色空间转换程序

主要基于colorsys实现,例子是从hls转换到rgb,假设要换颜色空间非常easy仅仅须要改动一个函数 用到了Scale和Canvas组件 代码例如以下: from Tkinter import * import colorsys #操作后的响应函数 def update(* args):colorr,g,b colorsys.hl…