多线程编程和单线程编程_生活与编程的平行线程

多线程编程和单线程编程

I’m convinced our deepest desire is, by paying the cost of time, to be shown a glimmer of some fundamental truth about the universe. To hear it whisper its lessons and point towards its purpose.

我坚信,我们最深切的愿望是通过花费时间来向人们展示有关宇宙的一些基本真理。 听听它的耳语,并指出它的目的。

And, if you look hard enough for these lessons, you will find them. Whether they are a manifestation of your mind or can be held in your hand, once you see them, they remain yours forever.

而且,如果您对这些课程足够认真,就会找到它们。 无论它们是您的思想的体现还是可以握在手中,一旦您看到它们,它们就永远属于您。

Programming offers significant parallels to life. We are tasked with creating something–something whose sum feels more significant than the parts. Like life, it is a test of bounded creativity. There are rules we must follow, some we should follow, and others we are free to ignore. Programming offers us a glimpse, however ephemeral it may be, into some fundamental truths about the world in which we reside.

编程为生活提供了重要的相似之处。 我们的任务是创造一些出头其总和感觉比部分更显著。 就像生活一样,它是对创造力的考验。 有规则,我们必须遵守,一些我们应该遵循,以及其他一些我们可以随意忽略。 编程让我们瞥见了关于我们所居住的世界的一些基本事实,无论它是多么短暂。

编程与生活之间的四个平行 (The Four Parallels Between Programming and Life)

迭代就是进步。 (Iteration is progress.)

Did you know, if you started the month with a single penny and it doubled every day, you would have $163 on the 15th of the month? Surely, you think, there must be a better way to make $163 in 15 days. But, if you wait another 15 days, you would have more than 5 million dollars.

您是否知道,如果您以一个便士开始一个月,并且每天都翻一番,那么您在该月的15号会有163美元? 当然,您认为,肯定有更好的方法可以在15天内赚到163美元。 但是,如果再等15天,您的收入将超过500万美元。

Go ahead, I’ll wait while you do the math.

继续,我会等你做数学的。

In programming, we use the term iterate to indicate repeating something. In a more formal definition, it is repeatedly applying a procedure to the previous result of that procedure. For example, adding the numbers 1 and 1 to get 2, then adding 1 and 2 to get 3, and so forth.

在编程中,我们使用术语“ 迭代”来表示重复某件事。 在更正式的定义中,它将重复地将一个过程应用于该过程的先前结果。 例如,将数字1和1相加得到2,然后将数字1和2相加得到3,依此类推。

When we iterate, we look for feedback. We wait for some condition to be met so we can either stop iterating or adjust how we are iterating. If we fail to listen for that feedback, we can get stuck in an infinite loop.

进行迭代时,我们会寻找反馈。 我们等待要满足一些条件,使我们可以停止迭代或调整我们如何迭代。 如果我们听不到这些反馈,就会陷入无限循环。

Life is no different. We often expect we can jump from point A to point B without ever defining what point A or point B is. And, even when we identify those points, we expect an immediate move from start to finish. Instead, what is often the truth, is we must incrementally make our way from beginning to end. We must listen for feedback that tells us where we are so we can make adjustments.

生活没有什么不同。 我们经常期望我们可以从A点跳到B点,而无需定义A点或B点是什么。 而且,即使我们确定了这些要点,我们也希望从头到尾立即采取行动。 相反,通常是事实,那就是我们必须从头到尾逐步发展自己的道路。 我们必须听取反馈,告诉我们我们在哪里,以便我们进行调整。

When we have goals, progress can often feel–for the first few days, weeks, or even months–non-existent. We’re often enticed to start over or start fresh. But in doing so, we fail to realize, while we might not have reached our destination, we are somewhere far past where we started. A complete restart isn’t necessary, we just need to make some minor adjustments.

当我们有了目标时,在最初的几天,几周甚至几个月内,通常都感觉不到进步。 我们常常被引诱重新开始或重新开始。 但是这样做时,我们未能意识到,虽然我们可能尚未到达目的地,但我们已经远远超出了开始的地方。 无需完全重启,我们只需要进行一些小的调整即可。

Stop starting over. Let iteration be the force the creates progress.

停止重新开始。 让迭代成为创造进度的力量。

最复杂的问题是已经解决的较小问题的集合。 (Most complex problems are collections of smaller problems that have already been solved.)

Even the most fascinating apps are a series of mostly mundane solutions to mundane problems. In fact, most of the solutions implemented within a program are nothing unique. It is the combination of those ordinary solutions that creates an extraordinary product.

即使是最引人入胜的应用程序,也可以使用一系列平凡的解决方案来解决平凡的问题。 实际上,程序中实现的大多数解决方案都不是唯一的。 那些普通解决方案的结合才创造出了非凡的产品。

In programming, there are different ways to use these quite-ordinary solutions. One way is through a term called abstraction. To abstract something is to move something away from something else.

在编程中,有多种方法可以使用这些非常普通的解决方案。 一种方法是通过称为抽象的术语。 抽象某物就是将某物从另一物移开。

In computer programming, when we abstract something, we are often building higher-level technology on top of lower-level technology. This makes it easier to work with lower-level technologies.

在计算机编程中,当我们抽象某些东西时,我们通常会在较低级别的技术之上构建较高级别的技术。 这使得使用低级技术更容易。

For example, most programming languages are abstractions of the enigmatic binary language (0s and 1s). They put a layer between us and some more fundamental, but cumbersome, level of interaction with the computer. These higher-level languages allow us to focus on higher-level problems.

例如,大多数编程语言都是神秘的二进制语言(0和1)的抽象 。 它们在我们之间以及与计算机进行一些更基本但又麻烦的交互级别之间建立了一层。 这些高级语言使我们可以专注于高级问题。

Another way we can more efficiently solve problems is by using someone else’s solutions. You may have also heard the term library. And, while I am not speaking of a poorly lit, dusty, and quiet location where books live, it isn’t far off.

我们可以更有效地解决问题的另一种方法是使用其他人的解决方案。 您可能还听说过一词。 而且,虽然我不是在谈论光线不足,灰尘多且安静的地方,但书并不遥远。

A library, in programming terms, is code that someone else wrote that solves routine problems. It also abstracts away those things which aren’t absolutely fundamental to solving whatever problem you have.

用编程的术语来说, 是别人写的解决常规问题的代码。 它还抽象了那些对于解决您所遇到的问题并非绝对重要的事情。

For example, if you are writing a program that requires someone to log in to use your application, you could write the code to encrypt and decrypt passwords yourself, or, you could use code written by someone else to do that for you. With the latter option, we free up time to focus on more significant problems our application is trying to solve.

例如,如果您正在编写一个程序,要求某人登录才能使用您的应用程序,则可以编写代码自己对密码进行加密和解密, 或者可以使用其他人编写的代码为您执行此操作。 使用后一种选择,我们可以腾出时间专注于我们的应用程序试图解决的更重要的问题。

All of us use abstractions and libraries in some shape or form. For example, the grocery store is an abstraction of producing our own food. A car is an abstraction of traveling on foot. An oven is an abstraction of building a fire. These are layers we place in front of us that allows us to allocate time to higher-level problems.

我们所有人都以某种形状或形式使用抽象和库。 例如,杂货店是我们自己生产食物的抽象。 汽车是徒步旅行的抽象概念。 烤箱是生火的抽象概念。 这些是我们摆在我们面前的层次,可让我们将时间分配给更高级别的问题。

Reinvent the wheel only to learn how to make a wheel, not to drive to the store.

重新发明轮子只是为了学习如何制造轮子,而不是开车去商店。

如何定义问题就是解决问题的方式。 (How you define a problem is how you will solve it.)

Recall the story of a truck that drove under a bridge and got stuck. Engineers spent hours trying to figure out how to move the bridge. A small child came up, face to face with the tires of the truck, and said, “what if you let the air out of the tires?”

回想一下卡车在桥下行驶并被卡住的故事。 工程师花费了数小时试图弄清楚如何移动桥梁。 一个小孩子站起来,与卡车的轮胎面对面,说道:“如果不让轮胎中的空气出来,那该怎么办?”

From the child’s vantage point, the problem wasn’t the bridge was too short, but rather the truck was too tall.

从孩子的角度出发,问题不是桥太短,而是卡车太高了。

Most people can solve any problem. In fact, most problems state the solution. For example, if the bridge is causing the issue, the answer is to do something with the bridge. If, however, the problem is that the truck is too tall, then the solution–almost glaringly obvious–is to make the truck shorter.

大多数人可以解决任何问题。 实际上,大多数问题都指出了解决方案。 例如,如果网桥是引起问题的原因,那么答案就是对网桥做些什么。 但是,如果问题是卡车太高,则解决方案(几乎显而易见)是使卡车缩短。

零件的布置比零件本身重要得多。 (The arrangement of parts is much more important than the parts themselves.)

What does the Google Maps codebase, the Declaration of Independence, Martin Luther King Jr.’s I have a dream speech, Steve Jobs’s 2005 commencement address, and my first app, Hello, World have in common?

什么是谷歌地图的代码库,独立宣言,马丁·路德·金是我有一个梦想演讲中,史蒂夫·乔布斯2005年毕业典礼上的演讲,我的第一个应用程序, 你好,世界有什么共同点?

The access to the same 26 letters of the English alphabet.

访问相同的26个英文字母。

There is very little that is more fascinating to me than the written word. The written word is one of the most powerful technologies that emerged from humans.

没有什么比书面文字更让我着迷了。 书面文字是人类出现的最强大的技术之一。

Yes, I use the term technology because–even carved into the wall of a cave–it fundamentally changed how we persist information. No longer was data constrained within the boundaries of our minds.

是的,我使用技术一词,是因为它甚至刻在洞穴的墙壁上,从根本上改变了我们保持信息的方式。 数据不再局限于我们的思维范围内。

While the purpose of the written word was initially linked to record-keeping, it quickly became a way to spread ideas. Some of these ideas would anger, and others inspire.

尽管最初将书面文字的目的与保存记录联系在一起,但它很快成为传播思想的一种方式。 其中一些想法会激怒,另一些则会激发灵感。

Every language (including computer language) has subtleties when transmitting information through writing or speech. The words and their constituent parts may be slightly different. Still, however, a language is a set of symbols that can be arranged into what seems to be an infinite number of ideas.

通过书写或语音传输信息时,每种语言(包括计算机语言)都具有微妙之处。 单词及其组成部分可能略有不同。 但是,语言仍然是一组符号,可以将这些符号排列成无数种思想。

For example, in the English language, there are roughly 29 symbols that I can use to represent nearly my entire universe. I’ve mentioned the 26 letters, but it is also helpful to have access to periods, commas, and question marks.

例如,在英语中,大约有29个符号可用来代表几乎整个宇宙。 我已经提到了26个字母,但是使用句点,逗号和问号也很有帮助。

Those 29 characters are available to you, me, and were available to Steve Jobs. Yet, each of us, throughout our lives, will follow different trajectories based on the combination of letters we chose to believe and speak into existence.

我和您都可以使用这29个字符,史蒂夫·乔布斯也可以使用。 然而,基于我们选择相信并说出存在的字母的组合,我们每个人一生都会遵循不同的轨迹。

Interestingly, while we often add words to the dictionary, we don’t usually add letters. This means, at the most fundamental level, that all the ideas that can exist, already do, with their constituent parts quietly waiting for us to shuffle them into existence.

有趣的是,尽管我们经常在字典中添加单词,但通常不添加字母。 这意味着,从最根本的层面上讲,所有可能存在的想法已经存在,它们的组成部分静静地等待着我们将它们改组为现实。

Les Brown sums it up well with this thought experiment:

Les Brown通过这个思想实验很好地总结了这一点:

Imagine if you will, being on your death bed. And standing around your bed–the ghosts of the ideas, the dreams, the abilities, the talents given to you by life.

想象一下,如果您愿意的话,就躺在死亡床上。 站在床旁–生活中赋予您的思想,梦想,能力和才华的幽灵。

And that you, for whatever reason, never acted on those ideas. You never pursued that dream. You never used those talents. We never saw your leadership. You never used your voice. You never wrote that book.

而且无论出于何种原因,您都从未对这些想法采取任何行动。 您从未追求过那个梦想。 您从未使用过这些才华。 我们从未见过您的领导。 你从来没有用过你的声音。 你从未写过那本书。

And there they are, standing around your bed, looking at you with large angry eyes saying: “We came to you. And only you could have given us life! Now we must die with you forever.”

他们在那里,站在你的床周围,用愤怒的大眼睛看着你,说:“我们来找你。 只有你能给我们生命! 现在我们必须永远与你同死。”

The question is — if you die today–what ideas, what dreams, what abilities, what talents, what gifts, would die with you?

问题是-如果您今天死了-您会死什么想法,什么梦想,什么能力,什么才能,什么礼物?

Thank you for reading!

感谢您的阅读!

woz

沃兹

Follow me on Twitter

在推特上关注我

翻译自: https://www.freecodecamp.org/news/the-parallel-threads-of-life-and-programming-2/

多线程编程和单线程编程

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/390449.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

剑指 Offer 67. 把字符串转换成整数

写一个函数 StrToInt,实现把字符串转换成整数这个功能。不能使用 atoi 或者其他类似的库函数。 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。 当我们寻找到的第一个非空字符为正或者负号时&#xff0c…

搭建MSSM框架(Maven+Spring+Spring MVC+MyBatis)

https://github.com/easonjim/ssm-framework 先欠着&#xff0c;后续再进行讲解&#xff1a; 一、Spring内核集成 二、Spring MVC集成 三、MyBatis集成 四、代码生成工具集成 >如有问题&#xff0c;请联系我&#xff1a;easonjim#163.com&#xff0c;或者下方发表评论。<…

4.RabbitMQ Linux安装

这里使用的Linux是CentOS6.2 将/etc/yum.repo.d/目录下的所有repo文件删除 先下载epel源 # wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo 修改epel-erlang.repo文件&#xff0c;如下图 添加CentOS 的下载源…

freecodecamp_如何对freeCodeCamp文章提供反馈

freecodecampWe at the freeCodeCamp editorial team do our best to ensure articles are as accurate as they can be.我们的freeCodeCamp编辑团队竭尽所能&#xff0c;以确保文章尽可能准确。 Still, we occasionally miss factual inaccuracies, non-functioning code exa…

如何对接oracle 建立pdb

Oracle数据库的结构是一个数据库实例下有许多用户&#xff0c;每一个用户有自己的表空间&#xff0c;即每一个用户相当于MySQL中的一个数据库。不久前下了oracle 12c的数据库&#xff0c;安装之后建user时才知道oracle12c 有一个很大的变动就是引入了pdb可插入数据库&#xff0…

二、数据库设计与操作

一、 数据库设计仿QQ数据库一共包括5张数据表&#xff0c;每张数据表结构如下&#xff1a;1、 tb_User&#xff08;用户信息表&#xff09;这张表主要用来存储用户的好友关系与信息字段名数据类型是否Null值默认值绑定描述IDint否用户账号PwdVarchar(50)否用户密码Frie…

hdu 过山车_从机械工程师到软件开发人员–我的编码过山车

hdu 过山车There arent many people out there who grew up dreaming of writing code. I definitely didnt. I wanted to design cars. But somehow I ended up building software.很少有人梦见编写代码。 我绝对没有。 我想设计汽车。 但是我最终以某种方式开发了软件。 I u…

mysql 两列互换

mysql 如果想互换两列的值&#xff0c;直接写 update 表 set col1col2&#xff0c;col2col1 这样的后果就是两列都是 col2 的值 注意这和sql server 是不同的&#xff0c; 如果想实现上述功能&#xff0c;添加一个自增列作为标识&#xff08;必须的&#xff09;&#xff0c; u…

剑指 Offer 36. 二叉搜索树与双向链表

输入一棵二叉搜索树&#xff0c;将该二叉搜索树转换成一个排序的循环双向链表。要求不能创建任何新的节点&#xff0c;只能调整树中节点指针的指向。 为了让您更好地理解问题&#xff0c;以下面的二叉搜索树为例&#xff1a; 我们希望将这个二叉搜索树转化为双向循环链表。链表…

游戏引擎开发和物理引擎_视频游戏开发的最佳游戏引擎

游戏引擎开发和物理引擎In this article, well look at some of the most popular game engines for video game development. Youll get a brief overview of each engine so you can choose which to use for your project.在本文中&#xff0c;我们将介绍一些用于视频游戏开…

TPS和QPS的区别和理解

TPS和QPS的区别和理解 原创 2016年04月26日 17:11:3114010QPS&#xff1a;Queries Per Second意思是“每秒查询率”&#xff0c;是一台服务器每秒能够相应的查询次数&#xff0c;是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准。 TPS&#xff1a;是Transaction…

1893. 检查是否区域内所有整数都被覆盖

theme: healer-readable 给你一个二维整数数组 ranges 和两个整数 left 和 right 。每个 ranges[i] [starti, endi] 表示一个从 starti 到 endi 的 闭区间 。 如果闭区间 [left, right] 内每个整数都被 ranges 中 至少一个 区间覆盖&#xff0c;那么请你返回 true &#xff…

004-docker常用命令[二]-容器操作ps,top,attach,export

2.3、容器操作 2.3.1、docker ps docker ps : 列出容器 语法 docker ps [OPTIONS] OPTIONS说明&#xff1a; -a :显示所有的容器&#xff0c;包括未运行的。 -f :根据条件过滤显示的内容。 --format :指定返回值的模板文件。 -l :显示最近创建的容器。 -n :列出最近创建的n…

【类】变量复用,函数复用

变量复用 变量复用&#xff0c;适用于以下场景&#xff1a;1&#xff0c;整个项目公用的部分&#xff08;比如errors&#xff09;&#xff1b;2&#xff0c;一组类要通信&#xff0c;或者同一个类的两个函数之间要通信&#xff0c;通信数据可以用类来定义和约束&#xff1b; 场…

python练习_如何使用Logzero在Python中练习记录

python练习Logzero is a Python package created by Chris Hager that simplifies logging with Python 2 and 3. Logzero makes it easier as a print statement to show information and debugging details.Logzero是Chris Hager创建的Python程序包&#xff0c;它简化了Pytho…

1736. 替换隐藏数字得到的最晚时间

给你一个字符串 time &#xff0c;格式为 hh:mm&#xff08;小时&#xff1a;分钟&#xff09;&#xff0c;其中某几位数字被隐藏&#xff08;用 ? 表示&#xff09;。 有效的时间为 00:00 到 23:59 之间的所有时间&#xff0c;包括 00:00 和 23:59 。 替换 time 中隐藏的数…

电脑棒安装linux_为什么要使用Linux? Linux很棒的11个理由

电脑棒安装linuxIn this article, well look at some of the things developers love about Linux so you can decide if its right for you.在本文中&#xff0c;我们将研究开发人员对Linux的一些喜爱&#xff0c;以便您可以确定它是否适合您。 持续有效的改进。 (Constant a…

1743. 从相邻元素对还原数组

存在一个由 n 个不同元素组成的整数数组 nums &#xff0c;但你已经记不清具体内容。好在你还记得 nums 中的每一对相邻元素。 给你一个二维整数数组 adjacentPairs &#xff0c;大小为 n - 1 &#xff0c;其中每个 adjacentPairs[i] [ui, vi] 表示元素 ui 和 vi 在 nums 中相…

十 web爬虫讲解2—Scrapy框架爬虫—Scrapy安装—Scrapy指令

Scrapy框架安装 1、首先&#xff0c;终端执行命令升级pip: python -m pip install --upgrade pip2、安装&#xff0c;wheel(建议网络安装) pip install wheel3、安装&#xff0c;lxml(建议下载安装)4、安装&#xff0c;Twisted(建议下载安装)5、安装&#xff0c;Scrapy(建议网络…

阿里与珠海横琴新区达成战略合作,阿里云助力打造横琴智能岛

5月17日&#xff0c;阿里巴巴集团、蚂蚁金服集团与珠海横琴新区管理委员会签署战略合作协议&#xff0c;三方将围绕云计算、政务民生服务、城市治理、电子商务等领域展开深入合作&#xff0c;推动横琴产业发展&#xff0c;共同建设新型智慧城市。 &#xff08;阿里巴巴集团、蚂…