[
  {
    "path": "(字幕)全40集中英字幕文本/01. 计算机早期历史-Early Computing.ass.txt",
    "content": "Hello world, I'm Carrie Anne, and welcome to Crash Course Computer Science!\nHello world！我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the course of this series, we're going to go from bits, bytes, transistors and logic gates,\n在这个系列中，我们会学习 Bits(位)，Bytes(字节)，晶体管, 逻辑门，\n\nall the way to Operating Systems, Virtual Reality and Robots!\n一直到操作系统，虚拟现实和机器人!\n\nWe're going to cover a lot, but just to clear things up\n我们要学很多东西，但预先说明\n\nwe ARE NOT going to teach you how to program.\n我们 *不会* 教你怎么编程\n\nInstead, we're going to explore a range of computing topics as a discipline and a technology.\n我们会从高层次上纵览一系列计算机话题\n\nComputers are the lifeblood of today's world.\n计算机是当今世界的命脉\n\nIf they were to suddenly turn off, all at once,\n如果突然关掉所有的计算机\n\nthe power grid would shut down, cars would crash, planes would fall,\n电网会关闭，车辆会相撞，飞机会坠毁\n\nwater treatment plants would stop, stock markets would freeze,\n净水厂会关闭，证券市场会停止运作\n\ntrucks with food wouldn't know where to deliver, and employees wouldn't get paid.\n装满食物的卡车不知运往何方，员工得不到薪水\n\nEven many non-computer objects -like DFTBA shirts and the chair I'm sitting on-\n甚至很多和计算机无关的东西，例如 DFTBA 的 T 恤和我现在坐的椅子\n\nare made in factories run by computers.\n也都是在计算机管理的工厂中制造的\n\nComputing really has transformed nearly every aspect of our lives.\n计算机改变了我们生活中几乎所有方面\n\nAnd this isn't the first time we've seen this sort of technology-driven global change.\n我们也不是第一次遇到推动全球发展的科技了\n\nAdvances in manufacturing during the Industrial Revolution\n工业革命中生产能力的提高\n\nbrought a new scale to human civilization - in agriculture, industry and domestic life.\n大幅提升了农业，工业，畜牧业的规模\n\nMechanization meant superior harvests and more food, mass produced goods,\n机械化导致更好的收成，更多的食物，商品可以大批量生产\n\ncheaper and faster travel and communication, and usually a better quality of life.\n旅行和通讯变得更便宜更快，生活质量变得更好.\n\nAnd computing technology is doing the same right now\n计算机和工业革命有一样的影响\n\n- from automated farming and medical equipment,\n从自动化农业和医疗设备\n\nto global telecommunications and educational opportunities,\n到全球通信和教育机会\n\nand new frontiers like Virtual Reality and Self Driving Cars.\n还有 虚拟现实 和 无人驾驶汽车 等新领域\n\nWe are living in a time likely to be remembered as the Electronic Age.\n现在这个时代很可能会被后人总结成 \"信息时代\"\n\nAnd with billions of transistors in just your smartphones, computers can seem pretty complicated,\n你的智能手机中有数十亿个晶体管，看起来好像很复杂\n\nbut really, they're just simple machines\n但实际上它是很简单的机器\n\nthat perform complex actions through many layers of abstraction.\n通过一层层的抽象  来做出复杂操作\n\nSo in this series, we're going break down those layers,\n在这个系列中，我们会一层层讲解，\n\nand build up from simple 1's and 0's, to logic units, CPUs,\n从最底层的1和0，到逻辑门，CPU\n\noperating systems, the entire internet and beyond.\n操作系统，整个互联网，以及更多~~\n\nAnd don't worry, in the same way someone buying t-shirts on a webpage\n不用担心，正如在网上买T恤的人 不用知道网站代码是怎么写的\n\ndoesn't need to know how that webpage was programmed,\n不用担心，正如在网上买T恤的人 不用知道网站代码是怎么写的\n\nor the web designer doesn't need to know how all the packets are routed,\n设计师不用知道数据包是怎么传输的\n\nor router engineers don't need to know about transistor logic,\n设计路由器的工程师不用理解晶体管的逻辑\n\nthis series will build on previous episodes but not be dependent on them.\n本系列中每个视频会接着上集继续讲，但并不依赖前面的视频\n\nBy the end of this series,\n等这个系列结束后\n\nI hope that you can better contextualize computing's role both in your own life and society,\n希望你能了解计算机在你的人生 以及社会中扮演什么角色\n\nand how humanity's (arguably) greatest invention is just in its infancy,\n以及这个人类史上最伟大的发明（可以这样说啦）是怎么开始的，\n\nwith its biggest impacts yet to come.\n它对未来还会有更大的影响\n\nBut before we get into all that, we should start at computing's origins,\n但深入之前，我们应该从计算的起源讲起,\n\nbecause although electronic computers are relatively new, the need for computation is not.\n虽然电子计算机才出现不久，但人类对计算的需求早就有了\n\nThe earliest recognized device for computing was the abacus,\n公认最早的计算设备是 算盘\n\ninvented in Mesopotamia around 2500 BCE.\n发明于\"美索不达米亚\"，大约公元前 2500 年\n\nIt's essentially a hand operated calculator,\n它是手动计算器，用来帮助加减数字\n\nthat helps add and subtract many numbers.\n它是手动计算器，用来帮助加减数字\n\nIt also stores the current state of the computation, much like your hard drive does today.\n它存储着当前的计算状态，类似于如今的硬盘\n\nThe abacus was created because,\n人们制造算盘是因为\n\nthe scale of society had become greater than\n社会的规模已经超出个人心算的能力\n\nwhat a single person could keep and manipulate in their mind.\n社会的规模已经超出个人心算的能力\n\nThere might be thousands of people in a village or tens of thousands of cattle.\n一个村庄可能有上千个人和上万头牛\n\nThere are many variants of the abacus,\n算盘有很多变种\n\nbut let's look at a really basic version with each row representing a different power of ten.\n但我们来看一个基础版，每行代表 10 的不同次方\n\nSo each bead on the bottom row represents a single unit,\n最底下那行，一个珠子代表 10 的 0 次方，也就是 1，\n\nin the next row they represent 10, the row above 100, and so on.\n再上面一行是 10 的 1 次方（也就是 10） \\N 再上面一行是 10 的 2 次方 （以此类推）\n\nLet's say we have 3 heads of cattle represented by 3 beads on the bottom row on the right side.\n假设最底部的 3 颗珠子，代表 3 头牛\n\nIf we were to buy 4 more cattle we would just slide 4 more beads to the right for a total of 7.\n假设再买 4 头牛，只需要向右移动 4 颗珠子，共 7 个珠子\n\nBut if we were to add 5 more after the first 3 we would run out of beads,\n但如果再买 5 头，珠子就不够用了\n\nso we would slide everything back to the left,\n所以把所有珠子移回左边\n\nslide one bead on the second row to the right, representing ten,\n在第二排把 1 颗珠子向右移动，代表 10\n\nand then add the final 2 beads on the bottom row for a total of 12.\n然后最底下那行，向右移动 2 颗珠子，代表 12\n\nThis is particularly useful with large numbers.\n这种方法处理大数字很有效\n\nSo if we were to add 1,251\n假设要表示 1251\n\nwe would just add 1 to the bottom row, 5 to the second row, 2 to the third row, and 1 to the fourth row\n从下往上：\\N第一行移 1 个，第二行移 5 个\\N第三行移 2 个，第四行移 1 个\n\n- we don't have to add in our head and the abacus stores the total for us.\n我们不用记在脑子里，算盘会记住.\n\nOver the next 4000 years, humans developed all sorts of clever computing devices,\n在接下来 4000 年，人类发明了各种巧妙的计算设备\n\nlike the astrolabe, which enabled ships to calculate their latitude at sea.\n比如星盘，让船只可以在海上计算纬度\n\nOr the slide rule, for assisting with multiplication and division.\n或计算尺，帮助计算乘法和除法\n\nAnd there are literally hundred of types of clocks created\n人们还创造了上百种时钟\n\nthat could be used to calculate sunrise, tides, positions of celestial bodies, and even just the time.\n算日出，潮汐，天体的位置，或纯粹拿来计时\n\nEach one of these devices made something that was previously laborious to calculate much faster,\n这些设备让原先很费力的事变得更快，更简单，更精确\n\neasier, and often more accurate\n这些设备让原先很费力的事变得更快，更简单，更精确\n\n- it lowered the barrier to entry,\n降低了门槛\n\nand at the same time, amplified our mental abilities -\n加强了我们的能力\n\ntake note, this is a theme we're going to touch on a lot in this series.\n记笔记!（敲黑板）这个系列会多次提到这一点\n\nAs early computer pioneer Charles Babbage said:\n计算机先驱 Charles Babbage 说过：\n\n\"At each increase of knowledge, as well as on the contrivance of every new tool,\n\"随着知识的增长和新工具的诞生，人工劳力会越来越少\"\n\nhuman labour becomes abridged.\"\n\"随着知识的增长和新工具的诞生，人工劳力会越来越少\"\n\nHowever, none of these devices were called \"computers\".\n然而，这些设备那时都不叫 \"计算机\"\n\nThe earliest documented use of the word \"computer\" is from 1613, in a book by Richard Braithwait.\n最早使用 \"计算机\" 一词的文献 \\N 来自 1613 年的一本书，作者 Richard Braithwait\n\nAnd it wasn't a machine at all - it was a job title.\n然而指的不是机器，而是一种职业\n\nBraithwait said,\nBraithwait 说：\n\n\"I have read the truest computer of times,\n\"我听说过的计算者里最厉害的，能把好几天的工作量大大缩减\"\n\nand the best arithmetician that ever breathed, and he reduceth thy dayes into a short number\".\n\"我听说过的计算者里最厉害的，能把好几天的工作量大大缩减\"\n\nIn those days, computer was a person who did calculations,\n那时, \"Computer\" 指负责计算的人\n\nsometimes with the help of machines, but often not.\n\"Computer\" 偶尔会用机器帮忙，但大部分时候靠自己\n\nThis job title persisted until the late 1800s,\n这个职位一直到 1800 年代还存在\n\nwhen the meaning of computer started shifting to refer to devices.\n之后 \"Computer\" 逐渐开始代表机器\n\nNotable among these devices was the Step Reckoner,\n其中\"步进计算器\"最有名\n\nbuilt by German polymath Gottfried Leibniz in 1694.\n由德国博学家 戈特弗里德·莱布尼茨 建造于 1694 年\n\nLeibniz said \"... it is beneath the dignity of excellent men to waste their time in calculation\n莱布尼茨说过 \"... 让优秀的人浪费时间算数简直侮辱尊严\n\nwhen any peasant could do the work just as accurately with the aid of a machine.\"\n农民用机器能算得一样准\"\n\nIt worked kind of like the odometer in your car,\n\"步进计算器\"有点像汽车里的里程表，不断累加里程数\n\nwhich is really just a machine for adding up the number of miles your car has driven.\n\"步进计算器\"有点像汽车里的里程表，不断累加里程数\n\nThe device had a series of gears that turned;\n它有一连串可以转动的齿轮\n\neach gear had ten teeth, to represent the digits from 0 to 9.\n每个齿轮有十个齿，代表数字0到9\n\nWhenever a gear bypassed nine, it rotated back to 0 and advanced the adjacent gear by one tooth.\n每当一个齿轮转过 9，它会转回 0，同时让旁边的齿轮前进 1 个齿\n\nKind of like when hitting 10 on that basic abacus.\n就像算盘超过 10 一样.\n\nThis worked in reverse when doing subtraction, too.\n做减法时，机器会反向运作.\n\nWith some clever mechanical tricks,\n利用一些巧妙的机械结构\n\nthe Step Reckoner was also able to multiply and divide numbers.\n步进计算器也能做乘法和除法\n\nMultiplications and divisions are really just many additions and subtractions.\n乘法和除法 实际上只是多个加法和减法\n\nFor example, if we want to divide 17 by 5, we just subtract 5, then 5, then 5 again,\n举例，17除以5，我们只要减5，减5，再减5\n\nand then we can't subtract any more 5's… so we know 5 goes into 17 three times, with 2 left over.\n直到不能再减 5，就知道了 17=5x3+2\n\nThe Step Reckoner was able to do this in an automated way,\n步进计算器 可以自动完成这种操作\n\nand was the first machine that could do all four of these operations.\n它是第一台能做\"加减乘除\"全部四种运算的机器\n\nAnd this design was so successful it was used for the next three centuries of calculator design.\n它的设计非常成功，以至于沿用了 3 个世纪.\n\nUnfortunately, even with mechanical calculators,\n不幸的是，即使有机械计算器\n\nmost real world problems required many steps of computation before an answer was determined.\n许多现实问题 依然需要很多步\n\nIt could take hours or days to generate a single result.\n算一个结果可能要几小时甚至几天\n\nAlso, these hand-crafted machines were expensive, and not accessible to most of the population.\n而且这些手工制作的机器非常昂贵，大部分人买不起\n\nSo, before 20th century,\n所以在 20 世纪以前\n\nmost people experienced computing through pre-computed tables\n大部分人会用预先算好的计算表\n\nassembled by those amazing \"human computers\" we talked about.\n这些计算表由之前说的 \"人力计算器\" 编撰\n\nSo if you needed to know the square root of 8 million 6 hundred and 75 thousand 3 hundred and 9,\n如果你想知道 867,5309 的平方根\n\ninstead of spending all day hand-cranking your step reckoner,\n与其花一整天来手摇 \"步进计算器\"\n\nyou could look it up in a huge book full of square root tables in a minute or so.\n你可以花一分钟在表里找答案\n\nSpeed and accuracy is particularly important on the battlefield,\n速度和准确性在战场上尤为重要\n\nand so militaries were among the first to apply computing to complex problems.\n因此军队很早就开始用计算解决复杂问题\n\nA particularly difficult problem is accurately firing artillery shells,\n如何精确瞄准炮弹是一个很难的问题\n\nwhich by the 1800s could travel well over a kilometer (or a bit more than half a mile).\n19世纪，这些炮弹的射程可以达到 1 公里以上（比半英里多一点）\n\nAdd to this varying wind conditions, temperature, and atmospheric pressure,\n因为风力，温度，大气压力会不断变化\n\nand even hitting something as large as a ship was difficult.\n想打中船一样大的物体也非常困难\n\nRange Tables were created that allowed gunners to look up environmental conditions\n于是出现了射程表，炮手可以查环境条件和射击距离\n\nand the distance they wanted to fire,\n于是出现了射程表，炮手可以查环境条件和射击距离\n\nand the table would tell them the angle to set the canon.\n然后这张表会告诉他们，角度要设成多少\n\nThese Range Tables worked so well, they were used well into World War Two.\n这些射程表很管用，二战中被广泛应用\n\nThe problem was, if you changed the design of the cannon or of the shell,\n问题是如果改了大炮或炮弹的设计，就要算一张新表\n\na whole new table had to be computed,\n问题是如果改了大炮或炮弹的设计，就要算一张新表\n\nwhich was massively time consuming and inevitably led to errors.\n这样很耗时而且会出错\n\nCharles Babbage acknowledged this problem in 1822\nCharles Babbage 在 1822 年写了一篇论文\n\nin a paper to the Royal Astronomical Society entitled:\n向皇家天文学会指出了这个问题\n\n\"Note on the application of machinery to the computation of astronomical and mathematical tables\".\n标题叫： \"机械在天文与计算表中的应用\"\n\nLet's go to the thought bubble.\n让我们进入思想泡泡\n\nCharles Babbage proposed a new mechanical device called the Difference Engine,\nCharles Babbage 提出了一种新型机械装置叫 \"差分机\"\n\na much more complex machine that could approximate polynomials.\n一个更复杂的机器，能近似多项式.\n\nPolynomials describe the relationship between several variables\n多项式描述了几个变量之间的关系\n\n- like range and air pressure, or amount of pizza Carrie Anne eats and happiness.\n比如射程和大气压力，或者 Carrie Anne 要吃多少披萨才开心\n\nPolynomials could also be used to approximate logarithmic and trigonometric functions,\n多项式也可以用于近似对数和三角函数\n\nwhich are a real hassle to calculate by hand.\n这些函数手算相当麻烦\n\nBabbage started construction in 1823,\nCharles Babbage 在 1823 年开始建造差分机\n\nand over the next two decades, tried to fabricate and assemble the 25,000 components,\n并在接下来二十年，试图制造和组装 25,000 个零件\n\ncollectively weighing around 15 tons.\n总重接近 15 吨\n\nUnfortunately, the project was ultimately abandoned.\n不幸的是，该项目最终放弃了\n\nBut, in 1991,\n但在 1991 年\n\nhistorians finished constructing a Difference Engine based on Babbage's drawings and writings\n历史学家根据 Charles Babbage 的草稿做了一个差分机\n\n- and it worked!\n而且它还管用！\n\nBut more importantly, during construction of the Difference Engine,\n但更重要的是，在差分机的建造期间\n\nBabbage imagined an even more complex machine - the Analytical Engine.\nCharles Babbage 构想了一个更复杂的机器 - 分析机\n\nUnlike the Difference Engine,\n不像差分机，步进计算器 和以前的其他计算设备\n\nStep Reckoner and all other computational devices before it\n不像差分机，步进计算器 和以前的其他计算设备\n\n- the Analytical Engine was a \"general purpose computer\".\n分析机是 \"通用计算机\"\n\nIt could be used for many things, not just one particular computation;\n它可以做很多事情，不只是一种特定运算\n\nit could be given data and run operations in sequence;\n甚至可以给它数据，然后按顺序执行一系列操作\n\nit had memory and even a primitive printer.\n它有内存 甚至一个很原始的打印机\n\nLike the Difference Engine, it was ahead of its time, and was never fully constructed.\n就像差分机，这台机器太超前了，所以没有建成\n\nHowever, the idea of an \"automatic computer\"\n然而，这种 \"自动计算机\" 的概念\n\n- one that could guide itself through a series of operations automatically,\n-计算机可以自动完成一系列操作\n\nwas a huge deal, and would foreshadow computer programs.\n是个跨时代的概念，预示着计算机程序的诞生\n\nEnglish mathematician Ada Lovelace wrote hypothetical programs for the Analytical Engine, saying,\n英国数学家 Ada Lovelace 给分析机写了假想的程序，她说：\n\n\"A new, a vast, and a powerful language is developed for the future use of analysis.\"\n\"未来会诞生一门全新的，强大的，专为分析所用的语言\"\n\nFor her work, Ada is often considered the world's first programmer.\n因此 Ada 被认为是世上第一位程序员.\n\nThe Analytical Engine would inspire, arguably, the first generation of computer scientists,\n分析机激励了（可以这么讲）第一代计算机科学家\n\nwho incorporated many of Babbage's ideas in their machines.\n这些计算机科学家 \\N 把很多 Charles Babbage 的点子融入到他们的机器\n\nThis is why Babbage is often considered the \"father of computing\".\n所以 Charles Babbage 经常被认为是 \"计算之父\"\n\nThanks! Thought Bubble\n谢啦！思想泡泡\n\nSo by the end of the 19th century,\n到了 19 世纪末\n\ncomputing devices were used for special purpose tasks in the sciences and engineering,\n科学和工程领域中的特定任务 会用上计算设备\n\nbut rarely seen in business, government or domestic life.\n但公司，政府，家庭中很少见到计算设备\n\nHowever, the US government faced a serious problem for its 1890 census\n然而，美国政府在 1890 年的人口普查中面临着严重的问题\n\nthat demanded the kind of efficiency that only computers could provide.\n只有计算机能提供所需的效率\n\nThe US Constitution requires that a census be conducted every ten years,\n美国宪法要求 10 年进行一次人口普查\n\nfor the purposes of distributing federal funds, representation in congress, and good stuff like that.\n目的是分配联邦资金，国会代表，等等\n\nAnd by 1880s, the US population was booming, mostly due to immigration.\n到 1880 年代，美国人口迅速增长，大部分因为移民\n\nThat census took seven years to manually compile\n人口普查要七年时间来手工编制，等做完都过时了\n\nand by the time it was completed, it was already out of date\n人口普查要七年时间来手工编制，等做完都过时了\n\n- and it was predicted that the 1890 census would take 13 years to compute.\n而且 1890 年的人口普查，预计要 13 年完成\n\nThat's a little problematic when it's required every decade!\n但人口普查可是 10 年一次啊！\n\nThe Census bureau turned to Herman Hollerith, who had built a tabulating machine.\n人口普查局找了 Herman Hollerith，他发明了打孔卡片制表机\n\nHis machine was \"electro-mechanical\"\n他的机器是 \"电动机械的\"\n\n- it used traditional mechanical systems for keeping count,\n- 用传统机械来计数\n\nlike Leibniz's Step Reckoner - but coupled them with electrically-powered components.\n结构类似莱布尼茨的乘法器，但用电动结构连接其他组件\n\nHollerith's machine used punch cards\nHollerith 的机器用打孔卡\n\nwhich were paper cards with a grid of locations that can be punched out to represent data.\n一种纸卡，上面有网格，用打孔来表示数据.\n\nFor example, there was a series of holes for marital status.\n举个例子，有一连串孔代表婚姻状况\n\nIf you were married, you would punch out the married spot,\n如果你结婚了，就在 \"结婚\" 的位置打孔\n\nthen when the card was inserted into Hollerith's machine, little metal pins would come down over the card\n当卡插入 Hollerith 的机器时，小金属针会到卡片上\n\n- if a spot was punched out, the pin would pass through the hole in the paper\n-如果有个地方打孔了，针会穿过孔\n\nand into a little vial of mercury, which completed the circuit.\n泡入一小瓶汞，联通电路\n\nThis now completed circuit powered an electric motor,\n电路会驱动电机\n\nwhich turned a gear to add one, in this case, to the \"married\" total.\n然后给 \"已婚\" 的齿轮 + 1\n\nHollerith's machine was roughly 10x faster than manual tabulations,\nHollerith 的机器速度是手动的 10 倍左右\n\nand the Census was completed in just two and a half years\n使人口普查在短短两年半内完成\n\n- saving the census office millions of dollars.\n给人口普查办公室省了上百万美元\n\nBusinesses began recognizing the value of computing,\n企业开始意识到计算机的价值\n\nand saw its potential to boost profits by improving labor- and data-intensive tasks,\n可以提升劳动力以及数据密集型任务 来提升利润\n\nlike accounting, insurance appraisals, and inventory management.\n比如会计，保险评估和库存管理等行业\n\nTo meet this demand, Hollerith founded The Tabulating Machine Company,\n为了满足这一需求，Hollerith 成立了制表机器公司\n\nwhich later merged with other machine makers in 1924\n这家公司后来在 1924 年与其它机械制造商合并\n\nto become The International Business Machines Corporation or IBM\n成为了 \"国际商业机器公司\"，简称 IBM\n\n- which you've probably heard of.\n-你可能听过 IBM\n\nThese electro-mechanical \"business machines\" were a huge success, transforming commerce and government,\n这些电子机械的 \"商业机器\" 取得了巨大成功，改变了商业和政府.\n\nand by the mid-1900s, the explosion in world population and the rise of globalized trade\n到了 1900 年代中叶，世界人口的爆炸和全球贸易的兴起\n\ndemanded even faster and more flexible tools for processing data,\n要求更快，更灵活的工具来处理数据\n\nsetting the stage for digital computers,\n为电子计算机的发展奠定了基础\n\nwhich we'll talk about next week.\n我们下周讨论\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/02. 电子计算机-Electronic Computing.ass.txt",
    "content": "Our last episode brought us to the start of the 20th century,\n上集讲到 20 世纪初\n\nwhere early, special purpose computing devices, like tabulating machines,\n当时的早期计算设备都针对特定用途  比如 制表机\n\nwere a huge boon to governments and business\n大大推进了政府和企业\n\n- aiding, and sometimes replacing, rote manual tasks.\n它们帮助, 甚至代替了人工\n\nBut the scale of human systems continued to increase at an unprecedented rate.\n然而人类社会的规模  在以前所未有的速度增长\n\nThe first half of the 20th century saw the world's population almost double.\n20世纪上半叶，世界人口几乎翻倍\n\nWorld War 1 mobilized 70 million people, and World War 2 involved more than 100 million.\n一战动员7千万人，二战1亿多人\n\nGlobal trade and transit networks became interconnected like never before,\n全球贸易和运输更加紧密\n\nand the sophistication of our engineering and scientific endeavors reached new heights\n工程和科学的复杂度也达到新高\n\n- we even started to seriously consider visiting other planets.\n- 我们甚至开始考虑造访其他行星\n\nAnd it was this explosion of complexity, bureaucracy, and ultimately data,\n复杂度的增高导致数据量暴增\n\nthat drove an increasing need for automation and computation.\n人们需要更多自动化 更强的计算能力\n\nSoon those cabinet-sized electro-mechanical computers grew into room-sized behemoths\n很快，柜子大小的计算机变成房间大小\n\nthat were expensive to maintain and prone to errors.\n维护费用高 而且容易出错\n\nAnd it was these machines that would set the stage for future innovation.\n而正是这些机器 为未来的创新打下基础\n\nOne of the largest electro-mechanical computers built was the Harvard Mark I,\n最大的机电计算机之一是 哈佛马克一号\n\ncompleted in 1944 by IBM for the Allies during World War 2.\nIBM 在 1944 完成建造，给二战同盟国建造的.\n\nIt contained 765,000 components, three million connections, and five hundred miles of wire.\n它有76万5千个组件，300万个连接点和500英里长的导线\n\nTo keep its internal mechanics synchronized,\n为了保持内部机械装置同步\n\nit used a 50-foot shaft running right through the machine driven by a five horsepower motor.\n它有一个50英尺的传动轴，由一个 5 马力的电机驱动\n\nOne of the earliest uses for this technology was running simulations for the Manhattan Project.\n这台机器最早的用途之一 是给\"曼哈顿计划\"跑模拟\n\nThe brains of these huge electro-mechanical beasts were relays:\n这台机器的大脑是\"继电器\"\n\nelectrically-controlled mechanical switches.\n继电器是：用电控制的机械开关\n\nIn a relay, there is a control wire that determines whether a circuit is opened or closed.\n继电器里，有根\"控制线路\"，控制电路是开还是关\n\nThe control wire connects to a coil of wire inside the relay.\n\"控制线路\" 连着一个线圈\n\nWhen current flows through the coil, an electromagnetic field is created,\n当电流流过线圈，线圈产生电磁场\n\nwhich in turn, attracts a metal arm inside the relay, snapping it shut and completing the circuit.\n吸引金属臂，从而闭合电路\n\nYou can think of a relay like a water faucet.\n你可以把继电器 想成水龙头\n\nThe control wire is like the faucet handle.\n把控制线路 想成水龙头把\n\nOpen the faucet, and water flows through the pipe.\n打开水龙头，水会流出来\n\nClose the faucet, and the flow of water stops.\n关闭水龙头，水就没有了\n\nRelays are doing the same thing, just with electrons instead of water.\n继电器是一样的，只不过控制的是电子  而不是水\n\nThe controlled circuit can then connect to other circuits, or to something like a motor,\n这个控制电路可以连到其他电路，比如马达\n\nwhich might increment a count on a gear,\n马达让计数齿轮 +1\n\nlike in Hollerith's tabulating machine we talked about last episode.\n就像上集中 Hollerith 的制表机一样\n\nUnfortunately, the mechanical arm inside of a relay *has mass*,\n不幸的是，继电器内的机械臂 *有质量*\n\nand therefore can't move instantly between opened and closed states.\n因此无法快速开关\n\nA good relay in the 1940's might be able to flick back and forth fifty times in a second.\n1940 年代一个好的继电器 1 秒能翻转 50 次\n\nThat might seem pretty fast, but it's not fast enough to be useful at solving large, complex problems.\n看起来好像很快，但还不够快，不足以解决复杂的大问题\n\nThe Harvard Mark I could do 3 additions or subtractions per second;\n哈佛马克一号，1 秒能做 3 次加法或减法运算\n\nmultiplications took 6 seconds, and divisions took 15.\n一次乘法要花 6 秒，除法要花 15 秒\n\nAnd more complex operations, like a trigonometric function, could take over a minute.\n更复杂的操作 比如三角函数，可能要一分钟以上\n\nIn addition to slow switching speed, another limitation was wear and tear.\n除了速度慢，另一个限制是齿轮磨损\n\nAnything mechanical that moves will wear over time.\n任何会动的机械都会随时间磨损\n\nSome things break entirely, and other things start getting sticky, slow, and just plain unreliable.\n有些部件会完全损坏，有些则是变黏，变慢，变得不可靠\n\nAnd as the number of relays increases, the probability of a failure increases too.\n并且随着继电器数量增加，故障概率也会增加\n\nThe Harvard Mark I had roughly 3500 relays.\n哈佛马克一号 有大约 3500 个继电器\n\nEven if you assume a relay has an operational life of 10 years,\n哪怕假设继电器的使用寿命是 10 年\n\nthis would mean you'd have to replace, on average, one faulty relay every day!\n也意味着平均每天得换一个故障继电器！\n\nThat's a big problem when you are in the middle of running some important, multi-day calculation.\n这个问题很严重，因为有些重要运算要运行好几天\n\nAnd that's not all engineers had to contend with.\n而且还有更多其他问题要考虑\n\nThese huge, dark, and warm machines also attracted insects.\n这些巨大，黑色，温暖的机器也会吸引昆虫\n\nIn September 1947, operators on the Harvard Mark II pulled a dead moth from a malfunctioning relay.\n1947年9月，哈佛马克2型的操作员从故障继电器中，拔出一只死虫\n\nGrace Hopper who we'll talk more about in a later episode noted,\nGrace Hopper（这位我们以后还会提到）曾说\n\n\"From then on, when anything went wrong with a computer,\n\"从那时起，每当电脑出了问题，\n\nwe said it had bugs in it.\"\n我们就说它出了 bug（虫子）\"\n\nAnd that's where we get the term computer bug.\n这就是术语 \"bug\" 的来源\n\nIt was clear that a faster, more reliable alternative to electro-mechanical relays was needed\n显然，如果想进一步提高计算能力\n\nif computing was going to advance further,\n我们需要更快更可靠的东西，来替代继电器\n\nand fortunately that alternative already existed!\n幸运的是，替代品已经存在了！\n\nIn 1904, English physicist John Ambrose Fleming\n在 1904 年，英国物理学家 \"约翰·安布罗斯·弗莱明\"\n\ndeveloped a new electrical component called a thermionic valve,\n开发了一种新的电子组件，叫\"热电子管\"\n\nwhich housed two electrodes inside an airtight glass bulb\n把两个电极装在一个气密的玻璃灯泡里\n\n- this was the first vacuum tube.\n-这是世上第一个真空管\n\nOne of the electrodes could be heated, which would cause it to emit electrons\n其中一个电极可以加热，从而发射电子\n\n– a process called thermionic emission.\n-这叫 \"热电子发射\"\n\nThe other electrode could then attract these electrons to create the flow of our electric faucet,\n另一个电极会吸引电子，形成\"电龙头\"的电流\n\nbut only if it was positively charged\n但只有带正电才行\n\n- if it had a negative or neutral charge, the electrons would no longer be attracted across the vacuum\n- 如果带负电荷或中性电荷，电子就没办法被吸引，越过真空区域\n\nso no current would flow.\n因此没有电流\n\nAn electronic component that permits the one-way flow of current is called a diode,\n电流只能单向流动的电子部件叫 \"二极管\"\n\nbut what was really needed was a switch to help turn this flow on and off.\n但我们需要的是，一个能开关电流的东西\n\nLuckily, shortly after, in 1906, American inventor Lee de Forest\n幸运的是，不久之后在 1906 年，美国发明家 \"李·德富雷斯特\"\n\nadded a third \"control\" electrode that sits between the two electrodes in Fleming's design.\n他在\"弗莱明\"设计的两个电极之间，加入了第三个 \"控制\" 电极\n\nBy applying a positive charge to the control electrode, it would permit the flow of electrons as before.\n向\"控制\"电极施加正电荷，它会允许电子流动\n\nBut if the control electrode was given a negative charge,\n但如果施加负电荷\n\nit would prevent the flow of electrons.\n它会阻止电子流动\n\nSo by manipulating the control wire, one could open or close the circuit.\n因此通过控制线路，可以断开或闭合电路\n\nIt's pretty much the same thing as a relay\n和继电器的功能一样\n\n- but importantly, vacuum tubes have no moving parts.\n- 但重要的是，真空管内没有会动的组件\n\nThis meant there was less wear,\n这意味着更少的磨损\n\nand more importantly, they could switch thousands of times per second.\n更重要的是，每秒可以开闭数千次\n\nThese triode vacuum tubes would become the basis of radio, long distance telephone,\n因此这些\"三极真空管\"成为了无线电，长途电话\n\nand many other electronic devices for nearly a half century.\n以及其他电子设备的基础，持续了接近半个世纪\n\nI should note here that vacuum tubes weren't perfect\n我应该提到，真空管不是完美的\n\n- they're kind of fragile, and can burn out like light bulbs,\n-它们有点脆弱，并且像灯泡一样会烧坏\n\nthey were a big improvement over mechanical relays.\n但比起机械继电器是一次巨大进步\n\nAlso, initially vacuum tubes were expensive\n起初，真空管非常昂贵\n\n– a radio set often used just one,\n收音机一般只用一个\n\nbut a computer might require hundreds or thousands of electrical switches.\n但计算机可能要上百甚至上千个电气开关\n\nBut by the 1940s,\n但到了 1940 年代\n\ntheir cost and reliability had improved to the point where they became feasible for use in computers….\n它的成本和可靠性得到改进，可以用在计算机里\n\nat least by people with deep pockets, like governments.\n至少有钱人负担得起，比如政府\n\nThis marked the shift from electro-mechanical computing to electronic computing.\n这标志着计算机 从机电转向电子\n\nLet's go to the Thought Bubble.\n我们来进入思想泡泡\n\nThe first large-scale use of vacuum tubes for computing was the Colossus MK 1,\n第一个大规模使用真空管的计算机是 \"巨人1号\"\n\ndesigned by engineer Tommy Flowers and completed in December of 1943.\n由工程师 Tommy Flowers 设计，完工于1943年12月\n\nThe Colossus was installed at Bletchley Park, in the UK,\n巨人1号 在英国的\"布莱切利园\", 用于破解纳粹通信\n\nand helped to decrypt Nazi communications.\n巨人1号 在英国的\"布莱切利园\", 用于破解纳粹通信\n\nThis may sound familiar because two years prior Alan Turing,\n听起来可能有点熟，因为 2 年前 阿兰·图灵\n\noften called the father of computer science,\n他经常被称为\"计算机科学之父\"\n\nhad created an electromechanical device, also at Bletchley Park, called the Bombe.\n图灵也在\"布莱切利园\"做了台机电装置，叫 \"Bombe\"\n\nIt was an electromechanical machine designed to break Nazi Enigma codes,\n这台机器的设计目的是  破解纳粹\"英格码\"通讯加密设备\n\nbut the Bombe wasn't technically a computer,\n但 Bombe 严格来说不算计算机\n\nand we'll get to Alan Turing's contributions later.\n我们之后会讨论\"阿兰·图灵\"的贡献\n\nAnyway, the first version of Colossus contained 1,600 vacuum tubes,\n总之，巨人1号有 1600 个真空管\n\nand in total, ten Colossi were built to help with code-breaking.\n总共造了 10 台巨人计算机，来帮助破解密码\n\nColossus is regarded as the first programmable, electronic computer.\n巨人 被认为是第一个可编程的电子计算机\n\nProgramming was done by plugging hundreds of wires into plugboards,\n编程的方法是把几百根电线插入插板\n\nsort of like old school telephone switchboards,\n有点像老电话交换机\n\nin order to set up the computer to perform the right operations.\n这是为了让计算机执行正确操作\n\nSo while \"programmable\", it still had to be configured to perform a specific computation.\n虽然\"可编程\" ，但还是要配置它\n\nEnter the The Electronic Numerical Integrator and Calculator - or ENIAC -\n电子数值积分计算机 \"ENIAC\"\n\ncompleted a few years later in 1946 at the University of Pennsylvania.\n几年后在 1946 年，在\"宾夕法尼亚大学\"完成建造\n\nDesigned by John Mauchly and J. Presper Eckert,\n设计者是 John Mauchly 和 J. Presper Eckert\n\nthis was the world's first truly general purpose, programmable, electronic computer.\n这是世上第一个真正的通用，可编程，电子计算机\n\nENIAC could perform 5000 ten-digit additions or subtractions per second,\nENIAC 每秒可执行 5000 次十位数加减法\n\nmany, many times faster than any machine that came before it.\n比前辈快了很多倍\n\nIt was operational for ten years,\n它运作了十年\n\nand is estimated to have done more arithmetic than the entire human race up to that point.\n据估计，它完成的运算，比全人类加起来还多\n\nBut with that many vacuum tubes failures were common,\n因为真空管很多，所以故障很常见\n\nand ENIAC was generally only operational for about half a day at a time before breaking down.\nENIAC 运行半天左右就会出一次故障\n\nThanks Thought Bubble.\n谢了 思想泡泡\n\nBy the 1950's, even vacuum-tube-based computing was reaching its limits.\n到 1950 年代，真空管计算机都达到了极限\n\nThe US Air Force's AN/FSQ-7 computer, which was completed in 1955,\n美国空军的 AN/FSQ-7 计算机于 1955 年完成\n\nwas part of the \"SAGE\" air defense computer system,\n是 \"SAGE\" 防空计算机系统的一部分\n\nwhich we'll talk more about in a later episode.\n之后的视频还会提到.\n\nTo reduce cost and size, as well as improve reliability and speed,\n为了降低成本和大小，同时提高可靠性和速度\n\na radical new electronic switch would be needed.\n我们需要一种新的电子开关\n\nIn 1947, Bell Laboratory scientists John Bardeen, Walter Brattain, and William Shockley\n1947 年，贝尔实验室科学家 \\N John Bardeen，Walter Brattain，William Shockley\n\ninvented the transistor,\n发明了晶体管\n\nand with it, a whole new era of computing was born!\n一个全新的计算机时代诞生了！\n\nThe physics behind transistors is pretty complex, relying on quantum mechanics,\n晶体管的物理学相当复杂，牵扯到量子力学\n\nso we're going to stick to the basics.\n所以我们只讲基础\n\nA transistor is just like a relay or vacuum tube\n晶体管 就像之前提过的\"继电器\"或\"真空管\"\n\n- it's a switch that can be opened or closed by applying electrical power via a control wire.\n-它是一个开关，可以用控制线路来控制开或关\n\nTypically, transistors have two electrodes separated by a material that sometimes can conduct electricity,\n晶体管有两个电极，\\N 电极之间有一种材料隔开它们，这种材料有时候导电\n\nand other times resist it\n有时候不导电\n\n- a semiconductor.\n- 这叫\"半导体\"\n\nIn this case, the control wire attaches to a \"gate\" electrode.\n控制线连到一个 \"门\" 电极\n\nBy changing the electrical charge of the gate,\n通过改变 \"门\" 的电荷\n\nthe conductivity of the semiconducting material can be manipulated,\n我们可以控制半导体材料的导电性\n\nallowing current to flow or be stopped\n来允许或不允许 电流流动\n\n- like the water faucet analogy we discussed earlier.\n- 就像之前的水龙头比喻\n\nEven the very first transistor at Bell Labs showed tremendous promise\n贝尔实验室的第一个晶体管就展示了巨大的潜力\n\n- it could switch between on and off states 10,000 times per second.\n每秒可以开关 10,000 次\n\nFurther, unlike vacuum tubes made of glass and with carefully suspended, fragile components,\n而且，比起玻璃制成，小心易碎的真空管\n\ntransistors were solid material known as a solid state component.\n晶体管是固态的\n\nAlmost immediately, transistors could be made smaller than the smallest possible relays or vacuum tubes.\n晶体管可以远远小于继电器或真空管\n\nThis led to dramatically smaller and cheaper computers, like the IBM 608, released in 1957\n导致更小更便宜的计算机，比如1957年发布的IBM 608\n\n– the first fully transistor-powered, commercially-available computer.\n- 第一个完全用晶体管，而且消费者也可以买到的计算机\n\nIt contained 3000 transistors and could perform 4,500 additions,\n它有 3000 个晶体管，每秒执行 4500 次加法\n\nor roughly 80 multiplications or divisions, every second.\n每秒能执行 80 次左右的乘除法\n\nIBM soon transitioned all of its computing products to transistors,\nIBM 很快把所有产品都转向了晶体管\n\nbringing transistor-based computers into offices, and eventually, homes.\n把晶体管计算机带入办公室，最终引入家庭\n\nToday, computers use transistors that are smaller than 50 nanometers in size\n如今，计算机里的晶体管小于 50 纳米\n\n- for reference, a sheet of paper is roughly 100,000 nanometers thick.\n- 而一张纸的厚度大概是 10 万纳米\n\nAnd they're not only incredibly small, they're super fast\n晶体管不仅小，还超级快\n\n- they can switch states millions of times per second, and can run for decades.\n- 每秒可以切换上百万次，并且能工作几十年\n\nA lot of this transistor and semiconductor development happened\n很多晶体管和半导体的开发在\"圣克拉拉谷\"\n\nin the Santa Clara Valley, between San Francisco and San Jose, California.\n这个地方在加州，位于\"旧金山\"和\"圣荷西\"之间\n\nAs the most common material used to create semiconductors is silicon,\n而生产半导体最常见的材料是 \"硅\"\n\nthis region soon became known as Silicon Valley.\n所以这个地区被称为 \"硅谷\"\n\nEven William Shockley moved there, founding Shockley Semiconductor,\n甚至 William Shockley 都搬了过去，创立了\"肖克利半导体\"\n\nwhose employees later founded Fairchild Semiconductors,\n里面的员工后来成立了\"仙童半导体\"\n\nwhose employees later founded Intel - the world's largest computer chip maker today.\n这里面的员工后来创立了英特尔 - 当今世界上最大的计算机芯片制造商\n\nOk, so we've gone from relays to vacuum tubes to transistors.\n好了，我们从\"继电器\"到\"真空管\"到\"晶体管\"\n\nWe can turn electricity on and off really, really, really fast.\n我们可以让电路开闭得非常非常快\n\nBut how do we get from transistors to actually computing something,\n但我们是如何用晶体管做计算的？\n\nespecially if we don't have motors and gears?\n我们没有马达和齿轮啊？\n\nThat's what we're going to cover over the next few episodes.\n我们接下来几集会讲\n\nThanks for watching. See you next week.\n感谢观看 下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/03. 布尔逻辑 和 逻辑门-Boolean Logic & Logic Gates.ass.txt",
    "content": "Hi, I'm Carrie Anne and welcome to Crash Course Computer Science!\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nToday we start our journey up the ladder of abstraction,\n今天我们开始\"抽象\"的旅程\n\nwhere we leave behind the simplicity of being able to see every switch and gear,\n不用管底层细节，把精力用来构建更复杂的系统\n\nbut gain the ability to assemble increasingly complex systems.\n不用管底层细节，把精力用来构建更复杂的系统\n\nLast episode, we talked about how computers evolved from electromechanical devices,\n上集，我们谈了计算机最早是机电设备\n\nthat often had decimal representations of numbers\n一般用十进制计数\n\n- like those represented by teeth on a gear\n- 比如用齿轮数来代表十进制\n\n- to electronic computers with transistors that can turn the flow of electricity on or off.\n- 再到晶体管计算机\n\nAnd fortunately, even with just two states of electricity,\n幸运的是，只用 开/关 两种状态也可以代表信息\n\nwe can represent important information.\n幸运的是，只用 开/关 两种状态也可以代表信息\n\nWe call this representation Binary\n这叫 二进制\n\n-- which literally means \"of two states\",\n- 意思是\"用两种状态表示\"\n\nin the same way a bicycle has two wheels or a biped has two legs.\n就像自行车有两个轮，双足动物有两条腿\n\nYou might think two states isn't a lot to work with, and you'd be right!\n你可能觉得两种状态不多，你是对的！\n\nBut, it's exactly what you need for representing the values \"true\" and \"false\".\n但如果只需要表示 true 和 false，两个值就够了\n\nIn computers, an \"on\" state, when electricity is flowing, represents true.\n电路闭合，电流流过，代表 \"真\"\n\nThe off state, no electricity flowing, represents false.\n电路断开，无电流流过，代表\"假\"\n\nWe can also write binary as 1's and 0's instead of true's and false's\n二进制也可以写成 1 和 0 而不是 true 和 false\n\n- they are just different expressions of the same signal\n- 只是不同的表达方式罢了\n\n- but we'll talk more about that in the next episode.\n- 我们下集会讲更多细节\n\nNow it is actually possible to use transistors for more than just turning electrical current on and off,\n晶体管的确可以不只是 开/关，还可以让不同大小的电流通过\n\nand to allow for different levels of current.\n晶体管的确可以不只是 开/关，还可以让不同大小的电流通过\n\nSome early electronic computers were ternary, that's three states,\n一些早期电子计算机是三进制的，有 3 种状态\n\nand even quinary, using 5 states.\n甚至五进制，5 种状态\n\nThe problem is, the more intermediate states there are,\n问题是，状态越多，越难区分信号\n\nthe harder it is to keep them all seperate\n问题是，状态越多，越难区分信号\n\n-- if your smartphone battery starts running low or there's electrical noise\n- 如果手机快没电了或者附近有电噪音\n\nbecause someone's running a microwave nearby,\n因为有人在用微波炉，\n\nthe signals can get mixed up...\n信号可能会混在一起...\n\nand this problem only gets worse with transistors changing states millions of times per second!\n而每秒百万次变化的晶体管会让这个问题变得更糟！\n\nSo, placing two signals as far apart as possible\n所以我们把两种信号尽可能分开\n\n- using just 'on and off' - gives us the most distinct signal to minimize these issues.\n- 只用\"开\"和\"关\"两种状态，可以尽可能减少这类问题\n\nAnother reason computers use binary\n计算机用二进制的另一个原因是\n\nis that an entire branch of mathematics already existed that dealt exclusively with true and false values.\n有一整个数学分支存在，专门处理\"真\"和\"假\"\n\nAnd it had figured out all of the necessary rules and operations for manipulating them.\n它已经解决了所有法则和运算\n\nIt's called Boolean Algebra!\n叫\"布尔代数\"！\n\nGeorge Boole, from which Boolean Algebra later got its name,\n乔治·布尔（George Boole）是布尔二字的由来\n\nwas a self-taught English mathematician in the 1800s.\n是一位 19 世纪自学成才的英国数学家\n\nHe was interested in representing logical statements that went \"under, over, and beyond\"\n他有兴趣用数学式子 扩展亚里士多德基于哲学的逻辑方法\n\nAristotle's approach to logic, which was, unsurprisingly, grounded in philosophy.\n他有兴趣用数学式子 扩展亚里士多德基于哲学的逻辑方法\n\nBoole's approach allowed truth to be systematically and formally proven, through logic equations\n布尔用 逻辑方程 系统而正式的证明真理(truth)\n\nwhich he introduced in his first book, \"The Mathematical Analysis of Logic\" in 1847.\n他在 1847 年的第一本书\"逻辑的数学分析\"中介绍过\n\nIn \"regular\" algebra -- the type you probably learned in high school -- the values of variables\n在\"常规\"代数里 - 你在高中学的那种 - 变量的值\n\nare numbers, and operations on those numbers are things like addition and multiplication.\n是数字，可以进行加法或乘法之类的操作\n\nBut in Boolean Algebra, the values of variables are true and false, and the operations are logical.\n但在布尔代数中，变量的值是 true 和 false，\\N 能进行逻辑操作\n\nThere are three fundamental operations in Boolean Algebra: a NOT, an AND, and an OR operation.\n布尔代数中有三个基本操作：NOT, AND 和 OR\n\nAnd these operations turn out to be really useful so we're going to look at them individually.\n这些操作非常有用，我们一个个来看\n\nA NOT takes a single boolean value, either true or false, and negates it.\nNOT 操作把布尔值反转，\\N把 true 进行 NOT 就会变成 false，反之亦然\n\nIt flips true to false, and false to true.\nNOT 操作把布尔值反转，\\N把 true 进行 NOT 就会变成 false，反之亦然\n\nWe can write out a little logic table that shows the original value under Input,\n我们可以根据 NOT 操作的输入和输出，做出这个表\n\nand the outcome after applying the operation under Output.\n我们可以根据 NOT 操作的输入和输出，做出这个表\n\nNow here's the cool part -- we can easily build boolean logic out of transistors.\n酷的地方是 - 用晶体管可以轻松实现这个逻辑\n\nAs we discussed last episode, transistors are really just little electrically controlled switches.\n上集说过，晶体管只是电控制的开关\n\nThey have three wires: two electrodes and one control wire.\n有 3 根线：2 根电极和 1 根控制线\n\nWhen you apply electricity to the control wire,\n控制线通电时\n\nit lets current flow through from one electrode, through the transistor, to the other electrode.\n电流就可以从一个电极流到另一个电极\n\nThis is a lot like a spigot on a pipe\n就像水龙头一样\n\n-- open the tap, water flows,\n- 打开水龙头，就有水流出来\n\nclose the tap, water shuts off.\n关掉水龙头，就没水了\n\nYou can think of the control wire as an input,\n可以把控制线，当做输入 ( input ) \\N 底部的电极，当做输出（output）\n\nand the wire coming from the bottom electrode as the output.\n可以把控制线，当做输入 ( input ) \\N 底部的电极，当做输出（output）\n\nSo with a single transistor, we have one input and one output.\n所以 1 个晶体管，有一个输入和一个输出\n\nIf we turn the input on, the output is also on because the current can flow through it.\n如果我们打开输入（input on) \\N 输出也会打开（output on） \\N 因为电流可以流过\n\nIf we turn the input off, the output is also off and the current can no longer pass through.\n如果关闭输入（input off） \\N 输出也会关闭（output off）\\N 因为电流无法通过\n\nOr in boolean terms, when the input is true, the output is true.\n或者用布尔术语来说\\N 输入为 真，输出为 真\n\nAnd when the input is false, the output is also false.\n输入为 假 \\N 输出为 假\n\nWhich again we can show on a logic table.\n我们也可以把这个做成\"真值表\"\n\nThis isn't a very exciting circuit though because its not doing anything\n这个电路没什么意思，因为它没做什么事\n\n-- the input and output are the same.\n- 输入和输出是一样的\n\nBut, we can modify this circuit just a little bit to create a NOT.\n但我们可以稍加修改，实现 NOT\n\nInstead of having the output wire at the end of the transistor, we can move it before.\n与其把下面那根线当做 输出，我们可以把 输出 放到上面\n\nIf we turn the input on, the transistor allows current to pass through it to the \"ground\",\n如果打开 输入，电流可以流过然后 \"接地\"\n\nand the output wire won't receive that current\n输出就没有电流，所以输出是 off\n\n- so it will be off.\n输出就没有电流，所以输出是 off\n\nIn our water metaphor grounding would be like\n如果用水来举例\n\nif all the water in your house was flowing out of a huge hose\n就像家里的水都从一个大管子流走了\n\nso there wasn't any water pressure left for your shower.\n打开淋浴头一点水也没有\n\nSo in this case if the input is on, output is off.\n如果输入是 on，输出是 off\n\nWhen we turn off the transistor, though, current is prevented from flowing down it to the ground,\n当输入是 off，电流没法接地，就流过了输出，所以输出是 on\n\nso instead, current flows through the output wire.\n当输入是 off，电流没法接地，就流过了输出，所以输出是 on\n\nSo the input will be off and the output will be on.\n如果输入是 off，输出是 on\n\nAnd this matches our logic table for NOT, so congrats, we just built a circuit that computes NOT!\n和 NOT 操作表一样！太棒了！我们做了个有点用的电路！\n\nWe call them NOT gates - we call them gates because they're controlling the path of our current.\n我们叫它 \"NOT 门\" \\N 之所以叫 \"门\"，是因为它能控制电流的路径\n\nThe AND Boolean operation takes two inputs, but still has a single output.\n\"AND\"操作有 2 个输入，1 个输出\n\nIn this case the output is only true if both inputs are true.\n如果 2 个输入都是 true，输出才是 true\n\nThink about it like telling the truth.\n你可以想成是 说真话\n\nYou're only being completely honest if you don't lie even a little.\n如果完全不说谎，才是诚实\n\nFor example, let's take the statement,\n举例，看如下这个句子\n\n\"My name is Carrie Anne AND I'm wearing a blue dress\".\n我叫 Carrie Anne \"而且\"我穿着蓝色的衣服\n\nBoth of those facts are true, so the whole statement is true.\n2 个都是真的，所以整个是真的\n\nBut if I said, \"My name is Carrie Anne AND I'm wearing pants\" that would be false,\n但如果说，我叫 Carrie Anne\"而且\"我穿了裤子, 就是假的\n\nbecause I'm not wearing pants.\n因为我没穿裤子\n\nOr trousers.\n或长裤，如果你是英国人你会用这个词……（英/美单词不同梗）\n\nIf you're in England.\n或长裤，如果你是英国人你会用这个词……（英/美单词不同梗）\n\nThe Carrie Anne part is true, but a true AND a false, is still false.\n虽然前半句是真的，但是 真 \"AND\" 假，还是假\n\nIf I were to reverse that statement it would still obviously be false,\n就算把前后顺序反过来，也依然是 假\n\nand if I were to tell you two complete lies that is also false,\n如果我说 2 个假的事情，那么结果是假。\n\nand again we can write all of these combinations out in a table.\n和上次一样，可以给\"AND\"做个表\n\nTo build an AND gate, we need two transistors connected together\n为了实现 \"AND 门\"，我们需要 2 个晶体管连在一起\n\nso we have our two inputs and one output.\n这样有 2 个输入和 1 个输出\n\nIf we turn on just transistor A, current won't flow because the current is stopped by transistor B.\n如果只打开 A，不打开 B \\N 电流无法流到 output，所以输出是 false\n\nAlternatively, if transistor B is on, but the transistor A is off,\n如果只打开 B，不打开 A ，也一样，电流无法流到 output\n\nthe same thing, the current can't get through.\n如果只打开 B，不打开 A ，也一样，电流无法流到 output\n\nOnly if transistor A AND transistor B are on does the output wire have current.\n只有 A 和 B 都打开了，output 才有电流\n\nThe last boolean operation is OR\n最后一个是 OR （前面讲了 NOT 和 AND)\n\n-- where only one input has to be true for the output to be true.\n只要 2 个输入里，其中 1 个是 true，输出就是 true\n\nFor example, my name is Margaret Hamilton OR I'm wearing a blue dress.\n比如，我叫 Margaret Hamilton\"或\"我穿着蓝色衣服\n\nThis is a true statement because although I'm not Margaret Hamilton unfortunately,\n结果是 true，虽然我不是 Margaret Hamilton\n\nI am wearing a blue dress, so the overall statement is true.\n但是我穿着蓝色衣服，所以结果是 true\n\nAn OR statement is also true if both facts are true.\n对于\"OR 操作\"来说，\\N如果 2 个 输入都是 true，输出也是 true\n\nThe only time an OR statement is false is if both inputs are false.\n只有 2 个输入都是 false，OR 的结果才是 false\n\nBuilding an OR gate from transistors needs a few extra wires.\n实现 \"OR 门\" 除了晶体管还要额外的线\n\nInstead of having two transistors in series -- one after the other --\n不是串联起来。而是并联\n\nwe have them in parallel.\n不是串联起来。而是并联\n\nWe run wires from the current source to both transistors.\n然后左边这条线有电流输入\n\nWe use this little arc to note that the wires jump over one another and aren't connected,\n我们用\"小拱门\"代表 2 条线没连在一起，只是跨过而已\n\neven though they look like they cross.\n虽然看起来像连在一起\n\nIf both transistors are turned off, the current is prevented from flowing to the output,\n如果 A 和 B 都是 off，电流无法流过\n\nso the output is also off.\n所以输出是 off\n\nNow, if we turn on just Transistor A, current can flow to the output.\n如果打开 A，电流可以流过。输出是 on\n\nSame thing if transistor A is off, but Transistor B in on.\n如果只打开 B 也一样\n\nBasically if A OR B is on, the output is also on.\n只要 A OR B 是 on， 输出就是 on\n\nAlso, if both transistors are on, the output is still on.\n如果 A 和 B 都 on，结果是 on\n\nOk, now that we've got NOT, AND, and OR gates,\n好，现在 NOT 门, AND 门, OR 门 都搞定了\n\nand we can leave behind the constituent transistors and move up a layer of abstraction.\n我们可以进行一次抽象\n\nThe standard engineers use for these gates are a triangle with a dot for a NOT,\nNOT 门的画法是三角形前面一个圆点\n\na D for the AND, and a spaceship for the OR.\nAND 门用 D 表示 ，OR 门用太空船表示\n\nThose aren't the official names, but that's howI like to think of them.\n\"D 形状和太空船\"不是标准叫法, 只是我喜欢这样叫而已\n\nRepresenting them and thinking about them this way allows us to build even bigger components\n我们可以用这种方法表示它们，构建更大的组件\n\nwhile keeping the overall complexity relatively the same\n就不会变得很复杂\n\n- just remember that that mess of transistors and wires is still there.\n- 晶体管和电线依然在那里，我们只是用符号来代表而已\n\nFor example, another useful boolean operation in computation is called an Exclusive OR\n除了前面说的三个\\N 另一个有用的布尔操作叫 \"异或\"\n\n- or XOR for short.\n- 简称 XOR\n\nXOR is like a regular OR, but with one difference:\nXOR 就像普通 OR，但有一个区别：\n\nif both inputs are true, the XOR is false.\n如果 2 个输入都是 true，XOR 输出 false\n\nThe only time an XOR is true is when one input is true and the other input is false.\n想要 XOR 输出 true \\N 一个输入必须是 true，另一个必须是 false\n\nIt's like when you go out to dinner and your meal comes with a side salad OR a soup\n就像你出去吃晚饭，你点的饭要么配沙拉，要么配汤\n\n- sadly, you can't have both!\n- 你不能两个都要！\n\nAnd building this from transistors is pretty confusing,\n用晶体管实现 XOR 门有点烧脑子\n\nbut we can show how an XOR is created from our three basic boolean gates.\n但我可以展示一下\\N 怎么用前面提到的 3 种门来做 XOR 门\n\nWe know we have two inputs again -- A and B -- and one output.\n我们有 2 个输入，A 和 B ，还有 1 个输出.\n\nLet's start with an OR gate, since the logic table looks almost identical to an OR.\n我们先放一个 OR 门. 因为 OR 和 XOR 的逻辑表很像\n\nThere's only one problem - when A and B are true, the logic is different from OR,\n只有 1 个问题 - 当 A 和 B 都是 true 时 \\N OR 的输出和想要的 XOR 输出不一样\n\nand we need to output \"false\".\n我们想要 false\n\nAnd XOR turns out to be a very useful component,\nXOR 超有用的\n\nand we'll get to it in another episode,\n我们下次再说它\n\nso useful in fact engineers gave it its own symbol too -- an OR gate with a smile :)\n因为超有用，\\N 工程师给了它一个符号，一个 OR 门 + 一个笑脸\n\nBut most importantly, we can now put XOR into our metaphorical toolbox\n重要的是，现在可以把 XOR 放入\"工具箱\"了\n\nand not have to worry about the individual logic gates that make it up,\n不用担心 XOR 具体用了几个门\n\nor the transistors that make up those gates,\n这几个门又是怎么用晶体管拼的\n\nor how electrons are flowing through a semiconductor.\n或电子是怎么流过半导体的\n\nMoving up another layer of abstraction.\n再次向上抽象\n\nWhen computer engineers are designing processors, they rarely work at the transistor level,\n工程师设计处理器时，很少在晶体管的层面上思考，\n\nand instead work with much larger blocks, like logic gates, and even larger components\n而是用更大的组件，比如逻辑门，或者由逻辑门组成的更大组件，\n\nmade up of logic gates, which we'll discuss in future episodes.\n我们以后会讲\n\nAnd even if you are a professional computer programmer,\n就算是专业程序员\n\nit's not often that you think about\n也不用考虑逻辑是怎样在物理层面实现的\n\nhow the logic that you are programming is actually implemented\n也不用考虑逻辑是怎样在物理层面实现的\n\nin the physical world by these teeny tiny components.\n也不用考虑逻辑是怎样在物理层面实现的\n\nWe've also moved from thinking about raw electrical signals to our first representation of data\n我们从电信号开始，到现在第一次表示数据\n\n- true and false - and we've even gotten a little taste of computation.\n- 真和假 - 开始有点\"计算\"的感觉了\n\nWith just the logic gates in this episode,\n仅用这集讲的 逻辑门\n\nwe could build a machine that evaluates complex logic statements,\n我们可以判断复杂的语句 比如：\n\nlike if \"Name is John Green AND after 5pm OR is Weekend AND near Pizza Hut\",\n[如果是 John Green] AND [下午 5 点后] \\N OR [周末] AND [在比萨店附近]\n\nthen \"John will want pizza\" equals true.\n那么 \"John 想要比萨\" = 真\n\nAnd with that, I'm starving, I'll see you next week.\n我都说饿了，下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/04. 二进制-Representing Numbers and Letters with Binary.ass.txt",
    "content": "Hi I'm Carrie Anne, this is Crash Course Computer Science\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nand today we're going to talk about how computers store and represent numerical data.\n今天，我们讲计算机如何存储和表示数字\n\nWhich means we've got to talk about Math!\n所以会有一些数学\n\nBut don't worry.\n不过别担心\n\nEvery single one of you already knows exactly what you need to know to follow along.\n你们的数学水平绝对够用了\n\nSo, last episode we talked about how transistors can be used to build logic gates,\n上集我们讲了，怎么用晶体管做逻辑门\n\nwhich can evaluate boolean statements.\n逻辑门可以判断布尔语句\n\nAnd in boolean algebra, there are only two, binary values: true and false.\n布尔代数只有两个值：True 和 False\n\nBut if we only have two values,\n但如果只有两个值，我们怎么表达更多东西？\n\nhow in the world do we represent information beyond just these two values?\n但如果只有两个值，我们怎么表达更多东西？\n\nThat's where the Math comes in.\n这就需要数学了\n\nSo, as we mentioned last episode, a single binary value can be used to represent a number.\n上集提到，1 个二进制值可以代表 1 个数\n\nInstead of true and false, we can call these two states 1 and 0 which is actually incredibly useful.\n我们可以把真和假 ，当做 1 和 0\n\nAnd if we want to represent larger things we just need to add more binary digits.\n如果想表示更多东西，加位数就行了\n\nThis works exactly the same way as the decimal numbers that we're all familiar with.\n和我们熟悉的十进制一样\n\nWith decimal numbers there are \"only\" 10 possible values a single digit can be; 0 through 9,\n十进制只有 10 个数（0到9）\n\nand to get numbers larger than 9 we just start adding more digits to the front.\n要表示大于 9 的数，加位数就行了\n\nWe can do the same with binary.\n二进制也可以这样玩\n\nFor example, let's take the number two hundred and sixty three.\n拿 263 举例\n\nWhat does this number actually represent?\n这个数字 \"实际\" 代表什么？\n\nWell, it means we've got 2 one-hundreds, 6 tens, and 3 ones.\n2 个 100 \\N6 个 10 \\N 3 个 1\n\nIf you add those all together, we've got 263.\n加在一起，就是 263\n\nNotice how each column has a different multiplier.\n注意每列有不同的乘数\n\nIn this case, it's 100, 10, and 1.\n100, 10, 1\n\nEach multiplier is ten times larger than the one to the right.\n每个乘数都比右边大十倍\n\nThat's because each column has ten possible digits to work with, 0 through 9,\n因为每列有 10 个可能的数字（0到9）\n\nafter which you have to carry one to the next column.\n如果超过 9，要在下一列进 1.\n\nFor this reason, it's called base-ten notation, also called decimal since deci means ten.\n因此叫 \"基于十的表示法\"  或十进制\n\nAND Binary works exactly the same way, it's just base-two.\n二进制也一样，只不过是基于 2 而已\n\nThat's because there are only two possible digits in binary - 1 and 0.\n因为二进制只有两个可能的数， 1 和 0\n\nThis means that each multiplier has to be two times larger than the column to its right.\n意味着每个乘数必须是右侧乘数的两倍\n\nInstead of hundreds, tens, and ones, we now have fours, twos and ones.\n就不是之前的 100, 10, 1 \\N 而是 4, 2, 1\n\nTake for example the binary number: 101.\n拿二进制数 101 举例\n\nThis means we have 1 four, 0 twos, and 1 one.\n意味着有\\N 1个 \"4\"  \\N 0个 \"2\"  \\N 1个 \"1\"\n\nAdd those all together and we've got the number 5 in base ten.\n加在一起，得到十进制的 5\n\nBut to represent larger numbers, binary needs a lot more digits.\n为了表示更大的数字，二进制需要更多位数\n\nTake this number in binary 10110111.\n拿二进制数 10110111 举例\n\nWe can convert it to decimal in the same way.\n我们可以用相同的方法转成十进制\n\nWe have 1 x 128, 0 x 64, 1 x 32, 1 x 16, 0 x 8, 1 x 4, 1 x 2, and 1 x 1.\n1 x 128 ，0 x 64 ，1 x 32 ，1 x 16 \\N 0 x 8 ，1 x 4 ，1 x 2 ，1 x 1\n\nWhich all adds up to 183.\n加起来等于 183\n\nMath with binary numbers isn't hard either.\n二进制数的计算也不难\n\nTake for example decimal addition of 183 plus 19.\n以十进制数 183 加 19 举例\n\nFirst we add 3 + 9, that's 12, so we put 2 as the sum and carry 1 to the ten's column.\n首先 3 + 9，得到 12，然后位数记作 2，向前进 1\n\nNow we add 8 plus 1 plus the 1 we carried, thats 10, so the sum is 0 carry 1.\n现在算 8+1+1=10，所以位数记作0，再向前进 1\n\nFinally we add 1 plus the 1 we carried, which equals 2.\n最后 1+1=2，位数记作2\n\nSo the total sum is 202.\n所以和是202\n\nHere's the same sum but in binary.\n二进制也一样\n\nJust as before, we start with the ones column.\n和之前一样，从个位开始\n\nAdding 1+1 results in 2, even in binary.\n1+1=2，在二进制中也是如此\n\nBut, there is no symbol \"2\" so we use 10 and put 0 as our sum and carry the 1.\n但二进制中没有 2，所以位数记作 0 ，进 1\n\nJust like in our decimal example.\n就像十进制的例子一样\n\n1 plus 1, plus the 1 carried,\n1+1，再加上进位的1\n\nequals 3 or 11 in binary,\n等于 3，用二进制表示是 11\n\nso we put the sum as 1 and we carry 1 again, and so on.\n所以位数记作 1，再进 1，以此类推\n\nWe end up with this number, which is the same as the number 202 in base ten.\n最后得到这个数字，跟十进制 202 是一样的\n\nEach of these binary digits, 1 or 0, is called a \"bit\".\n二进制中，一个 1 或 0  叫一\"位\"\n\nSo in these last few examples, we were using 8-bit numbers with their lowest value of zero\n上个例子我们用了 8 位 , 8 位能表示的最小数是 0,  8位都是0\n\nand highest value is 255, which requires all 8 bits to be set to 1.\n最大数是 255，8 位都是 1\n\nThats 256 different values, or 2 to the 8th power.\n能表示 256 个不同的值，2 的 8 次方\n\nYou might have heard of 8-bit computers, or 8-bit graphics or audio.\n你可能听过 8 位机，8 位图像，8 位音乐\n\nThese were computers that did most of their operations in chunks of 8 bits.\n意思是计算机里\\N 大部分操作都是 8 位 8 位这样处理的\n\nBut 256 different values isn't a lot to work with, so it meant things like 8-bit games\n但 256 个值不算多，意味着 8位游戏只能用 256 种颜色\n\nwere limited to 256 different colors for their graphics.\n但 256 个值不算多，意味着 8位游戏只能用 256 种颜色\n\nAnd 8-bits is such a common size in computing, it has a special word: a byte.\n8 位是如此常见，以至于有专门的名字：字节\n\nA byte is 8 bits.\n1 字节 = 8 位 \\N 1 bytes = 8 bits\n\nIf you've got 10 bytes, it means you've really got 80 bits.\n如果有 10 个字节，意味着有 80 位\n\nYou've heard of kilobytes, megabytes, gigabytes and so on.\n你听过 千字节（KB）兆字节（MB）千兆字节（GB）等等\n\nThese prefixes denote different scales of data.\n不同前缀代表不同数量级\n\nJust like one kilogram is a thousand grams,\n就像 1 千克 = 1000 克，1 千字节 = 1000 字节\n\n1 kilobyte is a thousand bytes.\n就像 1 千克 = 1000 克，1 千字节 = 1000 字节\n\nor really 8000 bits.\n或 8000 位\n\nMega is a million bytes (MB), and giga is a billion bytes (GB).\nMega 是百万字节（MB）, Giga 是十亿字节（GB）\n\nToday you might even have a hard drive that has 1 terabyte (TB) of storage.\n如今你可能有 1 TB 的硬盘\n\nThat's 8 trillion ones and zeros.\n8 万亿个1和0\n\nBut hold on!\n等等，我们有另一种计算方法\n\nThat's not always true.\n等等，我们有另一种计算方法\n\nIn binary, a kilobyte has two to the power of 10 bytes, or 1024.\n二进制里，1 千字节 = 2的10次方 = 1024 字节\n\n1000 is also right when talking about kilobytes,\n1000 也是千字节（KB）的正确单位\n\nbut we should acknowledge it isn't the only correct definition.\n1000 和 1024 都对\n\nYou've probably also heard the term 32-bit or 64-bit computers\n你可能听过 32 位 或 64 位计算机\n\nyou're almost certainly using one right now.\n你现在用的电脑几乎肯定是其中一种\n\nWhat this means is that they operate in chunks of 32 or 64 bits.\n意思是一块块处理数据，每块是 32 位或 64 位\n\nThat's a lot of bits!\n这可是很多位\n\nThe largest number you can represent with 32 bits is just under 4.3 billion.\n32 位能表示的最大数，是 43 亿左右\n\nWhich is thirty-two 1's in binary.\n也就是 32 个 1\n\nThis is why our Instagram photos are so smooth and pretty\n所以 Instagram 照片很清晰\n\n- they are composed of millions of colors,\n- 它们有上百万种颜色\n\nbecause computers today use 32-bit color graphics\n因为如今都用 32 位颜色\n\nOf course, not everything is a positive number\n当然，不是所有数都是正数\n\n- like my bank account in college.\n比如我上大学时的银行账户 T_T\n\nSo we need a way to represent positive and negative numbers.\n我们需要有方法表示正数和负数\n\nMost computers use the first bit for the sign:\n大部分计算机用第一位表示正负：\n\n1 for negative, 0 for positive numbers,\n1 是负，0 是正\n\nand then use the remaining 31 bits for the number itself.\n用剩下 31 位来表示符号外的数值\n\nThat gives us a range of roughly plus or minus two billion.\n能表示的数的范围大约是正 20 亿到负 20 亿\n\nWhile this is a pretty big range of numbers, it's not enough for many tasks.\n虽然是很大的数，但许多情况下还不够用\n\nThere are 7 billion people on the earth, and the US national debt is almost 20 trillion dollars after all.\n全球有 70 亿人口，美国国债近 20 万亿美元\n\nThis is why 64-bit numbers are useful.\n所以 64 位数很有用\n\nThe largest value a 64-bit number can represent is around 9.2 quintillion!\n64 位能表达最大数大约是 9.2×10 ^ 18\n\nThat's a lot of possible numbers and will hopefully stay above the US national debt for a while!\n希望美国国债在一段时间内不会超过这个数！\n\nMost importantly, as we'll discuss in a later episode,\n重要的是（我们之后的视频会深入讲）\n\ncomputers must label locations in their memory,\n计算机必须给内存中每一个位置，做一个 \"标记\"\n\nknown as addresses, in order to store and retrieve values.\n这个标记叫 \"地址\", 目的是为了方便存取数据\n\nAs computer memory has grown to gigabytes and terabytes - that's trillions of bytes\n如今硬盘已经增长到 GB 和 TB，上万亿个字节！\n\nit was necessary to have 64-bit memory addresses as well.\n内存地址也应该有 64 位\n\nIn addition to negative and positive numbers,\n除了负数和正数，计算机也要处理非整数\n\ncomputers must deal with numbers that are not whole numbers,\n除了负数和正数，计算机也要处理非整数\n\nlike 12.7 and 3.14, or maybe even stardate: 43989.1.\n比如 12.7 和 3.14，或\"星历 43989.1\"\n\nThese are called \"floating point\" numbers,\n这叫 浮点数\n\nbecause the decimal point can float around in the middle of number.\n因为小数点可以在数字间浮动\n\nSeveral methods have been developed to represent floating point numbers.\n有好几种方法 表示浮点数\n\nThe most common of which is the IEEE 754 standard.\n最常见的是 IEEE 754 标准\n\nAnd you thought historians were the only people bad at naming things!\n你以为只有历史学家取名很烂吗？\n\nIn essence, this standard stores decimal values sort of like scientific notation.\n它用类似科学计数法的方法，来存十进制值\n\nFor example, 625.9 can be written as 0.6259 x 10^3.\n例如，625.9 可以写成 0.6259×10 ^ 3\n\nThere are two important numbers here: the .6259 is called the significand.\n这里有两个重要的数：.6259 叫 \"有效位数\" , 3 是指数\n\nAnd 3 is the exponent.\n这里有两个重要的数：.6259 叫 \"有效位数\" , 3 是指数\n\nIn a 32-bit floating point number,\n在 32 位浮点数中\n\nthe first bit is used for the sign of the number -- positive or negative.\n第 1 位表示数的符号——正或负\n\nThe next 8 bits are used to store the exponent\n接下来 8 位存指数\n\nand the remaining 23 bits are used to store the significand.\n剩下 23 位存有效位数\n\nOk, we've talked a lot about numbers, but your name is probably composed of letters,\n好了，聊够数了，但你的名字是字母组成的\n\nso it's really useful for computers to also have a way to represent text.\n所以我们也要表示文字\n\nHowever, rather than have a special form of storage for letters,\n与其用特殊方式来表示字母 \\N 计算机可以用数表示字母\n\ncomputers simply use numbers to represent letters.\n与其用特殊方式来表示字母 \\N 计算机可以用数表示字母\n\nThe most straightforward approach might be to simply number the letters of the alphabet:\n最直接的方法是给字母编号：\n\nA being 1, B being 2, C 3, and so on.\nA是1，B是2，C是3，以此类推\n\nIn fact, Francis Bacon, the famous English writer,\n著名英国作家 弗朗西斯·培根（Francis Bacon）\n\nused five-bit sequences to encode all 26 letters of the English alphabet\n曾用 5位序列 来编码英文的 26 个字母\n\nto send secret messages back in the 1600s.\n在十六世纪传递机密信件\n\nAnd five bits can store 32 possible values - so that's enough for the 26 letters,\n五位（bit）可以存 32 个可能值（2^5） - 这对26个字母够了\n\nbut not enough for punctuation, digits, and upper and lower case letters.\n但不能表示 标点符号，数字和大小写字母\n\nEnter ASCII, the American Standard Code for Information Interchange.\nASCII，美国信息交换标准代码\n\nInvented in 1963, ASCII was a 7-bit code, enough to store 128 different values.\n发明于 1963 年，ASCII 是 7 位代码，足够存 128 个不同值\n\nWith this expanded range, it could encode capital letters, lowercase letters,\n范围扩大之后，可以表示大写字母，小写字母,\n\ndigits 0 through 9, and symbols like the @ sign and punctuation marks.\n数字 0 到 9, @ 这样的符号, 以及标点符号\n\nFor example, a lowercase 'a' is represented by the number 97, while a capital 'A' is 65.\n举例，小写字母 a 用数字 97 表示，大写字母 A 是 65\n\nA colon is 58 and a closed parenthesis is 41.\n: 是58  \\n ) 是41\n\nASCII even had a selection of special command codes,\nASCII 甚至有特殊命令符号\n\nsuch as a newline character to tell the computer where to wrap a line to the next row.\n比如换行符，用来告诉计算机换行\n\nIn older computer systems,\n在老计算机系统中\n\nthe line of text would literally continue off the edge of the screen if you didn't include a new line character!\n如果没换行符，文字会超出屏幕\n\nBecause ASCII was such an early standard,\n因为 ASCII 是个很早的标准\n\nit became widely used,\n所以它被广泛使用\n\nand critically, allowed different computers built by different companies to exchange data.\n让不同公司制作的计算机，能互相交换数据\n\nThis ability to universally exchange information is called \"interoperability\".\n这种通用交换信息的能力叫 \"互操作性\"\n\nHowever, it did have a major limitation: it was really only designed for English.\n但有个限制：它是为英语设计的\n\nFortunately, there are 8 bits in a byte, not 7,\n幸运的是，一个字节有8位，而不是7位\n\nand it soon became popular to use codes 128 through 255,\n128 到 255 的字符渐渐变得常用\n\npreviously unused, for \"national\" characters.\n这些字符以前是空的，是给各个国家自己  \"保留使用的\"\n\nIn the US, those extra numbers were largely used to encode additional symbols,\n在美国，这些额外的数字主要用于编码附加符号\n\nlike mathematical notation, graphical elements, and common accented characters.\n比如数学符号，图形元素和常用的重音字符\n\nOn the other hand, while the Latin characters were used universally,\n另一方面，虽然拉丁字符被普遍使用\n\nRussian computers used the extra codes to encode Cyrillic characters,\n在俄罗斯，他们用这些额外的字符表示西里尔字符\n\nand Greek computers, Greek letters, and so on.\n而希腊电脑用希腊字母，等等\n\nAnd national character codes worked pretty well for most countries.\n这些保留下来给每个国家自己安排的空位，\\N 对大部分国家都够用\n\nThe problem was,\n问题是\n\nif you opened an email written in Latvian on a Turkish computer,\n如果在 土耳其 电脑上打开 拉脱维亚语 写的电子邮件\n\nthe result was completely incomprehensible.\n会显示乱码\n\nAnd things totally broke with the rise of computing in Asia,\n随着计算机在亚洲兴起，这种做法彻底失效了\n\nas languages like Chinese and Japanese have thousands of characters.\n中文和日文这样的语言有数千个字符\n\nThere was no way to encode all those characters in 8-bits!\n根本没办法用 8 位来表示所有字符！\n\nIn response, each country invented multi-byte encoding schemes,\n为了解决这个问题，每个国家都发明了多字节编码方案\n\nall of which were mutually incompatible.\n但相互不兼容\n\nThe Japanese were so familiar with this encoding problem that they had a special name for it:\n日本人总是碰到编码问题，以至于专门有词来称呼：\n\n\"mojibake\", which means \"scrambled text\".\n\"mojibake\" 意思是 乱码\n\nAnd so it was born - Unicode - one format to rule them all.\n所以 Unicode 诞生了 - 统一所有编码的标准\n\nDevised in 1992 to finally do away with all of the different international schemes\n设计于 1992 年，解决了不同国家不同标准的问题\n\nit replaced them with one universal encoding scheme.\nUnicode 用一个统一编码方案\n\nThe most common version of Unicode uses 16 bits with space for over a million codes -\n最常见的 Unicode 是 16 位的，有超过一百万个位置 -\n\nenough for every single character from every language ever used\n对所有语言的每个字符都够了\n\nmore than 120,000 of them in over 100 types of script\n100 多种字母表加起来占了 12 万个位置。\n\nplus space for mathematical symbols and even graphical characters like Emoji.\n还有位置放数学符号，甚至 Emoji\n\nAnd in the same way that ASCII defines a scheme for encoding letters as binary numbers,\n就像 ASCII 用二进制来表示字母一样\n\nother file formats - like MP3s or GIFs -\n其他格式 - 比如 MP3 或 GIF  -\n\nuse binary numbers to encode sounds or colors of a pixel in our photos, movies, and music.\n用二进制编码声音/颜色，表示照片,电影,音乐\n\nMost importantly, under the hood it all comes down to long sequences of bits.\n重要的是，这些标准归根到底是一长串位\n\nText messages, this YouTube video, every webpage on the internet,\n短信，这个 YouTube 视频，互联网上的每个网页\n\nand even your computer's operating system, are nothing but long sequences of 1s and 0s.\n甚至操作系统，只不过是一长串 1 和 0\n\nSo next week,\n下周\n\nwe'll start talking about how your computer starts manipulating those binary sequences,\n我们会聊计算机怎么操作二进制\n\nfor our first true taste of computation.\n初尝\"计算\"的滋味\n\nThanks for watching. See you next week.\n感谢观看，下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/05. 算术逻辑单元-How Computers Calculate-the ALU.ass.txt",
    "content": "Hi, I'm Carrie Ann and this is Crash Course Computer Science.\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课\n\nSo last episode, we talked about how numbers can be represented in binary.\n上集，我们谈了如何用二进制表示数字\n\nRepresenting Like, 00101010 is 42 in decimal.\n比如二进制 00101010 是十进制的 42\n\nRepresenting and storing numbers is an important function of a computer,\n表示和存储数字是计算机的重要功能\n\nbut the real goal is computation, or manipulating numbers in a structured and purposeful way,\n但真正的目标是计算，有意义的处理数字\n\nlike adding two numbers together.\n比如把两个数字相加\n\nThese operations are handled by a computer's Arithmetic and Logic Unit,\n这些操作由计算机的 \"算术逻辑单元 \"处理\n\nbut most people call it by its street name:\n但大家会简称：ALU\n\nthe ALU.\n但大家会简称：ALU\n\nThe ALU is the mathematical brain of a computer.\nALU 是计算机的数学大脑\n\nWhen you understand an ALU's design and function,\n等你理解了 ALU 的设计和功能之后\n\nyou'll understand a fundamental part of modern computers.\n你就理解了现代计算机的基石\n\nIt is THE thing that does all of the computation in a computer,\nALU *就是* 计算机里负责运算的组件\\N 基本其他所有部件都用到了它\n\nso basically everything uses it.\nALU *就是* 计算机里负责运算的组件\\N 基本其他所有部件都用到了它\n\nFirst though, look at this beauty.\n先来看看这个美人\n\nThis is perhaps the most famous ALU ever, the Intel 74181.\n这可能是最著名的 ALU，英特尔 74181\n\nWhen it was released in 1970,\n1970 年发布时，它是第一个封装在单个芯片内的完整 ALU\n\nit was It was the first complete ALU that fit entirely inside of a single chip -\n1970 年发布时，它是第一个封装在单个芯片内的完整 ALU\n\nWhich was a huge engineering feat at the time.\n这在当时是惊人的工程壮举\n\nSo today we're going to take those Boolean logic gates we learned about last week\n今天我们用上周学的布尔逻辑门\n\nto build a simple ALU circuit with much of the same functionality as the 74181.\n做一个简单的 ALU 电路，功能和 74181 一样\n\nAnd over the next few episodes we'll use this to construct a computer from scratch.\n然后接下来几集，用它从头做出一台电脑\n\nSo it's going to get a little bit complicated,\n所以会有点复杂\n\nbut I think you guys can handle it.\n但我觉得你们搞的定\n\nAn ALU is really two units in one\nALU 有 2 个单元，1 个算术单元和 1 个逻辑单元\n\n-- there's an arithmetic unit and a logic unit.\nALU 有 2 个单元，1 个算术单元和 1 个逻辑单元\n\nLet's start with the arithmetic unit,\n我们先讲\"算术单元\"，它负责计算机里的所有数字操作\n\nwhich is responsible for handling all numerical operations in a computer,\n我们先讲\"算术单元\"，它负责计算机里的所有数字操作\n\nlike addition and subtraction.\n比如加减法\n\nIt also does a bunch of other simple things like add one to a number,\n它还做很多其他事情，比如给某个数字+1\n\nwhich is called an increment operation, but we'll talk about those later.\n这叫增量运算，我们之后会说\n\nToday, we're going to focus on the piece of rsistance, the crme de la crme of operations\n今天的重点是一切的根本 - \"把两个数字相加\"\n\nthat underlies almost everything else a computer does - adding two numbers together.\n今天的重点是一切的根本 - \"把两个数字相加\"\n\nWe could build this circuit entirely out of individual transistors,\n我们可以用单个晶体管一个个拼，把这个电路做出来，\\N 但很快就会复杂的难以理解\n\nbut that would get confusing really fast.\n我们可以用单个晶体管一个个拼，把这个电路做出来，\\N 但很快就会复杂的难以理解\n\nSo instead as we talked about in Episode 3\n所以与其用晶体管，我们会像第 3 集\n\n- we can use a high-level of abstraction and build our components out of logic gates,\n- 用更高层的抽象，用逻辑门来做\n\nin this case: AND, OR, NOT and XOR gates.\n我们会用到 AND，OR，NOT 和 XOR 逻辑门\n\nThe simplest adding circuit that we can build takes two binary digits, and adds them together.\n最简单的加法电路， \\N 是拿 2 个 bit 加在一起（bit 是 0 或 1）\n\nSo we have two inputs, A and B, and one output, which is the sum of those two digits.\n有 2 个输入：A 和 B， 1 个输出：就是两个数字的和\n\nJust to clarify: A, B and the output are all single bits.\n需要注意的是：A, B, 输出，这3个都是单个 Bit （ 0 或 1 ）\n\nThere are only four possible input combinations.\n输入只有四种可能\n\nThe first three are: 0+0 = 0\n前三个是\\N 0 + 0 = 0 \\N 1 + 0 = 1 \\N 0 + 1 = 1\n\n1+0 = 1 0+1 = 1\n前三个是\\N 0 + 0 = 0 \\N 1 + 0 = 1 \\N 0 + 1 = 1\n\nRemember that in binary, 1 is the same as true, and 0 is the same as false.\n记住二进制里，1 与 true 相同，0 与 false 相同\n\nSo this set of inputs exactly matches the boolean logic of an XOR gate,\n这组输入和输出，和 XOR 门的逻辑完全一样\n\nand we can use it as our 1-bit adder.\n所以我们可以把 XOR 用作 1 位加法器（adder）\n\nBut the fourth input combination, 1 + 1, is a special case. 1 + 1 is 2 (obviously)\n但第四个输入组合，1+1，是个特例 \\N 1+1=2（显然）\n\nbut there's no 2 digit in binary,\n但二进制里没有 2\n\nso as we talked about last episode, the result is 0 and the 1 is carried to the next column.\n上集说过，二进制 1+1 的结果是0，1进到下一位\n\nSo the sum is really 10 in binary.\n和是 10 (二进制)\n\nNow, the output of our XOR gate is partially correct - 1 plus 1, outputs 0.\nXOR 门的输出，只对了一部分， 1+1 输出 0\n\nBut, we need an extra output wire for that carry bit.\n但我们需要一根额外的线代表 \"进位\"\n\nThe carry bit is only \"true\" when the inputs are 1 AND 1,\n只有输入是 1 和 1 时，进位才是 \"true\"\n\nbecause that's the only time when the result (two) is bigger than 1 bit can store\n因为算出来的结果用 1 个 bit 存不下\n\nand conveniently we have a gate for that!\n方便的是，我们刚好有个逻辑门能做这个事！\n\nIt's not that complicated - just two logic gates -\n没那么复杂 - 就两个逻辑门而已\n\nbut let's abstract away even this level of detail\n让我们抽象化\n\nand encapsulate our newly minted half adder as its own component,\n把 \"半加器\" 封装成一个单独组件\n\nwith two inputs - bits A and B - and two outputs, the sum and the carry bits.\n两个输入   A 和 B 都是 1 位 \\N 两个输出  \"总和\" 与 \"进位\"\n\nThis takes us to another level of abstraction\n这进入了另一层抽象\n\nheh I feel like I say that a lot.\n我好像说了很多次，说不定会变成一个梗\n\nI wonder if this is going to become a thing.\n我好像说了很多次，说不定会变成一个梗\n\nAnyway, If you want to add more than 1 + 1\n如果想处理超过 1+1 的运算，我们需要\"全加器\"\n\nwe're going to need a \"Full Adder.\"\n如果想处理超过 1+1 的运算，我们需要\"全加器\"\n\nThat half-adder left us with a carry bit as output.\n半加器 输出了进位\n\nThat means that when we move on to the next column in a multi-column addition,\n意味着，我们算下一列的时候\n\nand every column after that, we are going to have to add three bits together, no two.\n还有之后的每一列，我们得加 3 个位在一起，并不是 2 个\n\nA full adder is a bit more complicated\n全加器复杂了一点点\n\n全加器表格\n\n- it takes three bits as inputs: A, B and C.\n有 3 个输入：A, B, C （都是 1 个 bit)\n\nSo the maximum possible input is 1 + 1 + 1,\n所以最大的可能是 1 + 1 + 1\n\nwhich equals 1 carry out 1, so we still only need two output wires: sum and carry.\n\"总和\"1 \"进位\"1 \\N 所以要两条输出线： \"总和\"和\"进位\"\n\nWe can build a full adder using half adders.\n我们可以用 半加器 做 全加器\n\nTo do this, we use a half adder to add A plus B\n我们先用半加器将 A 和 B 相加\n\njust like before - but then feed that result and input C into a second half adder.\n然后把 C 输入到第二个半加器\n\nLastly, we need a OR gate to check if either one of the carry bits was true.\n最后用一个 OR 门检查进位是不是 true\n\nThat's it, we just made a full adder!\n这样就做出了一个全加器！\n\nAgain,we can go up a level of abstraction and wrap up this full adder as its own component.\n我们可以再提升一层抽象，把全加器作为独立组件\n\nIt takes three inputs, adds them, and outputs the sum and the carry, if there is one.\n全加器会把 A，B，C 三个输入加起来 \\N 输出 \"总和\" 和 \"进位\"\n\nArmed with our new components, we can now build a circuit that takes two, 8-bit numbers\n现在有了新组件，我们可以相加两个 8 位数字\n\nLet's call them A and B  and adds them together.\n叫两个数字叫 A 和 B 好了\n\nLet's start with the very first bit of A and B,\n我们从 A  和 B 的第一位开始\n\nwhich we'll call A0 and B0.\n叫 A0 和 B0 好了\n\nAt this point, there is no carry bit to deal with,\n现在不用处理任何进位，因为是第一次加法\n\nbecause this is our first addition.\n现在不用处理任何进位，因为是第一次加法\n\nSo we can use our half adder to add these two bits together.\n所以我们可以用半加器，来加这2个数字\n\nThe output is sum0.\n输出叫 sum0\n\nNow we want to add A1 and B1 together.\n现在加 A1 和 B1\n\nIt's possible there was a carry from the previous addition of A0 and B0,\n因为 A0 和 B0 的结果有可能进位\n\nso this time we need to use a full adder that also inputs the carry bit.\n所以这次要用全加器，除了 A1 和 B1，还要连上进位\n\nWe output this result as sum1.\n输出叫 sum1\n\nThen, we take any carry from this full adder,\n然后，把这个全加器的进位 \\N 连到下个全加器的输入，处理 A2 和 B2\n\nand run it into the next full adder that handles A2 and B2.\n然后，把这个全加器的进位 \\N 连到下个全加器的输入，处理 A2 和 B2\n\nAnd we just keep doing this in a big chain until all 8 bits have been added.\n以此类推，把 8 个 bit 都搞定\n\nNotice how the carry bits ripple forward to each subsequent adder.\n注意每个进位是怎么连到下一个全加器的\n\nFor this reason, this is called an 8-bit ripple carry adder.\n所以叫 \"8位行波进位加法器\"\n\nNotice how our last full adder has a carry out.\n注意最后一个全加器有 \"进位\" 的输出\n\nIf there is a carry into the 9th bit, it means the sum of the two numbers is too large to fit into 8-bits.\n如果第 9 位有进位，代表着 2 个数字的和太大了，超过了 8 位\n\nThis is called an overflow.\n这叫 \"溢出\" (overflow)\n\nIn general, an overflow occurs when the result of an addition is too large\n一般来说 \"溢出\" 的意思是, 两个数字的和太大了\n\nto be represented by the number of bits you are using.\n超过了用来表示的位数\n\nThis can usually cause errors and unexpected behavior.\n这会导致错误和不可预期的结果\n\nFamously, the original PacMan arcade game used 8 bits to keep track of what level you were on.\n著名的例子是，吃豆人用 8 位存当前关卡数\n\nThis meant that if you made it past level 255 - the largest number storablein 8 bits - to level 256,\n如果你玩到了第 256 关（ 8 位 bit 最大表示 255）\n\nthe ALU overflowed.\nALU 会溢出\n\nThis caused a bunch of errors and glitches making the level unbeatable.\n造成一连串错误和乱码，使得该关卡无法进行\n\nThe bug became a rite of passage for the greatest PacMan players.\n这个 bug 成了厉害吃豆人玩家的代表\n\nSo if we want to avoid overflows,\n如果想避免溢出\n\nwe can extend our circuit with more full adders, allowing us to add 16 or 32 bit numbers.\n我们可以加更多全加器，可以操作 16 或 32 位数字\n\nThis makes overflows less likely to happen, but at the expense of more gates.\n让溢出更难发生，但代价是更多逻辑门\n\nAn additional downside is that it takes a little bit of time for each of the carries to ripple forward.\n另外一个缺点是，每次进位都要一点时间\n\nAdmittedly, not very much time, electrons move pretty fast,\n当然时间不久，因为电子移动的很快\n\nso we're talking about billionths of a second,\n但如今的量级是每秒几十亿次运算，所以会造成影响\n\nbut that's enough to make a difference in today's fast computers.\n但如今的量级是每秒几十亿次运算，所以会造成影响\n\nFor this reason, modern computers use a slightly different adding circuit\n所以，现代计算机用的加法电路有点不同\n\ncalled a 'carry-look-ahead' adder\n叫 \"超前进位加法器\"\n\nwhich is faster, but ultimately does exactly the same thing\n它更快，做的事情是一样的 - 把二进制数相加\n\n-- adds binary numbers.\n它更快，做的事情是一样的 - 把二进制数相加\n\nThe ALU's arithmetic unit also has circuits for other math operations\nALU 的算术单元，也能做一些其他数学运算\n\nand in general these 8 operations are always supported.\n一般支持这 8 个操作\n\nAnd like our adder, these other operations are built from individual logic gates.\n就像加法器一样，这些操作也是由逻辑门构成的\n\nInterestingly, you may have noticed that there are no multiply and divide operations.\n有趣的是，你可能注意到没有乘法和除法\n\nThat's because simple ALUs don't have a circuit for this,\n因为简单的 ALU 没有专门的电路来处理\n\nand instead just perform a series of additions.\n而是把乘法用多次加法来实现\n\nLet's say you want to multiply 12 by 5.\n假设想算 12x5\n\nThat's the same thing as adding 12 to itself 5 times.\n这和把 \"12\" 加 5 次是一样的\n\nSo it would take 5 passes through the ALU to do this one multiplication.\n所以要 5 次 ALU 操作来实现这个乘法\n\nAnd this is how many simple processors,\n很多简单处理器都是这样做的\n\nlike those in your thermostat, TV remote, and microwave, do multiplication.\n比如恒温器，电视遥控器和微波炉\n\nIt's slow, but it gets the job done.\n慢是慢，但是搞的定\n\nHowever, fancier processors, like those in your laptop or smartphone,\n然而笔记本和手机有更好的处理器\n\nhave arithmetic units with dedicated circuits for multiplication.\n有专门做乘法的算术单元\n\nAnd as you might expect, the circuit is more complicated than addition\n你可能猜到了，乘法电路比加法复杂\n\n-- there's no magic, it just takes a lot more logic gates\n- 没什么魔法，只是更多逻辑门\n\nwhich is why less expensive processors don't have this feature.\n所以便宜的处理器没有.\n\nOk, let's move on to the other half of the ALU:\n好了，我们现在讲 ALU 的另一半：逻辑单元\n\nthe Logic Unit.\n好了，我们现在讲 ALU 的另一半：逻辑单元\n\nInstead of arithmetic operations, the Logic Unit performs well...\n逻辑单元执行逻辑操作\n\nlogical operations, like AND, OR and NOT, which we've talked about previously.\n比如之前讨论过的 AND，OR 和 NOT 操作\n\nIt also performs simple numerical tests,\n它也能做简单的数值测试\n\nlike checking if a number is negative.\n比如一个数字是不是负数\n\nFor example, here's a circuit that tests if the output of the ALU is zero.\n例如，这是检查 ALU 输出是否为 0 的电路\n\nIt does this using a bunch of OR gates to see if any of the bits are 1.\n它用一堆 OR 门检查其中一位是否为 1\n\nEven if one single bit is 1,\n哪怕只有一个 Bit (位) 是1，\n\nwe know the number can't be zero and then we use a final NOT gate to flip this input\n我们就知道那个数字肯定不是 0，然后用一个 NOT 门取反\n\nso the output is 1 only if the input number is 0.\n所以只有输入的数字是 0，输出才为 1\n\nSo that's a high level overview of what makes up an ALU.\n以上就是 ALU 的一个高层次概括\n\nWe even built several of the main components from scratch, like our ripple adder.\n我们甚至从零做了几个主要组件，比如行波进位加法器\n\nAs you saw, it's just a big bunch of logic gates connected in clever ways.\n它们只是一大堆逻辑门巧妙的连在一起而已.\n\nWhich brings us back to that ALU you admired so much at the beginning of the episode.\n让我们回到视频开始时的 ALU，英特尔 74181\n\nThe Intel 74181.\n让我们回到视频开始时的 ALU，英特尔 74181\n\nUnlike the 8-bit ALU we made today, the 74181 could only handle 4-bit inputs,\n和我们刚刚做的 8 位 ALU 不同，74181 只能处理 4 位输入\n\nwhich means\n也就是说\n\nYOU BUILT AN ALU THAT'S LIKE TWICE AS GOOD AS THAT SUPER FAMOUS ONE. WITH YOUR MIND!\n你刚做了一个比英特尔 74181 还好的 ALU ！\n\nWell.. sort of.\n其实 差不多啦..\n\nWe didn't build the whole thing\n我们虽然没有全部造出来\n\nbut you get the idea.\n但你理解了整体概念\n\nThe 74181 used about 70 logic gates, and it couldn't multiply or divide.\n74181 用了大概 70 个逻辑门，但不能执行乘除.\n\nBut it was a huge step forward in miniaturization,\n但它向小型化迈出了一大步\n\nopening the doors to more capable and less expensive computers.\n让计算机可以更强大更便宜\n\nThis 4-bit ALU circuit is already a lot to take in,\n4 位 ALU 已经要很多逻辑门了\n\nbut our 8-bit ALU would require hundreds of logic gates to fully build\n但我们的 8 位 ALU 会需要数百个逻辑门\n\nand engineers don't want to see all that complexity when using an ALU,\n工程师不想在用 ALU 时去想那些事情,\n\nso they came up with a special symbol to wrap it all up, which looks like a big V'.\n所以想了一个特殊符号来代表它，看起来像一个大 \"V\"\n\nJust another level of abstraction!\n又一层抽象！\n\nOur 8-bit ALU has two inputs, A and B, each with 8 bits.\n我们的 8 位  ALU 有两个输入，A和B，都是 8 位 (bits)\n\nWe also need a way to specify what operation the ALU should perform,\n我们还需要告诉 ALU 执行什么操作\n\nfor example, addition or subtraction.\n例如加法或减法\n\nFor that, we use a 4-bit operation code.\n所以我们用 4 位的操作代码\n\nWe'll talk about this more in a later episode,\n我们之后的视频会再细说\n\nbut in brief, 1000 might be the command to add, while 1100 is the command for subtract.\n简言之,\"1000\"可能代表加法命令 \\N \"1100\"代表减法命令\n\nBasically, the operation code tells the ALU what operation to perform.\n操作代码告诉 ALU 执行什么操作\n\nAnd the result of that operation on inputs A and B is an 8-bit output.\n输出结果是 8 位的\n\nALUs also output a series of Flags,\nALU 还会输出一堆标志（Flag）\n\nwhich are 1-bit outputs for particular states and statuses.\n\"标志\"是1位的，代表特定状态.\n\nFor example, if we subtract two numbers, and the result is 0,\n比如相减两个数字，结果为 0\n\nour zero-testing circuit, the one we made earlier, sets the Zero Flag to True (1).\n我们的零测试电路（前面做的）\\N 会将零标志设为 True（1）\n\nThis is useful if we are trying to determine if two numbers are are equal.\n如果想知道两个数字是否相等，这个非常有用\n\nIf we wanted to test if A was less than B,\n如果想知道： A 是否小于 B\n\nwe can use the ALU to calculate A subtract B and look to see if the Negative Flag was set to true.\n可以用 ALU 来算 A 减 B，看负标志是否为 true\n\nIf it was, we know that A was smaller than B.\n如果是 true，我们就知道 A 小于 B\n\nAnd finally, there's also a wire attached to the carry out on the adder we built,\n最后，还有一条线连到加法器的进位\n\nso if there is an overflow, we'll know about it.\n如果有溢出，我们就知道\n\nThis is called the Overflow Flag.\n这叫溢出标志\n\nFancier ALUs will have more flags,\n高级 ALU 有更多标志\n\nbut these three flags are universal and frequently used.\n但这 3 个标志是 ALU 普遍用的\n\nIn fact, we'll be using them soon in a future episode.\n其实，我们之后的视频会用到它们\n\nSo now you know how your computer does all its basic mathematical operations digitally\n现在你知道了\\N 计算机是怎样在没有齿轮或杠杆的情况下 进行运算\n\nwith no gears or levers required.\n现在你知道了\\N 计算机是怎样在没有齿轮或杠杆的情况下 进行运算\n\nWe're going to use this ALU when we construct our CPU two episodes from now.\n接下来两集  我们会用 ALU 做 CPU\n\nBut before that, our computer is going to need some memory!\n但在此之前，计算机需要一些 \"记忆\" ！\n\nWe'll talk about that next week.\n我们下周会讲\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/06. 寄存器 & 内存-Registers and RAM.ass.txt",
    "content": "Hi, I'm Carrie Anne and welcome to Crash Course Computer Science.\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课\n\nSo last episode, using just logic gates, we built a simple ALU,\n上集，我们用逻辑门做了个简单 ALU\n\nwhich performs arithmetic and logic operations, hence the 'A' and the 'L'.\n它能执行算术(Arithmetic)和逻辑(Logic)运算 \\N ALU 里的 A 和 L 因此得名\n\nBut of course, there's not much point in calculating a result only to throw it away\n当然，算出来之后如果扔掉就没什么意义了\n\n- it would be useful to store that value somehow,\n得找个方法存起来\n\nand maybe even run several operations in a row.\n可能还要进行多个连续操作\n\nThat's where computer memory comes in!\n这就用到计算机内存了\n\nIf you've ever been in the middle of a long RPG campaign on your console,\n如果你在主机上打过一场长时间的对局\n\nor slogging through a difficult level on Minesweeper on your desktop,\n或玩困难模式的 \"扫雷\"\n\nand your dog came by, tripped and pulled the power cord out of the wall,\n然后狗跑过来，被电源线绊倒，把插头拔了出来\n\nyou know the agony of losing all your progress.\n你知道失去进度的痛苦\n\nCondolences.\n真同情你 :(\n\nBut the reason for your loss is that your console, your laptop and your computers\n你损失数据的原因是 \\N 电脑用的是\"随机存取存储器\"，简称\"RAM\"\n\nmake use of Random Access Memory, or RAM,\n你损失数据的原因是 \\N 电脑用的是\"随机存取存储器\"，简称\"RAM\"\n\nwhich stores things like game state - as long as the power stays on.\n它只能在有电的情况下存储东西，比如游戏状态\n\nAnother type of memory, called persistent memory, can survive without power,\n另一种存储 (memory) 叫持久存储，电源关闭时数据也不会丢失\n\nand it's used for different things;\n它用来存其他东西.\n\nWe'll talk about the persistence of memory in a later episode.\n我们之后会讨论存储 (memory) 的持久性问题\n\nToday, we're going to start small\n今天我们从简单开始\n\n- literally by building a circuit that can store one.. single.. bit of information.\n- 做只能存储 1 位的电路\n\nAfter that, we'll scale up, and build our very own memory module,\n之后再扩大，做出我们的内存模块\n\nand we'll combine it with our ALU next time, when we finally build our very own CPU!\n下次和 ALU 结合起来，做出 CPU！\n\nAll of the logic circuits we've discussed so far go in one direction\n我们至今说过的电路都是单向的\n\n- always flowing forward.\n- 总是向前流动\n\nlike our 8-bit ripple adder from last episode.\n比如上集的 8 位 \"脉动进位加法器\"\n\nBut we can also create circuits that loop back on themselves.\n但也可以做回向电路，把输出连回输入\n\nLet's try taking an ordinary OR gate, and feed the output back into one of its inputs\n我们拿一个 OR 门试试，把输出连回输入\n\nand see what happens.\n看看会发生什么\n\nFirst, let's set both inputs to 0.\n首先，两个输入都设为 0\n\nSo 0 OR 0 is 0, and so this circuit always outputs 0.\n\"0 OR 0\" 是 0，所以电路输出0\n\nIf we were to flip input A to 1.\n如果将 A 变成1\n\n1 OR 0 is 1, so now the output of the OR gate is 1.\n\"1 OR 0\" 为 1，所以输出 1\n\nA fraction of a second later, that loops back around into input B,\n一转眼的功夫，输出回到 B\n\nso the OR gate sees that both of its inputs are now 1.\nOR 门看到两个输入都是 1\n\n1 OR 1 is still 1, so there is no change in output.\n\"1 OR 1\" 仍然为1，所以输出不变\n\nIf we flip input A back to 0, the OR gate still outputs 1.\n如果将 A 变成 0，OR 门依然输出 1\n\nSo now we've got a circuit that records a \"1\" for us.\n现在我们有个电路能记录 \"1\"\n\nExcept, we've got a teensy tiny problem - this change is permanent!\n然而有个小问题：这是永久的！\n\nNo matter how hard we try, there's no way to get this circuit to flip back from a 1 to a 0.\n无论怎么试，都没法从 1 变回 0\n\nNow let's look at this same circuit, but with an AND gate instead.\n我们换成 AND 门看看会怎样\n\nWe'll start inputs A and B both at 1.\n开始时，A 和 B 都设 1\n\n1 AND 1 outputs 1 forever.\n\"1 AND 1\" 永远输出 1\n\nBut, if we then flip input A to 0, because it's an AND gate, the output will go to 0.\n如果之后 A 设为 0，由于是 AND 门，输出会变成 0\n\nSo this circuit records a 0, the opposite of our other circuit.\n这个电路能记录 0，和之前那个相反\n\nLike before, no matter what input we apply to input A afterwards, the circuit will always output 0.\n就像之前，无论 A 设什么值，电路始终输出 0\n\nNow we've got circuits that can record both 0s and 1s.\n现在有了能存 0 和 1 的电路\n\nThe key to making this a useful piece of memory is to combine our two circuits into what is\n为了做出有用的存储 (memory) \\N 我们把两个电路结合起来\n\ncalled the AND-OR Latch.\n这叫 \"AND-OR 锁存器\"\n\nIt has two inputs, a \"set\" input, which sets the output to a 1,\\Ncalled the AND-OR Latch.\nIt has two inputs, a \"set\" input, which sets the output to a 1,\n它有两个输入\\N  \"设置\"输入, 把输出变成 1\\N \"复位\"输入, 把输出变成 0\n\nand a \"reset\" input, which resets the output to a 0.\n它有两个输入\\N  \"设置\"输入, 把输出变成 1\\N \"复位\"输入, 把输出变成 0\n\nIf set and reset are both 0, the circuit just outputs whatever was last put in it.\n如果\"设置\"和\"复位\"都是 0，电路会输出最后放入的内容\n\nIn other words, it remembers a single bit of information!\n也就是说，它存住了 1 位的信息！\n\nMemory!\n存储！\n\nThis is called a \"latch\" because it \"latches onto\" a particular value and stays that way.\n这叫\"锁存\", 因为它\"锁定\"了一个值\n\nThe action of putting data into memory is called writing, whereas getting the data out is called reading.\n放入数据的动作叫 \"写入\"  ，拿出数据的动作叫 \"读取\"\n\nOk, so we've got a way to store a single bit of information!\n现在我们终于有办法存一个位了！\n\nGreat!\n超棒！\n\nUnfortunately, having two different wires for input - set and reset - is a bit confusing.\n麻烦的是, 用两条线 \"设置\"和\"复位\" 来输入, 有点难理解\n\nTo make this a little easier to use, we really want a single wire to input data,\n为了更容易用，我们希望只有一条输入线\n\nthat we can set to either 0 or 1 to store the value.\n将它设为 0 或 1 来存储值\n\nAdditionally, we are going to need a wire that enables the memory\n还需要一根线来\"启用\"内存\n\nto be either available for writing or \"locked\" down\n启用时允许写入，没启用时就 \"锁定\"\n\n- which is called the write enable line.\n- 这条线叫 \"允许写入线\"\n\nBy adding a few extra logic gates, we can build this circuit,\n加一些额外逻辑门，可以做出这个电路\n\nwhich is called a Gated Latch since the \"gate\" can be opened or closed.\n这叫\"门锁\"，因为门可以打开和关上\n\nNow this circuit is starting to get a little complicated.\n现在有点复杂了\n\nWe don't want to have to deal with all the individual logic gates...\n我们不想关心单独的逻辑门\n\nso as before, we're going to bump up a level of abstraction,\n所以我们提升一层抽象\n\nand put our whole Gated Latch circuit in a box -- a box that stores one bit.\n把 \"门锁\" 放到盒子里 - 这个盒子能存一个 bit\n\nLet's test out our new component!\n我们来测一下新组件！\n\nLet's start everything at 0.\n一切从 0 开始\n\nIf we toggle the Data wire from 0 to 1 or 1 to 0,\n数据输入从0换到1, 从1换到0\n\nnothing happens - the output stays at 0.\n什么也不会发生 - 输出依然是 0\n\nThat's because the write enable wire is off, which prevents any change to the memory.\n因为 \"允许写入线\" 是关闭的，所以内容不会变化\n\nSo we need to \"open\" the \"gate\" by turning the write enable wire to 1.\n所以要给 \"允许写入线\" 输入 1, \"打开\" 门\n\nNow we can put a 1 on the data line to save the value 1 to our latch.\n现在往 \"数据线\" 放 1，1 就能存起来了\n\nNotice how the output is now 1.\\NNow we can put a 1 on the data line to save the value 1 to our latch.\nNotice how the output is now 1.\n注意输出现在是 1 了\n\nSuccess!\n成功！\n\nWe can turn off the enable line and the output stays as 1.\n现在可以关掉  \"允许写入线\" ，输出会保持 1\n\nOnce again, we can toggle the value on the data line all we want,\n现在不管给 \"数据线\" 什么值\n\nbut the output will stay the same.\n输出都不会变\n\nThe value is saved in memory.\n值存起来了\n\nNow let's turn the enable line on again use our data line to set the latch to 0.\n现在又打开 \"允许写入线\"  \\N  \"数据线\" 设为0\n\nDone.\n完成\n\nEnable line off, and the output is 0.\n\"允许写入线\" 关闭，输出 0\n\nAnd it works!\n成功了！\n\nNow, of course, computer memory that only stores one bit of information isn't very useful\n当然，只能存 1 bit 没什么大用\n\n-- definitely not enough to run Frogger.\n- 肯定玩不了游戏\n\nOr anything, really.\n或做其它事情\n\nBut we're not limited to using only one latch.\n但我们没限制只能用一个锁存器\n\nIf we put 8 latches side-by-side, we can store 8 bits of information like an 8-bit number.\n如果我们并排放 8 个锁存器，\\N 可以存 8 位信息，比如一个 8 bit 数字\n\nA group of latches operating like this is called a register,\n一组这样的锁存器叫 \"寄存器\"\n\nwhich holds a single number, and the number of bits in a register is called its width.\n寄存器能存一个数字，这个数字有多少位，叫\"位宽\"\n\nEarly computers had 8-bit registers, then 16, 32,\n早期电脑用 8 位寄存器，然后是 16 位，32 位\n\nand today, many computers have registers that are 64-bits wide.\n如今许多计算机都有 64 位宽的寄存器\n\nTo write to our register, we first have to enable all of the latches.\n写入寄存器前，要先启用里面所有锁存器\n\nWe can do this with a single wire that connects to all of their enable inputs, which we set to 1.\n我们可以用一根线连接所有 \"允许输入线\", 把它设为 1\n\nWe then send our data in using the 8 data wires, and then set enable back to 0,\n然后用 8 条数据线发数据，然后将 \"允许写入线\" 设回 0\n\nand the 8 bit value is now saved in memory.\n现在 8 位的值就存起来了\n\nPutting latches side-by-side works ok for a small-ish number of bits.\n如果只有很少的位(bits)，把锁存器并排放置，也勉强够用了.\n\nA 64-bit register would need 64 wires running to the data pins, and 64 wires running to the outputs.\n64 位寄存器要 64 根数据线，64 根连到输出端\n\nLuckily we only need 1 wire to enable all the latches, but that's still 129 wires.\n幸运的是，我们只要 1 根线启用所有锁存器 \\N 但加起来也有 129 条线了\n\nFor 256 bits, we end up with 513 wires!\n如果存 256 位要 513 条线！\n\nThe solution is a matrix!\n解决方法是矩阵！\n\nIn this matrix, we don't arrange our latches in a row,\n在矩阵中，我们不并列排放锁存器\n\nwe put them in a grid.\n而是做成网格\n\nFor 256 bits, we need a 16 by 16 grid of latches with 16 rows and columns of wires.\n存 256 位，我们用 16x16 网格的锁存器，有 16 行 16 列\n\nTo activate any one latch, we must turn on the corresponding row AND column wire.\n要启用某个锁存器，就打开相应的 行线 和 列线\n\nLet's zoom in and see how this works.\n放大看看怎么做的\n\nWe only want the latch at the intersection of the two active wires to be enabled,\n我们只想打开交叉处  锁存器的 \"允许写入线\"\n\nbut all of the other latches should stay disabled.\n所有其他锁存器，保持关闭\n\nFor this, we can use our trusty AND gate!\n我们可以用 AND 门！\n\nThe AND gate will output a 1 only if the row and the column wires are both 1.\n只有 行线和列线 均为 1 ，AND 门才输出 1\n\nSo we can use this signal to uniquely select a single latch.\n所以可以用选择单个锁存器\n\nThis row/column setup connects all our latches with a single, shared, write enable wire.\n这种行/列排列法，用一根 \"允许写入线\" 连所有锁存器\n\nIn order for a latch to become write enabled,\n为了让锁存器变成 \"允许写入\"\n\nthe row wire, the column wire, and the write enable wire must all be 1.\n行线，列线和 \"允许写入线\" 都必须是 1\n\nThat should only ever be true for one single latch at any given time.\n每次只有 1 个锁存器会这样\n\nThis means we can use a single, shared wire for data.\n代表我们可以只用一根 \"数据线\"  \\N 连所有锁存器来传数据\n\nBecause only one latch will ever be write enabled, only one will ever save the data\n因为只有一个锁存器会启用，只有那个会存数据\n\n-- the rest of the latches will simply ignore values on the data wire because they are not write enabled.\n其他锁存器会忽略数据线上的值，因为没有 \"允许写入\"\n\nWe can use the same trick with a read enable wire to read the data later,\n我们可以用类似的技巧, 做\"允许读取线\"来读数据\n\nto get the data out of one specific latch.\n从一个指定的锁存器，读取数据\n\nThis means in total, for 256 bits of memory,\n所以对于 256 位的存储\n\nwe only need 35 wires - 1 data wire, 1 write enable wire, 1 read enable wire,\n只要 35 条线 \\N1条\"数据线\", 1条\"允许写入线\", 1条\"允许读取线\"\n\nand 16 rows and columns for the selection.\n还有16行16列的线用于选择锁存器 \\N （16+16=32, 32+3=35）\n\nThat's significant wire savings!\n这省了好多线！\n\nBut we need a way to uniquely specify each intersection.\n但我们需要某种方法来 唯一指定 交叉路口\n\nWe can think of this like a city,\n我们可以想成城市\n\nwhere you might want to meet someone at 12th avenue and 8th street\n你可能想和别人  在第 12 大道和第 8 街的交界碰面\n\n-- that's an address that defines an intersection.\n- 这是一个交叉点的地址\n\nThe latch we just saved our one bit into has an address of row 12 and column 8.\n我们刚刚存了一位的地址是 \"12行 8列\"\n\nSince there is a maximum of 16 rows, we store the row address in a 4 bit number.\n由于最多 16 行, 用 4 位就够了\n\n12 is 1100 in binary.\n12 用二进制表示为 1100\n\nWe can do the same for the column address: 8 is 1000 in binary.\n列地址也可以这样： 8 用二进制表示为 1000\n\nSo the address for the particular latch we just used can be written as 11001000.\n刚才说的\"12行 8列\"可以写成 11001000\n\nTo convert from an address into something that selects the right row or column,\n为了将地址转成  行和列\n\nwe need a special component called a multiplexer\n我们需要 \"多路复用器\"\n\n-- which is the computer component with a pretty cool name at least compared to the ALU.\n- 这个名字起码比 ALU 酷一点\n\nMultiplexers come in all different sizes,\n多路复用器有不同大小\n\nbut because we have 16 rows, we need a 1 to 16 multiplexer.\n因为有 16 行，我们需要 1 到 16 多路复用器\n\nIt works like this.\n工作方式是\n\nYou feed it a 4 bit number, and it connects the input line to a corresponding output line.\n输入一个 4 位数字，它会把那根线，连到相应的输出线\n\nSo if we pass in 0000, it will select the very first column for us.\n如果输入 0000，它会选择第一列\n\nIf we pass in 0001, the next column is selected, and so on.\n如果输入 0001，会选择下一列，依此类推\n\nWe need one multiplexer to handle our rows and another multiplexer to handle the columns.\n一个多路复用器处理行(row) \\N 另一个多路复用器处理列(column)\n\nOk, it's starting to get complicated again,\n好吧，开始有点复杂了\n\nso let's make our 256-bit memory its own component.\n那么把 256 位内存当成一个整体好了\n\nOnce again a new level of abstraction!\n又提升了一层抽象！\n\nIt takes an 8-bit address for input - the 4 bits for the column and 4 for the row.\n它输入一个 8 位地址：4 位代表列，4 位代表行\n\nWe also need write and read enable wires.\n我们还需要 \"允许写入线\" 和 \"允许读取线\"\n\nAnd finally, we need just one data wire, which can be used to read or write data.\n最后，还需要一条数据线，用于读/写数据\n\nUnfortunately, even 256-bits of memory isn't enough to run much of anything,\n不幸的是， 256 位的内存也没法做什么事\n\nso we need to scale up even more!\n所以还要扩大规模\n\nWe're going to put them in a row.\n把它们并排放置\n\nJust like with the registers.\n就像寄存器一样\n\nWe'll make a row of 8 of them, so we can store an 8 bit number - also known as a byte.\n一行8个，可以存一个 8 位数字 \\N 8 位也叫一个字节（byte）\n\nTo do this, we feed the exact same address into all 8 of our 256-bit memory components at the same time,\n为了存一个 8 位数字，我们同时给 8 个 256 位内存一样的地址\n\nand each one saves one bit of the number.\n每个地址存 1 位\n\nThat means the component we just made can store 256 bytes at 256 different addresses.\n意味着这里总共能存 256 个字节 （byte）\n\nAgain, to keep things simple, we want to leave behind this inner complexity.\n再次，为了简单，我们不管内部\n\nInstead of thinking of this as a series of individual memory modules and circuits,\n不看作是一堆独立的存储模块和电路\n\nwe'll think of it as a uniform bank of addressable memory.\n而是看成一个整体的可寻址内存\n\nWe have 256 addresses,\n我们有 256 个地址\n\nand at each address, we can read or write an 8-bit value.\n每个地址能读或写一个 8 位值\n\nWe're going to use this memory component next episode when we build our CPU.\n我们下集做 CPU 时会用到这个内存\n\nThe way that modern computers scale to megabytes and gigabytes of memory\n现代计算机的内存 \\N 扩展到上兆字节（MB）和千兆字节（GB）的方式\n\nis by doing the same thing we've been doing here\n和我们这里做的一样\n\n-- keep packaging up little bundles of memory into larger, and larger, and larger arrangements.\n不断把内存打包到更大规模\n\nAs the number of memory locations grow, our addresses have to grow as well.\n随着内存地址增多，内存地址也必须增长\n\n8 bits hold enough numbers to provide addresses for 256 bytes of our memory,\n8 位最多能代表 256 个内存地址 \\N（1111 1111 是255，0~255 一共 256 个数字）\n\nbut that's all.\n只有这么多\n\nTo address a gigabyte - or a billion bytes of memory - we need 32-bit addresses.\n要给千兆或十亿字节的内存寻址，需要 32 位的地址\n\nAn important property of this memory is that we can access any memory location, at any time, and in a random order.\n内存的一个重要特性是：可以随时访问任何位置\n\nFor this reason, it's called Random-Access Memory or RAM.\n因此叫 \"随机存取存储器\" ，简称 RAM\n\nWhen you hear people talking about how much RAM a computer has\n当你听到有人说 RAM 有多大\n\n- that's the computer's memory.\n他的意思是内存有多大\n\nRAM is like a human's short term or working memory,\nRAM 就像人类的短期记忆\n\nwhere you keep track of things going on right now\n记录当前在做什么事\n\n- like whether or not you had lunch or paid your phone bill.\n比如吃了午饭没，或有没有交电话费\n\nHere's an actual stick of RAM - with 8 memory modules soldered onto the board.\n这是一条真的内存，上面焊了 8 个内存模块\n\nIf we carefully opened up one of these modules and zoomed in,\n如果打开其中一个，然后放大\n\nThe first thing you would see are 32 squares of memory.\n会看到 32 个内存方块\n\nZoom into one of those squares, and we can see each one is comprised of 4 smaller blocks.\n放大其中一个方块，可以看到有 4 个小块\n\nIf we zoom in again, we get down to the matrix of individual bits.\n如果再放大，可以看到存一个\"位\"的矩阵\n\nThis is a matrix of 128 by 64 bits.\n这个矩阵是 128 位 x 64 位\n\nThat's 8192 bits in total.\n总共 8192 位\n\nEach of our 32 squares has 4 matrices, so that's 32 thousand, 7 hundred and 68 bits.\n每个方格 4 个矩阵 \\N 所以一个方格有 32768 个位 （8192 x 4 = 32768）\n\nAnd there are 32 squares in total.\n而一共 32 个方格\n\nSo all in all, that's roughly 1 million bits of memory in each chip.\n总而言之，1 个芯片大约存 100 万位\n\nOur RAM stick has 8 of these chips, so in total, this RAM can store 8 millions bits,\nRAM 有 8 个芯片，所以总共 800 万位\n\notherwise known as 1 megabyte.\n也就是 1 兆字节（1 MB）\n\nThat's not a lot of memory these days -- this is a RAM module from the 1980's.\n1 MB 如今不算大 - 这是 1980 年代的 RAM\n\nToday you can buy RAM that has a gigabyte or more of memory\n如今你可以买到千兆字节（GB）的 RAM\n\n- that's billions of bytes of memory.\n那可是数十亿字节的内存\n\nSo, today, we built a piece of SRAM - Static Random-Access Memory - which uses latches.\n今天，我们用锁存器做了一块 SRAM（静态随机存取存储器）\n\nThere are other types of RAM, such as DRAM, Flash memory, and NVRAM.\n还有其他类型的 RAM，如 DRAM，闪存和 NVRAM\n\nThese are very similar in function to SRAM,\n它们在功能上与 SRAM 相似\n\nbut use different circuits to store the individual bits\n但用不同的电路存单个位\n\n- for example, using different logic gates, capacitors, charge traps, or memristors.\n- 比如用不同的逻辑门，电容器，电荷捕获或忆阻器\n\nBut fundamentally, all of these technologies store bits of information\n但根本上  这些技术都是矩阵层层嵌套，来存储大量信息\n\nin massively nested matrices of memory cells.\n但根本上  这些技术都是矩阵层层嵌套，来存储大量信息\n\nLike many things in computing, the fundamental operation is relatively simple.\n就像计算机中的很多事情，底层其实都很简单\n\nit's the layers and layers of abstraction that's mind blowing\n让人难以理解的，是一层层精妙的抽象\n\n-- like a russian doll that keeps getting smaller and smaller and smaller.\n像一个越来越小的俄罗斯套娃\n\nI'll see you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/07. 中央处理器-The Central Processing Unit(CPU).ass.txt",
    "content": "Hi, I'm Carrie Anne, this is Crash Course Computer Science\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nand today, we're talking about processors.\n今天我们讲 处理器\n\nJust a warning though - this is probably the most complicated episode in the series.\n提示下 - 这集可能是最难的一集\n\nSo once you get this, you're golden.\n所以一旦你理解了，就会变得超厉害der~\n\nWe've already made a Arithmetic and Logic Unit,\n我们已经做了一个算术逻辑单元（ALU）\n\nwhich takes in binary numbers and performs calculations,\n输入二进制，它会执行计算\n\nand we've made two types of computer memory:\n我们还做了两种内存：\n\nRegisters -- small, linear chunks of memory, useful for storing a single value\n寄存器 - 很小的一块内存，能存一个值\n\nand then we scaled up, and made some RAM,\n之后我们增大做出了 RAM\n\na larger bank of memory that can store a lot of numbers located at different addresses.\nRAM 是一大块内存，能在不同地址存大量数字\n\nNow it's time to put it all together and build ourselves the heart of any computer,\n现在是时候把这些放在一起，组建计算机的 \"心脏\" 了\n\nbut without any of the emotional baggage that comes with human hearts.\n但这个 \"心脏\" 不会有任何包袱，比如人类情感.\n\nFor computers, this is the Central Processing Unit, most commonly called the CPU.\n计算机的心脏是\"中央处理单元\"，简称 \"CPU\"\n\nA CPU's job is to execute programs.\nCPU 负责执行程序\n\nPrograms, like Microsoft Office, Safari, or your beloved copy of Half Life: 2,\n比如 Office，Safari 浏览器，你最爱的 《半条命2》\n\nare made up of a series of individual operations,\n程序由一个个操作组成\n\ncalled instructions, because they \"instruct\" the computer what to do.\n这些操作叫\"指令\"(Instruction) \\N 因为它们\"指示\"计算机要做什么\n\nIf these are mathematical instructions, like add or subtract,\n如果是数学指令，比如加/减\n\nthe CPU will configure its ALU to do the mathematical operation.\nCPU 会让 ALU 进行数学运算\n\nOr it might be a memory instruction,\n也可能是内存指令，CPU 会和内存通信，然后读/写值\n\nin which case the CPU will talk with memory to read and write values.\n也可能是内存指令，CPU 会和内存通信，然后读/写值\n\nThere are a lot of parts in a CPU,\nCPU 里有很多组件.\n\nso we're going to lay it out piece by piece, building up as we go.\n所以我们一边说一边建\n\nWe'll focus on functional blocks, rather than showing every single wire.\n我们把重点放在功能，而不是一根根线具体怎么连\n\nWhen we do connect two components with a line,\n当我们用一条线连接两个组件时\n\nthis is an abstraction for all of the necessary wires.\n这条线只是所有必须线路的一个抽象\n\nThis high level view is called the microarchitecture.\n这种高层次视角叫  \"微体系架构\"\n\nOK, first, we're going to need some memory.\n好，我们首先要一些内存，把上集做的 RAM 拿来就行\n\nLets drop in the RAM module we created last episode.\n好，我们首先要一些内存，把上集做的 RAM 拿来就行\n\nTo keep things simple, we'll assume it only has 16 memory locations, each containing 8 bits.\n为了保持简单，假设它只有 16 个位置，每个位置存 8 位\n\nLet's also give our processor four, 8-bit memory registers, labeled A, B, C and D\n再来四个 8 位寄存器，叫 A，B，C，D\n\nwhich will be used to temporarily store and manipulate values.\n寄存器用来 临时存数据 和 操作数据\n\nWe already know that data can be stored in memory as binary values\n我们已经知道数据  是以二进制值存在内存里\n\nand programs can be stored in memory too.\n程序也可以存在内存里\n\nWe can assign an ID to each instruction supported by our CPU.\n我们可以给 CPU 支持的所有指令，分配一个 ID\n\n指令表\n\n指令\n\n描述\n\n4位操作码\n\n地址或寄存器\n\nIn our hypothetical example, we use the first four bits to store the \"operation code\",\n在这个假设的例子 \\N 我们用前四位存 \"操作代码\" （operation code）\n\nor opcode for short.\n简称 \"操作码\" （opcode）\n\nThe final four bits specify where the data for that operation should come from -\n后四位代表数据来自哪里\n\nthis could be registers or an address in memory.\n- 可以是寄存器或内存地址\n\nWe also need two more registers to complete our CPU.\n我们还需要两个寄存器，来完成 CPU.\n\nFirst, we need a register to keep track of where we are in a program.\n1. 一个寄存器追踪程序运行到哪里了，我们叫它  \"指令地址寄存器\"\n\nFor this, we use an instruction address register,\n1. 一个寄存器追踪程序运行到哪里了，我们叫它  \"指令地址寄存器\"\n\nwhich as the name suggests, stores the memory address of the current instruction.\n顾名思义，存当前指令的内存地址\n\nAnd then we need the other register to store the current instruction,\n2. 另一个寄存器存当前指令，叫  \"指令寄存器\"\n\nwhich we'll call the instruction register.\n2. 另一个寄存器存当前指令，叫  \"指令寄存器\"\n\nWhen we first boot up our computer, all of our registers start at 0.\n当启动计算机时，所有寄存器从 0 开始\n\nAs an example, we've initialized our RAM with a simple computer program that we'll to through today.\n为了举例，我们在 RAM 里放了一个程序，我们今天会过一遍\n\nThe first phase of a CPU's operation is called the fetch phase.\nCPU 的第一个阶段叫 \"取指令阶段\"\n\nThis is where we retrieve our first instruction.\n负责拿到指令\n\nFirst, we wire our Instruction Address Register to our RAM module.\n首先，将 \"指令地址寄存器\" 连到 RAM\n\nThe register's value is 0, so the RAM returns whatever value is stored in address 0.\n寄存器的值为 0，因此 RAM 返回地址 0 的值\n\nIn this case, 0010 1110.\n0010 1110 会复制到 \"指令寄存器\" 里\n\nThen this value is copied into our instruction register.\n0010 1110 会复制到 \"指令寄存器\" 里\n\nNow that we've fetched an instruction from memory,\n现在指令拿到了\n\nwe need to figure out what that instruction is\n要弄清是什么指令，才能执行（execute）\n\nso we can execute it.\n要弄清是什么指令，才能执行（execute）\n\nThat is run it.\n而不是杀死（kill）它\n\nNot kill it.\n而不是杀死（kill）它\n\nThis is called the decode phase.\n这是 \"解码阶段\"\n\n指令表\n\n指令\n\n描述\n\n4位操作码\n\n地址或寄存器\n\nIn this case the opcode, which is the first four bits, is: 0010.\n前 4 位 0010 是 LOAD A 指令\n\nThis opcode corresponds to the \"LOAD A\" instruction,\n前 4 位 0010 是 LOAD A 指令\n\nwhich loads a value from RAM into Register A.\n意思是，把 RAM 的值放入寄存器 A\n\nThe RAM address is the last four bits of our instruction which are 1110, or 14 in decimal.\n后 4 位 1110 是 RAM 的地址, 转成十进制是 14\n\nNext, instructions are decoded and interpreted by a Control Unit.\n接下来，指令由 \"控制单元\" 进行解码\n\nLike everything else we've built, it too is made out of logic gates.\n就像之前的所有东西 \\N  \"控制单元\" 也是逻辑门组成的\n\nFor example, to recognize a LOAD A instruction,\n比如，为了识别 \"LOAD A\" 指令\n\nwe need a circuit that checks if the opcode matches 0010\n需要一个电路，检查操作码是不是 0010\n\nwhich we can do with a handful of logic gates.\n我们可以用很少的逻辑门来实现.\n\nNow that we know what instruction we're dealing with,\n现在知道了是什么指令\n\nwe can go ahead and perform that instruction which is the beginning of the execute phase!\n就可以开始执行了，开始 \"执行阶段\"\n\nUsing the output of our LOAD_A checking circuit,\n用 \"检查是否 LOAD_A 指令的电路\"\n\nwe can turn on the RAM's read enable line and send in address 14.\n可以打开 RAM 的 \"允许读取线\", 把地址 14 传过去\n\nThe RAM retrieves the value at that address, which is 00000011, or 3 in decimal.\nRAM 拿到值，0000 0011，十进制的 3\n\nNow, because this is a LOAD_A instruction,\n因为是 LOAD_A 指令 \\N 我们想把这个值只放到寄存器 A，其他寄存器不受影响\n\nwe want that value to only be saved into Register A and not any of the other registers.\n因为是 LOAD_A 指令 \\N 我们想把这个值只放到寄存器 A，其他寄存器不受影响\n\nSo if we connect the RAM's data wires to our four data registers,\n所以需要一根线，把 RAM 连到 4 个寄存器\n\nwe can use our LOAD_A check circuit to enable the write enable only for Register A.\n用 \"检查是否 LOAD_A 指令的电路\" \\N 启用寄存器 A 的 \"允许写入线\"\n\nAnd there you have it\n这就成功了\n\n-- we've successfully loaded the value at RAM address 14 into Register A.\n- 把 RAM 地址 14 的值，放到了寄存器 A.\n\nWe've completed the instruction, so we can turn all of our wires off,\n既然指令完成了，我们可以关掉所有线路\n\nand we are ready to fetch the next instruction in memory.\n去拿下一条指令\n\nTo do this, we increment the Instruction Address Register by 1 which completes the execute phase.\n我们把 \"指令地址寄存器\"+1，\"执行阶段\"就此结束.\n\nLOAD_A is just one of several possible instructions that our CPU can execute.\nLOAD_A 只是 CPU 可以执行的各种指令之一\n\nDifferent instructions are decoded by different logic circuits,\n不同指令由不同逻辑电路解码\n\nwhich configure the CPU's components to perform that action.\n这些逻辑电路会配置 CPU 内的组件来执行对应操作\n\nLooking at all those individual decode circuits is too much detail,\n具体分析这些解码电路太繁琐了\n\nso since we looked at one example,\n既然已经看了 1 个例子，\n\nwe're going to go head and package them all up as a single Control Unit to keep things simple.\n干脆把 \"控制单元 \"包成一个整体，简洁一些.\n\nThat's right a new level of abstraction.\n没错，一层新抽象\n\nThe Control Unit is comparable to the conductor of an orchestra,\n控制单元就像管弦乐队的指挥\n\ndirecting all of the different parts of the CPU.\n\"指挥\" CPU 的所有组件\n\nHaving completed one full fetch/decode/execute cycle,\n\"取指令→解码→执行\" 完成后\n\nwe're ready to start all over again, beginning with the fetch phase.\n现在可以再来一次，从 \"取指令\" 开始\n\nThe Instruction Address Register now has the value 1 in it,\n\"指令地址寄存器\" 现在的值是 1\n\nso the RAM gives us the value stored at address 1, which is 0001 1111.\n所以 RAM 返回地址 1 里的值：0001 1111\n\nOn to the decode phase!\n到 \"解码\" 阶段！\n\n0001 is the \"LOAD B\" instruction, which moves a value from RAM into Register B.\n0001 是 LOAD B 指令 \\N 从 RAM 里把一个值复制到寄存器 B\n\nThe memory location this time is 1111, which is 15 in decimal.\n这次内存地址是 1111，十进制的 15\n\nNow to the execute phase!\n现在到 \"执行阶段\"！\n\nThe Control Unit configures the RAM to read address 15 and configures Register B to receive the data.\n\"控制单元\" 叫 RAM 读地址 15，并配置寄存器 B 接收数据\n\nBingo, we just saved the value 00001110, or the number 14 in decimal, into Register B.\n成功，我们把值 0000 1110 \\N 也就是十进制的 14 存到了寄存器 B\n\nLast thing to do is increment our instruction address register by 1,\n最后一件事是 \"指令地址寄存器\" +1\n\nand we're done with another cycle.\n我们又完成了一个循环\n\nOur next instruction is a bit different.\n下一条指令有点不同\n\nLet's fetch it.\n来取它吧\n\n1000 0100.\n1000 0100\n\nThat opcode 1000 is an ADD instruction.\n1000 是 ADD 指令\n\nInstead of an 4-bit RAM address, this instruction uses two sets of 2 bits.\n这次后面的 4 位不是 RAM 地址，\\N 而是 2 位 2 位分别代表 2 个寄存器\n\nRemember that 2 bits can encode 4 values,\n2 位可以表示 4 个值\n\nso 2 bits is enough to select any one of our 4 registers.\n所以足够表示 4 个寄存器\n\nThe first set of 2 bits is 01, which in this case corresponds to Register B,\n第一个地址是 01, 代表寄存器B\n\nand 00, which is Register A.\n第二个地址是 00, 代表寄存器A\n\nSo \"1000 01 00\" is the instruction for adding the value in Register B into the value in register A.\n因此，1000 0100，代表把寄存器 B 的值，加到寄存器 A 里\n\nSo to execute this instruction, we need to integrate the ALU we made in Episode 5 into our CPU.\n为了执行这个指令，我们要整合第 5 集的 ALU\n\nThe Control Unit is responsible for selecting the right registers to pass in as inputs,\n\"控制单元\" 负责选择正确的寄存器作为输入\n\nand configuring the ALU to perform the right operation.\n并配置 ALU 执行正确的操作\n\nFor this ADD instruction, the Control Unit enables Register B\n对于 \"ADD\" 指令， \"控制单元\" 会\n\nand feeds its value into the first input of the ALU.\n启用寄存器 B，作为 ALU 的第一个输入\n\nIt also enables Register A and feeds it into the second ALU input.\n还启用寄存器 A，作为 ALU 的第二个输入\n\nAs we already discussed, the ALU itself can perform several different operations,\n之前说过，ALU 可以执行不同操作\n\nso the Control Unit must configure it to perform an ADD operation by passing in the ADD opcode.\n所以控制单元必须传递 ADD 操作码告诉它要做什么\n\nFinally, the output should be saved into Register A.\n最后，结果应该存到寄存器 A\n\nBut it can't be written directly\n但不能直接写入寄存器 A\n\nbecause the new value would ripple back into the ALU and then keep adding to itself.\n这样新值会进入 ALU ，不断和自己相加\n\nSo the Control Unit uses an internal register to temporarily save the output,\n因此，控制单元用一个自己的寄存器暂时保存结果\n\nturn off the ALU, and then write the value into the proper destination register.\n关闭 ALU，然后把值写入正确的寄存器\n\nIn this case, our inputs were 3 and 14, and so the sum is 17, or 00010001 in binary,\n这里 3+14=17，二进制是 0001 0001\n\nwhich is now sitting in Register A.\n现在存到了寄存器 A\n\nAs before, the last thing to do is increment our instruction address by 1,\n和之前一样，最后一件事是把指令地址 + 1\n\nand another cycle is complete.\n这个循环就完成了\n\nOkay, so let's fetch one last instruction: 0100 1101.\n好，来看最后一个指令：0100 1101\n\nWhen we decode it we see that 0100 is a STORE_A instruction, with a RAM address of 13.\n解码得知是 STORE A 指令（把寄存器 A 的值放入内存） \\N RAM 地址 13\n\nAs usual, we pass the address to the RAM module,\n接下来，把地址传给 RAM\n\nbut instead of read-enabling the memory, we write-enable it.\n但这次不是 \"允许读取\" ，而是 \"允许写入\"\n\nAt the same time, we read-enable Register A.\n同时，打开寄存器 A 的 \"允许读取\"\n\nThis allows us to use the data line to pass in the value stored in register A.\n这样就可以把寄存器 A 里的值，传给 RAM\n\nCongrats, we just ran our first computer program!\n恭喜，我们刚运行了第一个电脑程序！\n\nIt loaded two values from memory, added them together,\n它从内存中加载两个值，相加，然后把结果放回内存\n\nand then saved that sum back into memory.\n它从内存中加载两个值，相加，然后把结果放回内存\n\nOf course, by me talking you through the individual steps,\n刚刚是我一步步来讲的,\n\nI was manually transitioning the CPU through its fetch, decode and execute phases.\n我们人工切换 CPU 的状态 \"取指令→解码→执行\"\n\nBut there isn't a mini Carrie Anne inside of every computer.\n但不是每台电脑里都有一个迷你 Carrie Anne\n\nSo the responsibility of keeping the CPU ticking along falls to a component called the clock.\n其实是 \"时钟\" 来负责管理 CPU 的节奏\n\nAs it's name suggests, the clock triggers an electrical signal at a precise and regular interval.\n时钟以精确的间隔  触发电信号\n\nIts signal is used by the Control Unit to advance the internal operation of the CPU,\n控制单元会用这个信号，推进 CPU 的内部操作\n\nkeeping everything in lock-step\n确保一切按步骤进行\n\n- like the dude on a Roman galley drumming rhythmically at the front,\n- 就像罗马帆船的船头，有一个人负责按节奏的击鼓,\n\nkeeping all the rowers synchronized... or a metronome.\n让所有划船的人同步... 就像节拍器一样\n\nOf course you can't go too fast,\n节奏不能太快\n\nbecause even electricity takes some time to travel down wires and for the signal to settle.\n因为就算是电也要一定时间来传输\n\nThe speed at which a CPU can carry out each step of the fetch-decode-execute cycle\nCPU \"取指令→解码→执行\" 的速度叫 \"时钟速度\"\n\nis called its Clock Speed.\nCPU \"取指令→解码→执行\" 的速度叫 \"时钟速度\"\n\nThis speed is measured in Hertz - a unit of frequency.\n单位是赫兹 - 赫兹是用来表示频率的单位\n\nOne Hertz means one cycle per second.\n1 赫兹代表一秒 1 个周期\n\nGiven that it took me about 6 minutes to talk you through 4 instructions\n因为我花了大概 6 分钟，给你讲了 4 条指令\n\nLOAD, LOAD, ADD and STORE\n读取→读取→相加→存储\n\nthat means I have an effective clock speed of roughly .03 Hertz.\n所以我的时钟速度大概是 0.03 赫兹\n\nAdmittedly, I'm not a great computer\n我承认我算数不快\n\nbut even someone handy with math might only be able to do one calculation in their head every second or 1 Hertz.\n但哪怕有人算数很快，最多也就是一秒一次，或 1 赫兹\n\nThe very first, single-chip CPU was the Intel 4004, a 4-bit CPU released in 1971.\n第一个单芯片 CPU 是 \"英特尔 4004\" \\N 1971 年发布的 4 位CPU\n\nIt's microarchitecture is actually pretty similar to our example CPU.\n它的微架构 很像我们之前说的 CPU\n\nDespite being the first processor of its kind,\n虽然是第一个单芯片的处理器\n\nit had a mind-blowing clock speed of 740 Kilohertz\n但它的时钟速度达到了 740 千赫兹 - 每秒 74 万次\n\n-- that's 740 thousand cycles per second.\n但它的时钟速度达到了 740 千赫兹 - 每秒 74 万次\n\nYou might think that's fast,\n你可能觉得很快\n\nbut it's nothing compared to the processors that we use today.\n但和如今的处理器相比不值一提\n\nOne megahertz is one million clock cycles per second,\n一兆赫兹是 1 秒 1 百万个时钟周期\n\nand the computer or even phone that you are watching this video on right now is no doubt a few gigahertz\n你现在看视频的电脑或手机，肯定有几千兆赫兹\n\n-- that's BILLIONs of CPU cycles every single... second.\n- 1 秒 10 亿次时钟周期\n\nAlso, you may have heard of people overclocking their computers.\n你可能听过有人会把计算机超频\n\nThis is when you modify the clock to speed up the tempo of the CPU\n意思是修改时钟速度，加快 CPU 的速度\n\n-- like when the drummer speeds up when the Roman Galley needs to ram another ship.\n- 就像罗马帆船要撞另一艘船时，鼓手会加快敲鼓速度\n\nChip makers often design CPUs with enough tolerance to handle a little bit of overclocking,\n芯片制造商经常给 CPU 留一点余地，可以接受一点超频\n\nbut too much can either overheat the CPU,\n但超频太多会让 CPU 过热\n\nor produce gobbledygook as the signals fall behind the clock.\n或产生乱码，因为信号跟不上时钟\n\nAnd although you don't hear very much about underclocking,\n你可能很少听说降频\n\nit's actually super useful.\n但降频其实很有用\n\nSometimes it's not necessary to run the processor at full speed...\n有时没必要让处理器全速运行\n\nmaybe the user has stepped away, or just not running a particularly demanding program.\n可能用户走开了，或者在跑一个性能要求较低的程序\n\nBy slowing the CPU down, you can save a lot of power,\n把 CPU 的速度降下来，可以省很多电\n\nwhich is important for computers that run on batteries, like laptops and smartphones.\n省电对用电池的设备很重要，比如笔记本和手机\n\nTo meet these needs,\n为了尽可能省电\n\nmany modern processors can increase or decrease their clock speed based on demand,\n很多现代处理器可以按需求  加快或减慢时钟速度\n\nwhich is called dynamic frequency scaling.\n这叫 \"动态调整频率\"\n\nSo, with the addition of a clock, our CPU is complete.\n加上时钟后，CPU 才是完整的.\n\nWe can now put a box around it, and make it its own component.\n现在可以放到盒子里，变成一个独立组件\n\nYup.\n对\n\nA new level of abstraction!\n一层新的抽象！\n\nRAM, as I showed you last episode,\nRAM，上集说过，是在 CPU 外面的独立组件\n\nlies outside the CPU as its own component,\nRAM，上集说过，是在 CPU 外面的独立组件\n\nand they communicate with each other using address, data and enable wires.\nCPU 和 RAM 之间 \\N 用 \"地址线\"  \"数据线\" 和 \"允许读/写线\" 进行通信\n\nAlthough the CPU we designed today is a simplified example,\n虽然今天我们设计的 CPU 是简化版的,\n\nmany of the basic mechanics we discussed are still found in modern processors.\n但我们提到的很多机制，依然存在于现代处理器里\n\nNext episode, we're going to beef up our CPU,\n下一集，我们要加强 CPU，给它扩展更多指令.\n\nextending it with more instructions as we take our first baby steps into software.\n同时开始讲软件.\n\nI'll see you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/08. 指令和程序-Instructions & Programs.ass.txt",
    "content": "Hi, I’m Carrie Anne and this is Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode, we combined an ALU, control unit, some memory, and a clock together to\n上集我们把 ALU, 控制单元, RAM, 时钟 结合在一起\n\nmake a basic, but functional Central Processing Unit – or CPU\n做了个基本，但可用的\"中央处理单元\", 简称 CPU\n\n– the beating, ticking heart of a computer.\n它是计算机的核心\n\nWe’ve done all the hard work of building many of these components from the electronic\n我们已经用电路做了很多组件.\n\ncircuits up, and now it’s time to give our CPU some actual instructions to process!\n这次我们给 CPU 一些指令来运行!\n\nThe thing that makes a CPU powerful is the fact that it is programmable –\nCPU 之所以强大，是因为它是可编程的 -\n\nif you write a different sequence of instructions, then the CPU will perform a different task.\n如果写入不同指令，就会执行不同任务\n\nSo the CPU is a piece of hardware which is controlled by easy-to-modify software!\nCPU 是一块硬件，可以被软件控制!\n\nLet’s quickly revisit the simple program that we stepped through last episode.\n我们重新看一下上集的简单程序\n\nThe computer memory looked like this.\n内存里有这些值\n\nEach address contained 8 bits of data.\n每个地址可以存 8 位数据\n\nFor our hypothetical CPU, the first four bits specified the operation code, or opcode, and\n因为我们的 CPU 是假设的，这里前4位是\"操作码\"\n\nthe second set of four bits specified an address or registers.\n后4位指定一个内存地址，或寄存器.\n\nIn memory address zero we have 0010 1110.\n内存地址 0 是 0010 1110\n\nAgain, those first four bits are our opcode which corresponds to a \"LOAD_A\" instruction.\n前 4 位代表 LOAD_A 指令\n\nThis instruction reads data from a location of memory specified in those last four bits\n意思是：把后 4 位指定的内存地址的值，放入寄存器 A\n\nof the instruction and saves it into Register A. In this case, 1110, or 14 in decimal.\n后 4 位是 1110，十进制的 14\n\nSo let’s not think of this of memory address 0 as \"0010 1110\", but rather as the instruction\n我们来把 0010 1110 看成 \"LOAD_A 14\" 指令\n\n\"LOAD_A 14\".\n我们来把 0010 1110 看成 \"LOAD_A 14\" 指令\n\nThat’s much easier to read and understand!\n这样更好理解！\n\nAnd for me to say!\n也更方便说清楚\n\nAnd we can do the same thing for the rest of the data in memory.\n可以对内存里剩下的数也这样转换.\n\nIn this case, our program is just four instructions long,\n这里，我们的程序只有4个指令\n\nand we’ve put some numbers into memory too, 3 and 14.\n还有数字 3 和 14\n\nSo now let’s step through this program:\n现在一步步看\n\nFirst is LOAD_A 14, which takes the value in address 14, which is the number 3,\n\"LOAD_A 14\" 是从地址 14 中拿到数字3，放入寄存器A\n\nand stores it into Register A.\n\"LOAD_A 14\" 是从地址 14 中拿到数字3，放入寄存器A\n\nThen we have a \"LOAD_B 15\" instruction, which takes the value in memory location 15,\n\"LOAD_B 15\" 是从地址 15 中拿到数字14，放入寄存器B\n\nwhich is the number 14, and saves it into Register B.\n\"LOAD_B 15\" 是从地址 15 中拿到数字14，放入寄存器B\n\nOkay.\n好.\n\nEasy enough.\n挺简单的！\n\nBut now we have an \"ADD\" instruction.\n下一个是 ADD 指令\n\nThis tells the processor to use the ALU to add two registers together,\n\"ADD B A\" 告诉 ALU \\N 把寄存器 B 和寄存器 A 里的数字加起来\n\nin this case, B and A are specified.\n\"ADD B A\" 告诉 ALU \\N 把寄存器 B 和寄存器 A 里的数字加起来\n\nThe ordering is important, because the resulting sum is saved into the second register that’s specified.\n（B和A的）顺序很重要，因为结果会存在第二个寄存器\n\nSo in this case, the resulting sum is saved into Register A.\n也就是寄存器 A\n\nAnd finally, our last instruction is \"STORE_A 13\", which instructs the CPU to write whatever\n最后一条指令是 \"STORE_A 13\" \\N 把寄存器 A 的值存入内存地址 13\n\nvalue is in Register A into memory location 13.\n最后一条指令是 \"STORE_A 13\" \\N 把寄存器 A 的值存入内存地址 13\n\nYesss!\n好棒！\n\nOur program adds two numbers together.\n我们把 2 个数加在了一起!\n\nThat’s about as exciting as it gets when we only have four instructions to play with.\n毕竟只有4个指令，也只能做这个了.\n\nSo let’s add some more!\n加多一些指令吧!\n\nNow we’ve got a subtract function, which like ADD, specifies two registers to operate on.\nSUB 是减法，和 ADD 一样也要 2 个寄存器来操作.\n\nWe’ve also got a fancy new instruction called JUMP.\n还有 JUMP（跳转）\n\nAs the name implies, this causes the program to \"jump\" to a new location.\n让程序跳转到新位置\n\nThis is useful if we want to change the order of instructions, or choose to skip some instructions.\n如果想改变指令顺序，或跳过一些指令，这个很实用\n\nFor example, a JUMP 0, would cause the program to go back to the beginning.\n举例, JUMP 0 可以跳回开头\n\nAt a low level, this is done by writing the value specified in the last four bits into\nJUMP 在底层的实现方式是 \\N 把指令后 4 位代表的内存地址的值\n\nthe instruction address register, overwriting the current value.\n覆盖掉 \"指令地址寄存器\" 里的值\n\nWe’ve also added a special version of JUMP called JUMP_NEGATIVE.\n还有一个特别版的 JUMP 叫 JUMP_NEGATIVE\n\n\"This only jumps the program if the ALU’s negative flag is set to true.\n它只在 ALU 的 \"负数标志\" 为真时，进行 JUMP\n\nAs we talked about in Episode 5, the negative flag is only set\n第5集讲过，算术结果为负，\"负数标志\"才是真\n\nwhen the result of an arithmetic operation is negative.\n第5集讲过，算术结果为负，\"负数标志\"才是真\n\nIf the result of the arithmetic was zero or positive, the negative flag would not be set.\n结果不是负数时, \"负数标志\"为假\n\nSo the JUMP NEGATIVE won’t jump anywhere, and the CPU will just continue on to the next instruction.\n如果是假，JUMP_NEGATIVE 就不会执行 \\N 程序照常进行\n\nOur previous program really should have looked like this to be correct,\n我们之前的例子程序，其实应该是这样，才能正确工作.\n\notherwise the CPU would have just continued on after the STORE instruction, processing all those 0’s.\n否则跑完  STORE_A 13 之后，\\N CPU 会不停运行下去，处理后面的 0\n\nBut there is no instruction with an opcode of 0, and so the computer would have crashed!\n因为 0 不是操作码，所以电脑会崩掉!\n\nIt’s important to point out here that we’re storing\n我还想指出一点，指令和数据都是存在同一个内存里的.\n\nboth instructions and data in the same memory.\n我还想指出一点，指令和数据都是存在同一个内存里的.\n\nThere is no difference fundamentally -- it’s all just binary numbers.\n它们在根本层面上毫无区别 - 都是二进制数\n\nSo the HALT instruction is really important because it allows us to separate the two.\nHALT 很重要，能区分指令和数据\n\nOkay, so let’s make our program a bit more interesting, by adding a JUMP.\n好，现在用 JUMP 让程序更有趣一些.\n\nWe’ll also modify our two starting values in memory to 1 and 1.\n我们还把内存中 3 和 14 两个数字，改成 1 和 1\n\nLets step through this program just as our CPU would.\n现在来从 CPU 的视角走一遍程序\n\nFirst, LOAD_A 14 loads the value 1 into Register A.\n首先 LOAD_A 14，把 1 存入寄存器A \\N（因为地址 14 里的值是 1）\n\nNext, LOAD_B 15 loads the value 1 into Register B.\n然后 LOAD_B 15，把 1 存入寄存器B\\N（因为地址 15 里的值也是 1）\n\nAs before, we ADD registers B and A together, with the sum going into Register A. 1+1 = 2,\n然后 ADD B A 把寄存器 B 和 A 相加 \\N 结果放到寄存器 A 里\n\nso now Register A has the value 2 in it (stored in binary of course)\n现在寄存器 A 的值是 2 \\N (当然是以二进制存的）\n\nThen the STORE instruction saves that into memory location 13.\n然后 STORE_A 13 指令，把寄存器 A 的值存入内存地址 13\n\nNow we hit a \"JUMP 2\" instruction.\n现在遇到 JUMP 2 指令\n\nThis causes the processor to overwrite the value in the instruction address register,\nCPU 会把\"指令地址寄存器\"的值，现在是 4，改成 2\n\nwhich is currently 4, with the new value, 2.\nCPU 会把\"指令地址寄存器\"的值，现在是 4，改成 2\n\nNow, on the processor’s next fetch cycle, we don’t fetch HALT,\n因此下一步不再是 HALT\n\ninstead we fetch the instruction at memory location 2, which is ADD B A.\n而是读内存地址 2 里的指令，也就是 ADD B A\n\nWe’ve jumped!\n我们跳转了!\n\nRegister A contains the value 2, and register B contains the value 1.\n寄存器 A 里是 2，寄存器 B 里是 1\n\nSo 1+2 = 3, so now Register A has the value 3.\n1+2=3，寄存器 A 变成 3\n\nWe store that into memory.\n存入内存\n\nAnd we’ve hit the JUMP again, back to ADD B A.\n又碰到 JUMP 2，又回到 ADD B A.\n\n1+3=4\n1+3=4\n\nSo now register A has the value 4.\n现在寄存器 A 是 4\n\nSee what's happening here?\n发现了吗？\n\nEvery loop, we’re adding one.\n每次循环都+1\n\nIts counting up!\n不断增多\n\nCooooool.\n酷\n\nBut notice there’s no way to ever escape.\n但没法结束啊\n\nWe’re never.. ever.. going to get to that halt instruction,\n永远不会碰到 HALT\n\nbecause we’re always going to hit that JUMP.\n总是会碰到 JUMP\n\nThis is called an infinite loop – a program that runs forever… ever… ever… ever…\n这叫无限循环 - 这个程序会永远跑下去.. 下去.. 下去.. 下去\n\never\n下去\n\nTo break the loop, we need a conditional jump.\n为了停下来，我们需要有条件的 JUMP\n\nA jump that only happens if a certain condition is met.\n只有特定条件满足了，才执行 JUMP.\n\nOur JUMP_NEGATIVE is one example of a conditional jump,\n比如 JUMP NEGATIVE 就是条件跳转的一个例子\n\nbut computers have other types too - like JUMP IF EQUAL and JUMP IF GREATER.\n还有其他类型的条件跳转，比如\\N  JUMP IF EQUAL（如果相等）\\N JUMP IF GREATER（如果更大）\n\nSo let’s make our code a little fancier and step through it.\n现在把代码弄花哨一点，再过一遍代码\n\nLike before, the program starts by loading values from memory into registers A and B.\n就像之前，程序先把内存值放入寄存器 A 和 B.\n\nIn this example, the number 11 gets loaded into Register A, and 5 gets loaded into Register B.\n寄存器 A 是 11，寄存器 B 是 5\n\nNow we subtract register B from register A. That’s 11 minus 5, which is 6,\nSUB B A，用 A 减 B，11-5=6\n\nand so 6 gets saved into Register A.\n6 存入寄存器 A\n\nNow we hit our JUMP NEGATIVE.\nJUMP NEGATIVE 出场\n\nThe last ALU result was 6.\n上一次 ALU 运算的结果是 6\n\nThat’s a positive number, so the the negative flag is false.\n是正数，所以 \"负数标志\" 是假\n\nThat means the processor does not jump.\n因此处理器不会执行 JUMP\n\nSo we continue on to the next instruction...\n继续下一条指令\n\n...which is a JUMP 2.\nJUMP 2\n\nNo conditional on this one, so we jump to instruction 2 no matter what.\nJUMP 2 没有条件，直接执行！\n\nOk, so we’re back at our SUBTRACT Register B from Register A. 6 minus 5 equals 1.\n又回到寄存器 A-B，6-5=1\n\nSo 1 gets saved into register A.\nA 变成 1\n\nNext instruction.\n下一条指令\n\nWe’re back again at our JUMP NEGATIVE.\n又是 JUMP NEGATIVE\n\n1 is also a positive number, so the CPU continues on to the JUMP 2, looping back around again\n因为 1 还是正数，因此 JUMP NEGATIVE 不会执行 \\N 来到下一条指令，JUMP 2\n\nto the SUBTRACT instruction.\n又来减一次\n\nThis time is different though.\n这次就不一样了\n\n1 minus 5 is negative 4.\n1-5=-4\n\nAnd so the ALU sets its negative flag to true for the first time.\n这次ALU的 \"负数标志\" 是真\n\nNow, when we advance to the next instruction,\n现在下一条指令\n\nJUMP_NEGATIVE 5, the CPU executes the jump to memory location 5.\nJUMP NEGATIVE 5, CPU 的执行跳到内存地址 5\n\nWe’re out of the infinite loop!\n跳出了无限循环！\n\nNow we have a ADD B to A. Negative 4 plus 5, is positive 1, and we save that into Register A.\n现在的指令是 ADD B A，-4+5=1，1 存入寄存器 A\n\nNext we have a STORE instruction that saves Register A into memory address 13.\n下一条指令  STORE_A 13，把 A 的值存入内存地址 13\n\nLastly, we hit our HALT instruction and the computer rests.\n最后碰到 HALT 指令，停下来.\n\nSo even though this program is only 7 instructions long, the CPU ended up executing 13 instructions,\n虽然程序只有 7 个指令，但 CPU 执行了 13 个指令,\n\nand that's because it looped twice internally.\n因为在内部循环了 2 次.\n\nThis code calculated the remainder if we divide 5 into 11, which is one.\n这些代码其实是算余数的，11除5余1\n\nWith a few extra lines of code, we could also keep track of how many loops we did, the count\n如果加多几行指令，我们还可以跟踪循环了多少次\n\nof which would be how many times 5 went into 11… we did two loops, so that means 5 goes\n11除5，循环2次\n\ninto 11 two times... with a remainder of 1.\n余1\n\nAnd of course this code could work for any two numbers, which we can just change in memory\n当然，我们可以用任意2个数，7和81，18和54，什么都行\n\nto whatever we want: 7 and 81, 18 and 54, it doesn’t matter\n当然，我们可以用任意2个数，7和81，18和54，什么都行\n\n-- that’s the power of software!\n这就是软件的强大之处\n\nSoftware also allowed us to do something our hardware could not.\n软件还让我们做到硬件做不到的事\n\nRemember, our ALU didn’t have the functionality to divide two numbers,\nALU 可没有除法功能\n\ninstead it’s the program we made that gave us that functionality.\n是程序给了我们这个功能.\n\nAnd then other programs can use our divide program to do even fancier things.\n别的程序也可以用我们的除法程序，来做其他事情\n\nAnd you know what that means.\n这意味着  一层新抽象！\n\nNew levels of abstraction!\n这意味着  一层新抽象！\n\nSo, our hypothetical CPU is very basic – all of its instructions are 8 bits long,\n我们这里假设的 CPU 很基础，所有指令都是 8 位,\n\nwith the opcode occupying only the first four bits.\n操作码只占了前面 4 位\n\nSo even if we used every combination of 4 bits, our CPU would only be able to support\n即便用尽 4 位，也只能代表 16 个指令\n\na maximum of 16 different instructions.\n即便用尽 4 位，也只能代表 16 个指令\n\nOn top of that, several of our instructions used the last 4 bits to specify a memory location.\n而且我们有几条指令，是用后 4 位来指定内存地址\n\nBut again, 4 bits can only encode 16 different values,\n因为 4 位最多只能表示 16 个值，\n\nmeaning we can address a maximum of 16 memory locations - that’s not a lot to work with.\n所以我们只能操作 16 个地址，这可不多.\n\nFor example, we couldn’t even JUMP to location 17,\n我们甚至不能 JUMP 17\n\nbecause we literally can’t fit the number 17 into 4 bits.\n因为 4 位二进制无法表示数字 17\n\nFor this reason, real, modern CPUs use two strategies.\n因此，真正的现代 CPU 用两种策略\n\nThe most straightforward approach is just to have bigger instructions, with more bits,\n最直接的方法是用更多位来代表指令，比如 32 位或 64 位\n\nlike 32 or 64 bits.\n最直接的方法是用更多位来代表指令，比如 32 位或 64 位\n\nThis is called the instruction length.\n这叫 指令长度\n\nUnsurprisingly.\n毫不意外\n\nThe second approach is to use variable length instructions.\n第二个策略是 \"可变指令长度\"\n\nFor example, imagine a CPU that uses 8 bit opcodes.\n举个例子，比如某个 CPU 用 8 位长度的操作码\n\nWhen the CPU sees an instruction that needs no extra values, like the HALT instruction,\n如果看到 HALT 指令，HALT 不需要额外数据\n\nit can just execute it immediately.\n那么会马上执行.\n\nHowever, if it sees something like a JUMP instruction, it knows it must also fetch\n如果看到 JUMP，它得知道位置值\n\nthe address to jump to, which is saved immediately behind the JUMP instruction in memory.\n这个值在 JUMP 的后面\n\nThis is called, logically enough, an Immediate Value.\n这叫 \"立即值\"\n\nIn such processor designs, instructions can be any number of bytes long,\n这样设计，指令可以是任意长度\n\nwhich makes the fetch cycle of the CPU a tad more complicated.\n但会让读取阶段复杂一点点\n\nNow, our example CPU and instruction set is hypothetical,\n要说明的是，我们拿来举例的 CPU 和指令集都是假设的,\n\ndesigned to illustrate key working principles.\n是为了展示核心原理\n\nSo I want to leave you with a real CPU example.\n所以我们来看个真的 CPU 例子.\n\nIn 1971, Intel released the 4004 processor.\n1971年，英特尔发布了 4004 处理器.\n\nIt was the first CPU put all into a single chip\n这是第一次把 CPU 做成一个芯片  \\N 给后来的英特尔处理器打下了基础\n\nand paved the path to the intel processors we know and love today.\n这是第一次把 CPU 做成一个芯片  \\N 给后来的英特尔处理器打下了基础\n\nIt supported 46 instructions, shown here.\n它支持 46 个指令\n\nWhich was enough to build an entire working computer.\n足够做一台能用的电脑\n\nAnd it used many of the instructions we’ve talked about like JUMP ADD SUBTRACT and LOAD.\n它用了很多我们说过的指令，比如 JUMP ADD SUB LOAD\n\nIt also uses 8-bit immediate values, like we just talked about, for things like JUMPs,\n它也用 8 位的\"立即值\"来执行 JUMP, 以表示更多内存地址.\n\nin order to address more memory.\n它也用 8 位的\"立即值\"来执行 JUMP, 以表示更多内存地址.\n\nAnd processors have come a long way since 1971.\n处理器从 1971 年到现在发展巨大.\n\nA modern computer processor, like an Intel Core i7, has thousands of different instructions\n现代 CPU, 比如英特尔酷睿 i7, 有上千个指令和指令变种\n\nand instruction variants, ranging from one to fifteen bytes long.\n长度从1到15个字节.\n\nFor example, there’s over a dozens different opcodes just for variants of ADD!\n举例，光 ADD 指令就有很多变种!\n\nAnd this huge growth in instruction set size is due in large part to extra bells and whistles\n指令越来越多，是因为给 CPU 设计了越来越多功能\n\nthat have been added to processor designs overtime, which we’ll talk about next episode.\n下集我们会讲\n\nSee you next week!\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/09. 高级CPU设计-Advanced CPU Designs.ass.txt",
    "content": "Hi, I’m Carrie Anne and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nAs we’ve discussed throughout the series, computers have come a long way from mechanical devices\n随着本系列进展，我们知道计算机进步巨大\n\ncapable of maybe one calculation per second,\n从 1 秒 1 次运算，到现在有千赫甚至兆赫的CPU\n\nto CPUs running at kilohertz and megahertz speeds.\n从 1 秒 1 次运算，到现在有千赫甚至兆赫的CPU\n\nThe device you’re watching this video on right now is almost certainly running at Gigahertz speeds\n你现在看视频的设备八成也有 GHz 速度\n\n- that’s billions of instructions executed every second.\n1 秒十亿条指令\n\nWhich, trust me, is a lot of computation!\n这是很大的计算量！\n\nIn the early days of electronic computing, processors were typically made faster by\n早期计算机的提速方式是  减少晶体管的切换时间.\n\nimproving the switching time of the transistors inside the chip\n早期计算机的提速方式是  减少晶体管的切换时间.\n\n- the ones that make up all the logic gates, ALUs\n晶体管组成了逻辑门，ALU 以及前几集的其他组件\n\nand other stuff we’ve talked about over the past few episodes.\n晶体管组成了逻辑门，ALU 以及前几集的其他组件\n\nBut just making transistors faster and more efficient only went so far, so processor designers\n但这种提速方法最终会碰到瓶颈，所以处理器厂商\n\nhave developed various techniques to boost performance allowing not only simple instructions\n发明各种新技术来提升性能，不但让简单指令运行更快\n\nto run fast, but also performing much more sophisticated operations.\n也让它能进行更复杂的运算\n\nLast episode, we created a small program for our CPU that allowed us to divide two numbers.\n上集我们写了个做除法的程序，给 CPU 执行\n\nWe did this by doing many subtractions in a row... so, for example, 16 divided by 4\n方法是做一连串减法，比如16除4 会变成\n\ncould be broken down into the smaller problem of 16 minus 4, minus 4, minus 4, minus 4.\n16-4 -4 -4 -4\n\nWhen we hit zero, or a negative number, we knew that we we’re done.\n碰到 0 或负数才停下.\n\nBut this approach gobbles up a lot of clock cycles, and isn’t particularly efficient.\n但这种方法要多个时钟周期，很低效\n\nSo most computer processors today have divide as one of the instructions\n所以现代 CPU 直接在硬件层面设计了除法 \\N 可以直接给 ALU 除法指令\n\nthat the ALU can perform in hardware.\n所以现代 CPU 直接在硬件层面设计了除法 \\N 可以直接给 ALU 除法指令\n\nOf course, this extra circuitry makes the ALU bigger and more complicated to design,\n这让 ALU 更大也更复杂一些\n\nbut also more capable - a complexity-for-speed tradeoff that\n但也更厉害 - \\N  复杂度 vs 速度 的平衡在计算机发展史上经常出现\n\nhas been made many times in computing history.\n但也更厉害 - \\N  复杂度 vs 速度 的平衡在计算机发展史上经常出现\n\nFor instance, modern computer processors now have special circuits for things like\n举例，现代处理器有专门电路来处理 \\N 图形操作, 解码压缩视频, 加密文档 等等\n\ngraphics operations, decoding compressed video, and encrypting files\n举例，现代处理器有专门电路来处理 \\N 图形操作, 解码压缩视频, 加密文档 等等\n\nall of which are operations that would take many many many clock cycles to perform with standard operations.\n如果用标准操作来实现，要很多个时钟周期.\n\nYou may have even heard of processors with MMX, 3DNow!, or SSE.\n你可能听过某些处理器有 MMX, 3DNOW, SSE\n\nThese are processors with additional, fancy circuits that allow them to\n它们有额外电路做更复杂的操作\n\nexecute additional fancy instructions - for things like gaming and encryption.\n用于游戏和加密等场景\n\nThese extensions to the instruction set have grown, and grown over time, and once people\n指令不断增加，人们一旦习惯了它的便利就很难删掉\n\nhave written programs to take advantage of them, it’s hard to remove them.\n指令不断增加，人们一旦习惯了它的便利就很难删掉\n\nSo instruction sets tend to keep getting larger and larger keeping all the old opcodes around for backwards compatibility.\n所以为了兼容旧指令集，指令数量越来越多\n\nThe Intel 4004, the first truly integrated CPU, had 46 instructions\n英特尔 4004，第一个集成CPU，有 46 条指令\n\n- which was enough to build a fully functional computer.\n足够做一台能用的计算机\n\nBut a modern computer processor has thousands of different instructions,\n但现代处理器有上千条指令，有各种巧妙复杂的电路\n\nwhich utilize all sorts of clever and complex internal circuitry.\n但现代处理器有上千条指令，有各种巧妙复杂的电路\n\nNow, high clock speeds and fancy instruction sets lead to another problem\n超高的时钟速度带来另一个问题\n\n- getting data in and out of the CPU quickly enough.\n- 如何快速传递数据给 CPU\n\nIt’s like having a powerful steam locomotive, but no way to shovel in coal fast enough.\n就像有强大的蒸汽机  但无法快速加煤\n\nIn this case, the bottleneck is RAM.\nRAM 成了瓶颈\n\nRAM is typically a memory module that lies outside the CPU.\nRAM 是 CPU 之外的独立组件\n\nThis means that data has to be transmitted to and from RAM along sets of data wires,\n意味着数据要用线来传递，叫\"总线\"\n\ncalled a bus.\n意味着数据要用线来传递，叫\"总线\"\n\nThis bus might only be a few centimeters long,\n总线可能只有几厘米\n\nand remember those electrical signals are traveling near the speed of light,\n别忘了电信号的传输接近光速\n\nbut when you are operating at gigahertz speeds\n但 CPU 每秒可以处理上亿条指令\n\n– that’s billionths of a second – even this small delay starts to become problematic.\n很小的延迟也会造成问题\n\nIt also takes time for RAM itself to lookup the address, retrieve the data\nRAM 还需要时间找地址 \\N 取数据，配置，输出数据\n\nand configure itself for output.\nRAM 还需要时间找地址 \\N 取数据，配置，输出数据\n\nSo a “load from RAM” instruction might take dozens of clock cycles to complete, and during\n一条\"从内存读数据\"的指令可能要多个时钟周期\n\nthis time the processor is just sitting there idly waiting for the data.\nCPU 空等数据\n\nOne solution is to put a little piece of RAM right on the CPU -- called a cache.\n解决延迟的方法之一是 \\N 给 CPU 加一点 RAM - 叫\"缓存\"\n\nThere isn’t a lot of space on a processor’s chip,\n因为处理器里空间不大，所以缓存一般只有 KB 或 MB\n\nso most caches are just kilobytes or maybe megabytes in size,\n因为处理器里空间不大，所以缓存一般只有 KB 或 MB\n\nwhere RAM is usually gigabytes.\n而 RAM 都是 GB 起步\n\nHaving a cache speeds things up in a clever way.\n缓存提高了速度\n\nWhen the CPU requests a memory location from RAM, the RAM can transmit\nCPU 从 RAM 拿数据时 \\N RAM 不用传一个，可以传一批\n\nnot just one single value, but a whole block of data.\nCPU 从 RAM 拿数据时 \\N RAM 不用传一个，可以传一批\n\nThis takes only a little bit more time,\n虽然花的时间久一点，但数据可以存在缓存\n\nbut it allows this data block to be saved into the cache.\n虽然花的时间久一点，但数据可以存在缓存\n\nThis tends to be really useful because computer data is often arranged and processed sequentially.\n这很实用，因为数据常常是一个个按顺序处理\n\nFor example, let say the processor is totalling up daily sales for a restaurant.\n举个例子，算餐厅的当日收入\n\nIt starts by fetching the first transaction from RAM at memory location 100.\n先取 RAM 地址 100 的交易额\n\nThe RAM, instead of sending back just that one value, sends a block of data, from memory\nRAM 与其只给1个值，直接给一批值\n\nlocation 100 through 200, which are then all copied into the cache.\n把地址100到200都复制到缓存\n\nNow, when the processor requests the next transaction to add to its running total, the\n当处理器要下一个交易额时\n\nvalue at address 101, the cache will say “Oh, I’ve already got that value right here,\n地址 101，缓存会说：\"我已经有了，现在就给你\"\n\nso I can give it to you right away!”\n地址 101，缓存会说：\"我已经有了，现在就给你\"\n\nAnd there’s no need to go all the way to RAM.\n不用去 RAM 取数据\n\nBecause the cache is so close to the processor,\n因为缓存离 CPU 近, 一个时钟周期就能给数据 - CPU 不用空等！\n\nit can typically provide the data in a single clock cycle -- no waiting required.\n因为缓存离 CPU 近, 一个时钟周期就能给数据 - CPU 不用空等！\n\nThis speeds things up tremendously over having to go back and forth to RAM every single time.\n比反复去 RAM 拿数据快得多\n\nWhen data requested in RAM is already stored in the cache like this it’s called a\n如果想要的数据已经在缓存，叫 缓存命中\n\ncache hit,\n如果想要的数据已经在缓存，叫 缓存命中\n\nand if the data requested isn’t in the cache, so you have to go to RAM, it’s a called\n如果想要的数据不在缓存，叫 缓存未命中\n\na cache miss.\n如果想要的数据不在缓存，叫 缓存未命中\n\nThe cache can also be used like a scratch space,\n缓存也可以当临时空间，存一些中间值，适合长/复杂的运算\n\nstoring intermediate values when performing a longer, or more complicated calculation.\n缓存也可以当临时空间，存一些中间值，适合长/复杂的运算\n\nContinuing our restaurant example, let’s say the processor has finished totalling up\n继续餐馆的例子，假设 CPU 算完了一天的销售额\n\nall of the sales for the day, and wants to store the result in memory address 150.\n想把结果存到地址 150\n\nLike before, instead of going back all the way to RAM to save that value,\n就像之前，数据不是直接存到 RAM\n\nit can be stored in cached copy, which is faster to save to,\n而是存在缓存，这样不但存起来快一些\n\nand also faster to access later if more calculations are needed.\n如果还要接着算，取值也快一些\n\nBut this introduces an interesting problem -\n但这样带来了一个有趣的问题\n\n- the cache’s copy of the data is now different to the real version stored in RAM.\n缓存和 RAM 不一致了.\n\nThis mismatch has to be recorded, so that at some point everything can get synced up.\n这种不一致必须记录下来，之后要同步\n\nFor this purpose, the cache has a special flag for each block of memory it stores, called\n因此缓存里每块空间  有一个特殊标记\n\nthe dirty bit\n叫 \"脏位\"\n\n-- which might just be the best term computer scientists have ever invented.\n- 这可能是计算机科学家取的最贴切的名字\n\nMost often this synchronization happens when the cache is full,\n同步一般发生在 当缓存满了而 CPU 又要缓存时\n\nbut a new block of memory is being requested by the processor.\n同步一般发生在 当缓存满了而 CPU 又要缓存时\n\nBefore the cache erases the old block to free up space, it checks its dirty bit,\n在清理缓存腾出空间之前，会先检查 \"脏位\"\n\nand if it’s dirty, the old block of data is written back to RAM before loading in the new block.\n如果是\"脏\"的, 在加载新内容之前, 会把数据写回 RAM\n\nAnother trick to boost cpu performance is called instruction pipelining.\n另一种提升性能的方法叫 \"指令流水线\"\n\nImagine you have to wash an entire hotel’s worth of sheets,\n想象下你要洗一整个酒店的床单\n\nbut you’ve only got one washing machine and one dryer.\n但只有 1 个洗衣机, 1 个干燥机\n\nOne option is to do it all sequentially: put a batch of sheets in the washer\n选择1：按顺序来，放洗衣机等 30 分钟洗完\n\nand wait 30 minutes for it to finish.\n选择1：按顺序来，放洗衣机等 30 分钟洗完\n\nThen take the wet sheets out and put them in the dryer and wait another 30 minutes for that to finish.\n然后拿出湿床单，放进干燥机等 30 分钟烘干\n\nThis allows you to do one batch of sheets every hour.\n这样1小时洗一批\n\nSide note: if you have a dryer that can dry a load of laundry in 30 minutes,\n另外一说：如果你有 30 分钟就能烘干的干燥机\n\nPlease tell me the brand and model in the comments, because I’m living with 90 minute dry times, minimum.\n请留言告诉我是什么牌子，我的至少要 90 分钟.\n\nBut, even with this magic clothes dryer,\n即使有这样的神奇干燥机,  \\N 我们可以用\"并行处理\"进一步提高效率\n\nyou can speed things up even more if you parallelize your operation.\n即使有这样的神奇干燥机,  \\N 我们可以用\"并行处理\"进一步提高效率\n\nAs before, you start off putting one batch of sheets in the washer.\n就像之前，先放一批床单到洗衣机\n\nYou wait 30 minutes for it to finish.\n等 30 分钟洗完\n\nThen you take the wet sheets out and put them in the dryer.\n然后把湿床单放进干燥机\n\nBut this time, instead of just waiting 30 minutes for the dryer to finish,\n但这次，与其干等 30 分钟烘干，\\N 可以放另一批进洗衣机\n\nyou simultaneously start another load in the washing machine.\n但这次，与其干等 30 分钟烘干，\\N 可以放另一批进洗衣机\n\nNow you’ve got both machines going at once.\n让两台机器同时工作\n\nWait 30 minutes, and one batch is now done, one batch is half done,\n30 分钟后，一批床单完成, 另一批完成一半\n\nand another is ready to go in.\n另一批准备开始\n\nThis effectively doubles your throughput.\n效率x2！\n\nProcessor designs can apply the same idea.\n处理器也可以这样设计\n\nIn episode 7, our example processor performed the fetch-decode-execute cycle sequentially\n第7集，我们演示了 CPU 按序处理\n\nand in a continuous loop: Fetch-decode-execute, fetch-decode-execute, fetch-decode-execute, and so on\n取指 → 解码 → 执行, 不断重复\n\nThis meant our design required three clock cycles to execute one instruction.\n这种设计，三个时钟周期执行 1 条指令\n\nBut each of these stages uses a different part of the CPU,\n但因为每个阶段用的是 CPU 的不同部分\n\nmeaning there is an opportunity to parallelize!\n意味着可以并行处理！\n\nWhile one instruction is getting executed, the next instruction could be getting decoded,\n\"执行\"一个指令时，同时\"解码\"下一个指令\n\nand the instruction beyond that fetched from memory.\n\"读取\"下下个指令\n\nAll of these separate processes can overlap\n不同任务重叠进行，同时用上 CPU 里所有部分.\n\nso that all parts of the CPU are active at any given time.\n不同任务重叠进行，同时用上 CPU 里所有部分.\n\nIn this pipelined design, an instruction is executed every single clock cycle\n这样的流水线  每个时钟周期执行1个指令\n\nwhich triples the throughput.\n吞吐量 x 3\n\nBut just like with caching this can lead to some tricky problems.\n和缓存一样，这也会带来一些问题\n\nA big hazard is a dependency in the instructions.\n第一个问题是 指令之间的依赖关系\n\nFor example, you might fetch something that the currently executing instruction is just about to modify,\n举个例子，你在读某个数据 \\N 而正在执行的指令会改这个数据\n\nwhich means you’ll end up with the old value in the pipeline.\n也就是说拿的是旧数据\n\nTo compensate for this, pipelined processors have to look ahead for data dependencies,\n因此流水线处理器  要先弄清数据依赖性\n\nand if necessary, stall their pipelines to avoid problems.\n必要时停止流水线，避免出问题\n\nHigh end processors, like those found in laptops and smartphones,\n高端 CPU，比如笔记本和手机里那种\n\ngo one step further and can dynamically reorder instructions with dependencies\n会更进一步，动态排序 有依赖关系的指令\n\nin order to minimize stalls and keep the pipeline moving,\n最小化流水线的停工时间\n\nwhich is called out-of-order execution.\n这叫 \"乱序执行\"\n\nAs you might imagine, the circuits that figure this all out are incredibly complicated.\n和你猜的一样，这种电路非常复杂\n\nNonetheless, pipelining is tremendously effective and almost all processors implement it today.\n但因为非常高效，几乎所有现代处理器都有流水线\n\nAnother big hazard are conditional jump instructions -- we talked about one example, a JUMP NEGATIVE,last episode.\n第二个问题是 \"条件跳转\"，比如上集的 JUMP NEGATIVE\n\nThese instructions can change the execution flow of a program depending on a value.\n这些指令会改变程序的执行流\n\nA simple pipelined processor will perform a long stall when it sees a jump instruction,\n简单的流水线处理器，看到 JUMP 指令会停一会儿 \\N 等待条件值确定下来\n\nwaiting for the value to be finalized.\n简单的流水线处理器，看到 JUMP 指令会停一会儿 \\N 等待条件值确定下来\n\nOnly once the jump outcome is known, does the processor start refilling its pipeline.\n一旦 JUMP 的结果出了，处理器就继续流水线\n\nBut, this can produce long delays, so high-end processors have some tricks to deal with this problem too.\n因为空等会造成延迟，所以高端处理器会用一些技巧\n\nImagine an upcoming jump instruction as a fork in a road - a branch.\n可以把 JUMP 想成是 \"岔路口\"\n\nAdvanced CPUs guess which way they are going to go, and start filling their pipeline with\n高端 CPU 会猜哪条路的可能性大一些\n\ninstructions based off that guess – a technique called speculative execution.\n然后提前把指令放进流水线，这叫 \"推测执行\"\n\nWhen the jump instruction is finally resolved, if the CPU guessed correctly,\n当 JUMP 的结果出了，如果 CPU 猜对了\n\nthen the pipeline is already full of the correct instructions and it can motor along without delay.\n流水线已经塞满正确指令，可以马上运行\n\nHowever, if the CPU guessed wrong, it has to discard all its speculative results and\n如果 CPU 猜错了，就要清空流水线\n\nperform a pipeline flush - sort of like when you miss a turn and have to do a u-turn to\n就像走错路掉头\n\nget back on route, and stop your GPS’s insistent shouting.\n让 GPS 不要再！叫！了！\n\nTo minimize the effects of these flushes, CPU manufacturers have developed sophisticated\n为了尽可能减少清空流水线的次数，CPU 厂商开发了复杂的方法\n\nways to guess which way branches will go, called branch prediction.\n来猜测哪条分支更有可能，叫\"分支预测\"\n\nInstead of being a 50/50 guess, today’s processors can often guess with over 90% accuracy!\n现代 CPU 的正确率超过 90%\n\nIn an ideal case, pipelining lets you complete one instruction every single clock cycle,\n理想情况下，流水线一个时钟周期完成 1 个指令\n\nbut then superscalar processors came along\n然后\"超标量处理器\"出现了，一个时钟周期完成多个指令\n\nwhich can execute more than one instruction per clock cycle.\n然后\"超标量处理器\"出现了，一个时钟周期完成多个指令\n\nDuring the execute phase even in a pipelined design,\n即便有流水线设计，在指令执行阶段\n\nwhole areas of the processor might be totally idle.\n处理器里有些区域还是可能会空闲\n\nFor example, while executing an instruction that fetches a value from memory,\n比如，执行一个 \"从内存取值\" 指令期间\n\nthe ALU is just going to be sitting there, not doing a thing.\nALU 会闲置\n\nSo why not fetch-and-decode several instructions at once, and whenever possible, execute instructions\n所以一次性处理多条指令（取指令+解码） 会更好.\n\nthat require different parts of the CPU all at the same time\n如果多条指令要 ALU 的不同部分，就多条同时执行\n\nBut we can take this one step further and add duplicate circuitry\n我们可以再进一步，加多几个相同的电路 \\N 执行出现频次很高的指令\n\nfor popular instructions.\n我们可以再进一步，加多几个相同的电路 \\N 执行出现频次很高的指令\n\nFor example, many processors will have four, eight or more identical ALUs,\n举例，很多 CPU 有四个, 八个甚至更多 完全相同的ALU\n\nso they can execute many mathematical instructions all in parallel!\n可以同时执行多个数学运算\n\nOk, the techniques we’ve discussed so far primarily optimize the execution throughput\n好了，目前说过的方法，都是优化 1 个指令流的吞吐量\n\nof a single stream of instructions,\n好了，目前说过的方法，都是优化 1 个指令流的吞吐量\n\nbut another way to increase performance is to run several streams of instructions at once\n另一个提升性能的方法是 同时运行多个指令流\n\nwith multi-core processors.\n用多核处理器\n\nYou might have heard of dual core or quad core processors.\n你应该听过双核或四核处理器\n\nThis means there are multiple independent processing units inside of a single CPU chip.\n意思是一个 CPU 芯片里，有多个独立处理单元\n\nIn many ways, this is very much like having multiple separate CPUs,\n很像是有多个独立 CPU\n\nbut because they’re tightly integrated, they can share some resources,\n但因为它们整合紧密，可以共享一些资源\n\nlike cache, allowing the cores to work together on shared computations.\n比如缓存，使得多核可以合作运算\n\nBut, when more cores just isn’t enough, you can build computers with multiple independent CPUs!\n但多核不够时，可以用多个 CPU\n\nHigh end computers, like the servers streaming this video from YouTube’s datacenter, often\n高端计算机，比如现在给你传视频的 Youtube 服务器\n\nneed the extra horsepower to keep it silky smooth for the hundreds of people watching simultaneously.\n需要更多马力，让上百人能同时流畅观看\n\nTwo- and four-processor configuration are the most common right now,\n2个或4个CPU是最常见的\n\nbut every now and again even that much processing power isn’t enough.\n但有时人们有更高的性能要求\n\nSo we humans get extra ambitious and build ourselves a supercomputer!\n所以造了超级计算机！\n\nIf you’re looking to do some really monster calculations\n如果要做怪兽级运算\n\n– like simulating the formation of the universe - you’ll need some pretty serious compute power.\n比如模拟宇宙形成，你需要强大的计算能力\n\nA few extra processors in a desktop computer just isn’t going to cut it.\n给普通台式机加几个 CPU 没什么用\n\nYou’re going to need a lot of processors.\n你需要很多处理器！\n\nNo.. no... even more than that.\n不…不…还要更多\n\nA lot more!\n更多\n\nWhen this video was made, the world’s fastest computer was located in\n截止至视频发布，世上最快的计算机在\n\nThe National Supercomputing Center in Wuxi, China.\n中国无锡的国家超算中心\n\nThe Sunway TaihuLight contains a brain-melting 40,960 CPUs, each with 256 cores!\n神威·太湖之光有 40960 个CPU，每个 CPU 有 256 个核心\n\nThats over ten million cores in total... and each one of those cores runs at 1.45 gigahertz.\n总共超过1千万个核心，每个核心的频率是 1.45GHz\n\nIn total, this machine can process 93 Quadrillion -- that’s 93 million-billions\n每秒可以进行 9.3 亿亿次浮点数运算\n\nfloating point math operations per second, knows as FLOPS.\n也叫 每秒浮点运算次数 (FLOPS)\n\nAnd trust me, that’s a lot of FLOPS!!\n相信我  这个速度很可怕\n\nNo word on whether it can run Crysis at max settings, but I suspect it might.\n没人试过跑最高画质的《孤岛危机》但我估计没问题\n\nSo long story short, not only have computer processors gotten a lot faster over the years,\n长话短说，这些年处理器不但大大提高了速度\n\nbut also a lot more sophisticated, employing all sorts of clever tricks to squeeze out\n而且也变得更复杂，用各种技巧\n\nmore and more computation per clock cycle.\n榨干每个时钟周期 做尽可能多运算\n\nOur job is to wield that incredible processing power to do cool and useful things.\n我们的任务是利用这些运算能力，做又酷又实用的事\n\nThat’s the essence of programming, which we’ll start discussing next episode.\n编程就是为了这个，我们下集说\n\nSee you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/10. 早期的编程方式-Early Programming.ass.txt",
    "content": "Hi, I'm Carrie Anne and welcome to Crash Course Computer Science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the last few episodes,\n前几集我们把重点放在计算机的原理\n\nWe've talked a lot about the mechanics of how computers work.\n前几集我们把重点放在计算机的原理\n\nHow they use complex circuits to save and retrieve values from memory,\n怎么从内存读写数据，执行操作\n\nand perform operations on those values\n怎么从内存读写数据，执行操作\n\nlike adding two numbers together.\n比如把两个数字加在一起\n\nWe've even briefly talked about sequences of operations,\n还简单讲了下指令的执行，也就是计算机程序\n\nwhich is a computer program\n还简单讲了下指令的执行，也就是计算机程序\n\nWhat we haven't talked about is how a program gets into a computer?\n但我们还没讲的是：程序如何\"进入\"计算机\n\nYou might remember in episode 7 and 8 ,\n你应该记得在第 7, 8 集，我们一步步讲了例子程序\n\nwe step through some simple example programs for the CPU that we had created\n你应该记得在第 7, 8 集，我们一步步讲了例子程序\n\nFor simplicity, we just waved our hands and said that the program was already magically in memory\n当时为了简单，我们假设程序已经魔法般在内存里了\n\nBut in reality, programs have to be loaded into a computer's memory.\n但事实是，程序需要加载进内存\n\nIt's not magic. It's computer science\n这不是魔法，是计算机科学！\n\nThe need to program machines existed way before the development of computers.\n给机器编程这个需求，早在计算机出现之前就有了\n\nThe most famous example of this was in textile manufacturing\n最著名的例子来自纺织业\n\nIf you just wanted to weave a big red tablecloth\n如果你只想织一块红色大桌布\n\nYou could simply feed red thread into a loom and let it run\n可以直接放红线进织布机\n\nWhat about if you wanted the cloth to have a pattern like stripes or plaid?\n但如果想要图案怎么办? 比如条纹或者方格\n\nWorkers would have to periodically reconfigure the loom as dictated by the pattern,\n工人要每隔一会儿 调整一次织布机\n\nbut this was labor intensive which made patterned fabrics expensive.\n因为非常消耗劳动力，所以图案纺织品很贵\n\nThe presence or absence of a hole in the card determined if a specific thread was held high or low in the loom\n特定位置有没有穿孔，决定了线是高是低\n\nSuch as the cross thread, called the weft,  passed above or below the thread\n横线是从上/从下穿过\n\nTo vary the pattern across rows these punch cards were arranged in long chains\n为了让每行图案不同，纸卡连成长条\n\nForming a sequence of commands for the loom.\n形成连续指令\n\nSound familiar?\n听起来很熟？\n\nMany consider Jacquard loom to be one of the earliest forms of programming.\n很多人认为雅卡尔织布机是最早的编程\n\nPunched cards, turned out to be a cheap, reliable, fairly human-readable way to store data.\n事实证明 穿孔纸卡便宜、可靠、也易懂\n\nNearly a century later,\n近一个世纪后\n\npunch cards were used to help tabulate the 1890 US census\n穿孔纸卡用于 1890 年美国人口普查\n\nwhich we talked about in episode 1\n我们在第一集提过\n\nEach card held an individual person's data.\n一张卡存一个人的信息\n\nthings like race\n比如种族\n\nmarital status\n婚姻状况\n\nnumber of children\n子女数量\n\ncountry of birth and so on\n出生国家 等等\n\nfor each demographic question\n针对每个问题，人口普查工作者会在对应位置打孔\n\na census worker would punch out a hole of the appropriate position\n针对每个问题，人口普查工作者会在对应位置打孔\n\nwhen a card was fed into the tabulating machine\n当卡片插入汇总机\n\na hole would cause the running total for that specific answer to be increased by one\n孔会让对应总和值+1\n\nin this way you could afeed the entire counties worth of people\n可以插入整个国家人口的卡片\n\nand at the end you'd have running totals for all of the questions that you ask\n在结束后得到各个总值\n\nIt is important to note here that early tabulating machines were not truly computers\n值得注意的是，早期汇总机不算计算机\n\nas they can only do one thing-tabulate\n因为它们只做一件事 - 汇总数据\n\ntheir operation was fixed and not programmable\n操作是固定的，不能编程\n\npunched cards stored data, but not a program\n穿孔纸卡存的是数据，不是程序.\n\nover the next 60 years, these business machines grew in capability\n之后60年，这些机器被加强，可以做减、乘、除\n\nAdding features to subtract multiply divide\n之后60年，这些机器被加强，可以做减、乘、除\n\nand even make simple decisions about when to perform certain operations.\n甚至可以做一些小决定，决定何时执行某指令\n\nTo trigger these functions appropriately\n为了正确执行不同计算，程序员需要某种控制面板\n\nso that different calculations could be performed, a programmer accessed a control panel\n为了正确执行不同计算，程序员需要某种控制面板\n\nthis panel was full of little sockets into which a programmer would plug cables\n面板有很多小插孔，程序员可以插电线\n\nto pass values and signals between different parts of the machine\n让机器的不同部分  互相传数据和信号\n\nfor this reason they were also called plug boards\n因此也叫 \"插线板\"\n\nUnfortunately this meant having to rewire the machine each time a different program needed to be run\n不幸的是, 这意味着 运行不同程序要重新接线\n\nAnd so by the 1920s these plug boards were made swappable\n所以到 1920 年代，控制面板变成了可拔插\n\nThis not only made programming a lot more comfortable\n让编程更方便\n\nbut also allowed for different programs be plugged into a machine\n可以给机器插入不同程序\n\nFor example one board might be wired to calculate sales tax\n比如，一个插线板算销售税，另一个算工资单\n\nWhile another helps with payroll\n比如，一个插线板算销售税，另一个算工资单\n\nBut plug boards were fiendishly complicated to program\n但给插线板编程很复杂\n\nThis tangle of wires is a program for calculating a profit loss summary using an IBM 402 accounting machine\n图中乱成一团的线  负责算盈亏总额 \\N 用于 IBM 402 核算机\n\nwhich were popular in the 1940s\n在 1940 年代这样做很流行\n\nAnd this style of plug board programming wasn't unique through electromechanical computers\n用插线板编程  不只在机电计算机流行\n\nThe world's first general-purpose electronic computer, the ENIAC, completed in 1946\n世上第一台通用电子计算机，ENIAC，完成于 1946 年\n\nused a ton of them\n用了一大堆插线板\n\nEven after a program had been completely figured out on paper\n程序在纸上设计好之后\n\nPhysically wiring up the ENIAC and getting the program to run could take upwards of three weeks\n给 ENIAC 连线，最多可能花三个星期\n\nGiven the enormous cost of these early computers, weeks of downtime simply to switch programs was unacceptable\n因为早期计算机非常昂贵 \\N 停机几个星期只为换程序  完全无法接受\n\nand the new faster more flexible way to program machines was badly needed\n人们急需更快、更灵活的新方式来编程\n\nFortunately by the late 1940s and into the 50s\n幸运的是，到 1940 年代晚期 1950 年代初\n\nelectronic memory was becoming feasible\n内存变得可行\n\nAs costs fell, memory size grew, instead of storing a program as a physical plug board of wires\n价格下降, 容量上升.  与其把程序存在插线板\n\nit became possible to store a program entirely in a computer's memory\n存在内存变得可行\n\nwhere it could be easily changed by programmers and quickly accessed by the CPU\n这样程序易于修改、方便 CPU 快速读取\n\nthese machines were called Stored-program Computers\n这类机器叫 \"存储程序计算机\"\n\nWith enough computer memory you could store not only the program you wanted to run\n如果内存足够，不仅可以存要运行的程序\n\nbut also any data your program would need\n还可以存程序需要的数据\n\nincluding new values it created along the way\n包括程序运行时产生的新数据\n\nUnifying the program and data into a single shared memory is called the Von Neumann Architecture\n程序和数据都存在一个地方，叫 \"冯诺依曼结构\"\n\nnamed after John Von Neumann\n命名自 约翰·冯·诺依曼\n\na prominent mathematician and physicist who worked on the Manhattan project and several early electronic computers\n杰出的数学家和物理学家 \\N 参与了曼哈顿计划和早期电子计算机项目\n\nand once said I am thinking about something much more important than Bombs\n他曾说：我在思考比炸弹重要得多的东西\n\nI'm thinking about computers\n计算机\n\nThe hallmarks of a Von Neumann computer are a processing unit containing an arithmetic logic unit\n冯诺依曼计算机的标志是，一个处理器(有算术逻辑单元)+\n\ndata registers and instruction register and instruction address register\n数据寄存器+指令寄存器+指令地址寄存器\n\nAnd finally a memory to store both data and instructions\n+内存（负责存数据和指令)\n\nHopefully this sounds familiar\n希望这听起来很耳熟\n\nBecause we actually built a Von Neumann computer in episode 7\n因为第7集我们造了一个冯诺依曼计算机\n\nThe very first Von Neumann Architecture Stored-program computer\n第一台冯诺依曼架构的\"储存程序计算机\"\n\nwas constructed in 1948 by the University of Manchester, nicknamed Baby.\n由曼彻斯特大学于 1948 年建造完成，绰号\"宝宝\"\n\nand even the computer you are watching this video right now\n甚至你现在看视频的计算机，也在用一样的架构\n\nuses the same architecture\n甚至你现在看视频的计算机，也在用一样的架构\n\nNow electronic computer memory is great and all\n虽然有内存很棒\n\nbut you still have to load the program and data into the computer before it can run\n但程序和数据  依然需要某种方式输入计算机\n\nand for this reason punch cards were used\n所以用穿孔纸卡\n\nLet's get to the Thought bubbles\n让我们进入  思维泡泡\n\nWell into the 1980s almost all computers have a punch card reader\n到1980年代，几乎所有的计算机都有穿孔纸卡读取器\n\nwhich could suck in a single punch card at a time\n可以吸入一张卡片，把卡片内容写进内存\n\nand write the contents of the card into the computer's memory\n可以吸入一张卡片，把卡片内容写进内存\n\nIf you load it in a stack of punch cards,\n如果放了一叠卡片，读取器会一个个写进内存\n\nthe reader would load them all into memory sequentially as a big block\n如果放了一叠卡片，读取器会一个个写进内存\n\nonce the program and data were in memory, the computer would be told to execute it\n一旦程序和数据写入完毕，电脑会开始执行\n\nOf course even simple computer programs might have hundreds of instructions\n即便简单程序也有几百条指令，要用一叠纸卡来存\n\nwhich meant that programs were stored as stacks of punch cards\n即便简单程序也有几百条指令，要用一叠纸卡来存\n\nSo if you ever have the misfortune of accidentally dropping your program on the floor\n如果不小心摔倒弄撒了\n\nit could take you hours days or even weeks to put the code back in the right order\n要花上几小时、几天、甚至几周来整理\n\nA common trick was to draw a diagonal line on the side of the card stack called striping,\n有个小技巧是  在卡片侧面画对角线\n\nso you'd have at least some clue how to get it back into the right order\n如果弄散了，整理起来会方便很多\n\nThe largest program ever punched into punch cards was the US Air Force's SAGE air defense system, completed in 1955.\n用纸卡的最大型程序 \\N 是美国空军的 SAGE 防空系统，于 1955 年完成\n\nand its peak, the project is said to have employed 20% of the world's programmers\n据称顶峰时期 雇佣了世上 20% 程序员\n\nIts main control program was stored on a whopping 62,500 punch cards\n主控制程序用了 62500 张穿孔纸卡\n\nwhich is equivalent to roughly 5 megabytes of data\n等同于大约 5MB 的数据\n\nPretty underwhelming by today's standards\n以如今的标准，不值一提\n\nAnd punch cards weren't only useful for getting data into computers\n穿孔纸卡不仅可以往计算机放数据\n\nbut also getting data out of them\n还可以取出数据\n\nAt the end of a program results could be written out of computer memory and onto punch cards by, well, punching cards\n程序运行到最后，结果可以输到纸卡上，方式嘛，当然是打孔\n\nthen this data could be analyzed by humans or loaded into a second program for additional computation\n然后人可以分析结果，或者再次放进计算机，做进一步计算\n\nThanks, thought-bubble\n谢了 思维泡泡\n\nA close cousin to punch cards was punched paper tape\n穿孔纸卡 的亲戚是纸带\n\nWhich is basically the same idea, but continuous instead of being on individual cards\n基本是一回事，只不过更连续，不是一张张卡.\n\nAnd of course we haven't talked about Hard Drives, CD-ROMs, DVDs, USB-Thumb drives and other similar goodies\n当然我们还没提硬盘, 只读光盘, DVD, U盘等等\n\nWe'll get to those more advanced types of data storage in a future episode\n以后我们会讲这些更先进的存储方法\n\nFinally in addition to plug boards and punch paper\n最后，除了插线板和穿孔纸卡\n\nthere was another common way to program and control computers in pre-1980\n在 1980 年代前，还有一种常见编程方式\n\nPanel programming\n面板编程\n\nRather than having to physically plug in cables to activate certain functions\n与其插一堆线到插线板\n\nthis could also be done with huge panels full of switches and buttons\n可以用一大堆开关和按钮，做到一样的效果\n\nAnd there were indicator lights to display the status of various functions and values in memory\n面板上有指示灯，代表各种函数的状态和内存中的值\n\nComputers of the 50s and 60s often featured huge control consoles that look like this\n50和60年代的计算机，一般都有这样巨大的控制台\n\nAlthough it was rare to input a whole program using just switches,it was possible\n很少有人只用开关来输入一整个程序，但技术上是可行的\n\nAnd early home computers made for the hobbyist market use switches extensively\n早期针对计算机爱好者的家用计算机，大量使用了开关\n\nbecause most home users couldn't afford expensive peripherals like punch card readers\n因为大多数家庭用户负担不起昂贵的外围设备 \\N 比如穿孔纸卡读取器\n\nThe first commercially successful home computer was the Altair 8800\n第一款取得商业成功的家用计算机是 Altair 8800\n\nwhich sold in two versions: Pre-assembled and the Kit\n有两种版本可以买: \\N 1. 预先装好的整机  \\N 2. 需要组装的组件\n\nthe Kit which was popular with amateur computing enthusiasts,\n计算机爱好者 喜欢买组件版\n\nsold for the then unprecedented low price are around $400 in 1975\n售价极低，在 1975 年卖 400 美元左右\n\nOr about $2,000 in 2017\n相当于 2017 年的 2000 美元\n\nTo program the 8800, you'd literally toggle the switches on the front panel\n为了给 8800 编程，你要拨动面板上的开关\n\nto enter the binary op-codes for the instruction you wanted\n输入二进制操作码\n\nThen you press the deposit button to write that value into memory\n然后按 \"存储键\" 把值存入内存\n\nThen in the next location in memory you toggle the switches again\n然后会到下一个内存位置 \\N 你可以再次拨开关，写下一个指令\n\nfor your next instruction deposit it and so on\n重复这样做\n\nWhen you finally entered your whole program into memory\n把整个程序都写入内存之后\n\nyou would toggle the switches moves back to memory address 0\n可以推动开关，回到内存地址0\n\npress the run button and watch the little lights blink\n然后按运行按钮，灯会闪烁\n\nThat was home computing in 1975, Wow.\n这就是 1975 年的家用计算机, 哇.\n\nWhether it was plug board, switches or punched paper\n不管是插线板、开关或穿孔纸卡\n\nProgramming these early computers was the realm of experts\n早期编程都是专家活\n\neither professionals who did this for living or technology enthusiasts\n不管是全职还是技术控，都要非常了解底层硬件\n\nyou needed intimate knowledge of the underlying hardware,\n不管是全职还是技术控，都要非常了解底层硬件\n\nso things like processor op-codes and register wits, to write programs\n比如 操作码, 寄存器等, 才能写程序\n\nThis meant programming was hard and tedious and even professional engineers\n所以编程很难，很烦\n\nand scientists struggled to take full advantage of what computing could offer\n哪怕工程师和科学家都无法 完全发挥计算机的能力\n\nWhat was needed was a simpler way to tell computers what to do,\n我们需要一种更简单方式  告诉计算机要做什么\n\na simpler way to write programs\n一种更简单的编程方式\n\nAnd that brings us to programming languages, which we'll talk about next episode\n这带领我们到下一个话题 - 编程语言, 我们下集会讲\n\nSee you next week\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/11. 编程语言发展史-The First Programming Languages.ass.txt",
    "content": "This episode is brought to you by CuriosityStream.\n本集由 CuriosityStream 赞助播出\n\nHi, I'm Carrie Anne and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nSo far, for most of this series, we've focused on hardware\n之前我们把重点放在硬件 - 组成计算机的物理组件\n\n-- the physical components of computing --\n之前我们把重点放在硬件 - 组成计算机的物理组件\n\nthings like: electricity and circuits, registers and RAM, ALUs and CPUs.\n比如电，电路，寄存器，RAM，ALU，CPU\n\nBut programming at the hardware level is cumbersome and inflexible,\n但在硬件层面编程非常麻烦\n\nso programmers wanted a more versatile way to program computers\n所以程序员想要一种更通用的方法编程\n\n- what you might call a \"softer\" medium.\n- 一种\"更软的\"媒介\n\nThat's right, we're going to talk about Software!\n没错，我们要讲软件！\n\nIn episode 8, we walked through a simple program for the CPU we designed.\n第 8 集我们一步步讲了一个简单程序\n\nThe very first instruction to be executed, the one at memory address 0, was 0010 1110.\n第一条指令在内存地址 0：0010 1110\n\nAs we discussed, the first four bits of an instruction is the operation code,\n之前说过，前 4 位是操作码\n\nor OPCODE for short.\n简称 OPCODE\n\nOn our hypothetical CPU, 0010 indicated a LOAD_A instruction\n对于这个假设 CPU，0010 代表 LOAD_A 指令\n\n-- which moves a value from memory into Register A.\n- 把值从内存复制到寄存器 A\n\nThe second set of four bits defines the memory location,\n后 4 位是内存地址，1110 是十进制的 14\n\nin this case, 1110, which is 14 in decimal.\n后 4 位是内存地址，1110 是十进制的 14\n\nSo what these eight numbers really mean is \"LOAD Address 14 into Register A\".\n所以这 8 位表达的意思是 \\N  \"读内存地址 14，放入寄存器 A\"\n\nWe're just using two different languages.\n只是用了两种不同语言\n\nYou can think of it like English and Morse Code.\n可以想成是英语和摩尔斯码的区别\n\n\"Hello\" and \".... . .-.. .-.. ---\" mean the same thing -- hello! --\n\"你好\" 和 \".... . .-.. .-.. ---\" 是一个意思：你好\n\nthey're just encoded differently.\n只是编码方式不同\n\nEnglish and Morse Code also have different levels of complexity.\n英语和摩尔斯码的复杂度也不同\n\nEnglish has 26 different letters in its alphabet and way more possible sounds.\n英文有 26 个字母以及各种发音\n\nMorse only has dots and dashes.\n摩尔斯码只有\"点\"和\"线\"\n\nBut, they can convey the same information, and computer languages are similar.\n但它们可以传达相同的信息，计算机语言也类似.\n\nAs we've seen, computer hardware can only handle raw, binary instructions.\n计算机能处理二进制，二进制是处理器的\"母语\"\n\nThis is the \"language\" computer processors natively speak.\n计算机能处理二进制，二进制是处理器的\"母语\"\n\nIn fact, it's the only language they're able to speak.\n事实上，它们*只能*理解二进制\n\nIt's called Machine Language or Machine Code.\n这叫\"机器语言\"或\"机器码\"\n\nIn the early days of computing, people had to write entire programs in machine code.\n在计算机早期阶段，必须用机器码写程序\n\nMore specifically, they'd first write a high-level version of a program on paper, in English,\n具体来讲，会先在纸上用英语写一个\"高层次版\"\n\nFor example \"retrieve the next sale from memory,\n举例：\"从内存取下一个销售额，\n\nthen add this to the running total for the day, week and year,\n然后加到天、周、年的总和\n\nthen calculate any tax to be added\"\n然后算税\"\n\n...and so on.\n等等...\n\nAn informal, high-level description of a program like this is called Pseudo-Code.\n这种对程序的高层次描述，叫 \"伪代码\"\n\nThen, when the program was all figured out on paper,\n在纸上写好后\n\nthey'd painstakingly expand and translate it into binary machine code by hand,\n用\"操作码表\"把伪代码转成二进制机器码\n\nusing things like opcode tables.\n用\"操作码表\"把伪代码转成二进制机器码\n\nAfter the translation was complete, the program could be fed into the computer and run.\n翻译完成后，程序可以喂入计算机并运行\n\nAs you might imagine, people quickly got fed up with this process.\n你可能猜到了，很快人们就厌烦了\n\nSo, by the late 1940s and into the 50s,\n所以在 1940~1950 年代\n\nprogrammers had developed slightly higher-level languages that were more human-readable.\n程序员开发出一种新语言， 更可读 更高层次\n\nOpcodes were given simple names, called mnemonics,\n每个操作码分配一个简单名字，叫\"助记符\"\n\nwhich were followed by operands, to form instructions.\n\"助记符\"后面紧跟数据，形成完整指令\n\nSo instead of having to write instructions as a bunch of 1's and 0's,\n与其用 1 和 0 写代码，程序员可以写\"LOAD_A 14\"\n\nprogrammers could write something like \"LOAD_A 14\".\n与其用 1 和 0 写代码，程序员可以写\"LOAD_A 14\"\n\nWe used this mnemonic in Episode 8 because it's so much easier to understand!\n我们在第 8 集用过这个助记符，因为容易理解得多！\n\nOf course, a CPU has no idea what \"LOAD_A 14\" is.\n当然，CPU 不知道 LOAD_A 14 是什么\n\nIt doesn't understand text-based language, only binary.\n它不能理解文字，只能理解二进制\n\nAnd so programmers came up with a clever trick.\n所以程序员想了一个技巧，写二进制程序来帮忙\n\nThey created reusable helper programs, in binary,\n所以程序员想了一个技巧，写二进制程序来帮忙\n\nthat read in text-based instructions,\n它可以读懂文字指令，自动转成二进制指令\n\nand assemble them into the corresponding binary instructions automatically.\n它可以读懂文字指令，自动转成二进制指令\n\nThis program is called\n这种程序叫\n\n-- you guessed it --\n你可能猜到了\n\nan Assembler.\n汇编器\n\nIt reads in a program written in an Assembly Language\n汇编器读取用\"汇编语言\"写的程序，然后转成\"机器码\"\n\nand converts it to native machine code.\n汇编器读取用\"汇编语言\"写的程序，然后转成\"机器码\"\n\n\"LOAD_A 14\" is one example of an assembly instruction.\n\"LOAD_A 14\" 是一个汇编指令的例子\n\nOver time, Assemblers gained new features that made programming even easier.\n随着时间推移，汇编器有越来越多功能，让编程更容易\n\nOne nifty feature is automatically figuring out JUMP addresses.\n其中一个功能是自动分析 JUMP 地址\n\nThis was an example program I used in episode 8:\n这里有一个第8集用过的例子：\n\nNotice how our JUMP NEGATIVE instruction jumps to address 5,\n注意, JUMP NEGATIVE 指令跳到地址 5\n\nand our regular JUMP goes to address 2.\nJUMP 指令跳到地址 2\n\nThe problem is, if we add more code to the beginning of this program,\n问题是，如果在程序开头多加一些代码\n\nall of the addresses would change.\n所有地址都会变\n\nThat's a huge pain if you ever want to update your program!\n更新程序会很痛苦！\n\nAnd so an assembler does away with raw jump addresses,\n所以汇编器不用固定跳转地址\n\nand lets you insert little labels that can be jumped to.\n而是让你插入可跳转的标签\n\nWhen this program is passed into the assembler,\n当程序被传入汇编器，汇编器会自己搞定跳转地址\n\nit does the work of figuring out all of the jump addresses.\n当程序被传入汇编器，汇编器会自己搞定跳转地址\n\nNow the programmer can focus more on programming\n程序员可以专心编程，不用管底层细节\n\nand less on the underlying mechanics under the hood\n程序员可以专心编程，不用管底层细节\n\nenabling more sophisticated things to be built by hiding unnecessary complexity.\n隐藏不必要细节来做更复杂的工作\n\nAs we've done many times in this series,\n我们又提升了一层抽象\n\nwe're once again moving up another level of abstraction.\n我们又提升了一层抽象\n\nHowever, even with nifty assembler features like auto-linking JUMPs to labels,\n然而，即使汇编器有这些厉害功能，比如自动跳转\n\nAssembly Languages are still a thin veneer over machine code.\n汇编只是修饰了一下机器码\n\nIn general, each assembly language instruction converts directly\n一般来说，一条汇编指令对应一条机器指令\n\nto a corresponding machine instruction - a one-to-one mapping -\n一般来说，一条汇编指令对应一条机器指令\n\nso it's inherently tied to the underlying hardware.\n所以汇编码和底层硬件的连接很紧密\n\nAnd the assembler still forces programmers to think about\n汇编器仍然强迫程序员思考  用什么寄存器和内存地址\n\nwhich registers and memory locations they will use.\n汇编器仍然强迫程序员思考  用什么寄存器和内存地址\n\nIf you suddenly needed an extra value,\n如果你突然要一个额外的数，可能要改很多代码\n\nyou might have to change a lot of code to fit it in.\n如果你突然要一个额外的数，可能要改很多代码\n\nLet's go to the Thought Bubble.\n让我们进入思考泡泡\n\nThis problem did not escape Dr. Grace Hopper.\n葛丽丝·霍普博士 也遇到了这个问题\n\nAs a US naval officer, she was one of the first programmers on the Harvard Mark 1 computer,\n作为美国海军军官，她是哈佛1号计算机的首批程序员之一\n\nwhich we talked about in Episode 2.\n这台机器我们在第 2 集提过\n\nThis was a colossal, electro-mechanical beast\n这台巨大机电野兽在 1944 年战时建造完成，帮助盟军作战\n\ncompleted in 1944 as part of the allied war effort.\n这台巨大机电野兽在 1944 年战时建造完成，帮助盟军作战\n\nPrograms were stored and fed into the computer on punched paper tape.\n程序写在打孔纸带上，放进计算机执行\n\nBy the way, as you can see,\n顺便一说，如果程序里有漏洞\n\nthey \"patched\" some bugs in this program\n顺便一说，如果程序里有漏洞\n\nby literally putting patches of paper over the holes on the punch tape.\n真的就 直接用胶带来补\"漏洞\"\n\nThe Mark 1's instruction set was so primitive,\nMark 1 的指令集非常原始，甚至没有 JUMP 指令\n\nthere weren't even JUMP instructions.\nMark 1 的指令集非常原始，甚至没有 JUMP 指令\n\nTo create code that repeated the same operation multiple times,\n如果代码要跑不止一次\n\nyou'd tape the two ends of the punched tape together, creating a physical loop.\n得把带子的两端连起来  做成循环\n\nIn other words, programming the Mark 1 was kind of a nightmare!\n换句话说，给 Mark 1 编程简直是噩梦！\n\nAfter the war, Hopper continued to work at the forefront of computing.\n战后，霍普继续在计算机前沿工作\n\nTo unleash the potential of computers,\n为了释放电脑的潜力\n\nshe designed a high-level programming language called \"Arithmetic Language Version 0\",\n她设计了一个高级编程语言，叫\"算术语言版本 0\"\n\nor A-0 for short.\n简称\"A-0\"\n\nAssembly languages have direct, one-to-one mapping to machine instructions.\n汇编与机器指令是一一对应的\n\nBut, a single line of a high-level programming language\n但一行高级编程语言  可能会转成几十条二进制指令\n\nmight result in dozens of instructions being executed by the CPU.\n但一行高级编程语言  可能会转成几十条二进制指令\n\nTo perform this complex translation, Hopper built the first compiler in 1952.\n为了做到这种复杂转换 \\N Hopper 在 1952 年创造了第一个编译器\n\nThis is a specialized program\n编译器专门把高级语言 转成低级语言\n\nthat transforms \"source\" code written in a programming language into a low-level language,\n编译器专门把高级语言 转成低级语言\n\nlike assembly or the binary \"machine code\" that the CPU can directly process.\n比如汇编或机器码（CPU 可以直接执行机器码）\n\nThanks, Thought Bubble.\n谢了 思想泡泡\n\nSo, despite the promise of easier programming,\n尽管\"使编程更简单\"很诱人\n\nmany people were skeptical of Hopper's idea.\n但很多人对霍普的点子持怀疑态度\n\nShe once said, \"I had a running compiler and nobody would touch it.\n她曾说\"我有能用的编译器，但没人愿意用\n\nthey carefully told me, computers could only do arithmetic;\n他们告诉我计算机只能做算术,不能运行程序\"\n\nthey could not do programs.\"\n他们告诉我计算机只能做算术,不能运行程序\"\n\nBut the idea was a good one,\n但这个点子是好的\n\nand soon many efforts were underway to craft new programming languages\n不久，很多人尝试创造新编程语言\n\n-- today there are hundreds!\n- 如今有上百种语言！\n\nSadly, there are no surviving examples of A-0 code,\n可惜的是，没有任何 A-0 的代码遗留下来\n\nso we'll use Python, a modern programming language, as an example.\n所以我们用 Python 举例（一门现代编程语言）\n\nLet's say we want to add two numbers and save that value.\n假设我们想相加两个数字，保存结果\n\nRemember, in assembly code,\n记住，如果用汇编代码\n\nwe had to fetch values from memory, deal with registers, and other low-level details.\n我们得从内存取值，和寄存器打交道，以及其他底层细节\n\nBut this same program can be written in python like so:\n但同样的程序可以用 Python 这样写：\n\nNotice how there are no registers or memory locations to deal with\n不用管寄存器或内存位置\n\n-- the compiler takes care of that stuff, abstracting away a lot of low-level and unnecessary complexity.\n- 编译器会搞定这些细节，不用管底层细节\n\nThe programmer just creates abstractions for needed memory locations, known as variables,\n程序员只需要创建 代表内存地址的抽象，叫\"变量\"\n\nand gives them names.\n给变量取名字\n\nSo now we can just take our two numbers, store them in variables we give names to\n现在可以把两个数 存在变量里\n\n-- in this case, I picked a and b but those variables could be anything -\n这里取名 A 和 B, 实际编程时你可以随便取名\n\nand then add those together, saving the result in c, another variable I created.\n然后相加两个数，把结果存在变量 C\n\nIt might be that the compiler assigns Register A under the hood to store the value in a,\n底层操作时，编译器可能把变量 A 存在寄存器 A\n\nbut I don't need to know about it!\n但我不需要知道这些！\n\nOut of sight, out of mind!\n眼不见心不烦\n\nIt was an important historical milestone,\n这是个重要历史里程碑\n\nbut A-0 and its later variants weren't widely used.\n但 A-0 和之后的版本没有广泛使用\n\nFORTRAN, derived from \"Formula Translation\",\nFORTRAN，名字来自 \"公式翻译\"\n\nwas released by IBM a few years later, in 1957,\n这门语言数年后由 IBM 在 1957 年发布\n\nand came to dominate early computer programming.\n主宰了早期计算机编程\n\nJohn Backus, the FORTRAN project director,\nFORTRAN 项目总监 John Backus 说过\n\nsaid: \"Much of my work has come from being lazy.\n\"我做的大部分工作都是因为懒\n\nI didn't like writing programs,\n我不喜欢写程序\n\nand so ... I started work on a programming system to make it easier to write programs.\"\n所以我写这门语言，让编程更容易\"\n\nYou know, typical lazy person.\n你懂的，典型的\"懒人\"\n\nThey're always creating their own programming systems.\n（白眼）创造自己的编程语言\n\nAnyway, on average, programs written in FORTRAN\n平均来说，FORTRAN 写的程序\n\nwere 20 times shorter than equivalent handwritten assembly code.\n比等同的手写汇编代码短 20 倍\n\nThen the FORTRAN Compiler would translate and expand that into native machine code.\n然后 FORTRAN 编译器会把代码转成机器码\n\nThe community was skeptical that the performance would be as good as hand written code,\n人们怀疑性能是否比得上手写代码\n\nbut the fact that programmers could write more code more quickly,\n但因为能让程序员写程序更快，所以成了一个更经济的选择\n\nmade it an easy choice economically:\n但因为能让程序员写程序更快，所以成了一个更经济的选择\n\ntrading a small increase in computation time for a significant decrease in programmer time.\n运行速度慢一点点，编程速度大大加快\n\nOf course, IBM was in the business of selling computers,\n当时 IBM 在卖计算机\n\nand so initially, FORTRAN code could only be compiled and run on IBM computers.\n因此最初 FORTRAN 代码只能跑在 IBM 计算机上\n\nAnd most programing languages and compilers of the 1950s\n1950 年代大多数编程语言和编译器\n\ncould only run on a single type of computer.\n只能运行在一种计算机上\n\nSo, if you upgraded your computer,\n如果升级电脑\n\nyou'd often have to re-write all the code too!\n可能要重写所有代码！\n\nIn response, computer experts from industry,\n因此工业界，学术界，政府的计算机专家 \\N 在 1959 年组建了一个联盟\n\nacademia and government formed a consortium in 1959\n因此工业界，学术界，政府的计算机专家 \\N 在 1959 年组建了一个联盟\n\n-- the Committee on Data Systems Languages, advised by our friend Grace Hopper --\n- 数据系统语言委员会，Grace Hopper 担任顾问\n\nto guide the development of a common programming language\n开发一种通用编程语言，可以在不同机器上通用\n\nthat could be used across different machines.\n开发一种通用编程语言，可以在不同机器上通用\n\nThe result was the high-level, easy to use,\n最后诞生了一门高级，易于使用，\n\nCommon Business-Oriented Language, or COBOL for short.\n\"普通面向商业语言\"，简称 COBOL\n\nTo deal with different underlying hardware,\n为了兼容不同底层硬件\n\neach computing architecture needed its own COBOL compiler.\n每个计算架构需要一个 COBOL 编译器\n\nBut critically, these compilers could all accept the same COBOL source code,\n最重​​要的是，这些编译器都可以接收相同 COBOL 代码\n\nno matter what computer it was run on.\n不管是什么电脑\n\nThis notion is called write once, run anywhere.\n这叫\"一次编写，到处运行\"\n\nIt's true of most programming languages today,\n如今大多数编程语言都是这样\n\na benefit of moving away from assembly and machine code,\n不必接触 CPU 特有的汇编码和机器码\n\nwhich is still CPU specific.\n不必接触 CPU 特有的汇编码和机器码\n\nThe biggest impact of all this was reducing computing's barrier to entry.\n减小了使用门槛\n\nBefore high level programming languages existed,\n在高级编程语言出现之前\n\nit was a realm exclusive to computer experts and enthusiasts.\n编程只是计算机专家和爱好者才会做的事\n\nAnd it was often their full time profession.\n而且通常是主职\n\nBut now, scientists, engineers, doctors, economists, teachers,\n但现在，科学家，工程师，医生，经济学家，教师\n\nand many others could incorporate computation into their work .\n等等，都可以把计算机用于工作\n\nThanks to these languages,\n感谢这些语言\n\ncomputing went from a cumbersome and esoteric discipline\n计算机科学从深奥学科 变成了大众化工具\n\nto a general purpose and accessible tool.\n计算机科学从深奥学科 变成了大众化工具\n\nAt the same time, abstraction in programming allowed those computer experts\n同时，编程的抽象也让计算机专家\n\n- now \"professional programmers\" -\n现在叫\"专业程序员\"\n\nto create increasingly sophisticated programs,\n制作更复杂的程序\n\nwhich would have taken millions, tens of millions, or even more lines of assembly code.\n如果用汇编写可能要上百万行\n\nNow, this history didn't end in 1959.\n当然，计算机的历史没有在 1959 年结束\n\nIn fact, a golden era in programming language design jump started,\n编程语言设计的黄金时代才刚刚开始\n\nevolving in lockstep with dramatic advances in computer hardware.\n和硬件一起飞速发展\n\nIn the 1960s, we had languages like ALGOL, LISP and BASIC.\n在 1960 年代，有 ALGOL, LISP 和 BASIC 等语言\n\nIn the 70's: Pascal, C and Smalltalk were released.\n70年代有：Pascal，C 和 Smalltalk\n\nThe 80s gave us C++, Objective-C, and Perl.\n80年代有：C++，Objective-C 和 Perl\n\nAnd the 90's: python, ruby, and Java.\n90年代有：Python，Ruby 和 Java\n\nAnd the new millennium has seen the rise of Swift, C#, and Go\n新千年 Swift, C#, Go 在崛起\n\n- not to be confused with Let it Go and Pokemon Go.\n不要把 Go 和\\N 《冰雪奇缘》的 Let it Go 和游戏 Pokemon Go 弄混\n\nAnyway, some of these might sound familiar\n有些语言你可能听起来耳熟 - 很多现在还存在\n\n-- many are still around today.\n有些语言你可能听起来耳熟 - 很多现在还存在\n\nIt's extremely likely that the web browser you're using right now\n你现在用的浏览器很可能是 C++ 或 Objective-C 写的\n\nwas written in C++ or Objective-C.\n你现在用的浏览器很可能是 C++ 或 Objective-C 写的\n\nThat list I just gave is the tip of the iceberg.\n我刚才说的编程语言名字 只是冰山一角\n\nAnd languages with fancy, new features are proposed all the time.\n新的编程语言在不断诞生\n\nEach new language attempts to leverage new and clever abstractions\n新语言想用更聪明的抽象\n\nto make some aspect of programming easier or more powerful,\n让某些方面更容易或更强大\n\nor take advantage of emerging technologies and platforms,\n或利用新技术和新平台带来的优势\n\nso that more people can do more amazing things, more quickly.\n让更多人能快速做出美妙的事情\n\nMany consider the holy grail of programming to be the use of \"plain ol' English\",\n许多人认为编程的\"圣杯\"是直接用英文\n\nwhere you can literally just speak what you want the computer to do,\n直接对计算机说话，然后它会理解并执行\n\nit figures it out, and executes it.\n直接对计算机说话，然后它会理解并执行\n\nThis kind of intelligent system is science fiction for now.\n这种智能系统目前只存在于科幻小说\n\nAnd fans of 2001: A Space Odyssey may be okay with that.\n\"2001：太空漫游\" 的粉丝可能没什么意见\n\nNow that you know all about programming languages,\n现在你理解了编程语言,\n\nwe're going to deep dive for the next couple of episodes,\n接下来几集 我们会深入了解\n\nand we'll continue to build your understanding\n接下来几集 我们会深入了解\n\nof how programming languages, and the software they create,\n编程语言和用语言写的软件\n\nare used to do cool and unbelievable things.\n是怎么做到那些酷事\n\nSee you next week.\n下周见\n\n（给 Curiosity Stream 打广告）\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/12. 编程原理-语句和函数-Programming Basics - Statements & Functions.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode we discussed how writing programs in native machine code,\n上集讲到用机器码写程序,\n\nand having to contend with so many low level details, was a huge impediment to writing complex programs.\n还要处理那么多底层细节  对写大型程序是个巨大障碍\n\nTo abstract away many of these low-level details, Programming Languages were developed that\n为了脱离底层细节，开发了编程语言\n\nlet programmers concentrate on solving a problem with computation, and less on nitty gritty hardware details.\n让程序员专心解决问题，不用管硬件细节\n\nSo today, we’re going to continue that discussion, and introduce some fundamental building blocks\n今天我们讨论  大多数编程语言都有的基本元素\n\nthat almost all programming languages provide.\n今天我们讨论  大多数编程语言都有的基本元素\n\nJust like spoken languages, programming languages have statements.\n就像口语一样，编程语言有\"语句\"\n\nThese are individual complete thoughts, like \"I want tea\" or \"it is raining\".\n语句表达单个完整思想，比如\"我想要茶\"或者\"在下雨\"\n\nBy using different words, we can change the meaning;\n用不同词汇可以代表不同含义 \\N 比如\"我想要茶\"变成\"我想要独角兽\"\n\nfor example, \"I want tea\" to \"I want unicorns\".\n用不同词汇可以代表不同含义 \\N 比如\"我想要茶\"变成\"我想要独角兽\"\n\nBut we can’t change \"I want tea\" to \"I want raining\" - that doesn’t make grammatical sense.\n但没法把\"我想要茶\"改成\"我想要雨\"- 语法毫无意义\n\nThe set of rules that govern the structure and composition of statements in a language\n规定句子结构的一系列规则 叫语法\n\nis called syntax.\n规定句子结构的一系列规则 叫语法\n\nThe English language has syntax, and so do all programming languages.\n英语有语法，所有编程语言也都有语法\n\n\"a = 5\" is a programming language statement.\na=5 是一个编程语言语句\n\nIn this case, the statement says a variable named A has the number 5 stored in it.\n意思是创建一个叫 a 的变量，把数字 5 放里面.\n\nThis is called an assignment statement because we're assigning a value to a variable.\n这叫\"赋值语句\"，把一个值赋给一个变量\n\nTo express more complex things, we need a series of statements,\n为了表达更复杂的含义，需要更多语句\n\nlike \"A is 5, B is 10, C equals A plus B\"\n比如 \\Na=5 \\N b=10 \\Nc=a+b\n\nThis program tells the computer to set variable ‘A’ equal to 5, variable ‘B’ to 10,\n意思是，变量 a 设为5，变量 b 设为10\n\nand finally to add ‘A’ and ‘B’ together, and put that result, which is 15, into -- you guessed it -- variable C.\n把 a 和 b 加起来，把结果 15 放进变量 c\n\nNote that we can call variables whatever we want.\n注意，变量名可以随意取\n\nInstead of A, B and C, it could be apples, pears, and fruits.\n除了 a b c，也可以叫苹果、梨、水果\n\nThe computer doesn’t care, as long as variables are uniquely named.\n计算机不在乎你取什么名，只要不重名就行\n\nBut it’s probably best practice to name them things that make sense\n当然取名最好还是有点意义，方便别人读懂\n\nin case someone else is trying to understand your code.\n当然取名最好还是有点意义，方便别人读懂\n\nA program, which is a list of instructions, is a bit like a recipe:\n程序由一个个指令组成，有点像菜谱：\n\nboil water, add noodles, wait 10 minutes, drain and enjoy.\n烧水、加面，等10分钟，捞出来就可以吃了\n\nIn the same way, the program starts at the first statement\n程序也是这样，从第一条语句开始\n\nand runs down one at a time until it hits the end.\n一句一句运行到结尾\n\nSo far, we’ve added two numbers together.\n刚才我们只是把两个数字加在一起\n\nBoring.\n无聊\n\nLet’s make a video game instead!\n我们来做一款游戏吧\n\nOf course, it’s way too early to think about coding an entire game,\n当然，现在这个学习阶段 \\N来编写一整个游戏还太早了\n\nso instead, we’ll use our example to write little snippets of code\n所以我们只写一小段一小段的代码\n\nthat cover some programming fundamentals.\n来讲解一些基础知识\n\nImagine we’re building an old-school arcade game where Grace Hopper has to capture bugs\n假设我们在写一款老派街机游戏：Grace Hopper 拍虫子\n\nbefore they get into the Harvard Mark 1 and crash the computer!\n阻止虫子飞进计算机造成故障\n\nOn every level, the number of bugs increases.\n关卡越高，虫子越多\n\nGrace has to catch them before they wear out any relays in the machine.\nGrace 要在虫子损坏继电器之前  抓住虫子\n\nFortunately, she has a few extra relays for repairs.\n好消息是  她有几个备用继电器\n\nTo get started, we’ll need to keep track of a bunch of values that are important for gameplay\n开始编写时，我们需要一些值 来保存游戏数据\n\nlike what level the player is on, the score, the number of bugs remaining,\n比如当前关卡数、分数、剩余虫子数、\n\nas well as the number of spare relays in Grace’s inventory.\nGrace 还剩几个备用继电器\n\nSo, we must \"initialize\" our variables, that is, set their initial value:\n所以我们要\"初始化\"变量 \\N \"初始化\"的意思是设置最开始的值.\n\n\"level equals 1, score equals 0, bugs equals 5, spare relays equals 4, and player name equals \"Andre\".\n关卡=1  分数=0  虫子数=5 \\N 备用继电器=4   玩家名=Andre\n\nTo create an interactive game, we need to control the flow of the program\n为了做成交互式游戏，程序的执行顺序要更灵活\n\nbeyond just running from top to bottom.\n不只是从上到下执行\n\nTo do this, we use Control Flow Statements.\n因此用 \"控制流语句\"\n\nThere are several types, but If Statements are the most common.\n控制流语句有好几种，最常见的是 if 语句\n\nYou can think of them as \"If X is true, then do Y\".\n可以想成是 \"如果 X 为真，那么执行 Y\"\n\nAn English language example is: \"If I am tired, then get tea\"\n用英语举例就是 \"如果累了, 就去喝茶\"\n\nSo if \"I am tired\" is a true statement, then I will go get tea\n如果 \"累了\" 为真，就去喝茶\n\nIf \"I am tired\" is false, then I will not go get tea.\n如果 \"累了\" 为假，就不喝茶\n\nAn IF statement is like a fork in the road.\nif 语句就像岔路口\n\nWhich path you take is conditional on whether the expression is true or false\n走哪条路  取决于 \"表达式\" 的真假，\n\nso these expressions are called Conditional Statements.\n因此这些表达式又叫 \"条件语句\"\n\nIn most programming languages, an if statement looks something like\n在大多数编程语言中，if 语句看起来像这样：\n\n\"If, expression, then, some code, then end the if statement\".\nif [条件], then [一些代码]，结束 if 语句.\n\nFor example, if \"level\" is 1, then we set the score to zero, because the player is just starting.\n比如，if [第一关]，then [分数设为0] \\N 因为玩家才刚开始游戏\n\nWe also set the number of bugs to 1, to keep it easy for now.\n同时把虫子数设为 1，让游戏简单些\n\nNotice the lines of code that are conditional on the if-statement are nested between the\n注意, 依赖于 if 条件的代码，要放在 IF 和 END IF 之间\n\nIF and END IF.\n注意, 依赖于 if 条件的代码，要放在 IF 和 END IF 之间\n\nOf course, we can change the conditional expression to whatever we want to test, like\n当然，条件表达式 可以改成别的，比如：\n\n\"is score greater than 10\"  or \"is bugs less than 1\".\n\"分数 >10\" 或者 \"虫子数 <1\"\n\nAnd If-Statements can be combined with an ELSE statement, which acts as a catch-all if the expression is false.\nif 还可以和 else 结合使用 \\N 条件为假会执行 else 里的代码\n\nIf the level is not 1, the code inside the ELSE block will be executed instead, and the\n如果不是第1关，else 里的指令就会被执行\n\nnumber of bugs that Grace has to battle is set to 3 times the level number.\nGrace 要抓的虫子数，是当前关卡数 * 3\n\nSo on level 2, it would be six bugs, and on level 3 there’s 9, and so on.\n所以第 2 关有 6 个虫子，第 3 关有 9 个虫子，以此类推\n\nScore isn’t modified in the ELSE block, so Grace gets to keep any points earned.\nelse 中没有改分数，所以 Grace 的分数不会变\n\nHere are some examples of if-then-else statements from some popular programming languages\n这里列了一些热门编程语言  if-then-else 的具体语法\n\n-- you can see the syntax varies a little, but the underlying structure is roughly the same.\n具体语法略有不同，但主体结构一样\n\nIf-statements are executed once, a conditional path is chosen, and the program moves on.\nif 语句 根据条件执行一次\n\nTo repeat some statements many times, we need to create a conditional loop.\n如果希望根据条件执行多次，需要\"条件循环\"\n\nOne way is a while statement, also called a while loop.\n比如 while 语句，也叫 \"while 循环\"\n\nAs you might have guessed, this loops a piece of code \"while\" a condition is true.\n当 while 条件为真，代码会重复执行\n\nRegardless of the programming language, they look something like this:\n不管是哪种编程语言，结构都是这样\n\nIn our game, let’s say at certain points, a friendly colleague restocks Grace with relays!\n假设到达一定分数会冒出一个同事，给 Grace 补充继电器\n\nHooray!\n棒极了！\n\nTo animate him replenishing our stock back up to a maximum of 4, we can use a while loop.\n把继电器补满到最大数 4 个 \\N 我们可以用 while 语句来做\n\nLet’s walk through this code.\n来过一遍代码\n\nFirst we’ll assume that Grace only has 1 tube left when her colleague enters.\n假设同事入场时， Grace 只剩一个继电器\n\nWhen we enter the while loop, the first thing the computer does is test its conditional…\n当执行 while 循环，第一件事是检查条件\n\nis relays less than 4?\n继电器数量<4?\n\nWell, relays is currently 1, so yes.\n继电器数量现在是1，所以是真\n\nNow we enter the loop!\n进入循环！\n\nThen, we hit the line of code: \"relays equals relays plus 1\".\n碰到这一行：继电器数量=继电器数量+1\n\nThis is a bit confusing because the variable is using itself in an assignment statement,\n看起来有点怪，变量的赋值用到了自己\n\nso let's unpack it.\n我们讲下这个\n\nYou always start by figuring out the right side of the equals sign first,\n总是从等号右边开始，\n\nso what does \"relays plus 1\" come out to be?\n\"继电器数量+1\" 是多少？\n\nWell, relays is currently the value 1, so 1 plus 1 equals 2.\n当前值是1，所以 1+1=2\n\nThen, this result gets saved back into the variable relays, writing over the old value,\n结果存到\"继电器数量\"，覆盖旧的值\n\nso now relays stores the value 2.\n所以现在继电器数量是 2\n\nWe’ve hit the end of the while loop, which jumps the program back up.\n现在到了结尾，跳回开始点\n\nJust as before, we test the conditional to see if we’re going to enter the loop.\n和之前一样，先判断条件，看要不要进入循环\n\nIs relays less than 4?\n继电器数量<4？\n\nWell, yes, relays now equals 2, so we enter the loop again!\n是，继电器数量是2，所以再次进入循环!\n\n2 plus 1 equals 3.\n2+1=3\n\nso 3 is saved into relays.\n3 存入\"继电器数量\"\n\nLoop again.\n回到开头\n\nIs 3 less than 4?\n3<4？\n\nYes it is!\n是!\n\nInto the loop again.\n进入循环\n\n3 plus 1 equals 4.\n3+1=4\n\nSo we save 4 into relays.\n4 存入\"继电器数量\"\n\nLoop again.\n回到开头\n\nIs 4 less than 4?....\n4<4?\n\nNo!\n不！\n\nSo the condition is now false, and thus we exit the loop and move on to any remaining code\n现在条件为假，退出循环，执行后面的代码\n\nThat’s how a while loop works!\nwhile 循环就是这样运作的!\n\nThere’s also the common For Loop.\n另一种常见的叫 \"for 循环\"\n\nInstead of being a condition-controlled loop that can repeat forever until the condition is false\n不判断条件，判断次数，会循环特定次数\n\na FOR loop is count-controlled; it repeats a specific number of times.\n不判断条件，判断次数，会循环特定次数\n\nThey look something like this:\n看起来像上图\n\nNow, let’s put in some real values.\n现在放些真正的值进去\n\nThis example loops 10 times, because we’ve specified that variable ‘i’\n上图例子会循环10次，因为设了变量 i\n\nstarts at the value 1 and goes up to 10.\n从 1 开始，一直到 10\n\nThe unique thing about a FOR loop is that each time it hits NEXT, it adds one to ‘i’.\nfor 的特点是，每次结束， i 会 +1\n\nWhen ‘i’ equals 10, the computer knows it’s been looped 10 times, and the loop exits\n当 i 等于10，就知道循环了10次，然后退出.\n\nWe can set the number to whatever we want -- 10, 42, or a billion -- it’s up to us.\n我们可以用任何数字，10, 42, 10 亿\n\nLet’s say we want to give the player a bonus at the end of each level\n假设每关结束后  给玩家一些奖励分\n\nfor the number of vacuum relays they have left over.\n奖励分多少取决于 继电器剩余数量\n\nAs the game gets harder, it takes more skill to have unused relays,\n随着难度增加，剩下继电器会越来越难\n\nso we want the bonus to go up exponentially based on the level.\n因此奖励分会根据当前关卡数，指数级增长\n\nWe need to write a piece of code that calculates exponents -\n我们要写一小段代码来算指数\n\nthat is, multiplying a number by itself a specific number of times.\n指数是一个数乘自己，乘特定次数\n\nA loop is perfect for this!\n用循环来实现简直完美!\n\nFirst lets initialize a new variable called \"bonus\" and set it to 1.\n首先，创建一个叫\"奖励分\"的新变量，设为 1 （看上图）\n\nThen, we create a FOR loop starting at 1, and looping up to the level number.\n然后 for 循环，从 1 到 [当前关卡数]\n\nInside that loop, we multiply bonus times the number of relays,\n[奖励分] x [继电器剩余数]，结果存入 [奖励分]\n\nand save that new value back into bonus.\n[奖励分] x [继电器剩余数]，结果存入 [奖励分]\n\nFor example, let’s say relays equals 2, and level equals 3.\n比如继电器数是2，关卡数是3\n\nSo the FOR loop will loop three times, which means bonus is going to get multiplied by\nfor 会循环3次，奖励分会乘\n\nrelays... by relays... by relays.\n继电器数量 x 继电器数量 x 继电器数量\n\nOr in this case, times 2, times 2, times 2, which is a bonus of 8!\n也就是1×2×2×2，奖励分是8，2的3次方\n\nThat’s 2 to the 3rd power!\n也就是1×2×2×2，奖励分是8，2的3次方\n\nThis exponent code is useful, and we might want to use it in other parts of our code.\n这个指数代码很实用，其他地方可能会用到\n\nIt’d be annoying to copy and paste this everywhere, and have to update the variable names each time.\n如果每次想用就复制粘贴，会很麻烦，每次都要改变量名\n\nAlso, if we found a bug, we’d have to hunt around and update every place we used it.\n如果代码发现问题，要补漏洞时 \\N 要把每一个复制黏贴过的地方都找出来改\n\nIt also makes code more confusing to look at.\n而且会让代码更难懂\n\nLess is more!\n少即是多！\n\nWhat we want is a way to package up our exponent code so we can use it, get the result, and\n我们想要某种方法，把代码\"打包\" \\N 可以直接使用，得出结果，\n\nnot have to see all the internal complexity.\n不用管内部复杂度.\n\nWe’re once again moving up a new level of abstraction!\n这又提升了一层抽象！\n\nTo compartmentalize and hide complexity,\n为了隐藏复杂度\n\nprogramming languages can package pieces of code into named functions,\n可以把代码打包成 \"函数\"\n\nalso called methods or subroutines in different programming languages.\n也叫 \"方法\" 或 \"子程序\"\\N（有些编程语言这么叫）\n\nThese functions can then be used by any other part of that program just by calling its name.\n其他地方想用这个函数，直接写函数名就可以了\n\nLet’s turn our exponent code into a function! First, we should name it.\n现在我们把指数代码变成函数.  第一步，取名.\n\nWe can call it anything we want, like HappyUnicorn,\n叫什么都行，比如\"快乐独角兽\"\n\nbut since our code calculates exponents, let’s call it exponent.\n但因为是算指数,  直接叫\"指数\"合适一些\n\nAlso, instead of using specific variable names, like \"relays\" and \"levels\",\n还有，与其用特定变量名，比如 \"继电器\" 和 \"关卡数\"\n\nwe specify generic variable names, like Base and Exp,\n用更通用的名字，比如 底数(Base) 和 指数(Exp)\n\nwhose initial values are going to be \"passed\" into our function from some other part of the program.\nBase 和 Exp 的初始值需要外部传入\n\nThe rest of our code is the same as before\n剩余代码和之前一样\n\nNow tucked into our function and with new variable names.\n现在完成了，有函数名和新变量名.\n\nFinally, we need to send the result of our exponent code back to the part of the program that requested it.\n最后, 我们还需要把结果 交给使用这个函数的代码\n\nFor this, we use a RETURN statement, and specify that the value in ‘result’ be returned.\n所以用 RETURN 语句，指明返回什么.\n\nSo our full function code looks like this:\n完整版代码是这样\n\nNow we can use this function anywhere in our program,\n现在可以随意用这个函数\n\nsimply by calling its name and passing in two numbers.\n只需要写出名字 然后传入2个数字  就可以了\n\nFor example, if we want to calculate 2 to the 44th power, we can just call \"exponent 2 comma 44.\"\n如果要算 2 的 44 次方，写 exponent(2,44)\n\nand like 18 trillion comes back.\n结果是 18 万亿左右\n\nBehind the scenes, 2 and 44 get saved into variables Base and Exp inside the function,\n幕后原理是，2 和 44 存进 Base 和 Exp\n\nit does all its loops as necessary, and then the function returns with the result.\n跑循环，然后返回结果\n\nLet’s use our newly minted function to calculate a score bonus.\n我们来用这个新函数 算奖励分\n\nFirst, we initialize bonus to 0.\n首先，奖励分初始化为 0\n\nThen we check if the player has any remaining relays with an if-statement.\n然后用 if 语句，看剩不剩继电器（看上图的 > 0）\n\nIf they do, we call our exponent function, passing in relays and level,\n如果还剩，用指数函数，传入 [继电器数] 和 [关卡数]\n\nwhich calculates relays to the power of level, and returns the result, which we save into bonus.\n它会算 [继电器数]的[关卡数]次方,  存入奖励分\n\nThis bonus calculating code might be useful later, so let’s wrap it up as a function too!\n这段算奖励分的代码，之后可能还会用，也打包成一个函数\n\nYes, a function that calls a function!\n没错，这个函数 (CalcBonus) \\N 会调用另一个函数 (Exponent)\n\nAnd then, wait for it…. we can use this function in an even more complex function.\n还有！这个 CalcBonus 函数，可以用在其他更复杂的函数\n\nLet’s write one that gets called everytime the player finishes a level.\n我们来写一个函数, 每一关结束后都会调用\n\nWe’ll call it \"LevelFinished\"\n叫 LevelFinished (关卡结束)\n\n- it needs to know the number of relays left, what level it was, and the current score;\n需要传入 [剩余继电器数]  [关卡数] [当前分]\n\nthose values have to get passed in.\n这些数据必须传入.\n\nInside our function, we’ll calculate the bonus, using our CalcBonus function,\n里面用 CalcBonus 算奖励分，并加进总分\n\nand add that to the running score.\n里面用 CalcBonus 算奖励分，并加进总分\n\nAlso, if the current score is higher than the game’s high score,\n还有，如果当前分 > 游戏最高分\n\nwe save the new high score and the players name.\n把新高分和玩家名 存起来\n\nNow we’re getting pretty fancy.\n现在代码变得蛮\"花哨\"了\n\nFunctions are calling functions are calling functions!\n函数调函数调函数\n\nWhen we call a single line of code, like this the complexity is hidden.\n我们写这样一行代码时，复杂度都隐藏起来了\n\nWe don’t see all the internal loops and variables,\n不需要知道内部的循环和变量\n\nwe just see the result come back as if by magic…. a total score of 53.\n只知道结果会像魔术一样返回，总分 53\n\nBut it’s not magic, it’s the power of abstraction!\n但是这不是魔术，是抽象的力量\n\nIf you understand this example, then you understand the power of functions,\n如果你理解了这个例子，就明白了函数的强大之处\n\nand the entire essence of modern programming.\n和现代编程的核心\n\nIt’s not feasible to write, for example, a web browser as one gigantically long list of statements.\n比如浏览器这样的复杂程序，用一长串语句来写是不可能的\n\nIt would be millions of lines long and impossible to comprehend!\n会有几百万行代码，没人能理解\n\nSo instead, software consists of thousands of smaller functions,\n所以现代软件由上千个函数组成\n\neach responsible for different features.\n每个负责不同的事\n\nIn modern programming, it’s uncommon to see functions longer than around 100 lines of code\n如今超过100行代码的函数很少见\n\nbecause by then, there’s probably something that\n如果多于 100 行，应该有东西可以拆出来做成一个函数\n\nshould be pulled out and made into its own function.\n如果多于 100 行，应该有东西可以拆出来做成一个函数\n\nModularizing programs into functions not only allows a single programmer to write an entire app\n模块化编程  不仅可以让单个程序员独立制作 App\n\nbut also allows teams of people to work efficiently on even bigger programs.\n也让团队协作可以写更大型的程序\n\nDifferent programmers can work on different functions,\n不同程序员写不同函数\n\nand if everyone makes sure their code works correctly,\n只需要确保自己的代码工作正常\n\nthen when everything is put together, the whole program should work too!\n把所有人的拼起来，整个程序也应该能正常运作！\n\nAnd in the real world, programmers aren’t wasting time writing things like exponents.\n现实中，程序员不会浪费时间写指数函数这种东西\n\nModern programming languages come with huge bundles of pre-written functions, called Libraries.\n现代编程语言 有很多预先写好的函数集合，叫 \"库\"\n\nThese are written by expert coders, made efficient and rigorously tested, and then given to everyone.\n由专业人员编写，不仅效率高，而且经过了仔细检查\n\nThere are libraries for almost everything, including networking, graphics, and sound\n几乎做所有事情都有库，网络、图像、声音\n\n-- topics we’ll discuss in future episodes.\n我们之后会讲这些主题.\n\nBut before we get to those, we need to talk about Algorithms.\n但在此之前，我们先讲算法\n\nIntrigued?\n好奇吗？\n\nYou should be.\n你应该才是！\n\nI’ll see you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/13. 算法入门 - Intro to Algorithms.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the past two episodes, we got our first taste of programming in a high-level language,\n前两集，我们\"初尝\"了高级编程语言\\N （比如 Python 和 Java）\n\nlike Python or Java.\n前两集，我们\"初尝\"了高级编程语言\\N （比如 Python 和 Java）\n\nWe talked about different types of programming language statements\n我们讨论了几种语句 - 赋值语句，if 语句，循环语句\n\n- like assignments, ifs, and loops -\n我们讨论了几种语句 - 赋值语句，if 语句，循环语句\n\nas well as putting statements into functions that perform a computation,\n以及把代码打包成 \"函数\"\n\nlike calculating an exponent.\n比如算指数\n\nImportantly, the function we wrote to calculate exponents is only one possible solution.\n重要的是，之前写的指数函数 \\N 只是无数解决方案的一种\n\nThere are other ways to write this function\n还有其它方案\n\n- using different statements in different orders -\n- 用不同顺序写不同语句 也能得到一样结果\n\nthat achieve exactly the same numerical result.\n- 用不同顺序写不同语句 也能得到一样结果\n\nThe difference between them is the algorithm,\n不同的是 \"算法\"，意思是：解决问题的具体步骤\n\nthat is the specific steps used to complete the computation.\n不同的是 \"算法\"，意思是：解决问题的具体步骤\n\nSome algorithms are better than others even if they produce equal results.\n即使结果一致，有些算法会更好\n\nGenerally, the fewer steps it takes to compute, the better it is,\n一般来说，所需步骤越少越好\n\nthough sometimes we care about other factors, like how much memory it uses.\n不过有时我们也会关心其他因素，比如占多少内存\n\nThe term algorithm comes from Persian polymath Muhammad ibn Musa al-Khwarizmi\n\"算法\" 一词来自 波斯博识者 阿尔·花拉子密\n\nwho was one of the fathers of algebra more than a millennium ago.\n1000 多年前的代数之父之一\n\nThe crafting of efficient algorithms\n如何想出高效算法 - 是早在计算机出现前就有的问题\n\n- a problem that existed long before modern computers -\n如何想出高效算法 - 是早在计算机出现前就有的问题\n\nled to a whole science surrounding computation,\n诞生了专门研究计算的领域，然后发展成一门现代学科\n\nwhich evolved into the modern discipline of...\n诞生了专门研究计算的领域，然后发展成一门现代学科\n\nyou guessed it!\n你猜对了！\n\nComputer Science!\n计算机科学！\n\nOne of the most storied algorithmic problems in all of computer science is sorting\n记载最多的算法之一是\"排序\"\n\nas in sorting names or sorting numbers.\n比如给名字、数字排序\n\nComputers sort all the time.\n排序到处都是\n\nLooking for the cheapest airfare,\n找最便宜的机票\n\narranging your email by most recently sent,\n按最新时间排邮件\n\nor scrolling your contacts by last name\n按姓氏排联系人\n\n-- those all require sorting.\n-这些都要排序\n\nYou might think\n你可能想\"排序看起来不怎么难… 能有几种算法呢?\"\n\n\"sorting isn't so tough how many algorithms can there possibly be?\"\n你可能想\"排序看起来不怎么难… 能有几种算法呢?\"\n\nThe answer is: a lot.\n答案是超多\n\nComputer Scientists have spent decades inventing algorithms for sorting,\n计算机科学家花了数十年发明各种排序算法\n\nwith cool names like Bubble Sort and Spaghetti Sort.\n还起了酷酷的名字，\"冒泡排序\"\"意面排序\"\n\nLet's try sorting!\n我们来试试排序！\n\nImagine we have a set of airfare prices to Indianapolis.\n试想有一堆机票价格，都飞往  印第安纳波利斯 (美国地名)\n\nWe'll talk about how data like this is represented in memory next week,\n数据具体怎么在内存中表示  下周再说\n\nbut for now, a series of items like this is called an array.\n上图的这样一组数据  叫\"数组\"（Array）\n\nLet's take a look at these numbers to help see how we might sort this programmatically.\n来看看怎么排序\n\nWe'll start with a simple algorithm.\n先从一种简单算法开始\n\nFirst, let's scan down the array to find the smallest number.\n先找到最小数，从最上面的 307 开始\n\nStarting at the top with 307.\n先找到最小数，从最上面的 307 开始\n\nIt's the only number we've seen, so it's also the smallest.\n因为现在只看了这一个，所以它是最小数\n\nThe next is 239, that's smaller than 307,\n下一个是 239，比 307 小\n\nso it becomes our new smallest number.\n所以新的最小数变成 239\n\nNext is 214, our new smallest number.\n下一个是 214 ，新的最小数\n\n250 is not, neither is 384, 299, 223 or 312.\n250 不是，384, 299, 223, 312 都不是\n\nSo we've finished scanning all numbers,\n现在扫完了所有数字\n\nand 214 is the smallest.\n214 是最小的\n\nTo put this into ascending order,\n为了升序排列（从小到大排序）\n\nwe swap 214 with the number in the top location.\n把 214 和最上面的数字，交换位置\n\nGreat! We sorted one number!\n好棒! 刚排序了一个数字！\n\nNow we repeat the same procedure,\n现在重复同样的过程\n\nbut instead of starting at the top, we can start one spot below.\n这次不从最上面开始，从第 2 个数开始\n\nFirst we see 239, which we save as our new smallest number.\n先看到 239，我们当作是 \"最小数\"\n\nScanning the rest of the array, we find 223 is the next smallest,\n扫描剩下的部分，发现 223 最小\n\nso we swap this with the number in the second spot.\n所以把它和第 2 位交换\n\nNow we repeat again, starting from the third number down.\n重复这个过程，从第 3 位数字开始\n\nThis time, we swap 239 with 307.\n让 239 和 307 互换位置\n\nThis process continues until we get to the very last number,\n重复直到最后一个数字\n\nand voila, the array is sorted and you're ready to book that flight to Indianapolis!\n瞧，数字排好了，可以买机票了！\n\nThe process we just walked through is one way\n刚刚这种方法，或者说算法，\n\n- or one algorithm - for sorting an array.\n刚刚这种方法，或者说算法，\n\nIt's called Selection sort - and it's pretty basic.\n叫 选择排序 - 非常基础的一种算法\n\nHere's the pseudo-code.\n以下是\"伪代码\"\n\nThis function can be used to sort 8, 80, or 80 million numbers\n这个函数可以排序8个, 80个或8千万个数字\n\n- and once you've written the function, you can use it over and over again.\n函数写好了就可以重复使用\n\nWith this sort algorithm, we loop through each position in the array, from top to bottom,\n这里用循环 遍历数组\n\nand then for each of those positions,\n每个数组位置都跑一遍循环，找最小数然后互换位置\n\nwe have to loop through the array to find the smallest number to swap.\n每个数组位置都跑一遍循环，找最小数然后互换位置\n\nYou can see this in the code, where one FOR loop is nested inside of another FOR loop.\n可以在代码中看到这一点 \\N （一个 for 循环套另一个 for 循环）\n\nThis means, very roughly, that if we want to sort N items, we have to loop N times,\n这意味着，大致来说，如果要排 N 个东西，要循环 N 次，\n\ninside of which, we loop N times, for a grand total of roughly N times N loops, or N squared.\n每次循环中再循环 N 次，共 N*N,  或 N\n\nThis relationship of input size to the number of steps the algorithm takes to run\n算法的 输入大小 和 运行步骤 之间的关系\n\ncharacterizes the complexity of the Selection Sort algorithm.\n叫算法的 复杂度\n\nIt gives you an approximation of how fast, or slow, an algorithm is going to be.\n表示运行速度的量级\n\nComputer Scientists write this order of growth in something known as - no joke -\n计算机科学家们把算法复杂度叫 - 没开玩笑\n\n\"big O notation\".\n大 O 表示法\n\nN squared is not particularly efficient.\n算法复杂度 O(N  ) 效率不高\n\nOur example array had n = 8 items, and 8 squared is 64.\n前面的例子有 8 个元素（n=8）, 8  = 64\n\nIf we increase the size of our array from 8 items to 80,\n如果 8 个变 80 个\n\nthe running time is now 80 squared, which is 6,400.\n运行时间变成 80  = 6400\n\nSo although our array only grew by 10 times - from 8 to 80 -\n虽然大小只增长了 10 倍（8 到 80）\n\nthe running time increased by 100 times - from 64 to 6,400!\n但运行时间增加了 100 倍！（64 到 6400 ）\n\nThis effect magnifies as the array gets larger.\n随着数组增大，对效率的影响会越来越大\n\nThat's a big problem for a company like Google,\n这对大公司来说是个问题，比如 谷歌\n\nwhich has to sort arrays with millions or billions of entries.\n要对几十亿条信息排序\n\nSo, you might ask,\n作为未来的计算机科学家你可能会问：有没有更高效的排序算法？\n\nas a burgeoning computer scientist, is there a more efficient sorting algorithm?\n作为未来的计算机科学家你可能会问：有没有更高效的排序算法？\n\nLet's go back to our old, unsorted array\n回到未排序的数组\n\nand try a different algorithm, merge sort.\n试另一个算法 \"归并排序\"\n\nThe first thing merge sort does is check if the size of the array is greater than 1.\n第一件事是检查数组大小是否 > 1\n\nIf it is, it splits the array into two halves.\n如果是，就把数组分成两半\n\nSince our array is size 8, it gets split into two arrays of size 4.\n因为数组大小是 8，所以分成两个数组，大小是 4\n\nThese are still bigger than size 1, so they get split again, into arrays of size 2,\n但依然大于 1，所以再分成大小是 2 的数组\n\nand finally they split into 8 arrays with 1 item in each.\n最后变成 8 个数组，每个大小为 1\n\nNow we are ready to merge, which is how \"merge sort\" gets its name.\n现在可以\"归并\"了，\"归并排序\"因此得名\n\nStarting with the first two arrays, we read the first - and only - value in them,\n从前两个数组开始，读第一个（也是唯一一个）值\n\nin this case, 307 and 239.\n307 和 239\n\n239 is smaller, so we take that value first.\n239 更小，所以放前面\n\nThe only number left is 307, so we put that value second.\n剩下的唯一数字是 307 ，所以放第二位\n\nWe've successfully merged two arrays.\n成功合并了两个数组\n\nWe now repeat this process for the remaining pairs, putting them each in sorted order.\n重复这个过程，按序排列\n\nThen the merge process repeats.\n然后再归并一次\n\nAgain, we take the first two arrays, and we compare the first numbers in them.\n同样，取前两个数组，比较第一个数\n\nThis time its 239 and 214.\n239 和 214\n\n214 is lowest, so we take that number first.\n214 更小，放前面\n\nNow we look again at the first two numbers in both arrays: 239 and 250.\n再看两个数组里的第一个数：239 和 250\n\n239 is lower, so we take that number next.\n239 更小，所以放下一位\n\nNow we look at the next two numbers: 307 and 250.\n看剩下两个数：307 和 250\n\n250 is lower, so we take that.\n250 更小，所以放下一位\n\nFinally, we're left with just 307, so that gets added last.\n最后剩下 307 ，所以放最后\n\nIn every case, we start with two arrays,\n每次都以 2 个数组开始\n\neach individually sorted, and merge them into a larger sorted array.\n然后合并成更大的有序数组\n\nWe repeat the exact same merging process for the two remaining arrays of size two.\n我们把刚隐藏起来的，下面的数组也这样做\n\nNow we have two sorted arrays of size 4.\n现在有两个大小是 4 的有序数组\n\nJust as before, we merge,\n就像之前，比较两个数组的第一个数，取最小数\n\ncomparing the first two numbers in each array, and taking the lowest.\n就像之前，比较两个数组的第一个数，取最小数\n\nWe repeat this until all the numbers are merged,\n重复这个过程，直到完成\n\nand then our array is fully sorted again!\n就排好了！\n\nThe bad news is: no matter how many times we sort these,\n但坏消息是：无论排多少次\n\nyou're still going to have to pay $214 to get to Indianapolis.\n你还是得付 214 美元到 印第安纳波利斯\n\nAnyway, the \"Big O\" computational complexity of merge sort is N times the Log of N.\n总之，\"归并排序\"的算法复杂度是 O(n * log n)\n\nThe N comes from the number of times we need to compare and merge items,\nn 是需要 比较+合并 的次数\n\nwhich is directly proportional to the number of items in the array.\n和数组大小成正比\n\nThe Log N comes from the number of merge steps.\nlog N 是合并步骤的次数\n\nIn our example, we broke our array of 8 items into 4,\n例子中把大小是 8 的数组，分成四个数组\n\nthen 2, and finally 1.\n然后分成 2 个，最后分成 1 个\n\nThat's 3 splits.\n分了 3 次\n\nSplitting in half repeatedly like this has a logarithmic relationship with the number of items\n重复切成两半，和数量成对数关系\n\n- trust me!\n相信我！\n\nLog base 2 of 8 equals 3 splits.\nLog   8=3\n\nIf we double the size of our array to 16 - that's twice as many items to sort -\n如果数组大小变成 16 - 之前的两倍\n\nit only increases the number of split steps by 1\n也只要多分割 1 次\n\nsince log base 2 of 16 equals 4.\n因为 Log   16=4\n\nEven if we increase the size of the array more than a thousand times,\n即使扩大一千倍\n\nfrom 8 items to 8000 items, the number of split steps stays pretty low.\n从8到8000，分割次数也不会增大多少\n\nLog base 2 of 8000 is roughly 13.\nlog   8000≈13\n\nThat's more, but not much more than 3 -- about four times larger --\n13 比 3 只是4倍多一点\n\nand yet we're sorting a lot more numbers.\n然而排序的元素多得多\n\nFor this reason, merge sort is much more efficient than selection sort.\n因此\"归并排序\"比\"选择排序\"更有效率\n\nAnd now I can put my ceramic cat collection in name order MUCH faster!\n这下我收藏的陶瓷猫  可以更快排序了！\n\nThere are literally dozens of sorting algorithms we could review,\n有好几十种排序算法，但没时间讲\n\nbut instead, I want to move on to my other favorite category of classic algorithmic problems:\n所以我们来谈一个经典算法问题：\n\ngraph search!\n图搜索\n\nA graph is a network of nodes connected by lines.\n\"图\" 是用线连起来的一堆 \"节点\"\n\nYou can think of it like a map, with cities and roads connecting them.\n可以想成地图，每个节点是一个城市，线是公路\n\nRoutes between these cities take different amounts of time.\n一个城市到另一个城市，花的时间不同\n\nWe can label each line with what is called a cost or weight.\n可以用 成本(cost) 或 权重(weight) 来代称\n\nIn this case, it's weeks of travel.\n代表要几个星期\n\nNow let's say we want to find the fastest route\n假设想找\"高庭\"到\"凛冬城\"的最快路线\n\nfor an army at Highgarden to reach the castle at Winterfell.\n假设想找\"高庭\"到\"凛冬城\"的最快路线\n\nThe simplest approach would just be to try every single path exhaustively\n最简单的方法是尝试每一条路\n\nand calculate the total cost of each.\n计算总成本\n\nThat's a brute force approach.\n这是蛮力方法\n\nWe could have used a brute force approach in sorting,\n假设用蛮力方法 来排序数组\n\nby systematically trying every permutation of the array to check if it's sorted.\n尝试每一种组合，看是否排好序\n\nThis would have an N factorial complexity\n这样的时间复杂度是 O(n!)\n\n- that is the number of nodes, times one less, times one less than that, and so on until 1.\nn 是节点数，n! 是 n 乘 n-1 乘 n-2... 一直到 1\n\nWhich is way worse than even N squared.\n比 O(n  ) 还糟糕\n\nBut, we can be way more clever!\n我们可以更聪明些！\n\nThe classic algorithmic solution to this graph problem was invented by\n图搜索问题的经典算法  发明者是\n\none of the greatest minds in computer science practice and theory, Edsger Dijkstra\n理论计算机科学的伟人 Edsger Dijkstra\n\nso it's appropriately named Dijkstra's algorithm.\n所以叫 \"Dijkstra 算法\"\n\nWe start in Highgarden with a cost of 0, which we mark inside the node.\n从\"高庭\"开始，此时成本为0，把0标在节点里\n\nFor now, we mark all other cities with question marks\n其他城市标成问号，因为不知道成本多少\n\n- we don't know the cost of getting to them yet.\n其他城市标成问号，因为不知道成本多少\n\nDijkstra's algorithm always starts with the node with lowest cost.\nDijkstra 算法总是从成本最低的节点开始\n\nIn this case, it only knows about one node, Highgarden, so it starts there.\n目前只知道一个节点 \"高庭\", 所以从这里开始\n\nIt follows all paths from that node to all connecting nodes that are one step away,\n跑到所有相邻节点，记录成本\n\nand records the cost to get to each of them.\n跑到所有相邻节点，记录成本\n\nThat completes one round of the algorithm.\n完成了一轮算法\n\nWe haven't encountered Winterfell yet,\n但还没到\"凛冬城\"\n\nso we loop and run Dijkstra's algorithm again.\n所以再跑一次 Dijkstra 算法\n\nWith Highgarden already checked,\n\"高庭\" 已经知道了\n\nthe next lowest cost node is King's Landing.\n下一个成本最低的节点，是 \"君临城\"\n\nJust as before, we follow every unvisited line to any connecting cities.\n就像之前，记录所有相邻节点的成本\n\nThe line to The Trident has a cost of 5.\n到\"三叉戟河\"的成本是 5\n\nHowever, we want to keep a running cost from Highgarden,\n然而我们想记录的是，从\"高庭\"到这里的成本\n\nso the total cost of getting to The Trident is 8 plus 5, which is 13 weeks.\n所以\"三叉戟河\"的总成本是 8+5=13周\n\nNow we follow the offroad path to Riverrun,\n现在走另一条路到\"奔流城\"\n\nwhich has a high cost of 25, for a total of 33.\n成本高达 25 ，总成本 33\n\nBut we can see inside of Riverrun that we've already found a path with a lower cost of just 10.\n但 \"奔流城\" 中最低成本是 10\n\nSo we disregard our new path, and stick with the previous, better path.\n所以无视新数字，保留之前的成本 10\n\nWe've now explored every line from King's Landing and didn't find Winterfell, so we move on.\n现在看了\"君临城\"的每一条路，还没到\"凛冬城\" 所以继续.\n\nThe next lowest cost node is Riverrun, at 10 weeks.\n下一个成本最低的节点，是\"奔流城\"，要 10 周\n\nFirst we check the path to The Trident, which has a total cost of 10 plus 2, or 12.\n先看 \"三叉戟河\" 成本： 10+2=12\n\nThat's slightly better than the previous path we found, which had a cost of 13,\n比之前的 13 好一点\n\nso we update the path and cost to The Trident.\n所以更新 \"三叉戟河\" 为 12\n\nThere is also a line from Riverrun to Pyke with a cost of 3.\n\"奔流城\"到\"派克城\"成本是 3\n\n10 plus 3 is 13, which beats the previous cost of 14,\n10+3=13，之前是14\n\nand so we update Pyke's path and cost as well.\n所以更新 \"派克城\" 为 13\n\nThat's all paths from Riverrun checked. so you guessed it, Dijkstra's algorithm loops again.\n\"奔流城\"出发的所有路径都走遍了， \\N 你猜对了，再跑一次 Dijkstra 算法\n\nThe node with the next lowest cost is The Trident\n下一个成本最低的节点，是\"三叉戟河\"\n\nand the only line from The Trident that we haven't checked is a path to Winterfell!\n从\"三叉戟河\"出发，唯一没看过的路，通往\"凛冬城\"！\n\nIt has a cost of 10,\n成本是 10\n\nplus we need to add in the cost of 12 it takes to get to The Trident,\n加\"三叉戟河\"的成本 12\n\nfor a grand total cost of 22.\n总成本 22\n\nWe check our last path, from Pyke to Winterfell, which sums to 31.\n再看最后一条路，\"派克城\"到\"凛冬城\"，成本 31\n\nNow we know the lowest total cost, and also the fastest route for the army to get there,\n现在知道了最低成本路线，让军队最快到达,\n\nwhich avoids King's Landing!\n还绕过了\"君临城\"！\n\nDijkstra's original algorithm, conceived in 1956,\nDijkstra 算法的原始版本，构思于 1956 年\n\nhad a complexity of the number of nodes in the graph squared.\n算法复杂度是 O(n  )\n\nAnd squared, as we already discussed, is never great,\n前面说过这个效率不够好\n\nbecause it means the algorithm can't scale to big problems\n意味着输入不能很大\n\n- like the entire road map of the United States.\n比如美国的完整路线图\n\nFortunately, Dijkstra's algorithm was improved a few years later\n幸运的是，Dijkstra 算法几年后得到改进\n\nto take the number of nodes in the graph,\n变成 O(n log n + l)\n\ntimes the log of the number of nodes, PLUS the number of lines.\nn 是节点数，l 是多少条线\n\nAlthough this looks more complicated,\n虽然看起来更复杂\n\nit's actually quite a bit faster.\n但实际更快一些\n\nPlugging in our example graph, with 6 cities and 9 lines, proves it.\n用之前的例子，可以证明更快 \\N （6 个节点 9 条线）\n\nOur algorithm drops from 36 loops to around 14.\n从 36 减少到 14 左右\n\nAs with sorting,\n就像排序，图搜索算法也有很多，有不同优缺点\n\nthere are innumerable graph search algorithms, with different pros and cons.\n就像排序，图搜索算法也有很多，有不同优缺点\n\nEvery time you use a service like Google Maps to find directions,\n每次用谷歌地图时\n\nan algorithm much like Dijkstra's is running on servers to figure out the best route for you.\n类似 Dijkstra 的算法就在服务器上运行，找最佳路线\n\nAlgorithms are everywhere\n算法无处不在\n\nand the modern world would not be possible without them.\n现代世界离不开它们\n\nWe touched only the very tip of the algorithmic iceberg in this episode,\n这集只触及了算法的冰山一角\n\nbut a central part of being a computer scientist\n但成为计算机科学家的核心\n\nis leveraging existing algorithms and writing new ones when needed,\n是根据情况合理决定 用现有算法 还是自己写新算法\n\nand I hope this little taste has intrigued you to SEARCH further.\n希望这集的小例子能让你体会到这点\n\nI'll see you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/14. 数据结构-Data Structures.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode, we discussed a few example classic algorithms,\n上集讲了一些经典算法\n\nlike sorting a list of numbers and finding the shortest path in a graph.\n比如给数组排序，找图的最短路径\n\nWhat we didn't talk much about,\n而上集没讲的是\n\nis how the data the algorithms ran on was stored in computer memory.\n算法处理的数据  存在内存里的格式是什么\n\nYou don't want your data to be like John Green's college dorm room,\n你肯定不想数据像 John Green 的大学宿舍一样乱 \\N 到处都是食物，衣服和纸\n\nwith food, clothing and papers strewn everywhere.\n你肯定不想数据像 John Green 的大学宿舍一样乱 \\N 到处都是食物，衣服和纸\n\nInstead, we want our data to be structured,\n我们希望数据是结构化的，方便读取\n\nso that it's organized, allowing things to be easily retrieved and read.\n我们希望数据是结构化的，方便读取\n\nFor this, computer scientists use Data Structures!\n因此计算机科学家发明了 \"数据结构\"！\n\nWe already introduced one basic data structure last episode,\n上集已经介绍了一种基本数据结构：\n\nArrays, also called lists or Vectors in some languages.\n数组（Array）\\N 也叫列表（list）或向量（Vector）（在其它编程语言里）\n\nThese are a series of values stored in memory.\n数组的值一个个连续存在内存里\n\nSo instead of just a single value being saved into a variable, like 'j equals 5',\n所以不像之前，一个变量里只存一个值（比如 j = 5）\n\nwe can define a whole series of numbers, and save that into an array variable.\n我们可以把多个值存在数组变量里\n\nTo be able to find a particular value in this array, we have to specify an index.\n为了拿出数组中某个值，我们要指定一个下标（index）\n\nAlmost all programing languages start arrays at index 0,\n大多数编程语言里，数组下标都从 0 开始\n\nand use a square bracket syntax to denote array access.\n用方括号 [ ] 代表访问数组\n\nSo, for example, if we want to add the values in the first and third spots of our array 'j',\n如果想相加数组 J 的第一个和第三个元素\n\nand save that into a variable 'a', we would write a line of code like this.\n把结果存在变量 a，可以写上图这样一行代码\n\nHow an array is stored in memory is pretty straightforward.\n数组存在内存里的方式  十分易懂\n\nFor simplicity, let's say that the compiler chose to store ours at memory location 1,000.\n为了简单，假设编译器从内存地址 1000 开始存数组\n\nThe array contains 7 numbers, and these are stored one after another in memory, as seen here.\n数组有7个数字，像上图一样按顺序存.\n\nSo when we write \"j index of 0\", the computer goes to memory location 1,000,\n写 j[0]，会去内存地址 1000\n\nwith an offset of 0, and we get the value 5.\n加 0 个偏移，得到地址 1000，拿值：5\n\nIf we wanted to retrieve \"j index of 5\", our program goes to memory location 1000,\n如果写 j[5]，会去内存地址 1000\n\nplus an offset of 5, which in this case, holds a value of 4.\n加 5 个偏移，得到地址 1005，拿值： 4\n\nIt's easy to confuse the fifth number in the array with the number at index 5.\n很容易混淆 \"数组中第 5 个数\" 和 \"数组下标为 5 的数\"\n\nThey are not the same.\n它们不是一回事\n\nRemember, the number at index 5 is the 6th number in the array\n记住，下标 5 其实是数组中第 6 个数\n\nbecause the first number is at index 0.\n因为下标是从 0 开始算的\n\nArrays are extremely versatile data structures, used all the time,\n数组的用途广泛\n\nand so there are many functions that can handle them to do useful things.\n所以几乎所有编程语言  都自带了很多函数来处理数组\n\nFor example, pretty much every programming language comes with a built-in sort function,\n举例，数组排序函数很常见\n\nwhere you just pass in your array, and it comes back sorted.\n只需要传入数组，就会返回排序后的数组\n\nSo there's no need to write that algorithm from scratch.\n不需要写排序算法\n\nVery closely related are Strings, which are just arrays of characters,\n数组的亲戚是 字符串 (string)\n\nlike letters, numbers, punctuation and other written symbols.\n其实就是字母,数字,标点符号等  组成的数组\n\nWe talked about how computers store characters way back in Episode 4.\n第 4 集讨论过计算机怎么存储字符\n\nMost often, to save a string into memory, you just put it in quotes, like so.\n写代码时 用引号括起来就行了  \\N j = \"STAN ROCKS\"\n\nAlthough it doesn't look like an array, it is.\n虽然长的不像数组，但的确是数组\n\nBehind the scenes, the memory looks like this.\n幕后看起来像这样\n\nNote that the string ends with a zero in memory.\n注意，字符串在内存里以 0 结尾\n\nIt's not the character zero, but the binary value 0.\n不是\"字符0\"，是\"二进制值0\" \\N 这叫字符\"null\"，表示字符串结尾\n\nThis is called the null character, and denotes the end of the string in memory.\n不是\"字符0\"，是\"二进制值0\" \\N 这叫字符\"null\"，表示字符串结尾\n\nThis is important because if I call a function like \"print quote\",\n这个字符非常重要，如果调用 print 函数\n\nwhich writes the string to the screen,\nprint 在屏幕上输出字符串\n\nit prints out each character in turn starting at the first memory location,\n会从开始位置，逐个显示到屏幕\n\nbut it needs to know when to stop!\n但得知道什么时候停下来！\n\nOtherwise, it would print out every single thing in memory as text.\n否则会把内存里所有东西 都显示出来\n\nThe zero tells string functions when to stop.\n0 告诉函数何时停下\n\nBecause computers work with text so often,\n因为计算机经常处理字符串，所以有很多函数专门处理字符串\n\nthere are many functions that specifically handle strings.\n因为计算机经常处理字符串，所以有很多函数专门处理字符串\n\nFor example, many programming languages have a string concatenation function, or \"strcat\",\n比如连接字符串的 strcat\n\nwhich takes in two strings, and copies the second one to the end of the first.\nstrcat 接收两个字符串，把第二个放到第一个结尾.\n\nWe can use arrays for making one dimensional lists,\n我们可以用数组做一维列表\n\nbut sometimes you want to manipulate data that is two dimensional,\n但有时想操作二维数据\n\nlike a grid of numbers in a spreadsheet, or the pixels on your computer screen.\n比如电子表格，或屏幕上的像素\n\nFor this, we need a Matrix.\n那么需要 矩阵（Matrix）\n\nYou can think of a Matrix as an array of arrays!\n可以把矩阵看成  数组的数组！\n\nSo a 3 by 3 matrix is really  an array of size 3, with each index storing an array of size 3.\n一个 3x3 矩阵就是一个长度为3的数组 \\N 数组里每个元素都是一个长度为3的数组\n\nWe can initialize a matrix like so.\n可以这样初始化.\n\nIn memory, this is packed together in order like this.\n内存里是这样排列的\n\nTo access a value, you need to specify two indexes, like \"J index of 2, then index of 1\" -\n为了拿一个值，需要两个下标，比如 j[2][1]\n\nthis tells the computer you're looking for the item in subarray 2 at position 1.\n告诉计算机在找数组 2 里，位置是 1 的元素\n\nAnd this would give us the value 12.\n得到数字 12\n\nThe cool thing about matrices is we're not limited to 3 by 3\n矩阵酷的地方是，不止能做 3x3 的矩阵\n\n-- we can make them any size we want\n任何维度都行\n\n-- and we can also make them any number of dimensions we want.\n任何维度都行\n\nFor example, we can create a five dimensional matrix and access it like this.\n可以做一个5维矩阵，然后这样访问 \\N a = j[2][0][18][18][3]\n\nThat's right, you now know how to access a five dimensional matrix\n现在你知道了  怎么读一个 5 维矩阵\n\n-- tell your friends!\n快去告诉你的朋友！\n\nSo far, we've been storing individual numbers or letters into our arrays or matrices.\n目前我们只存过单个数字/字符，存进数组或矩阵\n\nBut often it's useful to store a block of related variables together.\n但有时, 把几个有关系的变量存在一起, 会很有用\n\nLike, you might want to store a bank account number along with its balance.\n比如银行账户号和余额\n\nGroups of variables like these can be bundled together into a Struct.\n多个变量打包在一起叫  结构体 (Struct)\n\nNow we can create variables that aren't just single numbers,\n现在多个不同类型数据，可以放在一起\n\nbut are compound data structures, able to store several pieces of data at once.\n现在多个不同类型数据，可以放在一起\n\nWe can even make arrays of structs that we define,\n甚至可以做一个数组，里面放很多结构体\n\nwhich are automatically bundled together in memory.\n这些数据在内存里  会自动打包在一起\n\nIf we access, for example, J index of 0, we get back the whole struct stored there,\n如果写 j[0]，能拿到  j[0] 里的结构体\n\nand we can pull the specific account number and balance data we want.\n然后拿银行账户和余额\n\nThis array of structs, like any other array,\n存结构体的数组，和其它数组一样\n\ngets created at a fixed size that can't be enlarged to add more items.\n创建时就有固定大小，不能动态增加大小\n\nAlso, arrays must be stored in order in memory,\n还有，数组在内存中 按顺序存储\n\nmaking it hard to add a new item to the middle.\n在中间插入一个值很困难\n\nBut, the struct data structure can be used for\n但结构体可以创造更复杂的数据结构，消除这些限制\n\nbuilding more complicated data structures that avoid these restrictions.\n但结构体可以创造更复杂的数据结构，消除这些限制\n\nLet's take a look at this struct that's called a \"node\".\n我们来看一个结构体，叫 节点(node)\n\nIt stores a variable, like a number, and also a pointer.\n它存一个变量 \\N 一个指针（pointer）\n\nA pointer is a special variable that points, hence the name, to a location in memory.\n\"指针\" 是一种特殊变量，指向一个内存地址，因此得名.\n\nUsing this struct, we can create a linked list,\n用 节点 可以做 链表（linked list）\n\nwhich is a flexible data structure that can store many nodes.\n链表是一种灵活数据结构，能存很多个 节点 (node)\n\nIt does this by having each node point to the next node in the list.\n灵活性是通过每个节点 指向 下一个节点实现的\n\nLet's imagine we have three node structs saved in memory, at locations 1000, 1002 and 1008.\n假设有三个节点，在内存地址 1000，1002, 1008\n\nThey might be spaced apart because they were created at different times,\n隔开的原因 可能是创建时间不同\n\nand other data can sit between them.\n它们之间有其他数据\n\nSo, you see that the first node contains the value 7, and the location 1008 in its \"next\" pointer.\n可以看到第一个节点，值是 7，指向地址 1008\n\nThis means that the next node in the linked list is located at memory location 1008.\n代表下一个节点，位于内存地址 1008\n\nLooking down the linked list, to the next node,\n现在来到下一个节点\n\nwe see it stores the value 112 and points to another node at location 1002.\n值是 112，指向地址 1002\n\nIf we follow that, we find a node that contains the value 14\n如果跟着它，会看到一个值为 14 的节点\n\nand points back to the first node at location 1000.\n这个节点  指回地址 1000，也就是第一个节点\n\nSo this linked list happened to be circular,\n这叫 循环链表\n\nbut it could also have been terminated by using a next pointer value of 0\n但链表也可以是非循环的，最后一个指针是 0\n\n-- the null value -- which would indicate we've reached the end of the list.\n\"null\"，代表链表尽头\n\nWhen programmers use linked lists,\n当程序员用链表时\n\nthey rarely look at the memory values stored in the next pointers.\n很少看指针具体指向哪里\n\nInstead, they can use an abstraction of a linked list, that looks like this,\n而是用链表的抽象模型，就像上图\n\nwhich is much easier to conceptualize.\n更容易看懂\n\nUnlike an array, whose size has to be pre-defined,\n数组大小需要预先定好\n\nlinked lists can be dynamically extended or shortened.\n链表大小可以动态增减\n\nFor example, we can allocate a new node in memory,\n可以创建一个新节点，通过改变指针值，把新节点插入链表\n\nand insert it into this list, just by changing the next pointers.\n可以创建一个新节点，通过改变指针值，把新节点插入链表\n\nLinked Lists can also easily be re-ordered, trimmed, split, reversed, and so on.\n链表也很容易重新排序，两端缩减，分割，倒序等\n\nWhich is pretty nifty!\n超方便！\n\nAnd pretty useful for algorithms like sorting, which we talked about last week.\n链表也适合上集的排序算法\n\nOwing to this flexibility, many more-complex data structures are built on top of linked lists\n因为灵活，很多复杂数据结构 都用链表\n\nThe most famous and universal are queues and stacks.\n最出名的是 队列（queue）和 栈（stack）\n\nA queue - like the line at your post office - goes in order of arrival.\n\"队列\" 就像邮局排队，谁先来就排前面\n\nThe person who has been waiting the longest, gets served first.\n\"队列\" 就像邮局排队，谁先来就排前面\n\nNo matter how frustrating it is that all you want to do is buy stamps\n虽然你可能只想买邮票，而前面的人要寄 23 个包裹\n\nand the person in front of you seems to be mailing 23 packages.\n虽然你可能只想买邮票，而前面的人要寄 23 个包裹\n\nBut, regardless, this behavior is called First-In First-Out, or FIFO.\n这叫 先进先出（FIFO）\n\nThat's the first part.\n我指队列，不是指那 23 个包裹\n\nNot the 23 packages thing.\n我指队列，不是指那 23 个包裹\n\nImagine we have a pointer, named \"post office queue\", that points to the first node in our linked list.\n想象有个指针叫\"邮局队列\"，指向链表第一个节点\n\nOnce we're done serving Hank, we can read Hank's next pointer,\n第一个节点是 Hank，服务完 Hank 之后 \\N 读取 Hank 的指针\n\nand update our \"post office queue\" pointer to the next person in the line.\n把\"邮局队列\"指向下一个人\n\nWe've successfully dequeued Hank -- he's gone, done, finished.\n这样就把 Hank \"出队\"（dequeue）了\n\nIf we want to enqueue someone, that is, add them to the line,\n如果我们想把某人\"入队\"（enqueue） \\N 意思是加到队列里\n\nwe have to traverse down the linked list until we hit the end,\n要遍历整个链表到结尾\n\nand then change that next pointer to point to the new person.\n然后把结尾的指针，指向新人（Nick）\n\nWith just a small change, we can use linked lists as stacks, which are LIFO…\n只要稍作修改，就能用链表做 栈，\\N 栈是后进先出(LIFO)\n\nLast-In First-Out.\n只要稍作修改，就能用链表做 栈，\\N 栈是后进先出(LIFO)\n\nYou can think of this like a stack of pancakes...\n可以把\"栈\"想成一堆松饼\n\nas you make them, you add them to the top of stack.\n做好一个新松饼，就堆在之前上面\n\nAnd when you want to eat one, you take them from the top of the stack.\n吃的时候，是从最上面开始\n\nDelicious!\n美味！\n\nInstead of enqueueing and dequeuing,\n栈就不叫\"入队\"\"出队\"了\n\ndata is pushed onto the stack and popped from the stacks.\n叫\"入栈\"（push） \"出栈\"（pop）\n\nYep, those are the official terms!\n对，这些是正确术语！\n\nIf we update our node struct to contain not just one, but two pointers,\n如果节点改一下，改成 2 个指针\n\nwe can build trees,\n就能做 树（tree）\n\nanother data structure that's used in many algorithms.\n很多算法用了 \"树\" 这种数据结构\n\nAgain, programmers rarely look at the values of these pointers,\n同样，程序员很少看指针的具体值\n\nand instead conceptualize trees like this: The top most node is called the root.\n而是把\"树\"抽象成这样：最高的节点叫\"根节点\"（root）\n\nAnd any nodes that hang from other nodes are called children nodes.\n\"根节点\"下的所有节点   都叫\"子节点\"（children）\n\nAs you might expect, nodes above children are called parent nodes.\n任何子节点的直属上层节点，叫\"母节点\"（parent node）\n\nDoes this example imply that Thomas Jefferson is the parent of Aaron Burr?\n这个例子能说明 托马斯·杰斐逊 是 阿龙·伯尔 的父亲吗？\n\nI'll leave that to your fanfiction to decide.\n我让你们的同人文来决定\n\nAnd finally, any nodes that have no children\n没有任何\"子节点\"的节点\n\n-- where the tree ends -- are called Leaf Nodes.\n也就是\"树\"结束的地方，叫\"叶节点\"（leaf）\n\nIn our example, nodes can have up to two children,\n在这里的例子中，节点最多只可以有 2 个子节点\n\nand for that reason, this particular data structure is called a binary tree.\n因此叫 二叉树（binary tree）\n\nBut you could just as easily have trees with three, four or any number of children\n但你可以随便改，弄成 3个，4个，或更多\n\nby modifying the data structure accordingly.\n但你可以随便改，弄成 3个，4个，或更多\n\nYou can even have tree nodes that use linked lists to store all the nodes they point to.\n甚至节点 可以用链表存所有子节点\n\nAn important property of trees - both in real life and in data structures - is that\n\"树\"的一个重要性质是（不管现实中还是数据结构中）\n\nthere's a one-way path from roots to leaves.\n\"根\"到\"叶\"是 单向 的\n\nIt'd be weird if roots connected to leaves, that connected to roots.\n如果根连到叶，叶连到根  就很奇怪\n\nFor data that links arbitrarily, that include things like loops,\n如果数据随意连接，包括循环\n\nwe can use a graph data structure instead.\n可以用\"图\"表示\n\nRemember our graph from last episode of cities connected by roads?\n还记得上集用路连接城市的\"图\"吗？\n\nThis can be stored as nodes with many pointers, very much like a tree,\n这种结构  可以用有多个指针的节点表示\n\nbut there is no notion of roots and leaves, and children and parents…\n因此没有 根 叶 子节点 父节点 这些概念\n\nAnything can point to anything!\n可以随意指向！\n\nSo that's a whirlwind overview\n以上概述了计算机科学中，最主要的一些数据结构\n\nof pretty much all of the fundamental data structures used in computer science.\n以上概述了计算机科学中，最主要的一些数据结构\n\nOn top of these basic building blocks,\n这些基本结构之上，程序员做了各种新变体，有不同性质.\n\nprogrammers have built all sorts of clever variants, with slightly different properties\n这些基本结构之上，程序员做了各种新变体，有不同性质.\n\n-- data structures like red-black trees and heaps, which we don't have time to cover.\n比如\"红黑树\"和\"堆\"，我们没时间讲\n\nThese different data structures have properties that are useful for particular computations.\n不同数据结构适用于不同场景\n\nThe right choice of data structure can make your job a lot easier,\n选择正确数据结构会让工作更简单\n\nso it pays off to think about how you want to structure your data before you jump in.\n所以花时间考虑用什么数据结构是值得的\n\nFortunately, most programming languages come with\n幸运的是，大多数编程语言自带了预先做好的数据结构\n\nlibraries packed full of ready-made data structures.\n幸运的是，大多数编程语言自带了预先做好的数据结构\n\nFor example, C++ has its Standard Template Library, and Java has the Java Class Library.\n比如，C++有\"标准模板库\"，Java有\"Java 类库\"\n\nThese mean programmers don't have to waste time implementing things from scratch,\n程序员不用浪费时间从零写\n\nand can instead wield the power of data structures to do more interesting things,\n时间可以花在更有趣的事情\n\nonce again allowing us to operate at a new level of abstraction!\n又提升了一层抽象！\n\nI'll see you next week.\n下周见！\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/15. 阿兰·图灵-Alan Turing.ass.txt",
    "content": "Hi, I'm Carrie Anne and welcome to Crash Course computer science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the past a few episodes,\n前几集我们聊了基础，比如函数，算法和数据结构\n\nwe've been building up our understanding of computer science fundamentals,\n前几集我们聊了基础，比如函数，算法和数据结构\n\nsuch as functions, algorithms and data structures.\n前几集我们聊了基础，比如函数，算法和数据结构\n\nToday, we're going to take a step back and look at the person\n今天，我们来看一位对计算机理论 贡献巨大的人\n\nwho formulated many of the theoretical concepts that underline modern computation.\n今天，我们来看一位对计算机理论 贡献巨大的人\n\nThe father of computer science\n计算机科学之父\n\nand not quite Benedict Cumberbatch lookalike, Alan Turing.\n长得不怎么像 本尼 的 阿兰·图灵\n\nAlan Mathison Turing was born in London in 1912\n阿兰·马蒂森·图灵 于 1921 年出生在伦敦，\\N 从小就表现出惊人数学和科学能力\n\nand showed an incredible aptitude for maths and science throughout his early education.\n阿兰·马蒂森·图灵 于 1921 年出生在伦敦，\\N 从小就表现出惊人数学和科学能力\n\nHis first brush of what we now call computer science came in 1935\n他对计算机科学的建树始于 1935 年\n\nwhile he was a master student at King's College in Cambridge.\n当时他是剑桥国王学院的硕士生\n\nHe set out to solve a problem posed by German Mathematician David Hilbert\n他开始解决德国数学家 大卫·希尔伯特 提出的问题\n\nknown as the Entscheidungsproblem\n叫 Entscheidungsproblem （德语）\n\nor decision problem,\n即\"可判定性问题\":\n\nwhich asked the following:\n即\"可判定性问题\":\n\nis there an algorithm that takes, as input, a statement written in formal logic,\n是否存在一种算法，输入正式逻辑语句 \\N 输出准确的\"是\"或\"否\"答案？\n\nand produces a \"yes\" or \"no\" answer that's always accurate?\n是否存在一种算法，输入正式逻辑语句 \\N 输出准确的\"是\"或\"否\"答案？\n\nIf such an algorithm existed,\n如果这样的算法存在， \\N 可以回答比如 \"是否有一个数大于所有数\"\n\nwe could use it to answer questions like, \"Is there a number bigger than all numbers?\"\n如果这样的算法存在， \\N 可以回答比如 \"是否有一个数大于所有数\"\n\nNo, there's not. We know the answer to that one,\n不, 没有.  我们知道答案\n\nbut there are many other questions in mathematics that we'd like to know the answer too.\n但有很多其他数学问题，我们想知道答案\n\nSo if this algorithm existed, we'd want to know it.\n所以如果这种算法存在,  我们想知道\n\nThe American mathematician Alonzo Church first presented a solution to this problem in 1935.\n美国数学家 阿隆佐·丘奇  \\N 于 1935年 首先提出解决方法\n\nHe developed a system of mathematical expressions called Lambda Calculus\n开发了一个叫\"Lambda 算子\"的数学表达系统\n\nand demonstrated that no such universal algorithm could exist.\n证明了这样的算法不存在\n\nAlthough Lambda Calculus was capable of representing any computation,\n虽然\"Lambda 算子\"能表示任何计算\n\nthe mathematical technique was difficult to apply and understand.\n但它使用的数学技巧 难以理解和使用\n\nAt pretty much the same time on the other side of the Atlantic,\n同时在大西洋另一边\n\nAlan Turing came up with his own approach to solve the decision problem.\n阿兰·图灵 想出了自己的办法来解决\"可判定性问题\"\n\nHe proposed a hypothetical computing machine, which we now call a Turing Machine.\n提出了一种假想的计算机，现在叫\"图灵机\"\n\nTuring Machines provided a simple, yet powerful\n图灵机提供了简单又强大的数学计算模型\n\nmathematical model of computation.\n图灵机提供了简单又强大的数学计算模型\n\nAlthough using totally different mathematics,\n虽然用的数学不一样\n\nthey were functionally equivalent to lambda calculus in terms of their computational power.\n但图灵机的计算能力和 Lambda 算子一样\n\nHowever their relative simplicity made them much more popular\n同时因为图灵机更简单，所以在新兴的计算机领域更受欢迎\n\nin the burgeoning field of computer science.\n同时因为图灵机更简单，所以在新兴的计算机领域更受欢迎\n\nIn fact, they're simple enough that I'm going to explain it right now.\n因为它如此简单，我现在就给你解释\n\nA Turing Machine is a theoretical computing device\n图灵机是一台理论计算设备\n\nThere's also a state variable in which we can hold a piece of information\n还有一个状态变量，保存当前状态\n\nabout the current state of the machine.\n还有一个状态变量，保存当前状态\n\nAnd a set of rules that describes what the machine does.\n还有一组规则，描述机器做什么\n\nGiven a state and the current symbol the head is reading,\n规则是根据 当前状态+读写头看到的符号，决定机器做什么\n\nthe rule can be to write a symbol on the tape,\n结果可能是在纸带写入一个符号\n\nchange the state of the machine, move the read/write head to the left or right by one spot\n或改变状态，或把读写头移动一格\n\nor any combination of these actions.\n或执行这些动作的组合\n\nTo make this concrete, let's work through a simple example:\n为了更好理解，讲个简单例子：\n\na Turing Machine that reads a string of ones ending in a zero\n让图灵机读一个以零结尾的字符串\n\nand computes whether there is an even number of ones.\n并计算 1 的出现次数  是不是偶数\n\nIf that's true,\n如果是, 在纸带上写一个 1\n\nthe machine will write a one to the tape\n如果是, 在纸带上写一个 1\n\nand if it's false, it'll write a zero.\n如果不是，在纸带上写一个 0\n\nFirst we need to define our Turing machine rules.\n首先要定义\"图灵机\"的规则\n\nIf the state is even and the current symbol of the tape is one,\n如果当前状态是\"偶数\",  当前符号是1\n\nthen we update the machine state to odd and move the head to the right.\n那么把状态更新为\"奇数\"，把读写头向右移动\n\nOn the other hand if the state is even and the current symbol is zero,\n如果当前状态为偶数，当前符号是 0\n\nwhich means we've reached the end of the string of ones,\n意味着到了字符串结尾\n\nthen we write one to the tape and change the state to halt,\n那么在纸带上写一个 1，并且把状态改成 停机(halt)\n\nas in we're finished and the Turing machine has completed the computation.\n状态改为\"停机\" 是因为图灵机已完成计算\n\nWe also need rules for when the Turing machine is in an odd state,\n但我们还需要 2 条规则，来处理状态为奇数的情况\n\none rule for the symbol on the tape is a zero and another for when it is one.\n一条处理 奇数 + 纸带是 0 的情况 \\N 一条处理 奇数 + 纸带是 1 的情况\n\nLastly we need to define a Starting state, which we'll set to be even.\n最后，要决定机器的初始状态，这里定成\"偶数\"\n\nNow we've defined the rules in the starting state of our Turing machine,\n定义好了 起始状态+规则\n\nwhich is comparable to a computer program, we can run it on some example input.\n就像写好了程序，现在可以输入了\n\nLet's say we store 1 1 0 onto tape.\n假设把\"1 1 0\"放在纸带上，有两个 1，是偶数\n\nThat's two ones, which means there is an even number of ones,\n假设把\"1 1 0\"放在纸带上，有两个 1，是偶数\n\nand if that's news to you,\n如果\"偶数\"对你是新知识 \\N 也许我们该开一门【十分钟速成课：数学】\n\nWe should probably get working on crash course Math.\n如果\"偶数\"对你是新知识 \\N 也许我们该开一门【十分钟速成课：数学】\n\nNotice that our rules only ever move their head to the right\n注意，规则只让 读写头 向右移动\n\nso the rest of the tape is irrelevant.\n其他部分无关紧要，为了简单所以留空\n\nWe'll leave it blank for simplicity.\n其他部分无关紧要，为了简单所以留空\n\nOur Turing machine is all ready to go so let's start it.\n\"图灵机\"准备好了，开始吧\n\nOur state is even and the first number we see is one.\n机器起始状态为\"偶数\"，看到的第一个数是 1\n\nThat matches our topmost rule and so we execute the effect,\n符合最上面那条规则，所以执行对应的步骤\n\nwhich is to update the state to odd and move the read/write head to the right by one spot.\n把状态更新到\"奇数\"， 读写头向右移动一格\n\nOkay, now we see another one on the tape, But this time our state is odd\n然后又看到 1, 但机器状态是\"奇数\"，所以执行第三条规则\n\nand so we execute our third rule\n然后又看到 1, 但机器状态是\"奇数\"，所以执行第三条规则\n\nwhich sets the state back to even and moves the head to the right.\n使机器状态变回\"偶数\"，读写头向右移动一格\n\nNow we see a 0 and our current state is even\n现在看到 0，并且机器状态是 偶数，所以执行第二条规则\n\nso we execute our second rule\n现在看到 0，并且机器状态是 偶数，所以执行第二条规则\n\nwhich is to write a 1 to the tape signifying that yes, it's true,\n在纸带上写 1，表示\"真\" 的确有偶数个 1\n\nthere is an even number of ones,\n在纸带上写 1，表示\"真\" 的确有偶数个 1\n\nand finally the machine halts.\n然后机器停机\n\nThat's how Turing machines work.\n这就是图灵机的原理，很简单对吧？\n\nPretty simple, right?\n这就是图灵机的原理，很简单对吧？\n\nso you might be wondering why there's such a big deal.\n你可能想知道 有什么大不了的\n\nWell, Turing shows that this simple hypothetical machine\n图灵证明了这个简单假想机器\n\ncan perform any computation if given enough time and memory.\n如果有足够时间和内存，可以执行任何计算\n\nIt's a general-purpose computer.\n它是一台通用计算机\n\nOur program was a simple example.\n刚才的程序就是个简单例子\n\nBut with enough rules, states and tape,\n只要有足够的规则，状态和纸带  可以创造任何东西\n\nyou could build anything\n只要有足够的规则，状态和纸带  可以创造任何东西\n\n- a web browser, world of warcraft, whatever!\n浏览器, 魔兽世界 任何东西！\n\nOf course it would be ridiculously inefficient, but it is theoretically possible.\n当然 这样做效率很低，但理论上可行.\n\nAnd that's why, as a model of computing,\n所以图灵机是很强大的计算模型\n\nit's such a powerful idea.\n所以图灵机是很强大的计算模型\n\nIn fact, in terms of what it can and cannot compute\n事实上，就可计算和不可计算而言\n\nthere's no computer more powerful than a turing machine.\n没有计算机比图灵机更强大\n\nA computer that is as powerful is called Turing complete.\n和图灵机一样强大的，叫 \"图灵完备\"\n\nEvery modern computing system, your laptop, your smartphone\n每个现代计算系统 比如笔记本电脑，智能手机\n\nand even the little computer inside your microwave and thermostat\n甚至微波炉和恒温器内部的小电脑\n\nare all Turing Complete.\n都是\"图灵完备\"的\n\nTo answer Hilbert's decision problem,\n为了回答可判定性问题\n\nTuring applied these new Turing machines to an intriguing computational puzzle:\n他把图灵机用于一个有趣计算问题：\n\nthe halting problem.\n\"停机问题\"\n\nPut simply this asks\n简单说就是\n\n\"Is there an algorithm that can determine,\n\"给定图灵机描述和输入纸带，是否有算法可以确定\n\ngiven a description of a turing machine and the input from its tape,\n\"给定图灵机描述和输入纸带，是否有算法可以确定\n\nwhether the Machine will run forever or halt?\"\n机器会永远算下去还是到某一点会停机？\n\nFor example we know our Turing machine will halt when given the input 1 1 0\n我们知道输入 1 1 0，图灵机会停机\n\nBecause we literally walk through the example until it halted,\n因为刚做过这个例子，它最后停机了\n\nbut what about a more complex problem?\n但如果是更复杂的问题呢？\n\nIs there a way to figure out if the program will halt without executing it?\n有没有办法在不执行的情况，弄清会不会停机？\n\nSome programs might take years to run\n一些程序可能要运行好几年\n\nso it would be useful to know before we run it\n所以在运行前知道 会不会出结果很有用\n\nand wait and wait and wait and then start getting worried and wonder\n否则就要一直等啊等，忧虑到底会不会出结果\n\nand then decades later when you're old and gray control-alt-delete.\n当几十年后变老了，再按强制结束\n\nSo much sadness!\n好悲伤！\n\nUnfortunately, Turing came up with a proof that shows the halting problem was in fact unsolvable,\n图灵通过一个巧妙逻辑矛盾 \\N 证明了停机问题是无法解决的\n\nthrough a clever logical contradiction.\n图灵通过一个巧妙逻辑矛盾 \\N 证明了停机问题是无法解决的\n\nLet's follow his reasoning.\n我们来看看他的推理\n\nImagine we have a hypothetical Turing machine that takes a description of a program\n想象有一个假想图灵机，\\N 输入：问题的描述 + 纸带的数据\n\nand some input for his tape\n想象有一个假想图灵机，\\N 输入：问题的描述 + 纸带的数据\n\nand always outputs either Yes, it halts, or no, it doesn't.\n输出 Yes 代表会\"停机\"，输出 No 代表不会\n\nAnd I'm going to give this machine a fun name\n我要给这台机器一个有趣的名字叫 H， \\N 来自\"停机\"的第一个字母\n\nH for Halts.\n我要给这台机器一个有趣的名字叫 H， \\N 来自\"停机\"的第一个字母\n\nDon't worry about how it works.\n不用担心它具体怎么工作\n\nLet's just assume such a machine exists.\n假设这样的机器存在就好  毕竟重点是推论\n\nWe're talking theory here.\n假设这样的机器存在就好  毕竟重点是推论\n\nTuring reasons if there existed a program whose halting behavior was not decidable by H,\n图灵推理说： 如果有个程序， H 无法判断是否会\"停机\"\n\nit would mean the halting problem is unsolvable.\n意味着\"停机问题\"无法解决\n\nTo find one, Turing designed another Turing machine that built on top of H.\n为了找到这样的程序，图灵用 H 设计了另一个图灵机\n\nIf H says the program halts,\n如果 H 说程序会\"停机\"，那么新机器会永远运行（即不会停机）\n\nthen we'll make our new machine loop forever.\n如果 H 说程序会\"停机\"，那么新机器会永远运行（即不会停机）\n\nIf the answer is no, it doesn't the halt.\n如果 H 的结果为 No，代表不会停机\n\nThat will have the new machine output no and halt.\n那么让新机器输出 No，然后\"停机\"\n\nIn essence, we're building a machine that does the opposite of what H says.\n实质上是一台和 H 输出相反的机器\n\nHalt if the program doesn't halt\n如果程序不停机，就停机\n\nand run forever if the program halts.\n如果程序停机，就永远运行下去\n\nSo this argument will also need to add a splitter to the front of our new machine.\n我们还需要在机器前面加一个分离器\n\nSo it accepts only one input and passes that as both the program and input into H.\n让机器只接收一个输入，\\N 这个输入既是程序，也是输入\n\nLet's call this new Machine Bizzaro.\n我们把这台新机器叫 异魔\n\nSo far this seems like a plausible machine right.\n目前为止，这个机器不难理解\n\nNow it's going to get pretty complicated.\n但接下来马上会变复杂，会有点难懂\n\nBut bear with me for a second.\n但接下来马上会变复杂，会有点难懂\n\nLook what happens when you pass bizzaro a description of itself as the input.\n如果把 异魔 的描述，作为本身的输入会怎样\n\nThis means We're asking h what bizzaro will do when asked to evaluate itself.\n意味着在问 H ，当异魔的输入是自己时会怎样\n\nBut if H says Bizzaro halts,\n但如果 H 说异魔会停机\n\nthen Bizzaro enters its infinite loop and thus doesn't halt.\n那么异魔会进入无限循环，因此不会停机\n\nAnd if H says the Bizzaro doesn't halt, then Bizzaro outputs no and halt.\n如果 H 说异魔不会停机，那么异魔会输出 No 然后停机\n\nSo H can't possibly decide the halting problem correctly\n所以 H 不能正确判定 停机问题\n\nbecause there is no answer.\n因为没有答案\n\nIt's a paradox.\n这是一个悖论\n\nAnd this paradox means that the halting problem cannot be solved with Turing machines.\n意味着\"停机问题\"不能用图灵机解决\n\nRemember Turing proves that Turing machines could implement any computation.\n还记得刚刚说： 图灵证明了图灵机可以实现任何计算\n\nSo this solution to the halting problem proves\n\"停机问题\"证明了，不是所有问题都能用计算解决\n\nthat not all problems can be solved by computation.\n\"停机问题\"证明了，不是所有问题都能用计算解决\n\nWow, that's some heavy stuff.\n哇，好难理解\n\nI might have to watch that again myself.\n我都可能要再看一遍\n\nLong story short, Church and Turing showed there were limits to the ability of computers.\n长话短说，丘奇和图灵证明了计算机的能力有极限\n\nNo matter how much time or memory you have,\n无论有多少时间或内存，有些问题是计算机无法解决的\n\nthere are just some problems that cannot be solved ever.\n无论有多少时间或内存，有些问题是计算机无法解决的\n\nThe concurrent efforts by Church and Turing to determine the limits of computation,\n丘奇和图灵证明了计算是有极限的，\n\nand in general, formalize computability, are now called the Church-Turing Thesis.\n起步了可计算性理论，现在叫\"丘奇-图灵论题\"\n\nAt this point in 1936, Turing was only 24 years old\n当时是1936年，图灵只有24岁\n\nand really only just beginning his career.\n他的职业生涯才刚刚开始\n\nFrom 1936 through 1938,\n从1936年到1938年 \\N 在丘奇指导下，他在普林斯顿拿到博士学位\n\nhe completed a PhD at Princeton University under the guidance of Church\n从1936年到1938年 \\N 在丘奇指导下，他在普林斯顿拿到博士学位\n\nthen after graduating he returned to Cambridge.\n毕业后回到剑桥\n\nShortly after in 1939, Britain became embroiled in World War II.\n1939年后不久，英国卷入第二次世界大战\n\nTuring's genius was quickly applied for the war effort.\n图灵的才能很快被投入战争\n\nIn fact, a year before the war started,\n事实上，在战争开始前一年\n\nhe was already working part-time at the UK's government Code and Cypher school,\n他已经在英国政府的 密码破译学校兼职\n\nwhich was the British code breaking group based out of Bletchley Park.\n位于\"布莱切利园\"的一个密码破译组织\n\nOne of his main efforts was figuring out how to decrypt German communications.\n他的工作内容之一是破解德国的通信加密\n\nEspecially those that use the Enigma Machine.\n特别是\"英格玛机\"加密的信息\n\nIn short, these machines scrambled text\n简单说，英格玛机会加密明文\n\nlike you type the letters H-E-L-L-O\n如果输入字母 H-E-L-L-O\n\nand the letters X-W-D-B-J would come out.\n机器输出 X-W-D-B-J\n\nThis process is called Encryption.\n这个过程叫\"加密\"\n\nThe scrambling wasn't random.\n文字不是随便打乱的\n\nThe behavior was defined by a series of real world rotors on the top of the enigma machine.\n加密由\"英格玛机\"顶部的齿轮组合决定\n\nEach were 26 possible rotational positions.\n每个齿轮有26个可能位置\n\nThere was also a plug board at the front of the machine that allow pairs of letters to be swapped.\n机器前面还有插板，可以将两个字母互换\n\nIn total, there were billions of possible settings.\n总共有上十亿种可能\n\nIf you had your only enigma machine and you knew the correct rotor and plug board settings,\n如果你有\"英格玛机\"，并且知道正确的齿轮和插头设置\n\nyou could type in X-W-D-B-J and \"hello\" would come out.\n输入X-W-D-B-J，机器会输出 hello\n\nIn other words, you decrypted the message.\n解密了这条消息\n\nOf course, the German military wasn't sharing their enigma settings on Social Media.\n当然，德军不会把机器设置发到微博上\n\nSo the allies had to break the code.\n盟军必须自己破译密码\n\nWith billions of Rotor and plug board combinations,\n有数十亿种组合，根本没法手工尝试所有组合\n\nthere was no way to check them all by hand.\n有数十亿种组合，根本没法手工尝试所有组合\n\nFortunately for Turing, Enigma Machines and the people who operated them were not perfect.\n幸运的是，英格玛机和操作员不是完美的\n\nLike one key flaw was that a letter would never be encoded as itself,\n一个大缺陷是：字母加密后绝不会是自己\n\nas in an H was never encrypted as an H.\nH 加密后绝对不是 H\n\nTuring building on earlier work by Polish code breakers\n图灵接着之前波兰破译专家的成果继续工作\n\ndesigned a special-purpose electro-mechanical computer called the bombe\n设计了一个机电计算机，叫 Bombe\n\nthat took advantages of this flaw.\n利用了这个缺陷，它对加密消息尝试多种组合\n\nIt tried lots and lots of combinations of enigma settings for a given encrypted message.\n利用了这个缺陷，它对加密消息尝试多种组合\n\nIf the bombe found a setting that led to a letter being encoded as itself\n如果发现字母解密后和原先一样\n\nwhich we know no enigma machines could do.\n我们知道英格玛机决不会这么做\n\nThat combination was discarded then the machine moved on to try another combination.\n这个组合会被跳过，接着试另一个组合\n\nSo bombe was used to greatly narrow the number of Possible enigma settings.\nBombe 大幅减少了搜索量\n\nThis allowed human code breakers to hone their efforts on the most probable solutions,\n让破译人员把精力花在更有可能的组合\n\nlooking for things like common german words in fragments of decoded text.\n比如在解码文本中找常见的德语单词\n\nPeriodically, the Germans would suspect someone was decoding their communications\n德国人时不时会怀疑有人在破解，然后升级英格玛机\n\nand upgrade the enigma machine,\n德国人时不时会怀疑有人在破解，然后升级英格玛机\n\nlike they'd add another rotor creating many more combinations.\n比如加一个齿轮，创造更多可能组合\n\nThey even built entirely new encryption machines.\n他们甚至还做了全新的加密机\n\nThroughout the war, Turing and his colleagues at Bletchley Park\n整个战争期间，图灵和同事在布莱切利园努力破解加密\n\nworked tirelessly to defeat these mechanisms.\n整个战争期间，图灵和同事在布莱切利园努力破解加密\n\nAnd overall, the intelligence gained from decrypted German communications\n解密得到的德国情报，为盟军赢得了很多优势\n\ngave the allies an edge in many theaters\n解密得到的德国情报，为盟军赢得了很多优势\n\nwith some historians arguing is shortened the war by years.\n有些史学家认为他们把战争减短了好几年\n\nAfter the war, Turing return to academia\n战后，图灵回到学术界 \\N 为许多早期计算机工作做出贡献\n\nand contributed to many early electronic computing efforts\n战后，图灵回到学术界 \\N 为许多早期计算机工作做出贡献\n\nlike the Manchester Mark 1, which was an early and influential stored-program computer.\n比如曼彻斯特 1 号，一个早期有影响力的存储程序计算机\n\nBut his most famous post-war contribution was the Artificial Intelligence.\n但他最有名的战后贡献是\"人工智能\"\n\nA field's so new that it didn't get that name until 1956.\n这个领域很新，直到1956年才有名字\n\nIt's a huge topic. So we'll get to it again in future episodes.\n这个话题很大，以后再谈（第34集）\n\nIn 1950, Turing could envision a future where computers\n1950 年，图灵设想了未来的计算机\n\nwere powerful enough to exhibit intelligence equivalent to\n拥有和人类一样的智力，或至少难以区分\n\nor at least indistinguishable from that of a human.\n拥有和人类一样的智力，或至少难以区分\n\nTuring postulated that a computer would deserve to be called intelligent\n图灵提出 \\N 如果计算机能欺骗人类相信它是人类，才算是智能\n\nif it could deceive a human into believing that it was human.\n图灵提出 \\N 如果计算机能欺骗人类相信它是人类，才算是智能\n\nThis became the basis of a simple test, now called the Turing test.\n这成了智能测试的基础，如今叫\"图灵测试\"\n\nImagine that you are having a conversation with two different people\n想像你在和两个人沟通 \\N 不用嘴或面对面，而是来回发消息\n\nnot by voice or in person, but by sending type notes back and forth,\n想像你在和两个人沟通 \\N 不用嘴或面对面，而是来回发消息\n\nyou can ask any questions you want and you get replies.\n可以问任何问题，然后会收到回答\n\nBut one of those two people is actually a computer.\n但其中一个是计算机\n\nIf you can't tell which one is human and which one is a computer,\n如果你分不出哪个是人类，哪个是计算机\n\nthen the computer passes the test.\n那么计算机就通过了图灵测试\n\nThere's a modern version of this test called\n这个测试的现代版叫\n\na completely automated public turing test to tell computers and humans apart\n\"公开全自动图灵测试，用于区分计算机和人类\"\n\nor Captcha for short.\n简称\"验证码\"\n\nThese are frequently used on the internet to prevent automated systems\n防止机器人发垃圾信息等\n\nfrom doing things like posting spam on websites.\n防止机器人发垃圾信息等\n\nI'll admit sometimes I can't read what those squiggly things say.\n我承认 有时我都认不出那些扭曲的东西是什么字\n\nDoes that mean I'm a computer?\n这难道意味着我是计算机？\n\nNormally in this series, we don't delve into the personal lives of these historical figures.\n通常这个系列我们不会深入历史人物的个人生活\n\nBut in Turing's case his name has been inextricably tied to tragedy\n但图灵与悲剧密不可分\n\nso his story is worth mentioning.\n所以他的故事值得一提\n\nTuring was gained a time when homosexuality was illegal in the United Kingdom and much of the world.\n图灵那个时代，同性恋是违法的，英国和大部分国家都是\n\nAnd an investigation into a 1952 Burglary at his home\n1952 年调查他家的入室盗窃案时，向当局暴露了他的性取向\n\nrevealed his sexual orientation to the authorities,\n1952 年调查他家的入室盗窃案时，向当局暴露了他的性取向\n\nwho charged him with gross indecency.\n被起诉 \"行为严重不检点\"\n\nTuring was convicted and given a choice between imprisonment,\n图灵被定罪，有2个选择： \\N 1. 入狱  2. 接受激素来压制性欲\n\nor probation with hormonal treatments to suppress his sexuality.\n图灵被定罪，有2个选择： \\N 1. 入狱  2. 接受激素来压制性欲\n\nHe chose the latter in part to continue his academic work,\n他选了后者，部分原因是为了继续学术工作\n\nbut it altered his mood and personality.\n但药物改变了他的情绪和性格\n\nAlthough the exact circumstances will never be known,\n虽然确切情况永远无法得知\n\nit's most widely accepted that Alan Turing took his own life by poison in 1954.\n图灵于1954年服毒自尽，年仅41岁\n\nHe was only 41.\n图灵于1954年服毒自尽，年仅41岁\n\nMany things have been named in recognition of Turing's contributions to theoretical computer science\n由于图灵对计算机科学贡献巨大，许多东西以他命名\n\nBut perhaps the most prestigious among them is the Turing award\n其中最出名的是\"图灵奖\"\n\nthe highest distinction in the field of computer science.\n计算机领域的最高奖项\n\nEquivalent to a Nobel prize in Physics, chemistry or other sciences.\n相当于物理, 化学等其它领域的诺贝尔奖\n\nDespite a life cut short, Alan inspire the first generation of computer scientists\n虽然英年早逝，但图灵激励了第一代计算机科学家\n\nand lead key groundwork that enabled a digital era that we get to enjoy today.\n而且为如今便利的数字时代 做出了重要基石性工作\n\nI'll see you next week.\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/16. 软件工程-Software Engineering.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nSo we've talked a lot about sorting in this series\n之前花了很多时间讲排序\n\nand often code to sort a list of numbers might only be ten lines long,\n也写了些 10 行左右的排序代码\n\nwhich is easy enough for a single programmer to write.\n对1个程序员来说很容易写\n\nPlus, it's short enough that you don't need any special tools\n而且代码很短，不必用专门工具\n\n- you could do it in Notepad.\n- 记事本就够了\n\nReally!\n真的！\n\nBut, a sorting algorithm isn't a program;\n但排序算法很少会是独立程序 \\N 更可能是大项目的一小部分\n\nit's likely only a small part of a much larger program.\n但排序算法很少会是独立程序 \\N 更可能是大项目的一小部分\n\nFor example, Microsoft Office has roughly 40 millions lines of code.\n举个例子，微软的 Office 大约有 4000 万代码\n\n40 MILLION!\n4000 万！\n\nThat's way too big for any one person to figure out and write!\n太多了，一个人不可能做到\n\nTo build huge programs like this, programmers use a set of tools and practices.\n为了写大型程序，程序员用各种工具和方法\n\nTaken together, these form the discipline of Software Engineering\n所有这些形成了\"软件工程\"学科\n\n- a term coined by engineer Margaret Hamilton,\n- 这个词由工程师 Margaret Hamilton 创造\n\nwho helped NASA prevent serious problems during the Apollo missions to the moon.\n她帮助 NASA 在阿波罗计划中避免了严重问题\n\nShe once explained it this way:\n她曾说过：\n\n\"It's kind of like a root canal: you waited till the end,\n\"有点像牙根管治疗：你总是拖到最后才做 \\N 但有些事可以预先做好\n\n[but] there are things you could have done beforehand.\n\"有点像牙根管治疗：你总是拖到最后才做 \\N 但有些事可以预先做好\n\nIt's like preventative healthcare,\n有点像预防性体检, 只不过是预防软件出错\"\n\nbut it's preventative software.\"\n有点像预防性体检, 只不过是预防软件出错\"\n\nAs I mentioned in episode 12,\n第 12 集提过\n\nbreaking big programs into smaller functions allows many people to work simultaneously.\n把大项目分解成小函数  可以让多人同时工作\n\nThey don't have to worry about the whole thing,\n不用关心整个项目，关心自己的函数就好了\n\njust the function they're working on.\n不用关心整个项目，关心自己的函数就好了\n\nSo, if you're tasked with writing a sort algorithm,\n如果你的任务是写排序算法\n\nyou only need to make sure it sorts properly and efficiently.\n你只需要确保高效和正确就可以了\n\nHowever, even packing code up into functions isn't enough.\n然而把代码打包成函数 依然不够\n\nMicrosoft Office probably contains hundreds of thousands of them.\n如果只是这样，微软 Office 会有几十万个函数\n\nThat's better than dealing with 40 million lines of code,\n虽然比 4000 万行代码要好一些，但还是太多了\n\nbut it's still way too many \"things\" for one person or team to manage.\n虽然比 4000 万行代码要好一些，但还是太多了\n\nThe solution is to package functions into hierarchies,\n解决办法是：把函数打包成层级. \\N 把相关代码都放在一起，打包成对象（objects）\n\npulling related code together into \"objects\".\n解决办法是：把函数打包成层级. \\N 把相关代码都放在一起，打包成对象（objects）\n\nFor example, car's software might have several functions related to cruise control,\n例如，汽车软件中 可能有几个和定速巡航有关的函数\n\nlike setting speed, nudging speed up or down, and stopping cruise control altogether.\n比如 设定速度，逐渐加速减速，停止定速巡航\n\nSince they're all related,\n因为这些函数都相关，可以包装成一个\"定速巡航对象\"\n\nwe can wrap them up into a unified cruise control object.\n因为这些函数都相关，可以包装成一个\"定速巡航对象\"\n\nBut, we don't have to stop there,\n但不止如此，我们还可以做更多\n\ncruise control is just one part of the engine's software.\n\"定速巡航\"只是引擎软件的一部分\n\nThere might also be sets of functions that control spark plug ignition,\n可能还有 \"火花塞点火\" \"燃油泵\" 和 \"散热器\"\n\nfuel pumps, and the radiator.\n可能还有 \"火花塞点火\" \"燃油泵\" 和 \"散热器\"\n\nSo we can create a \"parent\" Engine Object\n我们可以做一个\"引擎对象\" 来包括所有\"子\"对象\n\nthat contains all of these \"children\" objects.\n我们可以做一个\"引擎对象\" 来包括所有\"子\"对象\n\nIn addition to children *objects*,\n除了子对象，\"引擎对象\"可能有自己的函数\n\nthe engine itself might have its *own* functions.\n除了子对象，\"引擎对象\"可能有自己的函数\n\nYou want to be able to stop and start it, for example.\n比如 开关引擎\n\nIt'll also have its own variables,\n它也会有自己的变量，比如汽车行驶了多少英里\n\nlike how many miles the car has traveled.\n它也会有自己的变量，比如汽车行驶了多少英里\n\nIn general, objects can contain other objects, functions and variables.\n总的来说，对象可以包其它对象，函数和变量\n\nAnd of course, the engine is just one part of a Car Object.\n当然，\"引擎对象\"只是\"汽车对象\"的一部分\n\nThere's also the transmission, wheels, doors, windows, and so on.\n还有传动装置，车轮，门，窗等\n\nNow, as a programmer, if I want to set the cruise control,\n作为程序员，如果想设\"定速巡航\"\n\nI navigate down the object hierarchy,\n要一层层向下\n\nfrom the outermost objects to more and more deeply nested ones.\n从最外面的对象往里找\n\nEventually, I reach the function I want to trigger:\n最后找到想执行的函数：\n\n\"Car, then engine, then cruise control, then set cruise speed to 55\".\nCar. Engine.  CruiseControl.  setCruiseSpeed(55)\n\nProgramming languages often use something equivalent to the syntax shown here.\n编程语言经常用类似这样的语法\n\nThe idea of packing up functional units into nested objects is called\n把函数打包成对象的思想叫 \"面向对象编程\"\n\nObject Oriented Programming.\n把函数打包成对象的思想叫 \"面向对象编程\"\n\nThis is very similar to what we've done all series long:\n这种思想和之前类似\n\nhide complexity by encapsulating low-level details in higher-order components.\n通过封装组件，隐藏复杂度\n\nBefore we packed up things like transistor circuits into higher-level boolean gates.\n之前把晶体管  打包成了逻辑门\n\nNow we're doing the same thing with software.\n现在软件也这样做\n\nYet again, it's a way to move up a new level of abstraction!\n又提升了一层抽象！\n\nBreaking up a big program, like a car's software,\n把大型软件（如汽车软件）\\N 拆成一个个更小单元，适合团队合作\n\ninto functional units is perfect for teams.\n把大型软件（如汽车软件）\\N 拆成一个个更小单元，适合团队合作\n\nOne team might be responsible for the cruise control system,\n一个团队负责定速巡航系统\n\nand a single programmer on that team tackles a handful of functions.\n团队里的一位程序员负责其中一些函数\n\nThis is similar to how big, physical things are built, like skyscrapers.\n类似建摩天大楼\n\nYou'll have electricians running wires,\n有电工装电线\n\nplumbers fitting pipes,\n管道工配管\n\nwelders welding,\n焊接工焊接\n\npainters painting,\n油漆工涂油漆\n\nand hundreds of other people teeming all over the hull.\n还有成百上千人做其他事情\n\nThey work together on different parts simultaneously,\n在不同岗位同时工作，各尽其能\n\nleveraging their different skills.\n在不同岗位同时工作，各尽其能\n\nUntil one day, you've got a whole working building!\n直到整栋楼完成\n\nBut, returning to our cruise control example\n回到定速巡航的例子\n\nits code is going to have to make use of functions in other parts of the engine's software,\n定速巡航 要用到引擎的其它函数，来保持车速\n\nto, you know, keep the car at a constant speed.\n定速巡航 要用到引擎的其它函数，来保持车速\n\nThat code isn't part of the cruise control team's responsibility.\n定速巡航 团队不负责这些代码，另一个团队负责\n\nIt's another team's code.\n定速巡航 团队不负责这些代码，另一个团队负责\n\nBecause the cruise control team didn't write that,\n因为是其他团队的代码，\n\nthey're going to need good documentation about what each function in the code does,\n定速巡航 团队需要文档 帮助理解代码都做什么\n\nand a well-defined Application Programming Interface\n以及定义好的 \"程序编程接口\" -简称 API\n\n-- or API for short.\n以及定义好的 \"程序编程接口\" -简称 API\n\nYou can think of an API as the way that\nAPI 帮助不同程序员合作 \\N 不用知道具体细节，只要知道怎么使用就行了\n\ncollaborating programmers interact across various parts of the code.\nAPI 帮助不同程序员合作 \\N 不用知道具体细节，只要知道怎么使用就行了\n\nFor example, in the IgnitionControl object,\n例如\"点火控制\"对象中，可能有\"设置发动机转数\"函数\n\nthere might be functions to set the RPM of the engine,\n例如\"点火控制\"对象中，可能有\"设置发动机转数\"函数\n\ncheck the spark plug voltage,\n\"检查火花塞电压\"函数\n\nas well as fire the individual spark plugs.\n\"点燃单个火花塞\"函数\n\nBeing able to set the motor's RPM is really useful,\n\"设置发动机转速\"非常有用\n\nthe cruise control team is going to need to call that function.\n\"定速巡航\"团队要用到这个函数\n\nBut, they don't know much about how the ignition system works.\n但他们对点火系统不怎么了解\n\nIt's not a good idea to let them call functions that fire the individual spark plugs.\n让他们调用\"点燃单个火花塞\"函数，不是好主意\n\nOr the engine might explode!\n引擎可能会炸！\n\nMaybe.\n可能啦\n\nThe API allows the right people access to the right functions and data.\nAPI 控制哪些函数和数据让外部访问 \\N 哪些仅供内部\n\nObject Oriented Programming languages do this\n\"面向对象\"的编程语言 \\N 可以指定函数是 public 或 private，来设置权限\n\nby letting you specify whether functions are public or private.\n\"面向对象\"的编程语言 \\N 可以指定函数是 public 或 private，来设置权限\n\nIf a function is marked as \"private\",\n如果函数标记成 private\n\nit means only functions inside that object can call it.\n意味着 只有同一个对象内的其他函数能调用它\n\nSo, in this example, only other functions inside of IgnitionControl,\n在这个例子里，只有内部函数比如 setRPM\n\nlike the setRPM function,\n在这个例子里，只有内部函数比如 setRPM\n\ncan fire the sparkplugs.\n才能调用 fireSparkplug 函数\n\nOn the other hand, because the setRPM function is marked as public,\n而 setRPM 函数是 public  \\N 所以其它对象可以调用它，比如 定速巡航\n\nother objects can call it, like cruise control.\n而 setRPM 函数是 public  \\N 所以其它对象可以调用它，比如 定速巡航\n\nThis ability to hide complexity, and selectively reveal it,\n\"面向对象编程\"的核心是 \\N 隐藏复杂度，选择性的公布功能\n\nis the essence of Object Oriented Programming,\n\"面向对象\"的核心是 \\N 隐藏复杂度，选择性的公布功能\n\nand it's a powerful and popular way to tackle building large and complex programs.\n因为做大型项目很有效，所以广受欢迎\n\nPretty much every piece of software on your computer, or game running on your console,\n计算机上几乎所有软件，游戏机里几乎所有游戏\n\nwas built using an Object Oriented Programming Language,\n都是 \"面向对象\" 编程语言写的\n\nlike C++, C# or Objective-C.\n比如 C++, C#, Objective-C 等\n\nOther popular \"OO\" languages you may have heard of are Python and Java.\n其他流行 OO 语言，你可能听过 Python 和 Java\n\nIt's important to remember that code, before being compiled, is just text.\n有一点很重要：代码在编译前就只是文字而已\n\nAs I mentioned earlier,\n前面提过，你可以用记事本或任何文字处理器\n\nyou could write code in Notepad or any old word processor.\n前面提过，你可以用记事本或任何文字处理器\n\nSome people do.\n有人确实这样做\n\nBut generally, today's software developers use special-purpose applications for writing programs,\n但一般来说，现代软件开发者  会用专门的工具来写代码\n\nones that integrate many useful tools for writing, organizing, compiling and testing code.\n工具里集成了很多有用功能\\N 帮助写代码，整理，编译和测代码\n\nBecause they put everything you need in one place,\n因为集成了所有东西\n\nthey're called Integrated Development Environments ,\n因此叫 集成开发环境，简称 IDE\n\nor IDEs for short.\n因此叫 集成开发环境，简称 IDE\n\nAll IDEs provide a text editor for writing code,\n所有 IDE 都有写代码的界面\n\noften with useful features like automatic color-coding to improve readability.\n还带一些有用功能，比如代码高亮，来提高可读性\n\nMany even check for syntax errors as you type, like spell check for code.\n许多 IDE 提供实时检查，比如拼写\n\nBig programs contain lots of individual source files,\n大型项目有很多源代码文件\n\nso IDEs allow programmers to organize and efficiently navigate everything.\nIDE 帮助开发者整理和看代码\n\nAlso built right into the IDE is the ability to compile and run code.\n很多 IDE 还可以直接编译和运行代码\n\nAnd if your program crashes,\n如果程序崩了，因为你还没写完呢\n\nbecause it's still a work in progress,\n如果程序崩了，因为你还没写完呢\n\nthe IDE can take you back to the line of code where it happened,\nIDE 可以定位到出错代码\n\nand often provide additional information to help you track down and fix the bug,\n还会提供信息 帮你解决问题\n\nwhich is a process called debugging.\n这叫 调试（debug）\n\nThis is important\n调试很重要\n\nbecause most programmers spend 70 to 80% of their time testing and debugging,\n大多数程序员会花 70％~80％ 时间调试，而不是在写代码\n\nnot writing new code.\n大多数程序员会花 70％~80％ 时间调试，而不是在写代码\n\nGood tools, contained in IDEs,\n好工具能极大帮助程序员防止和解决错误\n\ncan go a long way when it comes to helping programmers prevent and find errors.\n好工具能极大帮助程序员防止和解决错误\n\nMany computer programmers can be pretty loyal to their IDEs though\n很多开发者只用一款 IDE\n\nBut let's be honest.\n但承认吧，VIM 才是最棒的编辑器\n\nVIM is where it's at.\n但承认吧，VIM 才是最棒的编辑器\n\nProviding you know how to quit.\n如果你知道怎么退出的话\n\nIn addition to coding and debugging,\n除了写代码和调试\n\nanother important part of a programmer's job is documenting their code.\n程序员工作的另一个重要部分是  给代码写文档\n\nThis can be done in standalone files called \"readme\",\n文档一般放在一个叫 README 的文件里\n\nwhich tell other programmers to read that help file before diving in.\n告诉其他程序员，看代码前先看这个文件\n\nIt can also happen right in the code itself with comment\n文档也可以直接写成\"注释\"，放在源代码里\n\nThese are specially-marked statements that the program knows\n注释是标记过的一段文字\n\nto ignore when the code is compiled.\n编译代码时  注释会被忽略\n\nThey exist only to help programmers figure out what's what in the source code.\n注释存在的唯一作用 \\N 就是帮助开发者理解代码\n\nGood documentation helps programmers when they revisit code they haven't seen for awhile,\n好文档能帮助开发者 \\N 几个月后理解自己的代码，对其他人也很重要\n\nbut it's also crucial for programmers who are totally new to it.\n好文档能帮助开发者 \\N 几个月后理解自己的代码，对其他人也很重要\n\nI just want to take a second here and reiterate that it's THE WORST\n我想花一秒 再强调一下注释很重要\n\nwhen someone parachutes a load of uncommented and undocumented code into your lap,\n最糟糕的就是拿到一堆代码，没有任何注释和文档\n\nand you literally have to go line by line to understand what the code is doing.\n结果得逐行读代码，理解到底干嘛的\n\nSeriously.\n我是认真的\n\nDon't be that person.\n别做那种人\n\nDocumentation also promotes code reuse.\n文档还可以提高复用性\n\nSo, instead of having programmers constantly write the same things over and over,\n与其让程序员一遍遍写同样的东西\n\nthey can track down someone else's code that does what they need.\n可以直接用别人写好的来解决问题\n\nThen, thanks to documentation,\n读文档看怎么用就行，不用读代码\n\nthey can put it to work in their program, without ever having to read through the code.\n读文档看怎么用就行，不用读代码\n\n\"Read the docs\" as they say.\n\"读文档啊\"\n\nIn addition to IDEs,\n除了 IDE，还有一个重要软件帮助团队协作\n\nanother important piece of software that\n除了 IDE，还有一个重要软件帮助团队协作\n\nhelps big teams work collaboratively on big coding projects is called\n除了 IDE，还有一个重要软件帮助团队协作\n\nSource Control,\n源代码管理\n\nalso known as version control or revision control.\n也叫\"版本控制\"\n\nMost often, at a big software company like Apple or Microsoft,\n苹果或微软这样的大型软件公司\n\ncode for projects is stored on centralized servers,\n会把代码放到一个中心服务器上\n\ncalled a code repository .\n叫\"代码仓库\"\n\nWhen a programmer wants to work on a piece of code,\n程序员想改一段代码时\n\nthey can check it out,\n可以 check out\n\nsort of like checking out a book out from a library.\n有点像从图书馆借书\n\nOften, this can be done right in an IDE.\n一般这种操作，可以直接在 IDE 内完成\n\nThen, they can edit this code all they want on their personal computer,\n然后开发者在自己的电脑上编辑代码\n\nadding new features and testing if they work.\n加新功能，测试\n\nWhen the programmer is confident their changes are working and there are no loose ends,\n如果代码没问题了，所有测试通过了\n\nthey can check the code back into the repository,\n可以把代码放回去\n\nknown as committing code, for everyone else to use.\n这叫  提交 (commit)\n\nWhile a piece of code is checked out,\n当代码被 check out，而且可能被改过了\n\nand presumably getting updated or modified,\n当代码被 check out，而且可能被改过了\n\nother programmers leave it alone.\n其他开发者不会动这段代码\n\nThis prevents weird conflicts and duplicated work.\n防止代码冲突和重复劳动\n\nIn this way, hundreds of programmers can be simultaneously checking in and out pieces of code,\n这样多名程序员可以同时写代码，建立庞大的系统\n\niteratively building up huge systems.\n这样多名程序员可以同时写代码，建立庞大的系统\n\nCritically, you don't want someone committing buggy code,\n重要的是，你不希望提交的代码里有问题 \\N 因为其他人可能用到了这些代码\n\nbecause other people and teams may rely on it.\n重要的是，你不希望提交的代码里有问题 \\N 因为其他人可能用到了这些代码\n\nTheir code could crash, creating confusion and lost time.\n导致他们的代码崩溃，造成困惑而且浪费时间\n\nThe master version of the code, stored on the server,\n代码的主版本 (master)\n\nshould always compile without errors and run with minimal bugs.\n应该总是编译正常，尽可能少 bug\n\nBut sometimes bugs creep in.\n但有时 bug 还是会出现\n\nFortunately, source control software keeps track of all changes,\n幸运的是，源代码管理可以跟踪所有变化\n\nand if a bug is found,\n如果发现 bug\n\nthe whole code, or just a piece,\n全部或部分代码，可以\"回滚\"到之前的稳定版\n\ncan be rolled back to an earlier, stable version.\n全部或部分代码，可以\"回滚\"到之前的稳定版\n\nIt also keeps track of who made each change,\n\"源代码管理\" 也记录了谁改了什么代码\n\nso coworkers can send nasty,\n所以同事可以给你发 讨厌的\n\nI mean, helpful\n我是说\"有帮助的\" 邮件给写代码的人\n\nand encouraging emails to the offending person.\n我是说\"有帮助的\" 邮件给写代码的人\n\nDebugging goes hand in hand with writing code,\n写代码和测代码密不可分\n\nand it's most often done by an individual or small team.\n测试一般由个人或小团队完成\n\nThe big picture version of debugging is Quality Assurance testing, or QA.\n测试可以统称 \"质量保证测试\"，简称 QA\n\nThis is where a team rigorously tests out a piece of software,\n严格测试软件的方方面面\n\nattempting to create unforeseen conditions that might trip it up.\n模拟各种可能情况，看软件会不会出错\n\nBasically, they elicit bugs.\n基本上就是找 bug\n\nGetting all the wrinkles out is a huge effort,\n解决大大小小的错误需要很多工作\n\nbut vital in making sure the software works\n但对确保软件质量至关重要\n\nas intended for as many users in as many situations as imaginable before it ships.\n让软件在各种情况下按预期运行\n\nYou've probably heard of beta software.\n你可能听过 \"beta 版\" 软件\n\nThis is a version of software that's mostly complete,\n意思是软件接近完成\n\nbut not 100% fully tested.\n但不是 100％ 完全测试过\n\nCompanies will sometimes release beta versions to the public to help them identify issues,\n公司有时会向公众发布 beta 版，以帮助发现问题\n\nit's essentially like getting a free QA team.\n用户就像免费的 QA 团队\n\nWhat you don't hear about as much\n你听过比较少的是 \\N beta 版之前的版本：alpha 版本\n\nis the version that comes before the beta: the alpha version.\n你听过比较少的是 \\N beta 版之前的版本：alpha 版本\n\nThis is usually so rough and buggy, it's only tested internally.\nalpha 版一般很粗糙，错误很多，\\N 经常只在公司内部测试\n\nSo, that's the tip of the iceberg in terms of the tools, tricks and techniques\n以上只是软件工程师用的工具和技巧的冰山一角\n\nthat allow software engineers to construct the huge pieces of software that we know and love today,\n它们帮助软件工程师制作令人喜爱的软件\n\nlike YouTube, Grand Theft Auto 5, and Powerpoint.\n如 YouTube，GTA5 和 PPT 等等\n\nAs you might expect,\n如你所料\n\nall those millions of lines of code needs some serious processing power to run at useful speeds,\n这些代码要强大的处理能力 才能高速速度运行\n\nso next episode we'll be talking about how computers got so incredibly fast.\n所以下集讨论，计算机怎么发展到如今这么快\n\nSee you then.\n到时见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/17. 集成电路&摩尔定律-Integrated Circuits & Moore’s Law.ass.txt",
    "content": "This episode is brought to you by Curiosity Stream.\n本集由 Curiosity Stream 赞助播出\n\nHi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N欢迎收看计算机科学速成课！\n\nOver the past six episodes, we delved into software,\n过去 6 集我们聊了软件 \\N 从早期编程方式到现代软件工程\n\nfrom early programming efforts to modern software engineering practices.\n过去 6 集我们聊了软件 \\N 从早期编程方式到现代软件工程\n\nWithin about 50 years, software grew in complexity from machine code punched by hand onto paper tape\n在大概50年里  软件从纸带打孔  \\N 变成面向对象编程语言  在集成开发环境中写程序\n\nto object oriented programming languages, compiled in integrated development environments.\n在大概50年里  软件从纸带打孔  \\N 变成面向对象编程语言  在集成开发环境中写程序\n\nBut this growth in sophistication would not have been possible without improvements in hardware.\n但如果没有硬件的大幅度进步 \\N 软件是不可能做到这些的\n\nTo appreciate computing hardware’s explosive growth in power and sophistication,\n为了体会硬件性能的爆炸性增长 \\N 我们要回到电子计算机的诞生年代\n\nwe need to go back to the birth of electronic computing.\n为了体会硬件性能的爆炸性增长 \\N 我们要回到电子计算机的诞生年代\n\nFrom roughly the 1940’s through the mid-1960s, every computer was built from individual parts,\n大约 1940年代~1960年代中期这段时间里 \\N 计算机都由独立部件组成\n\ncalled discrete components, which were all wired together.\n叫\"分立元件\" \\N 然后不同组件再用线连在一起\n\nFor example, the ENIAC, consisted of more than 17,000 vacuum tubes, 70,000 resistors,\n举例, ENIAC 有1万7千多个真空管, 7万个电阻\n\n10,000 capacitors, and 7,000 diodes, all of which required 5 million hand-soldered connections.\n1万个电容器, 7千个二极管, 5百万个手工焊点\n\nAdding more components to increase performance meant more connections, more wires\n如果想提升性能，就要加更多部件 \\N 这导致更多电线，更复杂\n\nand just more complexity, what was dubbed the Tyranny of Numbers.\n这个问题叫 \"数字暴政''\n\nBy the mid 1950s, transistors were becoming commercially available\n1950 年代中期，晶体管开始商业化（市场上买得到） \\N 开始用在计算机里\n\nand being incorporated into computers.\n1950 年代中期，晶体管开始商业化（市场上买得到） \\N 开始用在计算机里\n\nThese were much smaller, faster and more reliable than vacuum tubes\n晶体管比电子管 更小更快更可靠\n\nbut each transistor was still one discrete component.\n但晶体管依然是分立元件\n\nIn 1959, IBM upgraded their vacuum-tube-based \"709\" computers to transistors by replacing\n1959年，IBM 把 709 计算机从原本的电子管 \\N 全部换成晶体管\n\nby replacing all the discrete vacuum tubes with discrete transistors.\n1959年，IBM 把 709 计算机从原本的电子管 \\N 全部换成晶体管\n\nThe new machine, the IBM 7090, was six times faster and half the cost.\n诞生的新机器 IBM 7090  \\N 速度快 6 倍，价格只有一半\n\nThese transistorized computers marked the second generation of electronic computing.\n晶体管标志着\"计算 2.0 时代\"的到来\n\nHowever, although faster and smaller,\n虽然更快更小 \\N 但晶体管的出现 还是没有解决\"数字暴政\"的问题\n\ndiscrete transistors didn’t solve the Tyranny of Numbers.\n虽然更快更小 \\N 但晶体管的出现 还是没有解决\"数字暴政\"的问题\n\nIt was getting unwieldy to design,\n有几十万个独立元件的计算机不但难设计 \\N 而且难生产\n\nlet alone physically manufacture computers with hundreds of thousands of individual components.\n有几十万个独立元件的计算机不但难设计 \\N 而且难生产\n\nBy the the 1960s, this was reaching a breaking point.\n1960 年代，这个问题的严重性达到顶点 \\N 电脑内部常常一大堆电线缠绕在一起\n\nThe insides of computers were often just huge tangles of wires.\n1960 年代，这个问题的严重性达到顶点 \\N 电脑内部常常一大堆电线缠绕在一起\n\nJust look at what the inside of a PDP-8 from 1965 looked like!\n看看这个 1965 年 PDP-8 计算机的内部\n\nThe answer was to bump up a new level of abstraction, and package up underlying complexity!\n解决办法是引入一层新抽象，封装复杂性\n\nThe breakthrough came in 1958, when Jack Kilby, working at Texas Instruments,\n突破性进展在 1958 年 \\N 当时 Jack Killby 在德州仪器工作\n\ndemonstrated such an electronic part, \"wherein all the components of the electronic circuit are completely integrated.\n演示了一个电子部件：\\N \"电路的所有组件都集成在一起\"\n\nPut simply: instead of building computer parts out of many discrete components\n简单说就是：\\N 与其把多个独立部件用电线连起来，拼装出计算机\n\nand wiring them all together,\n简单说就是：\\N 与其把多个独立部件用电线连起来，拼装出计算机\n\nyou put many components together, inside of a new, single component.\n我们把多个组件包在一起，变成一个新的独立组件\n\nThese are called Integrated Circuits, or ICs.\n这就是 集成电路（IC）\n\nA few months later in 1959, Fairchild Semiconductor, lead by Robert Noyce, made ICs practical.\n几个月后，在1959年 Robert Noyce 的仙童半导体 \\N 让集成电路变为现实\n\nKilby built his ICs out of germanium, a rare and unstable material.\nKilby 用锗来做集成电路，锗很稀少而且不稳定\n\nBut, Fairchild used the abundant silicon, which makes up about a quarter of the earth's crust!\n仙童半导体公司用硅 \\N 硅的蕴藏量丰富，占地壳四分之一\n\nIt’s also more stable, therefore more reliable.\n也更稳定可靠\n\nFor this reason, Noyce is widely regarded as the father of modern ICs,\n所以 Noyce 被公认为现代集成电路之父\n\nushering in the electronics era... and also Silicon Valley, where Fairchild was based\n开创了电子时代，创造了硅谷（仙童公司所在地）\n\nand where many other semiconductor companies would soon pop up.\n之后有很多半导体企业都出现在硅谷\n\nIn the early days, an IC might only contain a simple circuit with just a few transistors,\n起初，一个 IC 只有几个晶体管 \\N 例如这块早期样品，由西屋公司制造\n\nlike this early Westinghouse example.\n起初，一个 IC 只有几个晶体管 \\N 例如这块早期样品，由西屋公司制造\n\nBut even this allowed simple circuits, like the logic gates from Episode 3,\n即使只有几个晶体管 \\N 也可以把简单电路，第 3 集的逻辑门，能封装成单独组件\n\nto be packaged up into a single component.\n即使只有几个晶体管 \\N 也可以把简单电路，第 3 集的逻辑门，能封装成单独组件\n\nICs are sort of like lego for computer engineers\nIC 就像电脑工程师的乐高积木 \\N 可以组合出无数种设计\n\n\"building blocks\" that can be arranged into an infinite array of possible designs.\nIC 就像电脑工程师的乐高积木 \\N 可以组合出无数种设计\n\nHowever, they still have to be wired together at some point\n但最终还是需要连起来， \\N 创造更大更复杂的电路，比如整个计算机\n\nto create even bigger and more complex circuits, like a whole computer.\n但最终还是需要连起来， \\N 创造更大更复杂的电路，比如整个计算机\n\nFor this, engineers had another innovation: printed circuit boards, or PCB\n所以工程师们再度创新：印刷电路板，简称 PCB\n\nInstead of soldering and bundling up bazillions of wires, PCBs, which could be mass manufactured,\nPCB 可以大规模生产，无需焊接或用一大堆线. \\N 它通过蚀刻金属线的方式，把零件连接到一起\n\nhave all the metal wires etched right into them to connect components together.\nPCB 可以大规模生产，无需焊接或用一大堆线. \\N 它通过蚀刻金属线的方式，把零件连接到一起\n\nBy using PCBs and ICs together, one could achieve exactly the same functional circuit\n把 PCB 和 IC 结合使用 \\N 可以大幅减少独立组件和电线，但做到相同的功能\n\nas that made from discrete components,\n把 PCB 和 IC 结合使用 \\N 可以大幅减少独立组件和电线，但做到相同的功能\n\nbut with far fewer individual components and tangled wires.\n把 PCB 和 IC 结合使用 \\N 可以大幅减少独立组件和电线，但做到相同的功能\n\nPlus, it’s smaller, cheaper and more reliable.\n而且更小，更便宜，更可靠.  三赢！\n\nTriple win!\n而且更小，更便宜，更可靠.  三赢！\n\nMany early ICs were manufactured using teeny tiny discrete components\n许多早期 IC 都是把很小的分立元件 \\N 封装成一个独立单元，例如这块 1964 年的IBM样品\n\npackaged up as a single unit, like this IBM example from 1964.\n许多早期 IC 都是把很小的分立元件 \\N 封装成一个独立单元，例如这块 1964 年的IBM样品\n\nHowever, even when using really really itty-bitty components,\n不过，即使组件很小 \\N 塞5个以上的晶体管还是很困难\n\nit was hard to get much more than around five transistors onto a single IC.\n不过，即使组件很小 \\N 塞5个以上的晶体管还是很困难\n\nTo achieve more complex designs, a radically different fabrication process was needed that\n为了实现更复杂的设计，需要全新的制作工艺 \\N \"光刻\"登场！\n\nchanged everything: Photolithography!\n为了实现更复杂的设计，需要全新的制作工艺 \\N \"光刻\"登场！\n\nIn short, it’s a way to use light to transfer complex patterns to a material, like a semiconductor\n简单说就是 \\N用光把复杂图案印到材料上，比如半导体\n\nIt only has a few basic operations, but these can be used to create incredibly complex circuits.\n它只有几个基础操作，但可以制作出复杂电路\n\nLet’s walk through a simple, although extensive example, to make one of these!\n下面用一个简单例子，来做一片这个！\n\nWe start with a slice of silicon, which, like a thin cookie, is called a wafer.\n我们从一片硅开始，叫\"晶圆\" \\N 长得像薄饼干一样\n\nDelicious!\n美味！\n\nSilicon, as we discussed briefly in episode 2, is special because it’s a semiconductor,\n我们在第 2 集讨论过 \\N 硅很特别，它是半导体\n\nthat is, a material that can sometimes conduct electricity and other times does not.\n它有时导电，有时不导电 \\N 我们可以控制导电时机\n\nWe can control where and when this happens,\n它有时导电，有时不导电 \\N 我们可以控制导电时机\n\nmaking Silicon the perfect raw material for making transistors.\n所以硅是做晶体管的绝佳材料\n\nWe can also use a wafer as a base to lay down complex metal circuits, so everything is integrated,\n我们可以用晶圆做基础 \\N 把复杂金属电路放上面，集成所有东西\n\nperfect for... integrated circuits!\n非常适合做.. 集成电路!\n\nThe next step is to add a thin oxide layer on top of the silicon,\n下一步是在硅片顶部  \\N 加一层薄薄的氧化层, 作为保护层\n\nwhich acts as a protective coating.\n下一步是在硅片顶部  \\N 加一层薄薄的氧化层, 作为保护层\n\nThen, we apply a special chemical called a photoresist.\n然后加一层特殊化学品, 叫 \"光刻胶\" \\N 光刻胶被光照射后 会变得可溶\n\nWhen exposed to light, the chemical changes, and becomes soluble,\n然后加一层特殊化学品, 叫 \"光刻胶\" \\N 光刻胶被光照射后 会变得可溶\n\nso it can be washed away with a different special chemical.\n可以用一种特殊化学药剂洗掉\n\nPhotoresists aren’t very useful by themselves,\n单单光刻胶本身，并不是很有用 \\N 但和\"光掩膜\"配合使用会很强大\n\nbut are super powerful when used in conjunction with a photomask.\n单单光刻胶本身，并不是很有用 \\N 但和\"光掩膜\"配合使用会很强大\n\nThis is just like a piece of photographic film, but instead of a photo of\n光掩膜就像胶片一样，只不过不是 \\N 吃墨西哥卷饼的可爱仓鼠，而是要转移到晶圆上的图案\n\na hamster eating a tiny burrito, it contains a pattern to be transferred onto the wafer.\n光掩膜就像胶片一样，只不过不是 \\N 吃墨西哥卷饼的可爱仓鼠，而是要转移到晶圆上的图案\n\nWe do this by putting a photomask over the wafer, and turning on a powerful light.\n把光掩膜盖到晶圆上，用强光照射 \\N 挡住光的地方，光刻胶不会变化\n\nWhere the mask blocks the light, the photoresist is unchanged.\n把光掩膜盖到晶圆上，用强光照射 \\N 挡住光的地方，光刻胶不会变化\n\nBut where the light does hit the photoresist it changes chemically ，\n光照到的地方，光刻胶会发生化学变化 \\N 洗掉它之后，暴露出氧化层\n\nwhich lets us wash away only the photoresist that was exposed to light, selectively revealing areas of our oxide layer.\n光照到的地方，光刻胶会发生化学变化 \\N 洗掉它之后，暴露出氧化层\n\nNow, by using another special chemical, often an acid, we can remove any exposed oxide,\n用另一种化学物质 - 通常是一种酸 \\N 可以洗掉\"氧化层\"露出的部分, 蚀刻到硅层\n\nand etch a little hole the entire way down to the raw silicon.\n用另一种化学物质 - 通常是一种酸 \\N 可以洗掉\"氧化层\"露出的部分, 蚀刻到硅层\n\nNote that the oxide layer under the photoresist is protected.\n注意，氧化层被光刻胶保护住了.\n\nTo clean up, we use yet another special chemical that washes away any remaining photoresist.\n为了清理光刻胶，我们用另一种化学药品洗掉它\n\nYep, there are a lot of special chemicals in photolithography,\n是的，光刻法用很多化学品，每种都有特定用途\n\neach with a very specific function!\n是的，光刻法用很多化学品，每种都有特定用途\n\nSo now we can see the silicon again,\n现在硅又露出来了 \\N 我们想修改硅露出来的区域  让它导电性更好\n\nwe want to modify only the exposed areas to better conduct electricity.\n现在硅又露出来了 \\N 我们想修改硅露出来的区域  让它导电性更好\n\nTo do that, we need to change it chemically through a process called: doping.\n所以用一种化学过程来改变它，叫\"掺杂\"\n\nI’m not even going to make a joke. Let’s move on.\n不是开玩笑！我们继续\n\nMost often this is done with a high temperature gas, something like Phosphorus,\n\"掺杂\" 通常用高温气体来做，比如磷 \\N 渗透进暴露出的硅，改变电学性质\n\nwhich penetrates into the exposed area of silicon.\n\"掺杂\" 通常用高温气体来做，比如磷 \\N 渗透进暴露出的硅，改变电学性质\n\nThis alters its electrical properties.\n\"掺杂\" 通常用高温气体来做，比如磷 \\N 渗透进暴露出的硅，改变电学性质\n\nWe’re not going to wade into the physics and chemistry of semiconductors,\n半导体的具体物理和化学性质我们不会深究,\n\nbut if you’re interested, there’s a link in the description to an excellent video\n如果你感兴趣，描述里有个视频链接 \\N 视频制作者是 Derek Muller 他的频道叫 Veritasium\n\nby our friend Derek Muller from Veritasium.\n如果你感兴趣，描述里有个视频链接 \\N 视频制作者是 Derek Muller 他的频道叫 Veritasium\n\nBut, we still need a few more rounds of photolithography to build a transistor.\n但我们还需要几轮光刻法 来做晶体管\n\nThe process essentially starts again, first by building up a fresh oxide layer ...\n过程基本一样，先盖氧化层，再盖光刻胶\n\nwhich we coat in photoresist.\n过程基本一样，先盖氧化层，再盖光刻胶\n\nNow, we use a photomask with a new and different pattern,\n然后用新的光掩膜，这次图案不同 \\N 在掺杂区域上方开一个缺口\n\nallowing us to open a small window above the doped area.\n然后用新的光掩膜，这次图案不同 \\N 在掺杂区域上方开一个缺口\n\nOnce again, we wash away remaining photoresist.\n洗掉光刻胶\n\nNow we dope, and avoid telling a hilarious joke, again, but with a different gas that\n然后用另一种气体掺杂 \\N 把一部分硅转成另一种形式\n\nconverts part of the silicon into yet a different form.\n然后用另一种气体掺杂 \\N 把一部分硅转成另一种形式\n\nTiming is super important in photolithography in order to control things like doping diffusionand etch depth.\n为了控制深度，时机很重要 \\N 我们不想超过之前的区域\n\nIn this case, we only want to dope a little region nested inside the other.\n为了控制深度，时机很重要 \\N 我们不想超过之前的区域\n\nNow we have all the pieces we need to create our transistor!\n现在 所有需要的组件都有了\n\nThe final step is to make channels in the oxide layer\n最后一步，在氧化层上做通道 \\N 这样可以用细小金属导线，连接不同晶体管\n\nso that we can run little metal wires to different parts of our transistor.\n最后一步，在氧化层上做通道 \\N 这样可以用细小金属导线，连接不同晶体管\n\nOnce more, we apply a photoresist, and use a new photomask to etch little channels.\n再次用光刻胶和光掩膜  蚀刻出小通道\n\nNow, we use a new process, called metalization,\n现在用新的处理方法 叫\"金属化\" \\N 放一层薄薄的金属，比如铝或铜\n\nthat allows us to deposit a thin layer of metal, like aluminium or copper.\n现在用新的处理方法 叫\"金属化\" \\N 放一层薄薄的金属，比如铝或铜\n\nBut we don’t want to cover everything in metal.\n但我们不想用金属盖住所有东西 \\N 我们想蚀刻出具体的电路\n\nWe want to etch a very specific circuit design.\n但我们不想用金属盖住所有东西 \\N 我们想蚀刻出具体的电路\n\nSo, very similar to before, we apply a photoresist, use a photomask, dissolve the exposed resist,\n所以又是类似的步骤 \\N 用光刻胶+光掩膜，然后溶掉暴露的光刻胶，暴露的金属\n\nand use a chemical to remove any exposed metal.\n所以又是类似的步骤 \\N 用光刻胶+光掩膜，然后溶掉暴露的光刻胶，暴露的金属\n\nWhew!\n咻~\n\nOur transistor is finally complete!\n晶体管终于做好了！ \\N 它有三根线，连接着硅的三个不同区域\n\nIt has three little wires that connect to three different parts of the silicon\n晶体管终于做好了！ \\N 它有三根线，连接着硅的三个不同区域\n\neach doped a particular way to create, in this example, what’s called a bipolar junction transistor.\n每个区域的掺杂方式不同，这叫双极型晶体管\n\nHere’s the actual patent from 1962, an invention that changed our world forever!\n这个 1962 年的真实专利，永远改变了世界\n\nUsing similar steps, photolithography can create other useful electronic elements, like\n用类似步骤，光刻可以制作其他电子元件 \\N 比如电阻和电容，都在一片硅上\n\nresistors and capacitors, all on a single piece of silicon\n用类似步骤，光刻可以制作其他电子元件 \\N 比如电阻和电容，都在一片硅上\n\nplus all the wires needed to hook them up into circuits\n而且互相连接的电路也做好了\n\nGoodbye discrete components!\n再见了，分立元件！\n\nIn our example, we made one transistor, but in the real world,\n之前的例子 只做了一个晶体管，但现实中 \\N 光刻法一次会做上百万个细节\n\nphotomasks lay down millions of little details all at once.\n之前的例子 只做了一个晶体管，但现实中 \\N 光刻法一次会做上百万个细节\n\nHere is what an IC might look like from above, with wires crisscrossing above and below each other,\n芯片放大是这样的，导线上下交错，连接各个元件\n\ninterconnecting all the individual elements together into complex circuits.\n芯片放大是这样的，导线上下交错，连接各个元件\n\nAlthough we could create a photomask for an entire wafer,\n尽管可以把光掩膜投影到一整片晶圆上 \\N 但光可以投射成任意大小\n\nwe can take advantage of the fact that light can be focused and projected to any size we want.\n尽管可以把光掩膜投影到一整片晶圆上 \\N 但光可以投射成任意大小\n\nIn the same way that a film can be projected to fill an entire movie screen,\n就像投影仪可以投满荧幕一样\n\nwe can focus a photomask onto a very small patch of silicon, creating incredibly fine details.\n我们可以把光掩膜 \\N 聚焦到极小的区域，制作出非常精细的细节\n\nA single silicon wafer is generally used to create dozens of ICs.\n一片晶圆可以做很多 IC \\N 整块都做完后，可以切割然后包进微型芯片\n\nThen, once you’ve got a whole wafer full, you cut them up and package them into microchips,\n一片晶圆可以做很多 IC \\N 整块都做完后，可以切割然后包进微型芯片\n\nthose little black rectangles you see in electronics all the time.\n微型芯片就是在电子设备中那些小长方体\n\nJust remember: at the heart of each of those chips is one of these small pieces of silicon.\n记住，芯片的核心都是一小片 IC\n\nAs photolithography techniques improved, the size of transistors shrunk, allowing for greater densities.\n随着光刻技术发展，晶体管变小  密度变高\n\nAt the start of the 1960s, an IC rarely contained more than 5 transistors,\n1960 年代初，IC 很少超过 5 个晶体管，因为塞不下\n\nthey just couldn’t possibly fit.\n1960 年代初，IC 很少超过 5 个晶体管，因为塞不下\n\nBut, by the mid 1960s, we were starting to see ICs with over 100 transistors on the market.\n但 1960 年代中期 \\N 市场上开始出现超过 100 个晶体管的 IC\n\nIn 1965, Gordon Moore could see the trend: that approximately every two years,\n1965年，戈登·摩尔看到了趋势：每两年左右，\n\nthanks to advances in materials and manufacturing, you could fit twice the number of transistors\n得益于材料和制造技术的发展 \\N 同样大小的空间，能塞进两倍数量的晶体管！\n\ninto the same amount of space.\n得益于材料和制造技术的发展 \\N 同样大小的空间，能塞进两倍数量的晶体管！\n\nThis is called Moore’s Law.\n这叫 摩尔定律\n\nThe term is a bit of a misnomer though.\n然而这个名字不太对 \\N 因为它不是定律，只是一种趋势\n\nIt’s not really a law at all, more of a trend.\n然而这个名字不太对 \\N 因为它不是定律，只是一种趋势\n\nBut it’s a good one.\n但它是对的\n\nIC prices also fell dramatically, from an average of $50 in 1962 to around $2 in 1968.\n芯片的价格也急剧下降 \\N 1962年平均50美元，下降到1968年2美元左右\n\nToday, you can buy ICs for cents.\n如今 几美分就能买到 IC\n\nSmaller transistors and higher densities had other benefits too.\n晶体管更小密度更高 还有其他好处\n\nThe smaller the transistor, the less charge you have to move around, allowing it to switch\n晶体管越小，要移动的电荷量就越少 \\N 能更快切换状态  耗电更少\n\nstates faster and consume less power.\n晶体管越小，要移动的电荷量就越少 \\N 能更快切换状态  耗电更少\n\nPlus, more compact circuits meant less delay in signals resulting in faster clock speeds.\n电路更紧凑 还意味着信号延迟更低 \\N 导致时钟速度更快\n\nIn 1968, Robert Noyce and Gordon Moore teamed up and founded a new company,\n1968年，罗伯特·诺伊斯 和 戈登·摩尔  \\N 联手成立了一家新公司\n\ncombining the words Integrated and Electronics...\n结合 Intergrated(集成) 和 Electronics(电子) 两个词\n\nIntel. the largest chip maker today.\n取名 Intel， 如今最大的芯片制造商\n\nThe Intel 4004 CPU, from Episodes 7 and 8, was a major milestone.\nIntel 4004 CPU, 在第 7, 8 集介绍过 \\N 是个重要里程碑\n\nReleased in 1971, it was the first processor that shipped as an IC, what’s called a microprocessor,\n发布于1971年 \\N 是第一个用 IC 做的处理器，也叫微型处理器\n\nbecause it was so beautifully small!\n因为真的非常小！\n\nIt contained 2,300 transistors.\n它有2300个晶体管\n\nPeople marveled at the level of integration, an entire CPU in one chip,\n人们惊叹于它的整合水平 \\N 整个 CPU 在一个芯片里\n\nwhich just two decades earlier would have filled an entire room using discrete components.\n而仅仅 20 年前，用分立元件会占满整个屋子\n\nThis era of integrated circuits, especially microprocessors, ushered in the third generation of computing.\n集成电路的出现 \\N 尤其是用来做微处理器，开启了计算 3.0\n\nAnd the Intel 4004 was just the start.\n而 Intel 4004 只是个开始，CPU 晶体管数量爆发增长\n\nCPU transistor count exploded!\n而 Intel 4004 只是个开始，CPU 晶体管数量爆发增长\n\nBy 1980, CPUs contained 30 thousand transistors.\n1980年，3 万晶体管 \\N  1990年，100 万晶体管\n\nBy 1990, CPUs breached the 1 million transistor count.\n1980年，3 万晶体管 \\N  1990年，100 万晶体管\n\nBy 2000, 30 million transistors,\n2000年，3000 万个晶体管\n\nand by 2010, ONE. BILLION. TRANSISTORS. IN ONE. IC. OMG!\n2010年，10亿个晶体管！\\N 在一个芯片里！我的天啊！\n\nTo achieve this density, the finest resolution possible with photolithography has improved\n为了达到这种密度，光刻的分辨率 \\N 从大约一万纳米，大概是人类头发直径的 1/10\n\nfrom roughly 10 thousand nanometers, that’s about 1/10th the thickness of a human hair,\n为了达到这种密度，光刻的分辨率 \\N 从大约一万纳米，大概是人类头发直径的 1/10\n\nto around 14 nanometers today.\n发展到如今的 14 纳米 \\N 比血红细胞小 400 倍！\n\nThat’s over 400 times smaller than a red blood cell!\n发展到如今的 14 纳米 \\N 比血红细胞小 400 倍！\n\nAnd of course, CPU’s weren’t the only components to benefit.\n当然，CPU 不是唯一受益的元件\n\nMost electronics advanced essentially exponentially:\n大多数电子器件都在指数式发展：\\N 内存，显卡，固态硬盘，摄像头感光元件，等等\n\nRAM, graphics cards, solid state hard drives, camera sensors, you name it.\n大多数电子器件都在指数式发展：\\N 内存，显卡，固态硬盘，摄像头感光元件，等等\n\nToday’s processors, like the A10 CPU inside Of an iPhone 7, contains a mind melting 3.3 BILLION\n如今的处理器，比如 iPhone 7 的 A10 CPU \\N 有33亿个晶体管\n\ntransistors in an IC roughly 1cm by 1cm.\n面积仅有 1cm x 1cm，比一张邮票还小\n\nThat’s smaller than a postage stamp!\n面积仅有 1cm x 1cm，比一张邮票还小\n\nAnd modern engineers aren’t laying out these designs by hand, one transistor at a time\n现代工程师设计电路时，当然不是手工一个个设计晶体管 \\N 这不是人力能做到的\n\n- it’s not humanly possible.\n现代工程师设计电路时，当然不是手工一个个设计晶体管 \\N 这不是人力能做到的\n\nStarting in the 1970’s, very-large-scale integration, or VLSI software, has been used\n1970年代开始，超大规模集成(VLSI)软件 \\N 用来自动生成芯片设计\n\nto automatically generate chip designs instead.\n1970年代开始，超大规模集成(VLSI)软件 \\N 用来自动生成芯片设计\n\nUsing techniques like logic synthesis, where whole, high-level components can be laid down,like a memory cache\n用比如 \"逻辑综合\" 这种技术 \\N 可以放一整个高级组件，比如内存缓存\n\nthe software generates the circuit in the most efficient way possible.\n软件会自动生成电路，做到尽可能高效\n\nMany consider this to be the start of fourth generation computers.\n许多人认为这是计算 4.0 的开始\n\nUnfortunately, experts have been predicting the end of Moore’s Law for decades\n坏消息是，专家们几十年来 \\N 一直在预言摩尔定律的终结\n\nand we might finally be getting close to it.\n现在可能终于接近了\n\nThere are two significant issues holding us back from further miniaturization.\n进一步做小，会面临 2 个大问题\n\nFirst, we’re bumping into limits on how fine we can make features on a photomask and\n1. 用光掩膜把图案弄到晶圆上 \\N 因为光的波长，精度已达极限\n\nit’s resultant wafer due to the wavelengths of light used in photolithography.\n1. 用光掩膜把图案弄到晶圆上 \\N 因为光的波长，精度已达极限\n\nIn response, scientists have been developing light sources with smaller and smaller wavelengths\n所以科学家在研制波长更短的光源，投射更小的形状\n\nthat can project smaller and smaller features.\n所以科学家在研制波长更短的光源，投射更小的形状\n\nThe second issue is that when transistors get really really small, where electrodes\n2. 当晶体管非常小，电极之间可能只距离几个原子 \\N 电子会跳过间隙，这叫：量子隧道贯穿\n\nmight be separated by only a few dozen atoms, electrons can jump the gap, a phenomenon called\n2. 当晶体管非常小，电极之间可能只距离几个原子 \\N 电子会跳过间隙，这叫：量子隧穿效应\n\nquantum tunneling.\n2. 当晶体管非常小，电极之间可能只距离几个原子 \\N 电子会跳过间隙，这叫：量子隧穿效应\n\nIf transistors leak current, they don’t make very good switches.\n如果晶体管漏电，就不是好开关\n\nNonetheless, scientists and engineers are hard at work figuring out ways around these problems.\n科学家和工程师在努力找解决方法\n\nTransistors as small as 1 nanometer have been demonstrated in research labs.\n实验室中已造出小至1纳米的晶体管\n\nWhether this will ever be commercially feasible remains MASKED in mystery.\n能不能商业量产依然未知，未来也许能解决\n\nBut maybe we’ll be able to RESOLVE it in the future.\n能不能商业量产依然未知，未来也许能解决\n\nI’m DIEING to know. See you next week.\n我非常期待！下周见！\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/18. 操作系统-Operating Systems.ass.txt",
    "content": "This episode is supported by Hover.\n本集由 Hover 赞助播出\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nComputers in the 1940s and early 50s ran one program at a time.\n1940,1950 年代的电脑，每次只能运行一个程序\n\nA programmer would write one at their desk, for example, on punch cards.\n程序员在打孔纸卡上写程序\n\nThen, they'd carry it to a room containing a room-sized computer,\n然后拿到一个计算机房间,  交给操作员\n\nand hand it to a dedicated computer operator.\n然后拿到一个计算机房间,  交给操作员\n\nThat person would then feed the program into the computer when it was next available.\n等计算机空下来了，操作员会把程序放入\n\nThe computer would run it, spit out some output, and halt.\n然后运行，输出结果，停机\n\nThis very manual process worked OK back when computers were slow,\n以前计算机慢，这种手动做法可以接受\n\nand running a program often took hours, days or even weeks.\n运行一个程序通常要几小时，几天甚至几周\n\nBut, as we discussed last episode,\n但上集说过，计算机越来越快，越来越快\n\ncomputers became faster... and faster... and faster\n但上集说过，计算机越来越快，越来越快\n\nexponentially so!\n指数级增长！\n\nPretty soon, having humans run around and inserting programs into readers\n很快，放程序的时间 比程序运行时间还长\n\nwas taking longer than running the actual programs themselves.\n很快，放程序的时间 比程序运行时间还长\n\nWe needed a way for computers to operate themselves,\n我们需要一种方式 让计算机自动运作\n\nand so, operating systems were born.\n于是\"操作系统\"诞生了\n\nOperating systems , or OS for short, are just programs.\n操作系统，简称 OS，其实也是程序\n\nBut, special privileges on the hardware let them run and manage other programs.\n但它有操作硬件的特殊权限  \\N 可以运行和管理其它程序\n\nThey're typically the first one to start when a computer is turned on,\n操作系统一般是开机第一个启动的程序\n\nand all subsequent programs are launched by the OS.\n其他所有程序 都由操作系统启动\n\nThey got their start in the 1950s,\n操作系统开始于 1950 年代 \\N 那时计算机开始变得更强大更流行\n\nas computers became more widespread and more powerful.\n操作系统开始于 1950 年代 \\N 那时计算机开始变得更强大更流行\n\nThe very first OS augmented the mundane, manual task of loading programs by hand.\n第一个操作系统 加强了程序加载方式\n\nInstead of being given one program at a time,\n之前只能一次给一个程序，现在可以一次多个\n\ncomputers could be given batches.\n之前只能一次给一个程序，现在可以一次多个\n\nWhen the computer was done with one,\n当计算机运行完一个程序，会自动运行下一个程序\n\nit would automatically and near-instantly start the next.\n当计算机运行完一个程序，会自动运行下一个程序\n\nThere was no downtime while someone scurried around an office to find the next program to run.\n这样就不会浪费时间，找下一个程序的纸卡\n\nThis was called batch processing .\n这叫 批处理\n\nWhile computers got faster, they also got cheaper.\n电脑变得更快更便宜，开始在出现在世界各地\n\nSo, they were popping up all over the world,\n电脑变得更快更便宜，开始在出现在世界各地\n\nespecially in universities and government offices.\n特别是大学和政府办公室\n\nSoon, people started sharing software.\n很快，人们开始分享软件，但有一个问题\n\nBut there was a problem\n很快，人们开始分享软件，但有一个问题\n\nIn the era of one-off computers, like the Harvard Mark 1 or ENIAC,\n在哈佛1号和 ENIAC 那个时代，计算都是一次性的\n\nprogrammers only had to write code for that one single machine.\n程序员只需要给那\"一台\"机器写代码\n\nThe processor, punch card readers, and printers were known and unchanging.\n处理器，读卡器，打印机都是已知的\n\nBut as computers became more widespread,\n但随着电脑越来越普遍，计算机配置并不总是相同的\n\ntheir configurations were not always identical,\n但随着电脑越来越普遍，计算机配置并不总是相同的\n\nlike computers might have the same CPU, but not the same printer.\n比如计算机可能有相同 CPU，但不同的打印机\n\nThis was a huge pain for programmers.\n这对程序员很痛苦\n\nNot only did they have to worry about writing their program,\n不仅要担心写程序，还要担心程序怎么和不同型号打印机交互\n\nbut also how to interface with each and every model of printer,\n不仅要担心写程序，还要担心程序怎么和不同型号打印机交互\n\nand all devices connected to a computer, what are called peripherals.\n以及计算机连着的其他设备，这些统称\"外部设备\"\n\nInterfacing with early peripherals was very low level,\n和早期的外部设备交互，是非常底层的\n\nrequiring programmers to know intimate hardware details about each device.\n程序员要了解设备的硬件细节\n\nOn top of that, programmers rarely had access to every model of a peripheral to test their code on.\n加重问题的是，程序员很少能拿到所有型号的设备来测代码\n\nSo, they had to write code as best they could, often just by reading manuals,\n所以一般是阅读手册来写代码，祈祷能正常运行\n\nand hope it worked when shared.\n所以一般是阅读手册来写代码，祈祷能正常运行\n\nThings weren't exactly plug-and-play\n现在是\"即插即用\"，以前是\"祈祷能用\"\n\nback then more plug-and-pray.\n现在是\"即插即用\"，以前是\"祈祷能用\"\n\nThis was clearly terrible,\n这很糟糕，所以为了程序员写软件更容易\n\nso to make it easier for programmers,\n这很糟糕，所以为了程序员写软件更容易\n\nOperating Systems stepped in as intermediaries between software programs and hardware peripherals.\n操作系统充当软件和硬件之间的媒介\n\nMore specifically, they provided a software abstraction, through APIs,\n更具体地说，操作系统提供 API 来抽象硬件，叫\"设备驱动程序\"\n\ncalled device drivers .\n更具体地说，操作系统提供 API 来抽象硬件，叫\"设备驱动程序\"\n\nThese allow programmers to talk to common input and output hardware,\n程序员可以用标准化机制  和输入输出硬件（I/O）交互\n\nor I/O for short, using standardized mechanisms.\n程序员可以用标准化机制  和输入输出硬件（I/O）交互\n\nFor example, programmers could call a function like \"print highscore\",\n比如，程序员只需调用 print(highscore)\n\nand the OS would do the heavy lifting to get it onto paper.\n操作系统会处理  输到纸上的具体细节\n\nBy the end of the 1950s, computers had gotten so fast,\n到 1950 年代尾声，电脑已经非常快了\n\nthey were often idle waiting for slow mechanical things, like printers and punch card readers.\n处理器经常闲着，等待慢的机械设备（比如打印机和读卡器）\n\nWhile programs were blocked on I/O,\n程序阻塞在 I/O 上\n\nthe expensive processor was just chillin'... not like a villain\n而昂贵的处理器则在度假，就是放松啥也不做\n\nyou know, just relaxing.\n而昂贵的处理器则在度假，就是放松啥也不做\n\nIn the late 50's, the University of Manchester, in the UK,\n50年代后期，英国曼彻斯特大学 \\N 开始研发世界上第一台超级计算机，Atlas\n\nstarted work on a supercomputer called Atlas, one of the first in the world.\n50年代后期，英国曼彻斯特大学 \\N 开始研发世界上第一台超级计算机，Atlas\n\nThey knew it was going to be wicked fast,\n他们知道机器会超级快，所以需要一种方式来最大限度的利用它\n\nso they needed a way to make maximal use of the expensive machine.\n他们知道机器会超级快，所以需要一种方式来最大限度的利用它\n\nTheir solution was a program called the Atlas Supervisor, finished in 1962.\n他们的解决方案是一个程序叫 Atlas Supervisor  \\N 于1962年完成\n\nThis operating system not only loaded programs automatically, like earlier batch systems,\n这个操作系统 \\N不仅像更早期的批处理系统那样，能自动加载程序\n\nbut could also run several at the same time on its single CPU.\n还能在单个 CPU 上同时运行几个程序\n\nIt did this through clever scheduling.\n它通过调度来做到这一点\n\nLet's say we have a game program running on Atlas,\n假设 Atlas 上有一个游戏在运行\n\nand we call the function \"print(highscore)\"\n并且我们调用一个函数 print(highscore)\n\nwhich instructs Atlas to print the value of a variable named \"highscore\"\n它让 Atlas 打印一个叫 highscore 的变量值\n\nonto paper to show our friends that we're the ultimate champion of virtual tiddlywinks.\n让朋友知道 我是最高分冠军\n\nThat function call is going to take a while, the equivalent of thousands of clock cycles,\nprint 函数运行需要一点时间，大概上千个时钟周期\n\nbecause mechanical printers are slow in comparison to electronic CPUs.\n但因为打印机比 CPU 慢，与其等着它完成操作\n\nSo instead of waiting for the I/O to finish,\n但因为打印机比 CPU 慢，与其等着它完成操作\n\nAtlas instead puts our program to sleep,\nAtlas 会把程序休眠，运行另一个程序\n\nthen selects and runs another program that's waiting and ready to run.\nAtlas 会把程序休眠，运行另一个程序\n\nEventually, the printer will report back to Atlas that it finished printing the value of \"highscore\".\n最终, 打印机会告诉 Atlas, 打印已完成\n\nAtlas then marks our program as ready to go,\nAtlas 会把程序标记成可继续运行\n\nand at some point, it will be scheduled to run again on the CPU,\n之后在某时刻会安排给 CPU 运行\n\nand continue onto the next line of code following the print statement.\n并继续 print 语句之后的下一行代码\n\nIn this way, Atlas could have one program running calculations on the CPU,\n这样, Atlas 可以在 CPU 上运行一个程序\n\nwhile another was printing out data,\n同时另一个程序在打印数据\n\nand yet another reading in data from a punch tape.\n同时另一个程序读数据\n\nAtlas' engineers doubled down on this idea,\nAtlas 的工程师做的还要多，配了4台纸带读取器，4台纸带打孔机\n\nand outfitted their computer with 4 paper tape readers, 4 paper tape punches,\nAtlas 的工程师做的还要多，配了4台纸带读取器，4台纸带打孔机\n\nand up to 8 magnetic tape drives.\n多达8个磁带驱动器\n\nThis allowed many programs to be in progress all at once,\n使多个程序可以同时运行，在单个 CPU 上共享时间\n\nsharing time on a single CPU.\n使多个程序可以同时运行，在单个 CPU 上共享时间\n\nThis ability, enabled by the Operating System, is called\n操作系统的这种能力叫\"多任务处理\"\n\nmultitasking.\n操作系统的这种能力叫\"多任务处理\"\n\nThere's one big catch to having many programs running simultaneously on a single computer, though.\n同时运行多个程序有个问题\n\nEach one is going to need some memory,\n每个程序都会占一些内存 \\N 当切换到另一个程序时，我们不能丢失数据\n\nand we can't lose that program's data when we switch to another program.\n每个程序都会占一些内存 \\N 当切换到另一个程序时，我们不能丢失数据\n\nThe solution is to allocate each program its own block of memory.\n解决办法是 给每个程序分配专属内存块\n\nSo, for example, let's say a computer has 10,000 memory locations in total.\n举个例子，假设计算机一共有 10000 个内存位置\n\nProgram A might get allocated memory addresses 0 through 999,\n程序 A 分配到内存地址 0 到 999\n\nand Program B might get 1000 through 1999, and so on.\n而程序 B 分配到内存地址 1000 到 1999，以此类推\n\nIf a program asks for more memory,\n如果一个程序请求更多内存，操作系统会决定是否同意\n\nthe operating system decides if it can grant that request,\n如果一个程序请求更多内存，操作系统会决定是否同意\n\nand if so, what memory block to allocate next.\n如果同意，分配哪些内存块\n\nThis flexibility is great, but introduces a quirk.\n这种灵活性很好，但带来一个奇怪的后果\n\nIt means that Program A could end up being allocated non-sequential blocks of memory,\n程序 A 可能会分配到非连续的内存块\n\nin say addresses 0 through 999, and 2000 through 2999.\n比如内存地址 0 到 999，以及 2000 到 2999\n\nAnd this is just a simple example\n这只是个简单例子\n\n- a real program might be allocated dozens of blocks scattered all over memory.\n真正的程序可能会分配到内存中数十个地方\n\nAs you might imagine,\n你可能想到了，这对程序员来说很难跟踪\n\nthis would get really confusing for programmers to keep track of.\n你可能想到了，这对程序员来说很难跟踪\n\nMaybe there's a long list of sales data in memory that\n也许内存里有一长串销售额，每天下班后要算销售总额\n\na program has to total up at the end of the day,\n也许内存里有一长串销售额，每天下班后要算销售总额\n\nbut this list is stored across a bunch of different blocks of memory.\n但列表 存在一堆不连续的内存块里\n\nTo hide this complexity, Operating Systems virtualize memory locations.\n为了隐藏这种复杂性，操作系统会把内存地址进行 \"虚拟化\"\n\nWith Virtual Memory, programs can assume their memory always starts at address 0,\n这叫 \"虚拟内存\"，程序可以假定内存总是从地址0开始\n\nkeeping things simple and consistent.\n简单又一致\n\nHowever, the actual, physical location in computer memory\n而实际物理位置  被操作系统隐藏和抽象了\n\nis hidden and abstracted by the operating system.\n而实际物理位置  被操作系统隐藏和抽象了\n\nJust a new level of abstraction.\n一层新的抽象\n\nLet's take our example Program B,\n用程序 B 来举例 \\N 它被分配了内存地址 1000 到 1999\n\nwhich has been allocated a block of memory from address 1000 to 1999.\n用程序 B 来举例 \\N 它被分配了内存地址 1000 到 1999\n\nAs far as Program B can tell, this appears to be a block from 0 to 999.\n对程序 B 而言，它看到的地址是 0 到 999\n\nThe OS and CPU handle the virtual-to-physical memory remapping automatically.\n操作系统会自动处理 \\N 虚拟内存和物理内存之间的映射\n\nSo, if Program B requests memory location 42,\n如果程序 B 要地址 42，实际上是物理地址 1042\n\nit really ends up reading address 1042.\n如果程序 B 要地址 42，实际上是物理地址 1042\n\nThis virtualization of memory addresses is even more useful for Program A,\n这种内存地址的虚拟化  对程序 A 甚至更有用\n\nwhich in our example, has been allocated two blocks of memory\n在例子中，A 被分配了两块隔开的内存\n\nthat are separated from one another.\n在例子中，A 被分配了两块隔开的内存\n\nThis too is invisible to Program A.\n程序 A 不知道这点.\n\nAs far as it can tell, it's been allocated a continuous block of 2000 addresses.\n以 A 的视角，它有 2000 个连续地址\n\nWhen Program A reads memory address 999,\n当程序 A 读内存地址 999 时 \\N 会刚好映射到物理内存地址 999\n\nthat does coincidentally map to physical memory address 999.\n当程序 A 读内存地址 999 时 \\N 会刚好映射到物理内存地址 999\n\nBut if Program A reads the very next value in memory, at address 1000,\n但如果程序 A 读下一个地址 1000\n\nthat gets mapped behind the scenes to physical memory address 2000.\n会映射到物理地址 2000\n\nThis mechanism allows programs to have flexible memory sizes,\n这种机制使程序的内存大小可以灵活增减 \\N 叫\"动态内存分配\"\n\ncalled dynamic memory allocation,\n这种机制使程序的内存大小可以灵活增减 \\N 叫\"动态内存分配\"\n\nthat appear to be continuous to them.\n对程序来说，内存看起来是连续的.\n\nIt simplifies everything and offers tremendous flexibility to the Operating System\n它简化了一切，为操作系统同时运行多个程序 \\N 提供了极大的灵活性\n\nin running multiple programs simultaneously.\n它简化了一切，为操作系统同时运行多个程序 \\N 提供了极大的灵活性\n\nAnother upside of allocating each program its own memory,\n给程序分配专用的内存范围，\\N 另一个好处是 这样隔离起来会更好\n\nis that they're better isolated from one another.\n给程序分配专用的内存范围，\\N 另一个好处是 这样隔离起来会更好\n\nSo, if a buggy program goes awry, and starts writing gobbledygook,\n如果一个程序出错，开始写乱七八糟的数据\n\nit can only trash its own memory, not that of other programs.\n它只能捣乱自己的内存，不会影响到其它程序.\n\nThis feature is called Memory Protection.\n这叫 \"内存保护\"\n\nThis is also really useful in protecting against malicious software, like viruses.\n防止恶意软件（如病毒）也很有用\n\nFor example, we generally don't want other programs to have the ability\n例如，我们不希望其他程序有能力 \\N 读或改邮件程序的内存\n\nto read or modify the memory of, let say, our email,\n例如，我们不希望其他程序有能力 \\N 读或改邮件程序的内存\n\nwith that kind of access,\n如果有这种权限 \\N 恶意软件可能以你的名义发邮件，甚至窃取个人信息\n\nmalware could send emails on your behalf and maybe steal personal information.\n如果有这种权限 \\N 恶意软件可能以你的名义发邮件，甚至窃取个人信息\n\nNot good!\n一点都不好！\n\nAtlas had both virtual and protected memory.\nAtlas 既有\"虚拟内存\"也有\"内存保护\"\n\nIt was the first computer and OS to support these features!\n是第一台支持这些功能的计算机和操作系统！\n\nBy the 1970s, computers were sufficiently fast and cheap.\n到 1970 年代，计算机足够快且便宜\n\nInstitutions like a university could buy a computer and let students use it.\n大学会买电脑让学生用\n\nIt was not only fast enough to run several programs at once,\n计算机不仅能同时运行多个程序，还能让多用户能同时访问\n\nbut also give several users simultaneous, interactive access.\n计算机不仅能同时运行多个程序，还能让多用户能同时访问\n\nThis was done through a terminal,\n多个用户用\"终端\"来访问计算机\n\nwhich is a keyboard and screen that connects to a big computer,\n\"终端\"只是键盘+屏幕，连到主计算机 \\N 终端本身没有处理能力\n\nbut doesn't contain any processing power itself.\n\"终端\"只是键盘+屏幕，连到主计算机 \\N 终端本身没有处理能力\n\nA refrigerator-sized computer might have 50 terminals connected to it,\n冰箱大小的计算机可能有50个终端，能让50个用户使用\n\nallowing up to 50 users.\n冰箱大小的计算机可能有50个终端，能让50个用户使用\n\nNow operating systems had to handle not just multiple programs,\n这时操作系统不但要处理多个程序，还要处理多个用户\n\nbut also multiple users.\n这时操作系统不但要处理多个程序，还要处理多个用户\n\nSo that no one person could gobble up all of a computer's resources,\n为了确保其中一个人  不会占满计算机资源\n\noperating systems were developed that offered time-sharing.\n开发了 分时操作系统\n\nWith time-sharing each individual user was only allowed to utilize\n意思是 每个用户只能用一小部分处理器，内存等\n\na small fraction of the computer's processor, memory, and so on.\n意思是 每个用户只能用一小部分处理器，内存等\n\nBecause computers are so fast,\n因为电脑很快 \\N 即使拿到 1/50 的资源也足以完成许多任务\n\neven getting just 1/50th of its resources was enough for individuals to complete many tasks.\n因为电脑很快 \\N 即使拿到 1/50 的资源也足以完成许多任务\n\nThe most influential of early time-sharing Operating Systems was\n早期分时操作系统中，最有影响力的是 \\N Multics（多任务信息与计算系统）\n\nMultics,  or Multiplexed Information and Computing Service,\n早期分时操作系统中，最有影响力的是 \\N Multics（多任务信息与计算系统）\n\nreleased in 1969.\n于 1969 年发布\n\nMultics was the first major operating system designed to be secure from the outset.\nMultics 是第一个，从设计时就考虑到安全的操作系统\n\nDevelopers didn't want mischievous users accessing data they shouldn't,\n开发人员不希望恶意用户 访问不该访问的数据\n\nlike students attempting to access the final exam on their professor's account.\n比如学生假装成教授，访问期末考试的文件\n\nFeatures like this meant Multics was really complicated for its time,\n这导致 Multics 的复杂度超过当时的平均水准\n\nusing around 1 Megabit of memory, which was a lot back then!\n操作系统会占大约 1 Mb 内存，这在当时很多！\n\nThat might be half of a computer's memory, just to run the OS!\n可能是内存的一半，只拿来运行操作系统！\n\nDennis Ritchie, one of the researchers working on Multics, once said:\nMultics 的研究人员之一 Dennis Ritchie 曾说过\n\n\"One of the obvious things that went wrong with Multics as a commercial success\n\"阻碍 Multics 获得商业成功的一个明显问题是\n\nwas just that it was sort of over-engineered in a sense.\n从某种方面来说，它被过度设计了，功能太多了\"\n\nThere was just too much in it.\"\n从某种方面来说，它被过度设计了，功能太多了\"\n\nThis lead Dennis, and another Multics researcher,\n所以 Dennis 和另一个 Multics 研究员 \\N Ken Thompson 联手打造新的操作系统\n\nKen Thompson, to strike out on their own and build a new, lean operating system\n所以 Dennis 和另一个 Multics 研究员 \\N Ken Thompson 联手打造新的操作系统\n\ncalled Unix.\n叫 Unix\n\nThey wanted to separate the OS into two parts:\n他们想把操作系统分成两部分：\n\nFirst was the core functionality of the OS,\n首先是操作系统的核心功能\n\nthings like memory management, multitasking,and dealing with I/O,\n如内存管理，多任务和输入/输出处理 \\N 这叫\"内核\"\n\nwhich is called the kernel .\n如内存管理，多任务和输入/输出处理 \\N 这叫\"内核\"\n\nThe second part was a wide array of useful tools that came bundled with,\n第二部分是一堆有用的工具\n\nbut not part of the kernel, things like programs and libraries.\n但它们不是内核的一部分（比如程序和运行库）\n\nBuilding a compact, lean kernel meant intentionally leaving some functionality out.\n紧凑的内核 意味着功能没有那么全面\n\nTom Van Vleck, another Multics developer, recalled:\nMultics 的另一个开发者 Tom Van Vleck 回忆说：\n\n\"I remarked to Dennis that easily half the code I was writing in Multics was error recovery code.\"\n\"我对 Dennis 说，我在 Multics 写的一半代码都是错误恢复代码\"\n\nHe said, \"We left all that stuff out of Unix.\n他说:\"Unix 不会有这些东西\n\nIf there's an error, we have this routine called panic,\n如果有错误发生，我们就让内核\"恐慌\"（panic）\n\nand when it is called, the machine crashes,\n当调用它时，机器会崩溃\n\nand you holler down the hall, 'Hey, reboot it.'\"\"\n你得在走廊里大喊，\"嘿，重启电脑\"\n\nYou might have heard of kernel panics.\n你可能听过 \"内核恐慌\"（kernel panic）\n\nThis is where the term came from.\n这就是这个词的来源\n\nIt's literally when the kernel crashes, has no recourse to recover,\n内核如果崩溃，没有办法恢复\n\nand so calls a function called \"panic\".\n所以调用一个叫\"恐慌\"（panic）的函数\n\nOriginally, all it did was print the word \"panic\" and then enter an infinite loop.\n起初只是打印\"恐慌\"一词，然后无限循环\n\nThis simplicity meant that Unix could be run on cheaper and more diverse hardware,\n这种简单性意味着  \\N Unix 可以在更便宜更多的硬件上运行\n\nmaking it popular inside Bell Labs, where Dennis and Ken worked.\n使 Unix 在 Dennis 和 Ken 工作的 \\N 贝尔实验室大受欢迎\n\nAs more developers started using Unix to build and run their own programs,\n越来越多开发人员用 Unix 写程序和运行程序\n\nthe number of contributed tools grew.\n工具数量日益增长\n\nSoon after its release in 1971,\n1971 年发布后不久\n\nit gained compilers for different programming languages and even a word processor,\n就有人写了不同编程语言的编译器 \\N 甚至文字处理器\n\nquickly making it one of the most popular OSes of the 1970s and 80s.\n使得 Unix 迅速成为 \\N 1970~80年代最流行的操作系统之一\n\nAt the same time, by the early 1980s,\n到 1980 年代早期\n\nthe cost of a basic computer had fallen to the point where individual people could afford one,\n计算机的价格 降到普通人买得起  \\N 这些叫\"个人电脑\"或\"家庭电脑\"\n\ncalled a personal or home computer.\n计算机的价格 降到普通人买得起  \\N 这些叫\"个人电脑\"或\"家庭电脑\"\n\nThese were much simpler than the big mainframes\n这些电脑比大型主机简单得多 \\N 主机一般在大学，公司和政府\n\nfound at universities, corporations, and governments.\n这些电脑比大型主机简单得多 \\N 主机一般在大学，公司和政府\n\nSo, their operating systems had to be equally simple.\n因此操作系统也得简单\n\nFor example, Microsoft's Disk Operating System, or MS-DOS, was just 160 kilobytes,\n举例，微软的磁盘操作系统（MS-DOS）只有 160 kB \\N 一张磁盘就可以容纳\n\nallowing it to fit, as the name suggests, onto a single disk.\n举例，微软的磁盘操作系统（MS-DOS）只有 160 kB \\N 一张磁盘就可以容纳\n\nFirst released in 1981, it became the most popular OS for early home computers,\n于 1981 年发布，成为早期家用电脑最受欢迎的操作系统\n\neven though it lacked multitasking and protected memory.\n虽然缺少\"多任务\"和\"保护内存\"这样功能\n\nThis meant that programs could,\n意味着程序经常使系统崩溃\n\nand would, regularly crash the system.\n意味着程序经常使系统崩溃\n\nWhile annoying, it was an acceptable tradeoff,\n虽然很讨厌但还可以接受，因为用户可以重启\n\nas users could just turn their own computers off and on again!\n虽然很讨厌但还可以接受，因为用户可以重启\n\nEven early versions of Windows,\n哪怕是微软 1985 年发布的早期 Windows \\N 虽然在 90 年代很流行\n\nfirst released by Microsoft in 1985  and which dominated the OS scene throughout the 1990s,\n哪怕是微软 1985 年发布的早期 Windows \\N 虽然在 90 年代很流行\n\nlacked strong memory protection.\n但却缺乏\"内存保护\"\n\nWhen programs misbehaved,\n当程序行为不当时，就会\"蓝屏\"\n\nyou could get the blue screen of death,\n当程序行为不当时，就会\"蓝屏\"\n\na sign that a program had crashed so badly that it took down the whole operating system.\n代表程序崩溃的非常严重，把系统也带崩溃了\n\nLuckily, newer versions of Windows have better protections and usually don't crash that often.\n幸运的是，新版Windows有更好的保护，不会经常崩溃\n\nToday, computers run modern operating systems,\n如今的计算机 有现代操作系统\n\nlike Mac OS X, Windows 10, Linux, iOS and Android.\n比如 Mac OS X，Windows 10 \\NLinux，iOS和Android\n\nEven though the computers we own are most often used by just a single person,\n虽然大部分设备只有一个人使用\n\nyou!\n你！\n\ntheir OS all have multitasking and virtual and protected memory.\n操作系统依然有\"多任务, \"虚拟内存\", \"内存保护\"\n\nSo, they can run many programs at once:\n因此可以同时运行多个程序：\n\nyou can watch YouTube in your web browser,\n一边在浏览器看 YouTube，一边在 Photoshop 修图\n\nedit a photo in Photoshop,\n一边在浏览器看 YouTube，一边在 Photoshop 修图\n\nplay music in Spotify and sync Dropbox all at the same time.\n用 Spotify 放音乐，同步 Dropbox\n\nThis wouldn't be possible without those decades of research and development on Operating Systems,\n如果没有操作系统这几十年的发展，这些都不可能,\n\nand of course the proper memory to store those programs.\n当然，我们也需要地方放程序\n\nWhich we'll get to next week.\n下周会讨论\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/19. 内存&储存介质-Memory & Storage.mp4.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nWe've talked about computer memory several times in this series,\n系列中 我们多次谈到内存（Memory）\n\nand we even designed some in Episode 6.\n甚至在第 6 集设计了一个简单内存\n\nIn general, computer memory is non-permanent.\n一般来说，电脑内存是 \"非永久性\"\n\nIf your xbox accidently gets unplugged and turns off,\n如果 Xbox 电源线不小心拔掉了，内存里所有数据都会丢失\n\nany data saved in memory is lost.\n如果 Xbox 电源线不小心拔掉了，内存里所有数据都会丢失\n\nFor this reason, it's called volatile memory.\n所以内存叫\"易失性\"存储器\n\nWhat we haven't talked so much about this series is storage,\n我们还没谈过的话题  是存储器（Storage）\n\nwhich is a tad different.\n存储器（Storage）和内存（Memory）有点不同\n\nAny data written to storage, like your hard drive,\n任何写入\"存储器\"的数据，比如你的硬盘 \\N 数据会一直存着，直到被覆盖或删除，断电也不会丢失\n\nwill stay there until it's over-written or deleted, even if the power goes out.\n任何写入\"存储器\"的数据，比如你的硬盘 \\N 数据会一直存着，直到被覆盖或删除，断电也不会丢失\n\nIt's non-volatile.\n存储器是\"非易失性\"的\n\nIt used to be that volatile memory was fast and non-volatile storage was slow,\n以前是\"易失性\"的速度快，\"非易失性\"的速度慢\n\nbut as computing technologies have improved, this distinction is becoming less true,\n但随着技术发展，两者的差异越来越小\n\nand the terms have started to blend together.\n但随着技术发展，两者的差异越来越小\n\nNowadays, we take for granted technologies like this little USB stick,\n如今我们认为稀松平常的技术，比如这个 U 盘\n\nwhich offers gigabytes of memory, reliable over long periods of time, all at low cost,\n能低成本+可靠+长时间  存储上 GB 的数据\n\nbut this wasn't always true.\n但以前可不是这样的\n\nThe earliest computer storage was paper punch cards,\n最早的存储介质是 打孔纸卡 \\N 以及纸卡的亲戚    打孔纸带\n\nand its close cousin, punched paper tape.\n最早的存储介质是 打孔纸卡 \\N 以及纸卡的亲戚    打孔纸带\n\nBy the 1940s, punch cards had largely standardized into a grid of 80 columns and 12 rows,\n到1940年代，纸卡标准是 80列x12行\n\nallowing for a maximum of 960 bits of data to be stored on a single card.\n一张卡能存 960 位数据 (80x12=960)\n\nThe largest program ever punched onto cards, that we know of,\n据我们所知的  最大纸卡程序\n\nwas the US Military's Semi-Automatic Ground Environment, or SAGE,\n是美国军方的\"半自动地面防空系统\" 简称 SAGE\n\nan Air Defense System that became operational in 1958.\n一个在 1958 年投入使用的防空系统\n\nThe main program was stored on 62,500 punchcards,\n主程序存储在 62,500 个纸卡上\n\nroughly equivalent to 5 megabytes of data,\n大小 5MB 左右, 相当如今手机拍张照\n\nthat's the size of an average smartphone photo today.\n大小 5MB 左右, 相当如今手机拍张照\n\nPunch cards were a useful and popular form of storage for decades,\n纸卡用了十几年，因为不用电而且便宜耐用\n\nthey didn't need power, plus paper was cheap and reasonably durable.\n纸卡用了十几年，因为不用电而且便宜耐用\n\nHowever, punchcards were slow and write-once,\n然而坏处是读取慢，只能写入一次\n\nyou can't easily un-punch a hole.\n打的孔无法轻易补上\n\nSo they were a less useful form of memory,\n对于存临时值，纸卡不好用\n\nwhere a value might only be needed for a fraction of a second during a program's execution,\n对于存临时值，纸卡不好用\n\nand then discarded.\n对于存临时值，纸卡不好用\n\nA faster, larger and more flexible form of computer memory was needed.\n我们需要更快更大更灵活的存储方式\n\nAn early and practical approach was developed by J. Presper Eckert,\nJ. Presper Eckert 在 1944 年建造 ENIAC 时发明了一种方法\n\nas he was finishing work on ENIAC in 1944.\nJ. Presper Eckert 在 1944 年建造 ENIAC 时发明了一种方法\n\nHis invention was called Delay Line Memory, and it worked like this.\n叫\"延迟线存储器\"（Delay Line Memory）原理如下\n\nYou take a tube and fill it with a liquid, like mercury.\n拿一个管子装满液体，如水银\n\nThen, you put a speaker at one end and microphone at the other.\n管子一端放扬声器，另一端放麦克风\n\nWhen you pulse the speaker, it creates a pressure wave.\n扬声器发出脉冲时  会产生压力波\n\nThis takes time to propagate to the other end of the tube,\n压力波需要时间  传播到另一端的麦克风\n\nwhere it hits the microphone,\n压力波需要时间  传播到另一端的麦克风\n\nconverting it back into an electrical signal.\n麦克风将压力波 转换回电信号.\n\nAnd we can use this propagation delay to store data!\n我们可以用压力波的传播延迟  来存储数据！\n\nImagine that the presence of a pressure wave is a 1\n假设有压力波代表 1，没有代表 0\n\nand the absence of a pressure wave is a 0.\n假设有压力波代表 1，没有代表 0\n\nOur speaker can output a binary sequence like 1010 0111.\n扬声器可以输出 1​​010 0111\n\nThe corresponding waves will travel down the tube, in order,\n压力波沿管子传播，过了一会儿，撞上麦克风，\n\nand a little while later, hit the microphone,\n压力波沿管子传播，过了一会儿，撞上麦克风，\n\nwhich converts the signal back into 1's and 0's.\n将信号转换回 1 和 0\n\nIf we create a circuit that connects the microphone to the speaker,\n如果加一个电路，连接麦克风和扬声器\n\nplus a little amplifier to compensate for any loss,\n再加一个放大器（Amplifier）来弥补信号衰弱\n\nwe can create a loop that stores data.\n就能做一个存储数据的循环\n\nThe signal traveling along the wire is near instantaneous,\n信号沿电线传播几乎是瞬时的,\n\nso there's only ever one bit of data showing at any moment in time.\n所以任何时间点只显示  1 bit 数据\n\nBut in the tube, you can store many bits!\n但管子中可以存储多个位(bit)\n\nAfter working on ENIAC, Eckert and his colleague John Mauchly,\n忙完 ENIAC 后，Eckert 和同事 John Mauchly\n\nset out to build a bigger and better computer called EDVAC, incorporating Delay Line Memory.\n着手做一个更大更好的计算机叫 EDVAC，使用了延迟线存储器\n\nIn total, the computer had 128 Delay Lines,\n总共有 128 条延迟线，每条能存 352 位（bits）\n\neach capable of storing 352 bits.\n总共有 128 条延迟线，每条能存 352 位（bits）\n\nThat's a grand total of 45 thousands bits of memory,\n总共能存 45,000 位(bit)\n\nnot too shabby for 1949!\n对 1949 年来说还不错！\n\nThis allowed EDVAC to be one of the very earliest Stored-Program Computers,\n这使得 EDVAC 成为最早的 \"存储程序计算机\" 之一\n\nwhich we talked about in Episode 10.\n我们在第 10 集讨论过\n\nHowever, a big drawback with delay line memory\n但\"延迟线存储器\"的一大缺点是\n\nis that you could only read one bit of data from a tube at any given instant.\n每一个时刻只能读一位 (bit) 数据\n\nIf you wanted to access a specific bit, like bit 112,\n如果想访问一个特定的 bit，比如第 112 位(bit) \\N 你得等待它从循环中出现\n\nyou'd have to wait for it to come around in the loop,\n如果想访问一个特定的 bit，比如第 112 位(bit) \\N 你得等待它从循环中出现\n\nwhat's called sequential or cyclic-access memory,\n所以又叫 \"顺序存储器\"或\"循环存储器\"\n\nwhereas we really want random access memory,\n而我们想要的是 \"随机存取存储器\" \\N 可以随时访问任何位置\n\nwhere we can access any bit at any time.\n而我们想要的是 \"随机存取存储器\" \\N 可以随时访问任何位置\n\nIt also proved challenging to increase the density of the memory,\n增加内存密度也是一个挑战\n\npacking waves closer together meant they were more easily mixed up.\n把压力波变得更紧密  意味着更容易混在一起\n\nIn response, new forms of delay line memory were invented,\n所以出现了其他类型的 \"延迟线存储器\"\n\nsuch as magnetostrictive delay lines .\n如 \"磁致伸缩延迟存储器\"\n\nThese delay lines use a metal wire that could be twisted,\n用金属线的振动来代表数据\n\ncreating little torsional waves that represented data.\n用金属线的振动来代表数据\n\nBy forming the wire into a coil, you could store around 1000 bits in a 1 foot by 1 foot square.\n通过把线卷成线圈，1英尺×1英尺的面积能存储大概 1000位(bit)\n\nHowever, delay line memory was largely obsolete by the mid 1950s,\n然而，延迟线存储器在 1950 年代中期就基本过时了\n\nsurpassed in performance, reliability and cost by a new kid on the block:\n因为出现了新技术，性能,可靠性和成本都更好\n\nmagnetic core memory which was constructed out of little magnetic donuts,\n\"磁芯存储器\"，用了像甜甜圈的小型磁圈\n\ncalled cores.\n\"磁芯存储器\"，用了像甜甜圈的小型磁圈\n\nIf you loop a wire around this core.\n如果给磁芯绕上电线，并施加电流，可以将磁化在一个方向\n\nand run an electrical current through the wire,\n如果给磁芯绕上电线，并施加电流，可以将磁化在一个方向\n\nwe can magnetize the core in a certain direction.\n如果给磁芯绕上电线，并施加电流，可以将磁化在一个方向\n\nIf we turn the current off, the core will stay magnetized.\n如果关掉电流，磁芯保持磁化\n\nIf we pass current through the wire in the opposite direction,\n如果沿相反方向施加电流\n\nthe magnetization direction, called polarity,\n磁化的方向（极性）会翻转\n\nflips the other way.\n磁化的方向（极性）会翻转\n\nIn this way, we can store 1's and 0's!\n这样就可以存 1 和 0！\n\n1 bit of memory isn't very useful, so these little donuts were arranged into grids.\n如果只存 1 位不够有用，所以把小甜甜圈排列成网格\n\nThere were wires for selecting the right row and column, and a wire that ran through every core,\n有电线负责选行和列 \\N 也有电线贯穿每个磁芯, 用于读写一位(bit)\n\nwhich could be used to read or write a bit.\n有电线负责选行和列 \\N 也有电线贯穿每个磁芯, 用于读写一位(bit)\n\nHere is an actual piece of core memory!\n我手上有一块磁芯存储器\n\nIn each of these little yellow squares, there are 32 rows and 32 columns of tiny cores,\n每个黄色方格  有32行x32列的磁芯 \\N 每个磁芯存 1 位数据\n\neach one holding 1 bit of data.\n每个黄色方格  有32行x32列的磁芯 \\N 每个磁芯存 1 位数据\n\nSo, each of these yellow squares could hold 1024 bits.\n所以能存 1024 位(bit)  (32x32=1024)\n\nIn total, there are 9 of these,\n总共 9 个黄色方格\n\nso this memory board could hold a maximum of 9216 bits,\n所以这块板子最多能存 9216 位(bit) (1024x9=9216)\n\nwhich is around 9 kilobytes.\n换算过来大约是 9 千字节 \\N (9216 bit ~= 9 kb)\n\nThe first big use of core memory was MIT's Whirlwind 1 computer, in 1953,\n磁芯内存的第一次大规模运用\\N 是 1953 年麻省理工学院的 Whirlwind 1 计算机\n\nwhich used a 32 by 32 core arrangement.\n磁芯排列是 32×32\n\nAnd, instead of just a single plane of cores, like this,\n用了 16 块板子，能存储大约 16000 位(bit)\n\nit was 16 boards deep, providing roughly 16 thousand bits of storage.\n用了 16 块板子，能存储大约 16000 位(bit)\n\nImportantly, unlike delay line memory,\n更重要的是，不像\"延迟线存储器\" \\N 磁芯存储器能随时访问任何一位(bit)\n\nany bit could be accessed at any time.\n更重要的是，不像\"延迟线存储器\" \\N 磁芯存储器能随时访问任何一位(bit)\n\nThis was a killer feature,\n这在当时非常了不起\n\nand magnetic core memory became the predominant Random Access Memory technology\n\"磁芯存储器\" 从 1950 年代中期开始成为主流 \\N 流行了 20 多年\n\nfor two decades, beginning in the mid 1950\n\"磁芯存储器\" 从 1950 年代中期开始成为主流 \\N 流行了 20 多年\n\neven though it was typically woven by hand!\n而且一般还是手工编织的！\n\nAlthough starting at roughly 1 dollar per bit,\n刚开始时  存储成本大约 1 美元 1 位(bit) \\N 到1970年代，下降到 1 美分左右\n\nthe cost fell to around 1 cent per bit by the 1970s.\n刚开始时  存储成本大约 1 美元 1 位(bit) \\N 到1970年代，下降到 1 美分左右\n\nUnfortunately, even 1 cent per bit isn't cheap enough for storage.\n不幸的是，即使每位 1 美分也不够便宜\n\nAs previously mentioned,\n之前提过，现代手机随便拍张照片都有 5 MB\n\nan average smartphone photo is around 5 megabytes in size,\n之前提过，现代手机随便拍张照片都有 5 MB\n\nthat's roughly 40 million bits.\n5MB 约等于 4000 万 bit\n\nWould you pay 4 hundred thousand dollars to store a photo on core memory?\n你愿意花 40 万美元在\"磁芯存储器\"上存照片吗？\n\nIf you have that kind of money to drop,\n如果你有这么多钱\n\ndid you know that Crash Course is on Patreon?\n你知道 Crash Course 在 Patreon 有赞助页吗？\n\nRight? Wink wink.\n对吧？你懂的\n\nAnyway, there was tremendous research into storage technologies happening at this time.\n总之，当时对存储技术进行了大量的研究\n\nBy 1951, Eckert and Mauchly had started their own company,\n到 1951 年，Eckert 和 Mauchly 创立了自己的公司\n\nand designed a new computer called UNIVAC,\n设计了一台叫 UNIVAC 的新电脑\n\none of the earliest commercially sold computers.\n最早进行商业销售的电脑之一\n\nIt debuted with a new form of computer storage:\n它推出了一种新存储：磁带\n\nmagnetic tape.\n它推出了一种新存储：磁带\n\nThis was a long, thin and flexible strip of magnetic material, stored in reels.\n磁带是纤薄柔软的一长条磁性带子  卷在轴上\n\nThe tape could be moved forwards or backwards inside of a machine called a tape drive.\n磁带可以在\"磁带驱动器\"内前后移动\n\nInside is a write head,\n里面有一个\"写头\"绕了电线，电流通过产生磁场\n\nwhich passes current through a wound wire to generate a magnetic field,\n里面有一个\"写头\"绕了电线，电流通过产生磁场\n\ncausing a small section of the tape to become magnetized.\n导致磁带的一小部分被磁化\n\nThe direction of the current sets the polarity, again, perfect for storing 1's and 0's.\n电流方向决定了极性，代表 1 和 0\n\nThere was also a separate read head could detect the polarity non-destructively.\n还有一个\"读头\"，可以非破坏性地检测极性\n\nThe UNIVAC used half-inch-wide tape with 8 parallel data tracks,\nUNIVAC 用了半英寸宽，8条并行的磁带\n\neach able to store 128 bits of data per inch.\n磁带每英寸可存 128 位数据\n\nWith each reel containing 1200 feet of tape,\n每卷有 1200 英尺长\n\nit meant you could store roughly 15 million bits\n意味着一共可以存 1500 万位左右\n\n- that's almost 2 megabytes!\n- 接近2兆字节！（2 MB）\n\nAlthough tape drives were expensive,\n虽然磁带驱动器很贵，但磁带又便宜又小\n\nthe magnetic tape itself was cheap and compact,\n虽然磁带驱动器很贵，但磁带又便宜又小\n\nand for this reason, they're still used today for archiving data.\n因此磁带至今仍用于存档\n\nThe main drawback is access speed.\n磁带的主要缺点是访问速度\n\nTape is inherently sequential,\n磁带是连续的，必须倒带或快进到达特定位置\n\nyou have to rewind or fast-forward to get to data you want.\n磁带是连续的，必须倒带或快进到达特定位置\n\nThis might mean traversing hundreds of feet of tape to retrieve a single byte,\n可能要几百英尺才能得到某个字节(byte)，这很慢\n\nwhich is slow.\n可能要几百英尺才能得到某个字节(byte)，这很慢\n\nA related popular technology in the 1950s and 60s was Magnetic Drum Memory.\n1950,60年代，有个类似技术是 \"磁鼓存储器\"\n\nThis was a metal cylinder - called a drum - coated in a magnetic material for recording data\n有金属圆筒，盖满了磁性材料以记录数据\n\nThe drum was rotated continuously,\n滚筒会持续旋转，周围有数十个读写头\n\nand positioned along its length were dozens of read and write heads.\n滚筒会持续旋转，周围有数十个读写头\n\nThese would wait for the right spot to rotate underneath them to read or write a bit of data.\n等滚筒转到正确的位置\\N 读写头会读或写 1 位(bit) 数据\n\nTo keep this delay as short as possible,\n为了尽可能缩短延迟, 鼓轮每分钟上千转！\n\ndrums were rotated thousand of revolutions per minute!\n为了尽可能缩短延迟, 鼓轮每分钟上千转！\n\nBy 1953, when the technology started to take off,\n到 1953 年，磁鼓技术飞速发展 \\N 可以买到存 80,000 位的\"磁鼓存储器\"\n\nyou could buy units able to record 80,000 bits of data\n到 1953 年，磁鼓技术飞速发展 \\N 可以买到存 80,000 位的\"磁鼓存储器\"\n\n- that's 10 kilobytes,\n- 也就是 10 KB\n\nbut the manufacture of drums ceased in the 1970s.\n但到 1970 年代 \"磁鼓存储器\" 不再生产\n\nHowever, Magnetic Drums did directly lead to the development of Hard Disk Drives,\n然而，磁鼓导致了硬盘的发展 \\N 硬盘和磁鼓很相似\n\nwhich are very similar, but use a different geometric configuration.\n然而，磁鼓导致了硬盘的发展 \\N 硬盘和磁鼓很相似\n\nInstead of large cylinder, hard disks use,\n不过硬盘用的是盘，不像磁鼓用圆柱体，因此得名\n\nwell disks that are hard.\n不过硬盘用的是盘，不像磁鼓用圆柱体，因此得名\n\nHence the name!\n不过硬盘用的是盘，不像磁鼓用圆柱体，因此得名\n\nThe storage principle is the same,\n原理是一样的，磁盘表面有磁性\n\nthe surface of a disk is magnetic,\n原理是一样的，磁盘表面有磁性\n\nallowing write and read heads to store and retrieve 1's and 0's.\n写入头和读取头  可以处理上面的 1 和 0\n\nThe great thing about disks is that they are thin,\n硬盘的好处是薄，可以叠在一起\n\nso you can stack many of them together,\n硬盘的好处是薄，可以叠在一起\n\nproviding a lot of surface area for data storage.\n提供更多表面积来存数据\n\nThat's exactly what IBM did for the world's first computer with a disk drive:\nIBM 对世上第一台磁盘计算机就是这样做的\n\nthe RAMAC 305.\nRAMAC 305\n\nSweet name BTW.\n顺便一说名字不错\n\nIt contained fifty, 24-inch diameter disks,\n它有 50 张 24 英寸直径的磁盘，总共能存 5 MB 左右\n\noffering a total storage capacity of roughly 5 megabytes.\n它有 50 张 24 英寸直径的磁盘，总共能存 5 MB 左右\n\nYess!! We've finally gotten to a technology that can store a single smartphone photo!\n太棒啦! 终于能存一张现代手机的照片了！这年是 1956 年\n\nThe year was 1956.\n太棒啦! 终于能存一张现代手机的照片了！这年是 1956 年\n\nTo access any bit of data,\n要访问某个特定 bit\n\na read/write head would travel up or down the stack to the right disk,\n一个读/写磁头会向上或向下移动，找到正确的磁盘\n\nand then slide in between them.\n然后磁头会滑进去\n\nLike drum memory, the disks are spinning,\n就像磁鼓存储器一样，磁盘也会高速旋转\n\nso the head has to wait for the right section to come around.\n所以读写头要等到正确的部分转过来\n\nThe RAMAC 305 could access any block of data, on average, in around 6/10ths of a second,\nRAMAC 305 访问任意数据，平均只要六分之一秒左右\n\nwhat's called the seek time.\n也叫寻道时间\n\nWhile great for storage, this was not nearly fast enough for memory,\n虽然六分之一秒对存储器来说算不错 \\N 但对内存来说还不够快\n\nso the RAMAC 305 also had drum memory and magnetic core memory.\n所以 RAMAC 305 还有\"磁鼓存储器\"和\"磁芯存储器\"\n\nThis is an example of a memory hierarchy,\n这是\"内存层次结构\"的一个例子\n\nwhere you have a little bit of fast memory, which is expensive,\n一小部分高速+昂贵的内存\n\nslightly more medium-speed memory, which is less expensive,\n一部分稍慢+相对便宜些的内存\n\nand then a lot of slowish memory, which is cheap.\n还有更慢+更便宜的内存\n\nThis mixed approach strikes a balance between cost and speed.\n这种混合  在成本和速度间取得平衡\n\nHard disk drives rapidly improved and became commonplace by the 1970s.\n1970 年代，硬盘大幅度改进并变得普遍\n\nA hard disk like this can easily hold 1 terabyte of data today\n如今的硬盘可以轻易容纳 1TB 的数据\n\n- that's a trillion bytes - or roughly 200,000 five megabyte photos!\n能存 20 万张 5MB 的照片！\n\nAnd these types of drives can be bought online for as little as 40 US dollars.\n网上最低 40 美元就可以买到\n\nThat's 0.0000000005 cents per bit.\n每 bit 成本 0.0000000005 美分\n\nA huge improvement over core memory's 1 cent per bit!\n比磁芯内存 1 美分 1 bit 好多了！\n\nAlso, modern drives have an average seek time of under 1/100th of a second.\n另外，现代硬盘的平均寻道时间低于 1/100 秒\n\nI should also briefly mention a close cousin of hard disks, the floppy disk,\n我简单地提一下硬盘的亲戚，软盘\n\nwhich is basically the same thing, but uses a magnetic medium that's, floppy.\n除了磁盘是软的，其他基本一样\n\nYou might recognise it as the save icon on some of your applications,\n你可能见过某些程序的保存图标是一个软盘\n\nbut it was once a real physical object!\n软盘曾经是真实存在的东西！\n\nIt was most commonly used for portable storage,\n软盘是为了便携，在 1970~1990 非常流行\n\nand became near ubiquitous from the mid 1970s up to the mid 90s.\n软盘是为了便携，在 1970~1990 非常流行\n\nAnd today it makes a pretty good coaster.\n如今当杯垫挺不错的\n\nHigher density floppy disks, like Zip Disks,\n密度更高的软盘，如 Zip Disks，在90年代中期流行起来\n\nbecame popular in the mid 1990s,\n密度更高的软盘，如 Zip Disks，在90年代中期流行起来\n\nbut fell out of favor within a decade.\n但十年内就消失了\n\nOptical storage came onto the scene in 1972, in the form of a 12-inch \"laser disc.\"\n光学存储器于 1972 年出现，12 英寸的\"激光盘\"\n\nHowever, you are probably more familiar with its later, smaller, are more popular cousin,\n你可能对后来的产品更熟：光盘（简称 CD）\n\nthe Compact Disk, or CD,\n你可能对后来的产品更熟：光盘（简称 CD）\n\nas well as the DVD which took off in the 90s.\n以及 90 年代流行的 DVD\n\nFunctionally, these technologies are pretty similar to hard disks and floppy disks,\n功能和硬盘软盘一样，都是存数据.\n\nbut instead of storing data magnetically,\n但用的不是磁性\n\noptical disks have little physical divots in their surface that cause light to be reflected differently,\n光盘表面有很多小坑，造成光的不同反射\n\nwhich is captured by an optical sensor, and decoded into 1's and 0's.\n光学传感器会捕获到，并解码为 1 和 0\n\nHowever, today, things are moving to solid state technologies, with no moving parts,\n如今，存储技术在朝固态前进，没有机械活动部件\n\nlike this hard drive and also this USB stick.\n比如这个硬盘，以及 U 盘\n\nInside are Integrated Circuits,\n里面是集成电路，我们在第 15 集讨论过\n\nwhich we talked about in Episode 15.\n里面是集成电路，我们在第 15 集讨论过\n\nThe first RAM integrated circuits became available in 1972 at 1 cent per bit,\n第一个 RAM 集成电路出现于 1972 年 \\N 成本每比特 1 美分\n\nquickly making magnetic core memory obsolete.\n使\"磁芯存储器\"迅速过时\n\nToday, costs have fallen so far,\n如今成本下降了更多 \\N 机械硬盘 被 固态硬盘 逐渐替代，简称 SSD\n\nthat hard disk drives are being replaced with non-volatile,\n如今成本下降了更多 \\N 机械硬盘 被 固态硬盘 逐渐替代，简称 SSD\n\nSolid State Drives, or SSDs, as the cool kids say.\n如今成本下降了更多 \\N 机械硬盘 被 固态硬盘 逐渐替代，简称 SSD\n\nBecause they contain no moving parts,\n由于 SSD 没有移动部件\n\nthey don't really have to seek anywhere,\n磁头不用等磁盘转\n\nso SSD access times are typically under 1/1000th of a second.\n所以 SSD 访问时间低于 1/1000 秒\n\nThat's fast!\n这很快！\n\nBut it's still many times slower than your computer's RAM.\n但还是比 RAM 慢很多倍\n\nFor this reason, computers today still use memory hierarchies.\n所以现代计算机 仍然用存储层次结构\n\nSo, we've come along way since the 1940s.\n我们从 1940 年代到现在进步巨大\n\nMuch like transistor count and Moore's law,\n就像在第 14 集讨论过的  晶体管数量和摩尔定律\n\nwhich we talked about in Episode 14,\n就像在第 14 集讨论过的  晶体管数量和摩尔定律\n\nmemory and storage technologies have followed a similar exponential trend.\n内存和存储技术也有类似的趋势\n\nFrom early core memory costing millions of dollars per megabyte, we're steadily fallen,\n从早期每 MB 成本上百万美元，下滑到\n\nto mere cents by 2000, and only fractions of a cent today.\n2000 年只要几分钱，如今远远低于 1 分钱\n\nPlus, there's WAY less punch cards to keep track of.\n完全没有打孔纸卡\n\nSeriously, can you imagine if there was a slight breeze in that room containing the SAGE program?\n你能想象 SEGA 的纸卡房间风一吹会怎样吗？\n\n62,500 punch cards.\n62,500 张卡\n\nI don't even want to think about it.\n我想都不敢想\n\nI'll see you next week.\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/20. 文件系统-Files & File Systems.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode we talked about data storage, how technologies like magnetic tape and hard\n上集我们讲了数据存储，磁带和硬盘这样的技术\n\ndisks can store trillions of bits of data,\n可以在断电状态长时间存上万亿个位\n\nfor long durations, even without power.\n可以在断电状态长时间存上万亿个位\n\nWhich is perfect for recording \"big blobs\" of related data,\n非常合适存一整块有关系的数据，或者说\"文件\"\n\nwhat are more commonly called computer files.\n非常合适存一整块有关系的数据，或者说\"文件\"\n\nYou've no doubt encountered many types,\n你肯定见过很多种文件 \\N 比如文本文件，音乐文件，照片和视频\n\nlike text files, music files, photos and videos.\n你肯定见过很多种文件 \\N 比如文本文件，音乐文件，照片和视频\n\nToday, we're going to talk about how files work,\n今天，我们要讨论文件到底是什么 \\N 以及计算机怎么管理文件\n\nand how computers keep them all organized with File Systems.\n今天，我们要讨论文件到底是什么 \\N 以及计算机怎么管理文件\n\nIt's perfectly legal for a file to contain arbitrary, unformatted data,\n随意排列文件数据完全没问题，但按格式排会更好\n\nbut it's most useful and practical if the data inside the file is organized somehow.\n随意排列文件数据完全没问题，但按格式排会更好\n\nThis is called a file format.\n这叫 \"文件格式\"\n\nYou can invent your own, and programmers do that from time to time,\n你可以发明自己的文件格式，程序员偶尔会这样做\n\nbut it's usually best and easiest to use an existing standard, like JPEG and MP3.\n但最好用现成标准，比如 JPEG 和 MP3\n\nLet's look at some simple file formats.\n来看一些简单文件格式，最简单的是文本文件\n\nThe most straightforward are text files,\n来看一些简单文件格式，最简单的是文本文件\n\nalso know as TXT file, which contain...surprise! text.\n也叫 TXT 文件, 里面包含的是... 文字 （惊喜吧）\n\nLike all computer files, this is just a huge list of numbers, stored as binary.\n就像所有其它文件，文本文件只是一长串二进制数\n\nIf we look at the raw values of a text file in storage, it would look something like this:\n原始值看起来会像这样：\n\nWe can view this as decimal numbers instead of binary,\n可以转成十进制看，但帮助不大\n\nbut that still doesn't help us read the text.\n可以转成十进制看，但帮助不大\n\nThe key to interpreting this data is knowing that TXT files use ASCII,\n解码数据的关键是 ASCII 编码\n\na character encoding standard we discussed way back in Episode 4.\n一种字符编码标准，第 4 集讨论过.\n\nSo, in ASCII, our first value, 72, maps to the capital letter H.\n第一个值 72 \\N 在 ASCII 中是大写字母 H\n\nAnd in this way, we decode the whole file.\n以此类推 解码其他数字\n\nLet's look at a more complicated example: a WAVE File, also called a WAV,\n来看一个更复杂的例子：波形(Wave)文件，也叫 WAV \\N 它存音频数据\n\nwhich stores audio.\n来看一个更复杂的例子：波形(Wave)文件，也叫 WAV \\N 它存音频数据\n\nBefore we can correctly read the data, we need to know some information,\n在正确读取数据前，需要知道一些信息\n\nlike the bit rate and whether it's a single track or stereo.\n比如码率(bit rate)，以及是单声道还是立体声\n\nData about data, is called meta data.\n关于数据的数据，叫\"元数据\"(meta data)\n\nThis metadata is stored at the front of the file, ahead of any actual data,\n元数据存在文件开头，在实际数据前面 \\N 因此也叫 文件头(Header)\n\nin what's known as a Header.\n元数据存在文件开头，在实际数据前面 \\N 因此也叫 文件头(Header)\n\nHere's what the first 44 bytes of a WAV file looks like.\nWAV 文件的前 44 个字节长这样\n\nSome parts are always the same, like where it spells out W-A-V-E.\n有的部分总是一样的，比如写着 WAVE 的部分\n\nOther parts contain numbers that change depending on the data contained within.\n其他部分的内容，会根据数据变化\n\nThe audio data comes right behind the metadata, and it's stored as a long list of numbers.\n音频数据紧跟在元数据后面，是一长串数字\n\nThese values represent the amplitude of sound captured many times per second, and if you\n数字代表每秒捕获多次的声音幅度\n\nwant a primer on sound, check out our video all about it in Crash Course Physics.\n如果想学声音的基础知识 \\N 可以看物理速成课第18集\n\nLink in the dobblydoo.\n如果想学声音的基础知识 \\N 可以看物理速成课第18集\n\nAs an example, let's look at a waveform of me saying: \"hello!\" Hello!\n举个例子，看一下\"你好\"的波形\n\nNow that we've captured some sound, let's zoom into a little snippet.\n现在捕获到了一些声音，我们放大看一下\n\nA digital microphone, like the one in your computer or smartphone,\n电脑和手机麦克风，每秒可以对声音进行上千次采样\n\nsamples the sound pressure thousands of times.\n电脑和手机麦克风，每秒可以对声音进行上千次采样\n\nEach sample can be represented as a number.\n每次采样可以用一个数字表示\n\nLarger numbers mean higher sound pressure, what's called amplitude.\n声压越高数字越大，也叫\"振幅\"\n\nAnd these numbers are exactly what gets stored in a WAVE file!\nWAVE 文件里存的就是这些数据！\n\nThousands of amplitudes for every single second of audio!\n每秒上千次的振幅！\n\nWhen it's time to play this file, an audio program needs to actuate the computer's speakers\n播放声音文件时，扬声器会产生相同的波形\n\nsuch that the original waveform is emitted.\n播放声音文件时，扬声器会产生相同的波形\n\n\"Hello!\"\n\"你好！\"\n\nSo, now that you're getting the hang of file formats, let's talk about bitmaps or\n现在来谈谈 位图(Bitmap)，后缀 .bmp, 它存图片\n\nBMP, which store pictures.\n现在来谈谈 位图(Bitmap)，后缀 .bmp, 它存图片\n\nOn a computer, Pictures are made up of little tiny square elements called pixels.\n计算机上，图片由很多个叫\"像素\"的方块组成\n\nEach pixel is a combination of three colors: red, green and blue.\n每个像素由三种颜色组成：红，绿，蓝\n\nThese are called additive primary colors, and they can be mixed together to create any\n叫\"加色三原色\"，混在一起可以创造其它颜色\n\nother color on our electronic displays.\n叫\"加色三原色\"，混在一起可以创造其它颜色\n\nNow, just like WAV files, BMPs start with metadata,\n就像 WAV 文件一样，BMP 文件开头也是元数据 \\N 有图片宽度，图片高度，颜色深度\n\nincluding key values like image width, image height, and color depth.\n就像 WAV 文件一样，BMP 文件开头也是元数据 \\N 有图片宽度，图片高度，颜色深度\n\nAs an example, let's say the metadata specified an image 4 pixels wide, by 4 pixels tall,\n举例，假设元数据说图是 4像素宽 x 4像素高\n\nwith a 24-bit color depth - that's 8-bits for red, 8-bits for green, and 8-bits for blue.\n颜色深度 24 位\\N  8 位红色，8 位绿色，8 位蓝色\n\nAs a reminder, 8 bits is the same as one byte.\n提醒一下，8位 (bit) 和 1字节(byte)是一回事\n\nThe smallest number a byte can store is 0, and the largest is 255.\n一个字节能表示的最小数是 0，最大 255\n\nOur image data is going to look something like this:\n图像数据看起来会类似这样：\\N 来看看第一个像素的颜色\n\nLet's look at the color of our first pixel.\n图像数据看起来会类似这样：\\N 来看看第一个像素的颜色\n\nIt has 255 for its red value, 255 for green and 255 for blue.\n红色是255，绿色是255，蓝色也是255\n\nThis equates to full intensity red, full intensity green and full intensity blue.\n这等同于全强度红色，全强度绿色和全强度蓝色\n\nThese colors blend together on your computer monitor to become white.\n混合在一起变成白色\n\nSo our first pixel is white!\n所以第一个像素是白色！\n\nThe next pixel has a Red-Green-Blue, or RGB value of 255, 255, 0.\n下一个像素的红绿蓝值，或 RGB 值 \\N  255,255,0 是黄色！\n\nThat's the color yellow!\n下一个像素的红绿蓝值，或 RGB 值 \\N  255,255,0 是黄色！\n\nThe pixel after that has a RGB value of 0,0,0 - that's zero intensity everything, which is black.\n下一个像素是 0,0,0 ，黑色\n\nAnd the next one is yellow.\n下一个是黄色\n\nBecause the metadata specified this was a 4 by 4 image, we know that we've reached\n因为元数据说图片是 4x4 \\N 我们知道现在到了第一行结尾\n\nthe end of our first row of pixels.\n因为元数据说图片是 4x4 \\N 我们知道现在到了第一行结尾\n\nSo, we need to drop down a row.\n所以换一行\n\nThe next RGB value is 255,255,0 yellow again.\n下一个 RGB 值是 255,255,0，又是黄色\n\nOkay, let's go ahead and read all the pixels in our 4x4 image tada!\n好，我们读完剩下的像素\n\nA very low resolution pac-man!\n一个低分辨率的吃豆人\n\nObviously this is a simple example of a small image,\n刚才显然只是一个简单例子，但这张图片也可以用 BMP 存\n\nbut we could just as easily store this image in a BMP.\n刚才显然只是一个简单例子，但这张图片也可以用 BMP 存\n\nI want to emphasize again that it doesn't matter if it's a text file, WAV,\n我想再次强调，不管是文本文件，WAV，BMP\n\nBMP, or fancier formats we don't have time to discuss,\n或是我们没时间讨论的其他格式\n\nUnder the hood, they're all the same: long lists of numbers, stored as binary, on a storage device.\n文件在底层全是一样的： 一长串二进制\n\nFile formats are the key to reading and understanding the data inside.\n为了知道文件是什么，文件格式至关重要\n\nNow that you understand files a little better, let's move on to\n现在你对文件更了解了 \\N 我们接下来讨论计算机怎么存文件\n\nhow computers go about storing them.\n现在你对文件更了解了 \\N 我们接下来讨论计算机怎么存文件\n\nEven though the underlying storage medium might be\n虽然硬件可能是磁带，磁鼓，磁盘或集成电路\n\na strip of tape, a drum, a disk, or integrated circuits...\n虽然硬件可能是磁带，磁鼓，磁盘或集成电路\n\nhardware and software abstractions let us think of storage as a\n通过软硬件抽象后，可以看成一排能存数据的桶\n\nlong line of little buckets that store values.\n通过软硬件抽象后，可以看成一排能存数据的桶\n\nIn the early days, when computers only performed one computation\n在很早期时，计算机只做一件事，比如算火炮射程表 \\N 整个储存器就像一整个文件\n\nlike calculating artillery range tables. the entire storage operated like one big file.\n在很早期时，计算机只做一件事，比如算火炮射程表 \\N 整个储存器就像一整个文件\n\nData started at the beginning of storage, and then filled it up in order as output was\n数据从头存到尾，直到占满\n\nproduced, up to the storage capacity.\n数据从头存到尾，直到占满\n\nHowever, as computational power and storage capacity improved, it became possible, and\n但随着计算能力和存储容量的提高 \\N 存多个文件变得非常有用\n\nuseful, to store more than one file at a time.\n但随着计算能力和存储容量的提高 \\N 存多个文件变得非常有用\n\nThe simplest option is to store files back-to-back.\n最简单的方法  是把文件连续存储\n\nThis can work... but how does the computer know where files begin and end?\n这样能用, \\N 但怎么知道文件开头和结尾在哪里？\n\nStorage devices have no notion of files C they're just a mechanism for storing lots of bits.\n储存器没有文件的概念，只是存储大量位\n\nSo, for this to work, we need to have a special file that records where other ones are located.\n所以为了存多个文件 \\N 需要一个特殊文件，记录其他文件的位置\n\nThis goes by many names, but a good general term is Directory File.\n这个特殊文件有很多名字，这里泛称 \"目录文件\"\n\nMost often, it's kept right at the front of storage, so we always know where to access it.\n这个文件经常存在最开头，方便找\n\nLocation zero!\n位置 0！\n\nInside the Directory File are the names of all the other files in storage.\n目录文件里，存所有其他文件的名字\n\nIn our example, they each have a name, followed by a period\n格式是文件名 + 一个句号 + 扩展名，比如 BMP 或 WAV\n\nand end with what's called a File Extension, like \"BMP\" or \"WAV\".\n格式是文件名 + 一个句号 + 扩展名，比如 BMP 或 WAV\n\nThose further assist programs in identifying file types.\n扩展名帮助得知文件类型\n\nThe Directory File also stores metadata about these files, like when they were created and\n目录文件还存文件的元数据，比如创建时间\n\nlast modified, who the owner is, and if it can be read, written or both.\n最后修改时间，文件所有者是谁\\N是否能读/写  或读写都行\n\nBut most importantly, the directory file contains where these files\n最重要的是，目录文件有文件起始位置和长度\n\nbegin in storage, and how long they are.\n最重要的是，目录文件有文件起始位置和长度\n\nIf we want to add a file, remove a file, change a filename, or similar,\n如果要添加文件，删除文件，更改文件名等\n\nwe have to update the information in the Directory File.\n必须更新目录文件\n\nIt's like the Table of Contents in a book, if you make a chapter shorter, or move it\n就像书的目录，如果缩短或移动了一个章节 \\N 要更新目录，不然页码对不上\n\nsomewhere else, you have to update the table of contents, otherwise the page numbers won't match!\n就像书的目录，如果缩短或移动了一个章节 \\N 要更新目录，不然页码对不上\n\nThe Directory File, and the maintenance of it, is an example of a very basic File System,\n目录文件，以及对目录文件的管理 \\N 是一个非常简单的文件系统例子\n\nthe part of an Operating System that manages and keep track of stored files.\n文件系统专门负责管理文件\n\nThis particular example is a called a Flat File System, because they're all stored at one level.\n刚刚的例子叫\"平面文件系统\" \\N因为文件都在同一个层次\n\nIt's flat!\n平的！\n\nOf course, packing files together, back-to-back, is a bit of a problem,\n当然，把文件前后排在一起  有个问题\n\nbecause if we want to add some data to let's say \"todo.txt\",\n如果给 todo.txt 加一点数据 \\N 会覆盖掉后面 carrie.bmp 的一部分\n\nthere's no room to do it without overwriting part of \"carrie.bmp\".\n如果给 todo.txt 加一点数据 \\N 会覆盖掉后面 carrie.bmp 的一部分\n\nSo modern File Systems do two things.\n所以现代文件系统会做两件事\n\nFirst, they store files in blocks.\n1. 把空间划分成一块块 \\N 导致有一些 \"预留空间\" 可以方便改动\n\nThis leaves a little extra space for changes, called slack space.\n1. 把空间划分成一块块 \\N 导致有一些 \"预留空间\" 可以方便改动\n\nIt also means that all file data is aligned to a common size, which simplifies management.\n同时也方便管理\n\nIn a scheme like this, our Directory File needs to keep track of\n用这样的方案，目录文件要记录文件在哪些块里\n\nwhat block each one is stored in.\n用这样的方案，目录文件要记录文件在哪些块里\n\nThe second thing File Systems do, is allow files to be broken up into chunks\n2. 拆分文件，存在多个块里\n\nand stored across many blocks.\n2. 拆分文件，存在多个块里\n\nSo let's say we open \"todo.txt\", and we add a few more items then the file becomes\n假设打开 todo.txt 加了些内容\\N 文件太大存不进一块里\n\ntoo big to be saved in its one block.\n假设打开 todo.txt 加了些内容\\N 文件太大存不进一块里\n\nWe don't want to overwrite the neighboring one, so instead, the File System allocates\n我们不想覆盖掉隔壁的块，所以文件系统会分配 \\N 一个没使用的块，容纳额外的数据\n\nan unused block, which can accommodate extra data.\n我们不想覆盖掉隔壁的块，所以文件系统会分配 \\N 一个没使用的块，容纳额外的数据\n\nWith a File System scheme like this, the Directory File needs to store\n目录文件会记录不止一个块，而是多个块\n\nnot just one block per file, but rather a list of blocks per file.\n目录文件会记录不止一个块，而是多个块\n\nIn this way, we can have files of variable sizes that can be easily\n只要分配块，文件可以轻松增大缩小\n\nexpanded and shrunk, simply by allocating and deallocating blocks.\n只要分配块，文件可以轻松增大缩小\n\nIf you watched our episode on Operating Systems, this should sound a lot like Virtual Memory.\n如果你看了第18集 操作系统 \\N 这听起来很像\"虚拟内存\"\n\nConceptually it's very similar!\n概念上讲的确很像！\n\nNow let's say we want to delete \"carrie.bmp\".\n假设想删掉 carrie.bmp \\N 只需要在目录文件删掉那条记录\n\nTo do that, we can simply remove the entry from the Directory File.\n假设想删掉 carrie.bmp \\N 只需要在目录文件删掉那条记录\n\nThis, in turn, causes one block to become free.\n让一块空间变成了可用\n\nNote that we didn't actually erase the file's data in storage, we just deleted the record of it.\n注意这里没有擦除数据，只是把记录删了\n\nAt some point, that block will be overwritten with new data, but until then, it just sits there.\n之后某个时候，那些块会被新数据覆盖 \\N 但在此之前，数据还在原处\n\nThis is one way that computer forensic teams can \"recover\" data from computers even\n所以计算机取证团队可以\"恢复\"数据\n\nthough people think it has been deleted. Crafty!\n虽然别人以为数据已经\"删了\", 狡猾！\n\nOk, let's say we add even more items to our todo list, which causes the File System\n假设往 todo.txt 加了更多数据 \\N 所以操作系统分配了一个新块，用了刚刚 carrie.bmp 的块\n\nto allocate yet another block to the file, in this case,\n假设往 todo.txt 加了更多数据 \\N 所以操作系统分配了一个新块，用了刚刚 carrie.bmp 的块\n\nrecycling the block freed from carrie.bmp.\n假设往 todo.txt 加了更多数据 \\N 所以操作系统分配了一个新块，用了刚刚 carrie.bmp 的块\n\nNow our \"todo.txt\" is stored across 3 blocks, spaced apart, and also out of order.\n现在 todo.txt 在 3 个块里，隔开了，顺序也是乱的\n\nFiles getting broken up across storage like this is called fragmentation.\n这叫碎片\n\nIt's the inevitable byproduct of files being created, deleted and modified.\n碎片是增/删/改文件导致的，不可避免\n\nFor many storage technologies, this is bad news.\n对很多存储技术来说，碎片是坏事\n\nOn magnetic tape, reading todo.txt into memory would require\n如果 todo.txt 存在磁带上，读取文件要\n\nseeking to block 1, then fast forwarding to block 5, and then rewinding to block 3\n先读块1, 然后快进到块5，然后往回转到块2\n\nthat's a lot of back and forth!\n来回转个半天\n\nIn real world File Systems, large files might be stored across hundreds of blocks,\n现实世界中，大文件可能存在数百个块里\n\nand you don't want to have to wait five minutes for your files to open.\n你可不想等五分钟才打开文件\n\nThe answer is defragmentation!\n答案是碎片整理！\n\nThat might sound like technobabble, but the process is really simple,\n这个词听起来好像很复杂，但实际过程很简单\n\nand once upon a time it was really fun to watch!\n以前看计算机做碎片整理 真的很有趣！\n\nThe computer copies around data so that files have blocks located together\n计算机会把数据来回移动，排列成正确的顺序\n\nin storage and in the right order.\n计算机会把数据来回移动，排列成正确的顺序\n\nAfter we've defragged, we can read our todo file,\n整理后 todo.txt 在 1 2 3，方便读取.\n\nnow located in blocks 1 through 3, in a single, quick read pass.\n整理后 todo.txt 在 1 2 3，方便读取.\n\nSo far, we've only been talking about Flat File Systems,\n目前只说了平面文件系统，文件都在同一个目录里.\n\nwhere they're all stored in one directory.\n目前只说了平面文件系统，文件都在同一个目录里.\n\nThis worked ok when computers only had a little bit of storage,\n如果存储空间不多，这可能就够用了 \\N 因为只有十几个文件\n\nand you might only have a dozen or so files.\n如果存储空间不多，这可能就够用了 \\N 因为只有十几个文件\n\nBut as storage capacity exploded, like we discussed last episode,\n但上集说过，容量爆炸式增长，文件数量也飞速增长\n\nso did the number of files on computers.\n但上集说过，容量爆炸式增长，文件数量也飞速增长\n\nVery quickly, it became impractical to store all files together at one level.\n很快，所有文件都存在同一层变得不切实际\n\nJust like documents in the real world, it's handy to store related files together in folders.\n就像现实世界\\N 相关文件放在同一个文件夹会方便很多\n\nThen we can put connected folders into folders, and so on.\n然后文件夹套文件夹.\n\nThis is a Hierarchical File System, and its what your computer uses.\n这叫\"分层文件系统\"，你的计算机现在就在用这个.\n\nThere are a variety of ways to implement this, but let's stick with the File System example\n实现方法有很多种，我们用之前的例子来讲重点好了\n\nwe've been using to convey the main idea.\n实现方法有很多种，我们用之前的例子来讲重点好了\n\nThe biggest change is that our Directory File needs to be able to point not just to files,\n最大的变化是 目录文件不仅要指向文件, 还要指向目录\n\nbut also other directories.\n最大的变化是 目录文件不仅要指向文件, 还要指向目录\n\nTo keep track of what's a file and what's a directory, we need some extra metadata.\n我们需要额外元数据  来区分开文件和目录，\n\nThis Directory File is the top-most one, known as the Root Directory.\n这个目录文件在最顶层，因此叫根目录\n\nAll other files and folders lie beneath this directory along various file paths.\n所有其他文件和文件夹，都在根目录下\n\nWe can see inside of our \"Root\" Directory File that we have 3 files\n图中可以看到根目录文件有3个文件 \\N 2个子文件夹：\"音乐\"和\"照片\"\n\nand 2 subdirectories: music and photos.\n图中可以看到根目录文件有3个文件 \\N 2个子文件夹：\"音乐\"和\"照片\"\n\nIf we want to see what's stored in our music directory, we have to go to that block and\n如果想知道\"音乐\"文件夹里有什么 \\N 必须去那边读取目录文件（格式和根目录文件一样）\n\nread the Directory File located there; the format is the same as our root directory.\n如果想知道\"音乐\"文件夹里有什么 \\N 必须去那边读取目录文件（格式和根目录文件一样）\n\nThere's a lot of great songs in there!\n有很多好歌啊！\n\nIn addition to being able to create hierarchies of unlimited depth,\n除了能做无限深度的文件夹 \\N 这个方法也让我们可以轻松移动文件\n\nthis method also allows us to easily move around files.\n除了能做无限深度的文件夹 \\N 这个方法也让我们可以轻松移动文件\n\nSo, if we wanted to move \"theme.wav\" from our root directory to the music directory,\n如果想把 theme.wav 从根目录移到音乐目录\n\nwe don't have to re-arrange any blocks of data.\n不用移动任何数据块\n\nWe can simply modify the two Directory Files, removing an entry from one and adding it to another.\n只需要改两个目录文件 \\N 一个文件里删一条记录，另一个文件里加一条记录\n\nImportantly, the theme.wav file stays in block 5.\ntheme.wav 依然在块5\n\nSo that's a quick overview of the key principles of File Systems.\n文件系统的几个重要概念  现在介绍完了.\n\nThey provide yet another way to move up a new level of abstraction.\n它提供了一层新抽象！\n\nFile systems allow us to hide the raw bits stored on magnetic tape, spinning disks and\n文件系统使我们不必关心 \\N 文件在磁带或磁盘的具体位置\n\nthe like, and they let us think of data as neatly organized and easily accessible files.\n整理和访问文件更加方便\n\nWe even started talking about users, not programmers, manipulating data,\n我们像普通用户一样直观操纵数据，比如打开和整理文件\n\nlike opening files and organizing them,\n我们像普通用户一样直观操纵数据，比如打开和整理文件\n\nforeshadowing where the series will be going in a few episodes.\n接下来几集也会从用户角度看问题\n\nI'll see  you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/21. 压缩-Compression.ass.txt",
    "content": "This episode is brought to you by Curiosity Stream.\n本集由 Curiosity Stream 赞助播出\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode we talked about Files, bundles of data, stored on a computer, that\n上集我们讨论了文件格式，如何编码文字，声音，图片\n\nare formatted and arranged to encode information, like text, sound or images.\n上集我们讨论了文件格式，如何编码文字，声音，图片\n\nWe even discussed some basic file formats, like text, wave, and bitmap.\n还举了具体例子 .txt .wav .bmp\n\nWhile these formats are perfectly fine and still used today,\n这些格式虽然管用，而且现在还在用 \\N 但它们的简单性意味着效率不高\n\ntheir simplicity also means they're not very efficient.\n这些格式虽然管用，而且现在还在用 \\N 但它们的简单性意味着效率不高\n\nIdeally, we want files to be as small as possible, so we can store lots of them without filling\n我们希望文件能小一点，这样能存大量文件，传输也会快一些\n\nup our hard drives, and also transmit them more quickly.\n我们希望文件能小一点，这样能存大量文件，传输也会快一些\n\nNothing is more frustrating than waiting for an email attachment to download. Ugh!\n等邮件附件下载烦死人了\n\nThe answer is compression, which literally squeezes data into a smaller size.\n解决方法是 压缩，把数据占用的空间压得更小\n\nTo do this, we have to encode data using fewer bits than the original representation.\n用更少的位(bit)来表示数据\n\nThat might sound like magic, but it's actually computer science!\n听起来像魔法，但其实是计算机科学！\n\nLets return to our old friend from last episode, Mr. Pac-man!\n我们继续用上集的 吃豆人例子，图像是 4像素x4像素\n\nThis image is 4 pixels by 4 pixels.\n我们继续用上集的 吃豆人例子，图像是 4像素x4像素\n\nAs we discussed, image data is typically stored as a list of pixel values.\n之前说过，图像一般存成一长串像素值\n\nTo know where rows end, image files have metadata, which defines properties like dimensions.\n为了知道一行在哪里结束 \\N 图像要有元数据，写明尺寸等属性\n\nBut, to keep it simple today, we're not going to worry about it.\n但为了简单起见，今天忽略这些细节\n\nIf you mix full intensity red, green and blue - that's 255 for all\n如果红绿蓝都是 255 会得到白色\n\nthree values - you get the color white.\n如果红绿蓝都是 255 会得到白色\n\nIf you mix full intensity red and green, but no blue (it's 0), you get yellow.\n如果混合 255红色和255绿色，会得到黄色\n\nWe have 16 pixels in our image, and each of those needs 3 bytes of color data.\n这个图像有16个像素(4x4),  每个像素3个字节\n\nThat means this image's data will consume 48 bytes of storage.\n总共占48个字节（16x3=48）\n\nBut, we can compress the data and pack it into a smaller number of bytes than 48!\n但我们可以压缩到少于 48 个字节\n\nOne way to compress data is to reduce repeated or redundant information.\n一种方法是 减少重复信息\n\nThe most straightforward way to do this is called Run-Length Encoding.\n最简单的方法叫 游程编码(Run-Length Encoding)\n\nThis takes advantage of the fact that there are often runs of identical values in files.\n适合经常出现相同值的文件\n\nFor example, in our pac-man image, there are 7 yellow pixels in a row.\n比如吃豆人 有7个连续黄色像素\n\nInstead of encoding redundant data: yellow pixel, yellow pixel, yellow pixel, and so\n与其全存下来：黄色，黄色，黄色...\n\non, we can just say \"there's 7 yellow pixels in a row\" by inserting\n可以插入一个额外字节，代表有7个连续黄色像素\n\nan extra byte that specifies the length of the run, like so:\n可以插入一个额外字节，代表有7个连续黄色像素\n\nAnd then we can eliminate the redundant data behind it.\n然后删掉后面的重复数据.\n\nTo ensure that computers don't get confused with which bytes are run lengths and which\n为了让计算机能分辨哪些字节是\"长度\" 哪些字节是\"颜色\" \\N 格式要一致\n\nbytes represent color, we have to be consistent in how we apply this scheme.\n为了让计算机能分辨哪些字节是\"长度\" 哪些字节是\"颜色\" \\N 格式要一致\n\nSo, we need to preface all pixels with their run-length.\n所以我们要给所有像素前面标上长度\n\nIn some cases, this actually adds data, but on the whole, we've dramatically reduced\n有时候数据反而会变多，但就这个例子而言\n\nthe number of bytes we need to encode this image.\n我们大大减少了字节数，之前是48 现在是24\n\nWe're now at 24 bytes, down from 48.\n我们大大减少了字节数，之前是48 现在是24\n\nThat's 50% smaller!\n小了50％！省了很多空间！\n\nA huge saving!\n小了50％！省了很多空间！\n\nAlso note that we haven't lost any data.\n还有，我们没有损失任何数据 \\N 我们可以轻易恢复到原来的数据\n\nWe can easily expand this back to the original form without any degradation.\n还有，我们没有损失任何数据 \\N 我们可以轻易恢复到原来的数据\n\nA compression technique that has this characteristic is called\n这叫\"无损压缩\"，没有丢失任何数据\n\nlossless compression, because we don't lose anything.\n这叫\"无损压缩\"，没有丢失任何数据\n\nThe decompressed data is identical to the original before compression, bit for bit.\n解压缩后，数据和压缩前完全一样\n\nLet's take a look at another type of lossless compression, where\n我们来看另一种无损压缩，它用更紧凑的方式表示数据块\n\nblocks of data are replaced by more compact representations.\n我们来看另一种无损压缩，它用更紧凑的方式表示数据块\n\nThis is sort of like \" don't forget to be awesome \" being replaced by DFTBA.\n有点像 \"别忘了变厉害\" 简写成 DFTBA\n\nTo do this, we need a dictionary that stores the mapping from codes to data.\n为此，我们需要一个字典，存储\"代码\"和\"数据\"间的对应关系\n\nLets see how this works for our example.\n我们看个例子\n\nWe can view our image as not just a string of individual pixels,\n我们可以把图像看成一块块，而不是一个个像素\n\nbut as little blocks of data.\n我们可以把图像看成一块块，而不是一个个像素\n\nFor simplicity, we're going to use pixel pairs, which are 6 bytes long,\n为了简单，我们把2个像素当成1块（占6个字节）\n\nbut blocks can be any size.\n但你也可以定成其他大小\n\nIn our example, there are only four pairings: White-yellow, black-yellow,\n我们只有四对： 白黄 黑黄 黄黄 白白\n\nyellow-yellow and white-white.\n我们只有四对： 白黄 黑黄 黄黄 白白\n\nThose are the data blocks in our dictionary we want to generate compact codes for.\n我们会为这四对  生成紧凑代码(compact codes)\n\nWhat's interesting, is that these blocks occur at different frequencies.\n有趣的是，这些块的出现频率不同\n\nOne method for generating efficient codes is building a Huffman Tree, invented by David\n1950年代 大卫·霍夫曼 发明了一种高效编码方式叫 \\N \"霍夫曼树\"（Huffman Tree） 当时他是麻省理工学院的学生\n\nHuffman while he was a student at MIT in the 1950s.\n1950年代 大卫·霍夫曼 发明了一种高效编码方式叫 \\N \"霍夫曼树\"（Huffman Tree） 当时他是麻省理工学院的学生\n\nHis algorithm goes like this.\n算法是这样的\n\nFirst, you layout all the possible blocks and their frequencies.\n首先，列出所有块和出现频率，每轮选两个最低的频率\n\nAt every round, you select the two with the lowest frequencies.\n首先，列出所有块和出现频率，每轮选两个最低的频率\n\nHere, that's Black-Yellow and White-White, each with a frequency of 1.\n这里 黑黄 和 白白 的频率最低，它们都是 1\n\nYou combine these into a little tree. which have a combined frequency of 2,\n可以把它们组成一个树，总频率 2\n\nso we record that.\n可以把它们组成一个树，总频率 2\n\nAnd now one step of the algorithm done.\n现在完成了一轮算法\n\nNow we repeat the process.\n现在我们重复这样做\n\nThis time we have three things to choose from.\n这次有3个可选\n\nJust like before, we select the two with the lowest frequency, put them into a little tree,\n就像上次一样，选频率最低的两个，放在一起，并记录总频率\n\nand record the new total frequency of all the sub items.\n就像上次一样，选频率最低的两个，放在一起，并记录总频率\n\nOk, we're almost done.\n好，我们快完成了\n\nThis time it's easy to select the two items with the lowest frequency\n这次很简单，因为只有2个选择\n\nbecause there are only two things left to pick.\n这次很简单，因为只有2个选择\n\nWe combine these into a tree, and now we're done!\n把它们组合成一棵树就完成了！\n\nOur tree looks like this, and it has a very cool property: it's arranged by frequency,\n现在看起来像这样，它有一个很酷的属性：按频率排列\n\nwith less common items lower down.\n频率低的在下面\n\nSo, now we have a tree, but you may be wondering how this gets us to a dictionary.\n现在有了一棵树，你可能在想  \"怎么把树变成字典？\"\n\nWell, we use our frequency-sorted tree to generate the codes we need\n我们可以把每个分支用 0 和 1 标注，就像这样\n\nby labeling each branch with a 0 or a 1, like so.\n我们可以把每个分支用 0 和 1 标注，就像这样\n\nWith this, we can write out our code dictionary.\n现在可以生成字典\n\nYellow-yellow is encoded as just a single 0.  White-yellow is encoded as 10\n黄黄 编码成 0  \\N 白黄 编码成 10 \\N 黑黄 编码成 110 \\N 白白 编码成 111\n\nBlack-Yellow is 1 1 0. and finally white-white is 1 1 1.\n黄黄 编码成 0  \\N 白黄 编码成 10 \\N 黑黄 编码成 110 \\N 白白 编码成 111\n\nThe really cool thing about these codewords is that there's no way to\n酷的地方是  它们绝对不会冲突\n\nhave conflicting codes, because each path down the tree is unique.\n因为树的每条路径是唯一的\n\nThis means our codes are prefix-free, that is no code starts with another complete code.\n意味着代码是\"无前缀\"的，没有代码是以另一个代码开头的\n\nNow, let's return to our image data and compress it!\n现在我们来压缩！\n\n-- NOT BYTES -- BITS!! That's less than 2 bytes of data!\n注意是位(bit)！ 不是字节(byte)！ \\N 14位(bit) 还不到2个字节(byte)！\n\nBut, don't break out the champagne quite yet!\n但，先别急着开香槟！\n\nThis data is meaningless unless we also save our code dictionary.\n字典也要保存下来，否则 14 bit 毫无意义\n\nSo, we'll need to append it to the front of the image data, like this.\n所以我们把字典 加到 14 bit 前面，就像这样\n\nNow, including the dictionary, our image data is 30 bytes long.\n现在加上字典，图像是 30 个字节(bytes)  \\N 比 48 字节好很多\n\nThat's still a significant improvement over 48 bytes.\n现在加上字典，图像是 30 个字节(bytes)  \\N 比 48 字节好很多\n\nThe two approaches we discussed,\n\"消除冗余\"和\"用更紧凑的表示方法\"，这两种方法通常会组合使用\n\nremoving redundancies and using more compact representations, are often combined,\n\"消除冗余\"和\"用更紧凑的表示方法\"，这两种方法通常会组合使用\n\nand underlie almost all lossless compressed file formats,\n几乎所有无损压缩格式都用了它们 \\N 比如 GIF, PNG, PDF, ZIP\n\nlike GIF, PNG, PDF and ZIP files.\n几乎所有无损压缩格式都用了它们 \\N 比如 GIF, PNG, PDF, ZIP\n\nBoth run-length encoding and dictionary coders are lossless compression techniques.\n游程编码 和 字典编码 都是无损压缩\n\nNo information is lost; when you decompress, you get the original file.\n压缩时不会丢失信息，解压后，数据和之前完全一样\n\nThat's really important for many types of files.\n无损对很多文件很重要\n\nLike, it'd be very odd if I zipped up a word document to send to you,\n比如我给你发了个压缩的 word 文档\\N 你解压之后发现内容变了，这就很糟糕了\n\nand when you decompressed it on your computer, the text was different.\n比如我给你发了个压缩的 word 文档\\N 你解压之后发现内容变了，这就很糟糕了\n\nBut, there are other types of files where we can get away with little changes, perhaps\n但其他一些文件，丢掉一些数据没什么关系\n\nby removing unnecessary or less important information, especially information\n丢掉那些人类看不出区别的数据\n\nthat human perception is not good at detecting.\n丢掉那些人类看不出区别的数据\n\nAnd this trick underlies most lossy compression techniques.\n大多数有损压缩技术，都用到了这点\n\nThese tend to be pretty complicated, so we're going to attack this at a conceptual level.\n实际细节比较复杂，所以我们讲概念就好\n\nLet's take sound as an example.\n以声音为例，你的听力不是完美的\n\nYour hearing is not perfect.\n以声音为例，你的听力不是完美的\n\nWe can hear some frequencies of sound better than others.\n有些频率我们很擅长，其他一些我们根本听不见，比如超声波\n\nAnd there are some we can't hear at all, like ultrasound.\n有些频率我们很擅长，其他一些我们根本听不见，比如超声波\n\nUnless you're a bat.\n除非你是蝙蝠\n\nBasically, if we make a recording of music, and there's data in the ultrasonic frequency range,\n举个例子，如果录音乐，超声波数据都可以扔掉 \\N 因为人类听不到超声波\n\nwe can discard it, because we know that humans can't hear it.\n举个例子，如果录音乐，超声波数据都可以扔掉 \\N 因为人类听不到超声波\n\nOn the other hand, humans are very sensitive to frequencies in the vocal range, like people\n另一方面，人类对人声很敏感，所以应该尽可能保持原样\n\nsinging, so it's best to preserve quality there as much as possible.\n另一方面，人类对人声很敏感，所以应该尽可能保持原样\n\nDeep bass is somewhere in between.\n低音介于两者之间，人类听得到，但不怎么敏感\n\nHumans can hear it, but we're less attuned to it.\n低音介于两者之间，人类听得到，但不怎么敏感\n\nWe mostly sense it.\n一般是感觉到震动\n\nLossy audio compressors takes advantage of this, and encode different\n有损音频压缩利用这一点，用不同精度编码不同频段\n\nfrequency bands at different precisions.\n有损音频压缩利用这一点，用不同精度编码不同频段\n\nEven if the result is rougher, it's likely that users won't perceive the difference.\n听不出什么区别，不会明显影响体验\n\nOr at least it doesn't dramatically affect the experience.\n听不出什么区别，不会明显影响体验\n\nAnd here comes the hate mail from the audiophiles!\n音乐发烧友估计要吐槽了！\n\nYou encounter this type of audio compression all the time.\n日常生活中你会经常碰到这类音频压缩\n\nIt's one of the reasons you sound different on a cellphone versus in person.\n所以你在电话里的声音 和现实中不一样\n\nThe audio data is being compressed, allowing more people to take calls at once.\n压缩音频是为了让更多人能同时打电话\n\nAs the signal quality or bandwidth get worse, compression algorithms remove more data,\n如果网速变慢了，压缩算法会删更多数据\n\nfurther reducing precision, which is why Skype calls sometimes sound like robots talking.\n进一步降低声音质量，所以 Skype 通话有时听起来像机器人\n\nCompared to an uncompressed audio format, like a WAV or FLAC (there we go, got the audiophiles back)\n和没压缩的音频格式相比，比如 WAV 或 FLAC \\N ( 这下音乐发烧友满意了）\n\ncompressed audio files, like MP3s, are often 10 times smaller.\n压缩音频文件如 MP3，能小10倍甚至更多.\n\nThat's a huge saving!\n省了超多空间！\n\nAnd it's why I've got a killer music collection on my retro iPod.\n所以我的旧 iPod 上有一堆超棒的歌\n\nDon't judge.\n别批判我\n\nThis idea of discarding or reducing precision in a manner that aligns with human perception\n这种删掉人类无法感知的数据的方法，叫\"感知编码\"\n\nis called perceptual coding,\n这种删掉人类无法感知的数据的方法，叫\"感知编码\"\n\nand it relies on models of human perception,\n它依赖于人类的感知模型，模型来自\"心理物理学\"领域\n\nwhich come from a field of study called Psychophysics.\n它依赖于人类的感知模型，模型来自\"心理物理学\"领域\n\nThis same idea is the basis of lossy compressed image formats, most famously JPEGs.\n这是各种\"有损压缩图像格式\"的基础，最著名的是 JPEG\n\nLike hearing, the human visual system is imperfect.\n就像听力一样，人的视觉系统也不是完美的.\n\nWe're really good at detecting sharp contrasts, like the edges of objects,\n我们善于看到尖锐对比，比如物体的边缘\n\nbut our perceptual system isn't so hot with subtle color variations.\n但我们看不出颜色的细微变化\n\nJPEG takes advantage of this by breaking images up into blocks of 8x8 pixels,\nJPEG 利用了这一点，把图像分解成 8x8 像素块\n\nthen throwing away a lot of the high-frequency spatial data.\n然后删掉大量高频率空间数据\n\nFor example, take this photo of our directors dog - Noodle.\n举个例子，这是导演的狗，面面\n\nSo cute!\n超可爱！\n\nLet's look at a patch of 8x8 pixels.\n我们来看其中一个 8x8 像素\n\nPretty much every pixel is different from its neighbor,\n几乎每个像素都和相邻像素不同，用无损技术很难压缩 \\N 因为太多不同点了\n\nmaking it hard to compress with loss-less techniques because there's just a lot going on.\n几乎每个像素都和相邻像素不同，用无损技术很难压缩 \\N 因为太多不同点了\n\nLots of little details.\n很多小细节\n\nBut human perception doesn't register all those details.\n但人眼看不出这些细节\n\nSo, we can discard a lot of that detail, and replace it with a simplified patch like this.\n因此可以删掉很多，用这样一个简单的块来代替\n\nThis maintains the visual essence, but might only use 10% of the data.\n这看起来一样，但可能只占10％的原始数据\n\nWe can do this for all the patches in the image and get this result.\n我们可以对所有 8x8 块做一样的操作\n\nYou can still see it's a dog, but the image is rougher.\n图片依然可以认出是一只狗，只是更粗糙一些\n\nSo, that's an extreme example, going from a slightly compressed JPEG to a highly compressed one,\n以上例子比较极端，进行了高度压缩，只有原始大小的八分之一\n\none-eighth the original file size.\n以上例子比较极端，进行了高度压缩，只有原始大小的八分之一\n\nOften, you can get away with a quality somewhere in between, and perceptually,\n通常你可以取得平衡，图片看起来差不多，但文件小不少\n\nit's basically the same as the original.\n通常你可以取得平衡，图片看起来差不多，但文件小不少\n\nCan you tell the difference between the two?\n你看得出两张图的区别吗？\n\nProbably not, but I should mention that video compression plays a role in that too,\n估计看不出，但我想提一下，视频压缩也造成了影响\n\nsince I'm literally being compressed in a video right now.\n毕竟你现在在看视频啊\n\nVideos are really just long sequences of images, so a lot of what I said\n视频只是一长串连续图片 \\N 所以图片的很多方面也适用于视频\n\nabout them applies here too.\n视频只是一长串连续图片 \\N 所以图片的很多方面也适用于视频\n\nBut videos can do some extra clever stuff, because between frames,\n但视频可以做一些小技巧 \\N 因为帧和帧之间很多像素一样\n\na lot of pixels are going to be the same.\n但视频可以做一些小技巧 \\N 因为帧和帧之间很多像素一样\n\nLike this whole background behind me!\n比如我后面的背景！\n\nThis is called temporal redundancy.\n这叫 时间冗余\n\nWe don't need to re-transmit those pixels every frame of the video.\n视频里不用每一帧都存这些像素 \\N 可以只存变了的部分\n\nWe can just copy patches of data forward.\n视频里不用每一帧都存这些像素 \\N 可以只存变了的部分\n\nWhen there are small pixel differences, like the readout on this frequency generator behind me,\n当帧和帧之间有小小的差异时，比如后面这个频率发生器\n\nmost video formats send data that encodes just the difference between patches,\n很多视频编码格式，只存变化的部分\n\nwhich is more efficient than re-transmitting all the pixels afresh, again taking advantage\n这比存所有像素更有效率 \\N 利用了帧和帧之间的相似性\n\nof inter-frame similarity.\n这比存所有像素更有效率 \\N 利用了帧和帧之间的相似性\n\nThe fanciest video compression formats go one step further.\n更高级的视频压缩格式 会更进一步\n\nThey find patches that are similar between frames, and not only copy them forward, with\n找出帧和帧之间相似的补丁 \\N 然后用简单效果实现，比如移动和旋转\n\nor without differences, but also can apply simple effects to them, like a shift or rotation.\n找出帧和帧之间相似的补丁 \\N 然后用简单效果实现，比如移动和旋转\n\nThey can also lighten or darken a patch between frames.\n变亮和变暗\n\nSo, if I move my hand side to side like this the video compressor will identify the similarity,\n如果我这样摆手，视频压缩器会识别到相似性\n\ncapture my hand in one or more patches, then just move these patches around between frames.\n用一个或多个补丁代表我的手，然后帧之间直接移动这些补丁\n\nYou're actually seeing my hand from the past kinda freaky, but it uses a lot less data.\n所以你看到的是我过去的手（不是实时的）\\N 有点可怕 但数据量少得多\n\nMPEG-4 videos, a common standard, are often 20 to 200 times\nMPEG-4 是常见标准，可以比原文件小20倍到200倍\n\nsmaller than the original, uncompressed file.\nMPEG-4 是常见标准，可以比原文件小20倍到200倍\n\nHowever, encoding frames as translations and rotations of patches from previous frames\n但用补丁的移动和旋转 来更新画面\n\ncan go horribly wrong when you compress too heavily, and there isn't\n当压缩太严重时会出错 \\N 没有足够空间更新补丁内的像素\n\nenough space to update pixel data inside of the patches.\n当压缩太严重时会出错 \\N 没有足够空间更新补丁内的像素\n\nThe video player will forge ahead, applying the right motions,\n即使补丁是错的，视频播放器也会照样播放\n\neven if the patch data is wrong.\n即使补丁是错的，视频播放器也会照样播放\n\nAnd this leads to some hilarious and trippy effects, which I'm sure you've seen.\n导致一些怪异又搞笑的结果，你肯定见过这些.\n\nOverall, it's extremely useful to have compression techniques for all the types of data I discussed today.\n总的来说，压缩对大部分文件类型都有用\n\n(I guess our imperfect vision and hearing are \"useful,\" too.)\n从这个角度来讲，人类不完美的视觉和听觉 也算有用\n\nAnd it's important to know about compression because it allows users to\n学习压缩非常重要 \\N 因为可以高效存储图片，音乐，视频\n\nstore pictures, music, and videos in efficient ways.\n学习压缩非常重要 \\N 因为可以高效存储图片，音乐，视频\n\nWithout it, streaming your favorite Carpool Karaoke videos on YouTube would be nearly impossible,\n如果没有压缩 \\N 在 YouTube 看\"明星拼车唱歌\"几乎不可能\n\ndue to bandwidth and the economics of transmitting that volume of data for free.\n因为你的带宽可能不够（会很卡） \\N 而且供应商不愿意免费传输那么多数据\n\nAnd now when your Skype calls sound like they're being taken over by demons,\n现在你知道为什么打 Skype 电话 \\N 有时像在和恶魔通话\n\nyou'll know what's really going on.\n现在你知道为什么打 Skype 电话 \\N 有时像在和恶魔通话\n\nI'll see you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/22. 命令行界面-Keyboards & Command Line Interfaces.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nWe've talked a lot about inputs and outputs in this series,\n我们之前讨论过 输入输出 \\N 但都是计算机组件互相输入输出\n\nbut they've mostly been between different parts of a computer\n我们之前讨论过 输入输出 \\N 但都是计算机组件互相输入输出\n\nlike outputting data from RAM or inputting instructions to a CPU.\n比如 RAM 输出数据，或输指令进 CPU\n\nWe haven't discussed much about inputs coming from humans.\n我们还没讲 来自人类的输入\n\nWe also haven't learned how people get information out of a computer,\n也没讲怎么从电脑中拿出信息，除了用打孔纸卡\n\nother than by printing or punching it onto paper.\n也没讲怎么从电脑中拿出信息，除了用打孔纸卡\n\nOf course, there's a wide variety of input and output devices that\n当然，有很多种 \"输入输出设备\"  \\N 让我们和计算机交互\n\nallow us users to communicate with computers.\n当然，有很多种 \"输入输出设备\"  \\N 让我们和计算机交互\n\nThey provide an interface between human and computer.\n它们在人类和机器间提供了界面\n\nAnd today, there's a whole field of study called Human-Computer Interaction.\n如今有整个学科专门研究这个，叫 \"人机交互\"\n\nThese interfaces are so fundamental to the user experience\n界面对用户体验非常重要 \\N 所以是我们接下来几集的重点\n\nthat they're the focus of the next few episodes.\n界面对用户体验非常重要 \\N 所以是我们接下来几集的重点\n\nAs we discussed at the very beginning of the series,\n在系列开头的几集，我们提过\n\nthe earliest mechanical and electro-mechanical computing devices\n早期机械计算设备 \\N 用齿轮，旋钮和开关等机械结构来输入输出\n\nused physical controls for inputs and outputs, like gears, knobs and switches,\n早期机械计算设备 \\N 用齿轮，旋钮和开关等机械结构来输入输出\n\nand this was pretty much the extent of the human interface.\n这些就是交互界面\n\nEven the first electronic computers, like Colossus and ENIAC,\n甚至早期电子计算机  比如 Colossus 和 ENIAC\n\nwere configured using huge panels of mechanical controls and patch wires.\n也是用一大堆机械面板和线 来操作\n\nIt could take weeks to enter in a single program, let alone run it,\n输入一个程序可能要几星期，还没提运行时间.\n\nand to get data out after running a program, results were most often printed to paper.\n运行完毕后想拿出数据，一般是打印到纸上\n\nPaper printers were so useful\n打印机超有用\n\nthat even Babbage designed one for his Difference Engine,\n甚至 查尔斯·巴贝奇 都给差分机专门设计了一个\n\nand that was in the 1820s!\n那可是 1820 年代!\n\nHowever, by the 1950s, mechanical inputs were rendered obsolete\n然而，到 1950 年代，机械输入完全消失\n\nby programs and data stored entirely on mediums like punch cards and magnetic tape.\n因为出现了打孔纸卡和磁带\n\nPaper printouts were still used for the final output,\n但输出仍然是打印到纸上\n\nand huge banks of indicator lights were developed\n还有大量指示灯，在运行中提供实时反馈\n\nto provide real time feedback while the program was in progress.\n还有大量指示灯，在运行中提供实时反馈\n\nIt's important to recognize that computer input of this era was\n那个时代的特点是 尽可能迁就机器 \\N 对人类好不好用是其次\n\ndesigned to be as simple and robust as possible for computers.\n那个时代的特点是 尽可能迁就机器 \\N 对人类好不好用是其次\n\nEase and understanding for users was a secondary concern.\n那个时代的特点是 尽可能迁就机器 \\N 对人类好不好用是其次\n\nPunch tape is a great example\n打孔纸带就是个好例子\n\nthis was explicitly designed to be easy for computers to read.\n就是为了方便计算机读取\n\nThe continuous nature of tape made it easy to handle mechanically,\n纸带是连续的，方便机器处理\n\nand the holes could be reliably detected with a mechanical or optical system,\n纸孔可以方便地 用机械或光学手段识别\n\nwhich encoded instructions and data.\n纸孔可以编码程序和数据\n\nBut of course, humans don't think in terms of little punched holes on strips of paper.\n当然, 人类不是以纸孔方式思考的.\n\nSo, the burden was on programmers.\n所以负担放到了程序员身上\n\nThey had to spend the extra time and effort to convert their ideas and programs\n他们要花额外时间和精力 \\N 转成计算机能理解的格式\n\ninto a language and a format that was easy for computers of the era to understand\n他们要花额外时间和精力 \\N 转成计算机能理解的格式\n\noften with the help of additional staff and auxiliary devices.\n一般需要额外人员和设备帮忙\n\nIt's also important to note that early computers, basically pre-1950,\n要注意的是，基本上 1950 年前的早期计算机 \\N \"输入\"的概念很原始\n\nhad an extremely simple notion of human input.\n要注意的是，基本上 1950 年前的早期计算机 \\N \"输入\"的概念很原始\n\nYes, humans input programs and data into computers,\n是的，的确是人类负责输入程序和数据 \\N 但计算机不会交互式回应\n\nbut these machines generally didn't respond interactively to humans.\n是的，的确是人类负责输入程序和数据 \\N 但计算机不会交互式回应\n\nOnce a program was started, it typically ran until it was finished.\n程序开始运行后会一直运行  直到结束\n\nThat's because these machines were way too expensive to be\n因为机器太贵了 \\N 不能等人类慢慢敲命令和给数据\n\nwaiting around for humans to type a command or enter data.\n因为机器太贵了 \\N 不能等人类慢慢敲命令和给数据\n\nAny input needed for a computation was fed in at the same time as the program.\n要同时放入程序和数据\n\nThis started to change in the late 1950s.\n这在 1950 年代晚期开始发生变化\n\nOn one hand, smaller-scale computers started to become cheap enough\n一方面，小型计算机变得足够便宜\n\nthat it was feasible to have a human-in-the loop;\n让人类来回和计算机交互  变得可以接受\n\nthat is, a back and forth between human and computer.\n交互式就是人和计算机之间来回沟通\n\nAnd on the other hand,\n而另一方面\n\nbig fancy computers became fast and sophisticated enough to support many programs and users at once,\n大型计算机变得更快，能同时支持多个程序和多个用户\n\nwhat were called multitasking and time-sharing systems .\n这叫\"多任务\"和\"分时系统\"\n\nBut these computers needed a way to get input from users.\n但交互式操作时 \\N 计算机需要某种方法来获得用户输入\n\nFor this, computers borrowed the ubiquitous data entry mechanism of the era: keyboards.\n所以借用了当时已经存在的数据录入机制：键盘\n\nAt this point, typing machines had already been in use for a few centuries,\n当时，打字机已经存在几个世纪了\n\nbut it was Christopher Latham Sholes, who invented the modern typewriter in 1868.\n但现代打字机是 \\N克里斯托弗·莱瑟姆·肖尔斯 在 1868 年发明的\n\nIt took until 1874 to refine the design and manufacture it,\n虽然到 1874 年才完成设计和制造\n\nbut it went on to be a commercial success.\n但之后取得了商业成功\n\nSholes' typewriter adopted an unusual keyboard layout that you know well QWERTY\n肖尔斯 的打字机用了不寻常的布局，QWERTY\n\nnamed for the top-left row of letter keys.\n名字来自键盘左上角按键\n\nThere has been a lot of speculation as to why this design was used.\n为什么这么设计 有很多猜测\n\nThe most prevalent theory is that it put common letter pairings in English far apart\n最流行的理论是  这样设计是为了 \\N 把常见字母放得远一些，避免按键卡住\n\nto reduce the likelihood of typebars jamming when entered in sequence.\n最流行的理论是  这样设计是为了 \\N 把常见字母放得远一些，避免按键卡住\n\nIt's a convenient explanation, but it's also probably false,\n这个解释虽然省事，但可能是错的，或至少不够全面\n\nor at least not the full story.\n这个解释虽然省事，但可能是错的，或至少不够全面\n\nIn fact, QWERTY puts many common letter pairs together,\n事实上，QWERTY 把很多常见字母放在了一起 \\N 比如 TH 和 ER\n\nlike \"TH\" and \"ER\".\n事实上，QWERTY 把很多常见字母放在了一起 \\N 比如 TH 和 ER\n\nAnd we know that Sholes and his team went through many iterations\n我们知道 肖尔斯和他的团队设计了很多版 \\N 才进化到这个布局\n\nbefore arriving at this iconic arrangement.\n我们知道 肖尔斯和他的团队设计了很多版 \\N 才进化到这个布局\n\nRegardless of the reason, the commercial success of Sholes' typewriter meant\n总之，肖尔斯 的打字机取得了成功 \\N 所以其它公司很快开始抄他的设计\n\nthe competitor companies that soon followed duplicated his design.\n总之，肖尔斯 的打字机取得了成功 \\N 所以其它公司很快开始抄他的设计\n\nMany alternative keyboard layouts have been proposed over the last century,\n过去一个世纪有不少新的键盘布局被发明，宣称各种好处\n\nclaiming various benefits.\n过去一个世纪有不少新的键盘布局被发明，宣称各种好处\n\nBut, once people had invested the time to learn QWERTY,\n但人们已经熟悉了 QWERTY 布局 \\N 根本不想学新布局\n\nthey just didn't want to learn something new.\n但人们已经熟悉了 QWERTY 布局 \\N 根本不想学新布局\n\nThis is what economists would call a switching barrier or switching cost.\n这是经济学家所说的 转换成本\n\nAnd it's for this very basic human reason\n所以现在都快1个半世纪了 \\N 我们还在用 QWERTY 键盘布局\n\nthat we still use QWERTY keyboards almost a century and a half later!\n所以现在都快1个半世纪了 \\N 我们还在用 QWERTY 键盘布局\n\nI should mention that QWERTY isn't universal.\n我应该提一下，QWERTY 不是通用的\n\nThere are many international variants,\n有很多变体，比如法国 AZERTY 布局\n\nlike the French AZERTY layout,\n有很多变体，比如法国 AZERTY 布局\n\nor the QWERTZ layout common in central Europe.\n以及中欧常见的 QWERTZ 布局\n\nInterestingly, Sholes didn't envision that typing would ever be faster than handwriting,\n有趣的是，肖尔斯 根本没想到打字会比手写快\n\nwhich is around 20 words per minute.\n手写速度大约是每分钟 20 个\n\nTypewriters were introduced chiefly for legibility and standardization of documents, not speed.\n打字机主要为了易读性和标准化，而不是速度\n\nHowever, as they became standard equipment in offices, the desire for speedy typing grew,\n然而随着打字机成为办公室标配 \\N 对快速打字的渴望越来越大\n\nand there were two big advances that unlocked typing's true potential.\n有两个重大进步  解放了打字的潜力\n\nAround 1880, Elizabeth Longley, a teacher at the Cincinnati Shorthand and Type-Writer Institute,\n1880年左右，辛辛那提速记学院 \\N 一名叫 伊丽莎白·朗利 的老师\n\nstarted to promote ten-finger typing.\n开始推广 十指打字\n\nThis required much less finger movement than hunt-and-peck,\n比一个手指打字要移动的距离短得多，所以速度更快\n\nso it offered enhanced typing speeds.\n比一个手指打字要移动的距离短得多，所以速度更快\n\nThen, a few years later, Frank Edward McGurrin, a federal court clerk in Salt Lake City,\n几年后，弗兰克·爱德华·麦克格林 \\N 盐湖城的一位联邦法庭书记\n\ntaught himself to touch-type; as in, he didn't need to look at the keys while typing.\n学会了盲打，打字时不用看键盘\n\nIn 1888, McGurrin won a highly publicized typing-speed contest,\n1888年，麦格高林 赢了备受关注的打字速度比赛\n\nafter which ten-finger, touch-typing began to catch on.\n之后\"十指盲打\"开始流行\n\nProfessional typists were soon able to achieve speeds upwards of 100 words per minute,\n专业打字员  每分钟 100 字以上\n\nmuch faster than handwriting!\n比手写快多了！而且清晰又整洁！\n\nAnd nice and neat too!\n比手写快多了！而且清晰又整洁！\n\nSo, humans are pretty good with typewriters,\n虽然人类擅长用打字机\n\nbut we can't just plunk down a typewriter in front of a computer and have it type\n但我们没法把打字机塞到计算机面前，让它打字\n\nthey have no fingers!\n计算机又没有手指\n\nInstead, early computers adapted a special type of typewriter that was used for telegraphs,\n所以早期计算机用了一种特殊打字机，是专门用来发电报的,\n\ncalled a teletype machine.\n叫 电传打字机\n\nThese were electromechanically-augmented typewriters\n这些打字机是强化过的，可以用电报线发送和接收文本\n\nthat can send and receive text over telegraph lines.\n这些打字机是强化过的，可以用电报线发送和接收文本\n\nPressing a letter on one teletype keyboard would cause a signal to be sent,\n按一个字母，信号会通过电报线，发到另一端\n\nover telegraph wires, to a teletype machine on the other end,\n按一个字母，信号会通过电报线，发到另一端\n\nwhich would then electromechanically type that letter.\n另一端的电传打字机会打出来\n\nThis allowed two humans to type to one another over long distances.\n使得两人可以长距离沟通\n\nbasically a steampunk version of a chat room.\n基本是个蒸汽朋克版聊天室\n\nSince these teletype machines already had an electronic interface,\n因为电传打字机有电子接口，稍作修改就能用于计算机\n\nthey were easily adapted for computer use,\n因为电传打字机有电子接口，稍作修改就能用于计算机\n\nand teletype computer interfaces were common in the 1960s and 70s.\n电传交互界面在 1960~1970 很常见\n\nInteraction was pretty straightforward.\n用起来很简单\n\nUsers would type a command, hit enter, and then the computer would type back.\n输入一个命令，按回车，然后计算机会输回来\n\nThis text \"conversation\" between a user and a computer went back and forth.\n用户和计算机来回\"对话\"\n\nThese were called command line interfaces,\n这叫\"命令行界面\"\n\nand they remained the most prevalent form of human-computer interaction\n它是最主要的人机交互方式，一直到 1980 年代\n\nup until around the 1980s.\n它是最主要的人机交互方式，一直到 1980 年代\n\nCommand Line interaction on a teletype machine looks something like this.\n用电传打字机的命令行交互  类似这样：\n\nA user can type any number of possible commands.\n用户可以输入各种命令\n\nLet's check out a few,\n我们来看几个命令，先看当前目录有什么文件\n\nbeginning with seeing all of the files in the current directory we're in.\n我们来看几个命令，先看当前目录有什么文件\n\nFor this, we would type the command, \"ls\", which is short for list,\n输入命令 ls，名字来自 list 的缩写\n\nand the computer replies with a list of the files in our current directory.\n然后计算机会列出 当前目录里的所有文件\n\nIf we want to see what's in our \"secretStarTrekDiscoveryCast.txt.txt file\",\n如果想看 secretStarTrekDiscoveryCast.txt 有什么\n\nwe use yet another command to display the contents.\n要用另一个命令 显示文件内容\n\nIn unix, we can call \"cat\" - short for concatenate.\nunix 用 cat 命令显示文件内容 \\N cat 是连接(concatenate)的缩写\n\nWe need to specify which file to display, so we include that after the command, called an argument.\n然后指定文件名，指定的方法是写在 cat 命令后面 \\N 传给命令的值叫 参数\n\nIf you're connected to a network with other users,\n如果同一个网络里有其他人\n\nyou can use a primitive version of a Find My Friends app\n你可以用 finger 命令找朋友 \\N 就像是个很原始的\"找朋友\" App\n\nto get more info on them with the command \"finger\".\n你可以用 finger 命令找朋友 \\N 就像是个很原始的\"找朋友\" App\n\nElectromechanical teletype machines\n电传打字机 直到1970年代左右都是主流交互方式\n\nwere the primary computing interface for most users up until around the 1970s.\n电传打字机 直到1970年代左右都是主流交互方式\n\nAlthough computer screens first emerged in the 1950s,\n尽管屏幕最早出现在 1950 年代 \\N 但对日常使用太贵 而且分辨率低\n\nand were used for graphics they were too expensive and low resolution for everyday use.\n尽管屏幕最早出现在 1950 年代 \\N 但对日常使用太贵 而且分辨率低\n\nHowever, mass production of televisions for the consumer market, and general improvements\n然而因为针对普通消费者的电视机开始量产 \\N 同时处理器与内存也在发展\n\nin processors and memory, meant that by 1970, it was economically viable\n到1970年代，屏幕代替电传打字机 变得可行\n\nto replace electromechanical teletype machines with screen-based equivalents.\n到1970年代，屏幕代替电传打字机 变得可行\n\nBut rather than build a whole new standard to interface computers with these screens,\n但与其为屏幕  专门做全新的标准\n\nengineers simply recycled the existing text-only, teletype protocol.\n工程师直接用现有的 电传打字机协议\n\nThese machines used a screen, which simulated endless paper.\n屏幕就像无限长度的纸 \\N 除了输入和输出字，没有其它东西\n\nIt was text in and text out, nothing more.\n屏幕就像无限长度的纸 \\N 除了输入和输出字，没有其它东西\n\nThe protocol was identical, so computers couldn't even tell if it was paper or a screen.\n协议是一样的，所以计算机分不出是纸还是屏幕\n\nThese virtual teletype or glass teletype machines became known as terminals .\n这些\"虚拟电传打字机\"或\"玻璃电传打字机\"\\N 叫 终端\n\nBy 1971, it was estimated, in the United States,\n到1971年，美国大约有 7 万台电传打字机 \\N 以及 7 万个终端\n\nthere was something on the order of 70,000 electro-mechanical teletype machines\n到1971年，美国大约有 7 万台电传打字机 \\N 以及 7 万个终端\n\nand 70,000 screen-based terminals in use.\n到1971年，美国大约有 7 万台电传打字机 \\N 以及 7 万个终端\n\nScreens were so much better, faster and more flexible, though.\n屏幕又好又快又灵活\n\nLike, you could delete a mistake and it would disappear.\n如果删一个错别字 会立刻消失\n\nSo, by the end of the 1970s, screens were standard.\n所以到 1970 年代末  屏幕成了标配\n\nYou might think that command line interfaces are way too primitive to do anything interesting.\n你也许会想，命令行界面太原始了 \\N 做不了什么有意思的事\n\nBut even when the only interaction was through text, programmers found a way to make it fun.\n即便只有文字 \\N 程序员也找到了一些方法，让它变得有趣一些\n\nEarly interactive, text-based computer games include famous titles like Zork,\n早期的著名交互式文字游戏  Zork\n\ncreated in 1977.\n出现于 1977 年\n\nPlayers of these sorts of early games were expected to engage their limitless imaginations\n早期游戏玩家需要丰富的想象力\n\nas they visualized the fictional world around them, like what terrifying monster confronted them\n想像自己身在虚构世界，比如\"四周漆黑一片\n\nwhen it was pitch black and you were likely to be eaten by a grue.\n附近可能有怪物会吃掉你\"\n\nLet's go back to our command line, now on a fancy screen-based terminal, and play!\n我们用命令行玩玩看\n\nJust like before, we can see what's in our current directory with the \"ls\" command.\n就像之前，我们可以用 ls 命令，看当前目录有什么\n\nThen, let's go into our games directory by using the \"cd\" command,  for \" change directory \".\n然后用 cd 命令，进入游戏文件夹 \\N cd 的意思是 \"改变文件夹\"\n\nNow, we can use our \"ls\" command again to see what games are installed on our computer.\n再用 ls 看有哪些游戏\n\nSweet, we have Adventure!\n超棒！我们有\"冒险旅程\"！(adventure)\n\nAll we have to do to run this program is type its name.\n想运行这个程序，只需要输入它的名字\n\nUntil this application halts, or we quit it, it takes over the command line.\n在程序自行停止或我们主动退出前 \\N 它会接管命令行\n\nWhat you're seeing here is actual interaction from \"Colossal Cave Adventure\",\n你现在看到的，是\"巨大洞穴冒险\"这款游戏的真实输出\n\nfirst developed by Will Crowther in 1976.\n由 Will Crowther 在 1976 年开发\n\nIn the game, players can type in one- or two-word commands to move around,\n游戏中，玩家可以输入1个词或2个词的命令 \\N 来移动人物，和其他东西交互，捡物品等\n\ninteract with objects, pickup items and so on.\n游戏中，玩家可以输入1个词或2个词的命令 \\N 来移动人物，和其他东西交互，捡物品等\n\nThe program acts as the narrator, describing locations, possible actions,\n然后游戏会像旁白一样，输出你的当前位置， \\N 告诉你能做什么动作，以及你的动作造成的结果\n\nand the results of those actions.\n然后游戏会像旁白一样，输出你的当前位置， \\N 告诉你能做什么动作，以及你的动作造成的结果\n\nCertain ones resulted in death!\n有些动作会导致死亡！\n\nThe original version only had 66 locations to explore,\n原始版本只有 66 个地方可供探索\n\nbut it's widely considered to be the first example of interactive fiction.\n但它被广泛认为是最早的互动式小说\n\nThese text adventure games later became multiplayer, called MUDs or Multi-User Dungeons.\n游戏后来从纯文字进化成多人游戏 \\N 简称 MUD，或多人地牢游戏\n\nAnd they're the great-forbearers of the awesome graphical MMORPG's\n是如今 MMORPG 的前辈 \\N （大型多人在线角色扮演游戏）\n\n(massive, multiplayer online role playing games) we enjoy today.\n是如今 MMORPG 的前辈 \\N （大型多人在线角色扮演游戏）\n\nAnd if you want to know more about the history of these and other games\n如果你想了解游戏史，我们有游戏速成课  \\N 主持人 Andre Meadows\n\nwe've got a whole series on it hosted by Andre Meadows!\n如果你想了解游戏史，我们有游戏速成课  \\N 主持人 Andre Meadows\n\nCommand line interfaces, while simple, are very powerful.\n命令行界面虽然简单  但十分强大\n\nComputer programming is still very much a written task, and as such,\n编程大部分依然是打字活 \\N 所以用命令行比较自然\n\ncommand lines are a natural interface.\n编程大部分依然是打字活 \\N 所以用命令行比较自然\n\nFor this reason, even today, most programmers use\n因此，即使是现在  \\N 大多数程序员工作中依然用命令行界面\n\ncommand line interfaces as part of their work.\n因此，即使是现在  \\N 大多数程序员工作中依然用命令行界面\n\nAnd they're also the most common way to access computers that are far away,\n而且用命令行访问远程计算机 是最常见的方式 \\N 比如服务器在另一个国家\n\nlike a server in a different country.\n而且用命令行访问远程计算机 是最常见的方式 \\N 比如服务器在另一个国家\n\nIf you're running Windows, macOS or Linux,\n如果你用 Windows, macOS, Linux\n\nyour computer has a command line interface one you may have never used.\n你的计算机有命令行界面，但你可能从来没用过\n\nCheck it out by typing \"cmd\" in your Windows search bar,\n你可以在 Windows 搜索栏中输入 cmd\n\nor search for Terminal on Mac.\n或在 Mac 上搜 Terminal\n\nThen install a copy of Zork and play on!\n然后你可以装 Zork 玩！\n\nSo, you can see how these early advancements still have an impact on computing today.\n现在你知道了 \\N 早期计算机的发展是如何影响到现在的.\n\nJust imagine if your phone didn't have a good ol' fashioned QWERTY keyboard.\n想想要是手机没有 QWERTY 键盘 \\N 在 Instagram 给图片配标题可就麻烦了\n\nIt could take forever to type your Instagram captions.\n想想要是手机没有 QWERTY 键盘 \\N 在 Instagram 给图片配标题可就麻烦了\n\nBut, there's still something missing from our discussion.\n但我们还有一个重要话题没讲\n\nAll the sweet sweet graphics!\n美妙的图形界面！\n\nThat's our topic for next week.\n这是下周的主题\n\nSee you soon.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/23. 屏幕&2D 图形显示-Screens&2D Graphics.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nThis 1960 PDP-1 is a great example of early computing with graphics.\n这台 1960 年的 PDP-1 \\N 是一个早期图形计算机的好例子\n\nYou can see a cabinet-sized computer on the left,\n你可以看到 左边是柜子大小的电脑\n\nan electromechanical teletype machine in the middle,\n中间是电传打字机\n\nand a round screen on the right.\n右边是一个圆形的屏幕\n\nNote how they're separated.\n注意它们是分开的\n\nThat's because text-based tasks and graphical tasks were often distinct back then.\n因为当时文本任务和图形任务是分开的.\n\nIn fact, these early computer screens had a very hard time rendering crisp text, whereas\n事实上，早期的屏幕无法显示清晰的文字\n\ntyped paper offered much higher contrast and resolution.\n而打印到纸上  有更高的对比度和分辨率\n\nThe most typical use for early computer screens was to keep track of a program's operation,\n早期屏幕的典型用途 是跟踪程序的运行情况\n\nlike values in registers.\n比如寄存器的值\n\nIt didn't make sense to have a teletype machine print this on paper\n如果用打印机 \\N 一遍又一遍打印出来没有意义\n\nover and over and over again -- that'd waste a lot of paper, and it was slow.\n不仅费纸而且慢\n\nOn the other hand, screens were dynamic and quick to update -- perfect for temporary values.\n另一方面，屏幕更新很快，对临时值简直完美\n\nComputer screens were rarely considered for program output, though.\n但屏幕很少用于输出计算结果，结果一般都打印到纸上\n\nInstead, any results from a computation were typically written to paper\n但屏幕很少用于输出计算结果，结果一般都打印到纸上\n\nor some other more permanent medium.\n或其它更永久的东西上\n\nBut, screens were so darn useful\n但屏幕超有用 \\N 到1960年代，人们开始用屏幕做很多酷炫的事情\n\nthat by the early 1960s, people started to use them for awesome things.\n但屏幕超有用 \\N 到1960年代，人们开始用屏幕做很多酷炫的事情\n\nA lot of different display technologies have been created over the decades,\n几十年间出现了很多显示技术\n\nbut the most influential, and also the earliest, were Cathode Ray Tubes, or CRT\n但最早最有影响力的是 阴极射线管（CRT）\n\nThese work by shooting electrons out of an emitter at a phosphor-coated screen.\n原理是把电子发射到 有磷光体涂层的屏幕上\n\nWhen electrons hit the coating, it glows for a fraction of a second.\n当电子撞击涂层时 会发光几分之一秒\n\nBecause electrons are charged particles,\n由于电子是带电粒子，路径可以用磁场控制\n\ntheir paths can be manipulated with electromagnetic fields.\n由于电子是带电粒子，路径可以用磁场控制\n\nPlates or coils are used inside to steer electrons to a desired position,\n屏幕内用板子或线圈  把电子引导到想要的位置\n\nboth left-right and up-down.\n上下左右都行\n\nWith this control, there are two ways you can draw graphics.\n既然可以这样控制，有 2 种方法绘制图形 \\N 1. 引导电子束描绘出形状\n\nThe first option is to direct the electron beam to trace out shapes.\n既然可以这样控制，有 2 种方法绘制图形 \\N 1. 引导电子束描绘出形状\n\nThis is called Vector Scanning.\n这叫\"矢量扫描\"\n\nBecause the glow persists for a little bit, if you repeat the path quickly enough,\n因为发光只持续一小会儿 \\N 如果重复得足够快 可以得到清晰的图像\n\nyou create a solid image.\n因为发光只持续一小会儿 \\N 如果重复得足够快 可以得到清晰的图像\n\nThe other option is to repeatedly follow a fixed path, scanning line by line,\n2. 按固定路径，一行行来 \\N 从上向下，从左到右，不断重复\n\nfrom top left to bottom right, and looping over and over again.\n2. 按固定路径，一行行来 \\N 从上向下，从左到右，不断重复\n\nYou only turn on the electron beam at certain points to create graphics.\n只在特定的点打开电子束，以此绘制图形\n\nThis is called Raster Scanning.\n这叫 \"光栅扫描\"\n\nWith this approach, you can display shapes... and even text... all made of little line segments.\n用这种方法，可以用很多小线段绘制形状  甚至文字\n\nEventually, as display technologies improved,\n最后，因为显示技术的发展\n\nit was possible to render crisp dots onto the screen, aka pixels.\n我们终于可以在屏幕上显示清晰的点，叫\"像素\"\n\nThe Liquid Crystal Displays, or LCDs,\n液晶显示器，简称 LCD\n\nthat we use today are quite a different technology.\n和以前的技术相当不同\n\nBut, they use raster scanning too,\n但 LCD 也用光栅扫描 \\N 每秒更新多次 像素里红绿蓝的颜色\n\nupdating the brightness of little tiny red, green and blue pixels many times a second.\n但 LCD 也用光栅扫描 \\N 每秒更新多次 像素里红绿蓝的颜色\n\nInterestingly, most early computers didn't use pixels\n有趣的是，很多早期计算机不用像素\n\n-- not because they couldn't physically,\n- 不是技术做不到, 而是因为像素占太多内存\n\nbut because it consumed way too much memory for computers of the time.\n- 不是技术做不到, 而是因为像素占太多内存\n\nA 200 by 200 pixel image contains 40,000 pixels.\n200像素×200像素的图像，有 40,000 个像素\n\nEven if you use just one bit of data for each pixel,\n哪怕每个像素只用一个 bit 表示 \\N 代表黑色或白色，连灰度都没有！\n\nthat's black OR white -- not grayscale!\n哪怕每个像素只用一个 bit 表示 \\N 代表黑色或白色，连灰度都没有！\n\n-- the image would consume 40,000 bits of memory.\n- 会占 40,000 bit 内存 \\N 比 PDP-1 全部内存的一半还多\n\nThat would have gobbled up more than half of a PDP-1's entire RAM.\n- 会占 40,000 bit 内存 \\N 比 PDP-1 全部内存的一半还多\n\nSo, computer scientists and engineers had to come up with clever tricks to render graphics\n所以计算机科学家和工程师，得想一些技巧来渲染图形 \\N 等内存发展到足够用\n\nuntil memory sizes caught up to our pixelicious ambitions.\n所以计算机科学家和工程师，得想一些技巧来渲染图形 \\N 等内存发展到足够用\n\nInstead of storing tens of thousands of pixels,\n所以早期计算机不存大量像素值 \\N 而是存符号，80x25个符号最典型\n\nearly computers stored a much smaller grid of letters, most typically 80 by 25 characters.\n所以早期计算机不存大量像素值 \\N 而是存符号，80x25个符号最典型\n\nThat's 2000 characters in total.\n总共 2000 个字符\n\nAnd if each is encoded in 8 bits, using something like ASCII,\n如果每个字符用 8 位表示，比如用 ASCII\n\nit would consume 16,000 bits of memory for an entire screen full of text,\n总共才 16000 位，这种大小更合理\n\nwhich is way more reasonable.\n总共才 16000 位，这种大小更合理\n\nTo pull this off, computers needed an extra piece of hardware that\n为此，计算机需要额外硬件\n\ncould read characters out of RAM, and convert them into raster graphics to be drawn onto the screen.\n来从内存读取字符，转换成光栅图形 \\N 这样才能显示到屏幕上\n\nThis was called a character generator, and they were basically the first graphics cards.\n这个硬件叫 \"字符生成器\"，基本算是第一代显卡\n\nInside, they had a little piece of Read Only Memory, a ROM,\n它内部有一小块只读存储器，简称 ROM\n\nthat stored graphics for each character, called a dot matrix pattern.\n存着每个字符的图形，叫\"点阵图案\"\n\nIf the graphics card saw the 8-bit code for the letter \"K\",\n如果图形卡看到一个 8 位二进制，发现是字母 K\n\nthen it would raster scan the 2D pattern for the letter K onto the screen, in the appropriate position.\n那么会把字母 K 的点阵图案 \\N光栅扫描显示到屏幕的适当位置\n\nTo do this, the character generator had special access to a portion of a computer's memory\n为了显示，\"字符生成器\" 会访问内存中一块特殊区域 \\N 这块区域专为图形保留，叫 屏幕缓冲区\n\nreserved for graphics, a region called the screen buffer.\n为了显示，\"字符生成器\" 会访问内存中一块特殊区域 \\N 这块区域专为图形保留，叫 屏幕缓冲区\n\nComputer programs wishing to render text to the screen\n程序想显示文字时，修改这块区域里的值就行\n\nsimply manipulated the values stored in this region,\n程序想显示文字时，修改这块区域里的值就行\n\njust as they could with any other data in RAM.\n程序想显示文字时，修改这块区域里的值就行\n\nThis scheme required much less memory,\n这个方案用的内存少得多 \\N 但也意味着 只能画字符到屏幕上\n\nbut it also meant the only thing you could draw was text.\n这个方案用的内存少得多 \\N 但也意味着 只能画字符到屏幕上\n\nEven still, people got pretty inventive with ASCII art!\n即使有这样限制 \\N 人们用 ASCII 艺术发挥了很多创意！\n\nPeople also tried to make rudimentary, pseudo-graphical interfaces out of this basic set of characters\n也有人用字符模仿图形界面\n\nusing things like underscores and plus signs to create boxes, lines and other primitive shapes.\n用下划线和加号来画盒子，线，和其他简单形状\n\nBut, the character set was really too small to do anything terribly sophisticated.\n但字符集实在太小，做不了什么复杂的事\n\nSo, various extensions to ASCII were made that added new semigraphical characters,\n因此对 ASCII 进行了各种扩展，加新字符\n\nlike IBM's CP437 character set, seen here, which was used in DOS.\n比如上图的 IBM CP437 字符集，用于 DOS.\n\nOn some systems, the text color and background color could be defined with a few extra bits.\n某些系统上 \\N 可以用额外的 bit 定义字体颜色和背景颜色\n\nThat allowed glorious interfaces like this DOS example,\n做出这样的 DOS 界面 \\N 这界面只用了刚刚提到的字符集\n\nwhich is built entirely out the character set you just saw.\n做出这样的 DOS 界面 \\N 这界面只用了刚刚提到的字符集\n\nCharacter generators were a clever way to save memory.\n字符生成器 是一种省内存的技巧 \\N 但没办法绘制任意形状\n\nBut, they didn't provide any way to draw arbitrary shapes.\n字符生成器 是一种省内存的技巧 \\N 但没办法绘制任意形状\n\nAnd that's important if you want to draw content like electrical circuits, architectural\n绘制任意形状很重要 \\N 因为电路设计，建筑平面图，地图，好多东西都不是文字！\n\nplans, maps, and... well pretty much everything that isn't text!\n绘制任意形状很重要 \\N 因为电路设计，建筑平面图，地图，好多东西都不是文字！\n\nTo do this, without resorting to memory-gobbling pixels,\n为了绘制任意形状，同时不吃掉所有内存\n\ncomputer scientists used the vector mode available on CRTs.\n计算机科学家用 CRT 上的\"矢量模式\"\n\nThe idea is pretty straightforward: all content to be drawn on screen is defined by a series of lines.\n概念非常简单：所有东西都由线组成\n\nThere's no text.\n没有文字这回事\n\nIf you need to draw text, you have to draw it out of lines.\n如果要显示文字，就用线条画出来\n\nDon't read between the lines here. There is only lines!\n只有线条，没有别的\n\nGot it? Alright, no more word play.\n明白了吗？好，我们举个实例吧\n\nI'm drawing the line here.\n明白了吗？好，我们举个实例吧\n\nLet's pretend this video is a cartesian plane, 200 units wide and 100 tall, with the\n假设这个视频是一个 笛卡尔平面 \\N 200个单位宽，100个单位高\n\norigin that's the zero-zero point in the upper left corner.\n原点 (0,0) 在左上角\n\nWe can draw a shape with the following vector commands,\n我们可以画形状，用如下矢量命令\n\nwhich we've borrowed from the Vectrex, an early vector display system.\n这些命令来自 Vectrex，一个早期矢量显示系统\n\nFirst, we reset, which clears the screen,\n首先，reset ，这个命令会清空屏幕\n\nmoves the drawing point of the electron gun to zero-zero,\n把电子枪的绘图点移动到坐标 (0,0)\n\nand sets the brightness of lines to zero.\n并把线的亮度设为 0\n\nThen we move the drawing point down to 50 50,\nMOVE_TO 50 50 \\N 把绘图点移动到坐标 (50,50)\n\nand set the line intensity to 100%.\nINTENSITY 100 \\N 把强度设为 100\n\nWith the intensity up, now we move to 100, 50, then 60, 75 and then back to 50,50.\n现在亮度提高了\\N 移动到 (100,50)  然后 (60,75)  然后 (50,50)\n\nThe last thing to do is set our line intensity back to 0%.\n最后把强度设回 0\n\nCool! We've got a triangle!\n酷，我们画了一个三角形！\n\nThis sequence of commands would consume on the order of 160 bits, which is way more efficient\n这些命令占 160 bit  \\N 比存一个庞大的像素矩阵更好\n\nthan keeping a huge matrix of pixel values!\n这些命令占 160 bit  \\N 比存一个庞大的像素矩阵更好\n\nJust like how characters were stored in memory and turned into graphics by a character generator,\n就像之前的\"字符生成器\" \\N把内存里的字符转成图形一样\n\nthese vector instructions were also stored in memory, and rendered to a screen using\n这些矢量指令也存在内存中 \\N 通过矢量图形卡画到屏幕上\n\na vector graphics card.\n这些矢量指令也存在内存中 \\N 通过矢量图形卡画到屏幕上\n\nHundreds of commands could be packed together, sequentially, in the screen buffer,\n数百个命令可以按序存在屏幕缓冲区\n\nand used to build up complex graphics. All made of lines!\n画出复杂图形，全是线段组成的！\n\nBecause all these vectors are stored in memory, computer programs can update the values freely,\n由于这些矢量都在内存中 \\N 程序可以更新这些值\n\nallowing for graphics that change over time -- Animation!\n让图形随时间变化 - 动画！\n\nOne of the very earliest video games, Spacewar!,\n最早的电子游戏之一, Spacewar!\n\nwas built on a PDP-1 in 1962 using vector graphics.\n是 1962 年在 PDP-1 上用矢量图形制作的.\n\nIt's credited with inspiring many later games, like Asteroids,\n它启发了许多后来的游戏，比如 爆破彗星(Asteroids)\n\nand even the first commercial arcade video game: Computer Space.\n甚至第一个商业街机游戏：太空大战\n\n1962 was also a huge milestone because of Sketchpad,\n1962 年是一个大里程碑 \\N  Sketchpad 诞生\n\nan interactive graphical interface\n一个交互式图形界面，用途是计算机辅助设计 (CAD)\n\nthat offered Computer-Aided Design -- called CAD Software today.\n一个交互式图形界面，用途是计算机辅助设计 (CAD)\n\nIt's widely considered the earliest example of a complete graphical application.\n它被广泛认为是第一个完整的图形程序\n\nAnd its inventor, Ivan Sutherland, later won the Turing Award for this breakthrough.\n发明人 伊万·萨瑟兰 后来因此获得图灵奖\n\nTo interact with graphics,\n为了与图形界面交互 \\N Sketchpad 用了当时发明不久的输入设备 光笔\n\nSketchpad used a recently invented input device called a light pen,\n为了与图形界面交互 \\N Sketchpad 用了当时发明不久的输入设备 光笔\n\nwhich was a stylus tethered to a computer with a wire.\n就是一个有线连着电脑的触控笔\n\nBy using a light sensor in the tip, the pen detected the refresh of the computer monitor.\n笔尖用光线传感器，可以检测到显示器刷新\n\nUsing the timing of the refresh,\n通过判断刷新时间，电脑可以知道笔的位置\n\nthe computer could actually figure out the pen's position on the screen!\n通过判断刷新时间，电脑可以知道笔的位置\n\nWith this light pen, and various buttons on a gigantic computer,\n有了光笔和各种按钮 \\N 用户可以画线和其他简单形状\n\nusers could draw lines and other simple shapes.\n有了光笔和各种按钮 \\N 用户可以画线和其他简单形状\n\nSketchpad could do things like make lines perfectly parallel, the same length, straighten\nSketchpad 可以让线条完美平行，长度相同 \\N 完美垂直90度，甚至动态缩放\n\ncorners into perfect 90 degree intersections, and even scale shapes up and down dynamically.\nSketchpad 可以让线条完美平行，长度相同 \\N 完美垂直90度，甚至动态缩放\n\nThese things that were laborious on paper, a computer now did with a press of a button!\n这些在纸上很费力，在计算机上非常简单！\n\nUsers were also able to save complex designs they created,\n用户还可以保存设计结果，方便以后再次使用 \\N 甚至和其他人分享\n\nand then paste them into later designs, and even share with other people.\n用户还可以保存设计结果，方便以后再次使用 \\N 甚至和其他人分享\n\nYou could have whole libraries of shapes, like electronic components and pieces of furniture\n你可以有一整个库 \\N 里面有电子元件和家具之类的\n\nthat you could just plop in and manipulate in your creations.\n可以直接拖进来用\n\nThis might all sound pretty routine from today's perspective.\n从如今的角度来看 好像很普通\n\nBut in 1962, when computers were still cabinet-sized behemoths chugging through punch cards,\n但在1962年 \\N 计算机还是吃纸带的大怪兽，有柜子般大小\n\nSketchpad and light pens were equal parts eye opening and brain melting.\nSketchpad 和光笔让人大开眼界\n\nThey represented a key turning point in how computers could be used.\n它们代表了人机交互方式的关键转折点\n\nThey were no longer just number crunching math machines that hummed along behind closed doors.\n电脑不再是关在门后 负责算数的机器了\n\nNow, they were potential assistants, interactively augmenting human tasks.\n可以当助手 帮人类做事\n\nThe earliest computers and displays with true pixel graphics emerged in the late 1960s.\n最早用真正像素的计算机和显示器\\N 出现于 1960 年代末\n\nBits in memory directly \"mapped\" to pixels on the screen,\n内存中的位(Bit) 对应屏幕上的像素\n\nwhat are called bitmapped displays.\n这叫 位图显示\n\nWith full pixel control, totally arbitrary graphics were possible.\n现在我们可以绘制任意图形了\n\nYou can think of a screen's graphics as a huge matrix of pixel values .\n你可以把图形想成一个巨大像素值矩阵\n\nAs before,\n就像之前\n\ncomputers reserve a special region of memory for pixel data, called the frame buffer.\n计算机把像素数据存在内存中一个特殊区域 \\N 叫\"帧缓冲区\"\n\nIn the early days, the computer's RAM was used,\n早期时，这些数据存在内存里\\N 后来存在高速视频内存里，简称 VRAM\n\nbut later systems used special high speed Video RAM, or VRAM,\n早期时，这些数据存在内存里\\N 后来存在高速视频内存里，简称 VRAM\n\nwhich was located on the graphics card itself for high speed access.\nVRAM 在显卡上，这样访问更快 \\N 如今就是这样做的.\n\nThis is how it's done today.\nVRAM 在显卡上，这样访问更快 \\N 如今就是这样做的.\n\nOn an 8-bit grayscale screen, we can set values from 0 intensity, which is black,\n在 8 位灰度屏幕上，我们可用的颜色范围是 0 强度（黑色）\n\nto 255 intensity, which is white.\n到 255 强度(白色)\n\nWell actually, it might be green... or orange, as many early displays couldn't do white.\n其实更像绿色或橙色 \\N 因为许多早期显示器不能显示白色\n\nLet's pretend this video is a really low resolution bitmapped screen,\n我们假设 这个视频在低分辨率的位图屏幕上\n\nwith a resolution of 60 by 35 pixels.\n分辨率 60x35像素\n\nIf we wanted to set the pixel at 10 10 to be white,\n如果我们想把 (10,10) 的像素设为白色 \\N 可以用这样的代码\n\nwe could do it with a piece of code like this.\n如果我们想把 (10,10) 的像素设为白色 \\N 可以用这样的代码\n\nIf we wanted to draw a line, let's say from 30, 0 to 30, 35, we can use a loop, like so.\n如果想画一条线  假设从(30,0)到(30,35) \\N 可以用这样一个循环\n\n.And this changes a whole line of pixels to white.\n把整列像素变成白色\n\nIf we want to draw something more complicated, let's say a rectangle,\n如果想画更复杂的图形，比如矩形，那么需要四个值\n\nwe need to know four values.\n如果想画更复杂的图形，比如矩形，那么需要四个值\n\nThe X and Y coordinate of its starting corner, and its width and height.\n1. 起始点X坐标  \\N2. 起始点Y坐标 \\N 3. 宽度 \\N 4. 高度\n\nSo far, we've drawn everything in white, so let's specify this rectangle to be grey.\n目前只试了白色，这次画矩形试下灰色\n\nGrey is halfway between 0 and 255, so that's a color value of 127.\n灰色介于0到255中间 \\N 所以我们用 127 (255/2=127.5)\n\nThen, with two loops C one nested in the other,\n然后用两个循环，一个套另一个\n\nso that the inner loop runs once for every iteration of the outer loop,\n这样外部每跑一次，内部会循环多次 \\N 可以画一个矩形\n\nwe can draw a rectangle.\n这样外部每跑一次，内部会循环多次 \\N 可以画一个矩形\n\nWhen the computer executes our code as part of its draw routine, it colors in all the\n计算机绘图时会用指定的颜色 127\n\npixels we specified.\n计算机绘图时会用指定的颜色 127\n\nLet's wrap this up into a \"draw rectangle function\", like this:\n我们来包装成 \"画矩形函数\"，就像这样：\n\nNow, to draw a second rectangle on the other side of the screen, maybe in black this time,\n假设要在屏幕的另一边 画第二个矩形 \\N 这次可能是黑色矩形\n\nwe can just call our rectangle drawing function. Voila!!\n可以直接调用 \"画矩形函数\", 超棒！\n\nJust like the other graphics schemes we've discussed,\n就像之前说的其他方案\n\nprograms can manipulate pixel data in the frame buffer, creating interactive graphics.\n程序可以操纵\"帧缓冲区\"中的像素数据，实现交互式图形\n\nPong time!\n乒乓球时间！\n\nOf course, programmers aren't wasting time writing drawing functions from scratch.\n当然，程序员不会浪费时间从零写绘图函数 \\N 而是用预先写好的函数来做，画直线，曲线，图形，文字等\n\nThey use graphics libraries with ready-to-go functions\n当然，程序员不会浪费时间从零写绘图函数 \\N 而是用预先写好的函数来做，画直线，曲线，图形，文字等\n\nfor drawing lines, curves, shapes, text, and other cool stuff.\n当然，程序员不会浪费时间从零写绘图函数 \\N 而是用预先写好的函数来做，画直线，曲线，图形，文字等\n\nJust a new level of abstraction!\n一层新抽象！\n\nThe flexibility of bitmapped graphics opened up a whole new world of possibilities for\n位图的灵活性，为交互式开启了全新可能 \\N 但它的高昂成本持续了十几年\n\ninteractive computing, but it remained expensive for decades.\n位图的灵活性，为交互式开启了全新可能 \\N 但它的高昂成本持续了十几年\n\nAs I mentioned last episode, by as late as 1971,\n上集提到，1971 年 \\N 整个美国也只有大约 7 万个电传打字机和 7 万个终端\n\nit was estimated there were around 70,000 electro-mechanical teletype machines\n上集提到，1971 年 \\N 整个美国也只有大约 7 万个电传打字机和 7 万个终端\n\nand 70,000 terminals in use, in the United States.\n上集提到，1971 年 \\N 整个美国也只有大约 7 万个电传打字机和 7 万个终端\n\nAmazingly, there were only around 1,000 computers in the US that had interactive graphical screens.\n令人惊讶的是 \\N 只有大约 1000 台电脑有交互式图形屏幕\n\nThat's not a lot!\n这可不多！\n\nBut the stage was set helped along by pioneering efforts like Sketchpad and Space Wars\nSketchpad 和 太空大战 这样的先驱  \\N 推动了图形界面发展\n\nfor computer displays to become ubiquitous,\n帮助普及了计算机显示器 \\N 由此，图形界面的曙光初现\n\nand with them, the dawn of graphical user interfaces,\n帮助普及了计算机显示器 \\N 由此，图形界面的曙光初现\n\nwhich we'll cover in a few episodes!\n接下来讲图形界面\n\nI'll see you next week.\n下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/24. 冷战和消费主义-The Cold War and Consumerism.ass.txt",
    "content": "Hi, I'm Carrie Anne and welcome to Crash Course Computer Science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nEarly in this series we covered computing history\n之前介绍了计算机历史 \\N 从人类文明的曙光开始 (第1集）\n\nFrom roughly the dawn of civilization,\n之前介绍了计算机历史 \\N 从人类文明的曙光开始 (第1集）\n\nup to the birth of electronic general purpose computers in the mid 1940s.\n一直到 1940 年代中期  电子计算机诞生\n\nA lot of the material we've discussed over the past 23 episodes\n过去 23 集里讲的很多东西\n\nlike programming languages and compilers\n比如编程语言和编译器，算法和集成电路\n\nAlgorithms and integrated circuits\n比如编程语言和编译器，算法和集成电路\n\nFloppy disks and operating systems, telly types and screens\n软盘和操作系统，电报机和屏幕\n\nall emerged over roughly a 30-year period,\n全都是1940~1970年代，大概这30年间里出现的\n\nFrom the mid 1940s up to the mid 1970s\n全都是1940~1970年代，大概这30年间里出现的\n\nThis is the era of computing before companies like Apple and Microsoft existed\n那时苹果和微软还不存在，也没有推特，谷歌或者 Uber.\n\nand long before anyone Tweeted, Googled or Uber-d.\n那时苹果和微软还不存在，也没有推特，谷歌或者 Uber.\n\nIt was a formative period setting the stage for personal computers,\n还没到个人电脑时代\n\nworldwide web, self-driving cars, virtual reality, and many other topics\n而万维网，无人驾驶汽车，虚拟现实等主题，\\N 这个系列的后半部分会讲\n\nwe'll get to in the second half of this series.\n而万维网，无人驾驶汽车，虚拟现实等主题，\\N 这个系列的后半部分会讲\n\nToday we're going to step back from circuits and algorithms\n今天, 我们不管电路和算法 \\N 来聊聊这个影响力巨大的时代\n\nand review this influential period.\n今天, 我们不管电路和算法 \\N 来聊聊这个影响力巨大的时代\n\nWe'll pay special attention to the historical backdrop of the cold war,\n我们会把重点放在 \\N 冷战，太空竞赛，全球化，消费主义的兴起.\n\nThe space race and the rise of globalization and consumerism.\n我们会把重点放在 \\N 冷战，太空竞赛，全球化，消费主义的兴起.\n\nPretty much immediately after World War II concluded in 1945,\n1945年二战结束后不久\n\nthere was tension between the world's two new superpowers\n两个超级大国的关系越发紧张，美国和苏联开始了冷战\n\nthe United States and the USSR\n两个超级大国的关系越发紧张，美国和苏联开始了冷战\n\nThe Cold War had begun and with it,\n因此政府往科学和工程学 投入大量资金\n\nmassive government spending on science and engineering.\n因此政府往科学和工程学 投入大量资金\n\nComputing which had already demonstrated its value\n计算机在战时已经证明了自身的价值 \\N 比如曼哈顿计划 和 破解纳粹通讯加密\n\nin wartime efforts like the Manhattan Project\n计算机在战时已经证明了自身的价值 \\N 比如曼哈顿计划 和 破解纳粹通讯加密\n\nand code breaking Nazi communications,\n计算机在战时已经证明了自身的价值 \\N 比如曼哈顿计划 和 破解纳粹通讯加密\n\nwas lavished with government funding.\n所以政府大量投入资源 \\N 各种雄心勃勃的项目得以进行\n\nThey enabled huge ambitious computing projects to be undertaken,\n所以政府大量投入资源 \\N 各种雄心勃勃的项目得以进行\n\nlike ENIAC, EDVAC, Atlas and Whirlwind all mentioned in previous episodes.\n比如之前提过的 ENIAC, EDVAC, Atlas, Whirlwind\n\nThis spurred rapid advances that simply weren't possible in the commercial sector alone,\n这种高速发展，如果仅靠商业运作是根本无法做到的\n\nwhere projects were generally expected to recoup development costs through sales.\n要依靠销售收回开发成本.\n\nThis began to change in the early 1950s,\n1950年代，事情开始发生变化,\n\nespecially with Eckert and Buckley's Univac 1,\n特别是 Univac 1，它是第一台取得商业成功的电脑\n\nthe first commercially successful computer.\n特别是 Univac 1，它是第一台取得商业成功的电脑\n\nUnlike ENIAC or Atlas , this wasn't just one single computer. It was a model of computers.\n不像 ENIAC 或 Atlas \\N Univanc 1 不是一台机器，而是一个型号\n\nin total more than 40 were built.\n一共造了40多台\n\nMost of these Univacs went to government offices or large companies.\n大部分 Univac 去了政府或大公司\n\nWhich was part of the growing military industrial complex in the United States,\n成为美国日益增长的军事工业综合体的一部分\n\nwith pockets deep enough to afford the cutting edge.\n因为政府有钱承担这些尖端科技.\n\nFamously, a Univac 1 built for the U.S atomic energy commission\n一个著名的例子是，\\N 一台给 美国原子能委员会 生产的 Univac 1\n\nwas used by CBS to predict the results of the 1952 U.S. presidential election.\n被 CBS 用来预测 1952 年美国总统大选的结果\n\nWith just 1% of the vote the computer correctly predicted\n仅用1％的选票，Univac 1 正确预测了结果. \\N 艾森豪威尔 获得压倒性胜利，而专家预测 史蒂文森 会赢\n\nEisenhower landslide, while pundits favored Stevenson.\n仅用1％的选票，Univac 1 正确预测了结果. \\N 艾森豪威尔 获得压倒性胜利，而专家预测 史蒂文森 会赢\n\nIt was a media event that helped propel computing to the forefront of the public's imagination\n这次事件把计算机推到了公众面前\n\nComputing was unlike machines of the past,\n计算机和以前的机器不一样\n\nwhich generally augmented human physical abilities.\n以前的机器 增强人类的物理能力\n\nTrucks allowed us to carry more, automatic looms whoa faster,\n比如卡车能带更多东西，自动织布机更快\n\nMachine tools were more precise and so on\n机床更精确 等等. 这些东西代表了工业革命.\n\nfor a bunch of contraptions that typify the industrial revolution.\n机床更精确 等等. 这些东西代表了工业革命.\n\nBut computers on the other hand could augment human intellect.\n而计算机增强的是人类智力\n\nThis potential wasn't lost on Vannevar Bush,\n范内瓦·布什 看到了这种潜力 \\N 他在1945年发表了一篇文章\n\nwho in 1945 published an article on a\n范内瓦·布什 看到了这种潜力 \\N 他在1945年发表了一篇文章\n\nhypothetical computing device he envisioned called the Memex.\n描述了一种假想计算设备叫 Memex\n\nThis was a device in which an individual stores all his books,\n可以用这个设备 \\N 存自己所有的书, 其他资料 以及和别人沟通\n\nrecords and communications and which is mechanized,\n而且数据是按照格式存储, \\N 所以可以快速查询，有很大灵活性.\n\nso it may be consulted with exceeding speed and flexibility\n而且数据是按照格式存储, \\N 所以可以快速查询，有很大灵活性.\n\nIt is an enlarged intimate supplement to his memory.\n可以辅助我们的记忆\n\nHe also predicted that wholly new forms of encyclopedia will appear,\n他还预测会出现 新的百科全书形式\n\nready-made, with a mesh of associative trails running through them.\n信息之间相互链接\n\nSound familiar?\n听起来是不是很熟悉？（维基百科）\n\nMemex directly inspired several subsequent game-changing systems,\nMemex 启发了  之后几个重要里程碑\n\nlike Ivan Sutherland Sketchpad, which we discussed last episode,\n比如上集 伊万·萨瑟兰 的 Sketchpad(画板)\n\nand Dough Engelbart's online system, which we will cover soon.\n以及后面很快会讲到 \\N Dough Engelbart 的 oN-LINE 系统（第26集）\n\nVannevar Bush was the head of the U.S. office of Scientific Research and Development,\n范内瓦·布什 \\N 做过\"美国科学研究与开发办公室\"的头头\n\nwhich was responsible for funding and coordinating scientific research during World War 2.\n这个部门负责在二战期间 \\N 资助和安排科学研究\n\nWith the Cold War brewing, Bush lobbied for a creation of a peace time equivalent,\n冷战时 范内瓦·布什 到处游说，\\N 想建立一个职责类似，但是在和平时期运作的部门\n\nthe National Science Foundation, formed in 1950.\n因此 国家科学基金会 于1950年成立\n\nTo this day the NSF provides federal funding to support scientific research in the United States.\n至今，国家科学基金会 \\N 依然负责给科学研究 提供政府资金\n\nAnd it is a major reason the U.S. has continued to be a leader in the technology sector.\n美国的科技领先全球，主要原因之一就是这个机构.\n\nIt was also in the 1950s that consumers started to buy transistor powered gadgets,\n1950年代，消费者开始买晶体管设备\n\nnotable among them was the transistor radio,\n其中值得注意的是 收音机\n\nwhich was small, durable and battery-powered.\n它又小又耐用，用电池就够了，而且便携\n\nAnd it was portable,\n它又小又耐用，用电池就够了，而且便携\n\nunlike the vacuum tube based radio sets from the 1940s and before.\n不像 1940 年代之前的收音机，用的是真空管.\n\nIt was a runaway success, the Furby or iPhone of its day.\n收音机非常成功，卖的像\"菲比精灵\"和 iPhone 一样畅销.\n\nThe Japanese government looking for industrial opportunities,\n日本政府也在寻求工业机会，想振兴战后经济，\n\nto bolster their post-war economy, soon got in on the action.\n日本政府也在寻求工业机会，想振兴战后经济，\n\nLicensing the rights to Transistors from Bell Labs in 1952.\n他们很快动手从贝尔实验室 取得晶体管的授权\n\nHelping launch the Japanese semiconductor and electronics industry.\n帮助振兴日本的半导体和电子行业\n\nIn 1955, the first Sony product was released:\n1955年，索尼的第一款产品面世\n\nThe TR-55 Transistor Radio. Concentrating on quality and price,\nTR-55 晶体管收音机. 他们把重心放在质量和价格.\n\nJapanese companies captured half of the U.S. Market for portable radios in just five years.\n因此日本公司在短短5年内，就占有了美国便携式收音机市场的一半.\n\nThis planted the first seeds of a major industrial rivalry in the decades to come.\n这为日本成为美国的强大工业对手，埋下伏笔\n\nIn 1953, there were only around 100 computers on the entire planet\n1953年，整个地球大概有100台计算机\n\nand at this point, the USSR was only a few years behind the West in computing technology,\n苏联这时的计算机科技  只比西方落后几年\n\ncompleting their first programmable electronic computer in 1950.\n苏联在1950年 \\N完成了第一个可编程电子计算机\n\nBut the Soviets were way ahead in the burgeoning space race.\n但苏联在太空竞赛远远领先\n\nLet's go to the thought-bubble.\n我们进入思想泡泡\n\nThe Soviets launched the world's first satellite into orbit, Sputnik one,\n苏联在1957年 \\N 把第一个卫星送上轨道，史波尼克1号\n\nin 1957, and a few years later in 1961.\n不久，在1961年\n\nSoviet Cosmonaut, Yuri Gagarin became the first human in space.\n苏联宇航员 尤里·加加林 第一个进入太空\n\nThis didn't sit well with the American public\n美国民众对此不满\n\nand prompted President Kennedy, a month after Gagarin's mission,\n使得肯尼迪总统 \\N 在加加林太空任务一个月后\n\nto encourage the nation to land a man on the moon within the decade. And it was expensive!\n提出要登陆月球. 登月很贵的!\n\nNASA's budget grew almost tenfold,\nNASA 的预算增长了几乎十倍,\n\npeaking in 1966 at roughly 4.5 percent of the U.S. Federal budget\n在 1966 年达到顶峰，占了政府预算的4.5%\n\nToday, It's around half a percent\n如今, NASA 的预算只占 0.5%\n\nNASA used this funding to tackle a huge array of enormous challenges\nNASA 用这笔钱资助各种科学研究\n\nthis culminated in the Apollo program\n阿波罗计划花的钱最多，雇了40万人左右\n\nWhich is peak employed roughly 400,000 people\n阿波罗计划花的钱最多，雇了40万人左右\n\nfurther supported by over 20,000 universities and companies\n而且有2万多家大学和公司参与.\n\none of these huge challenges was navigating in space\n其中一个挑战是 怎样在太空中导航\n\nNASA needed a computer to process complex trajectories\nNASA 需要电脑计算复杂的轨道来引导太空船\n\nand issue guidance commands to the spacecraft\nNASA 需要电脑计算复杂的轨道来引导太空船\n\nFor this, they built the Apollo guidance computer,\n因此，他们造了 \"阿波罗导航计算机\"\n\nThere were three significant requirements\n有3个重要要求\n\nFirst, the computer had to be fast, no surprise there.\n1. 计算机要快, 这在意料之中.\n\nSecond, it had to be small & lightweight\n2. 计算机要又小又轻.\n\nthere's not a lot of room in a spacecraft\n太空船里的空间不多\n\nand every ounce is precious when you're flying a quarter million miles to the moon\n而且要飞去月球，能轻一点是一点\n\nAnd finally it had to be really really ridiculously reliable\n3. 要超级可靠\n\nThis is super important in a spacecraft\n这对太空船非常重要，因为太空中有很多震动，辐射，极端温度变化\n\nWhere there's lots of vibration radiation and temperature change\n这对太空船非常重要，因为太空中有很多震动，辐射，极端温度变化\n\nAnd there's no running to Best Buy, if something breaks.\n如果东西坏掉了，可没办法去\"百思买\"买新的\n\nthe technology of the era of vacuum tubes and discrete transistors\n那时的主流科技 \\N 真空管和晶体管 无法胜任这些要求\n\nJust weren't up to the task\n那个时代的主流科技，真空管和离散晶体管，无法胜任这些要求.\n\nso NASA turned to a brand-new technology, integrated circuits.\n所以 NASA 用全新科技：集成电路\n\nWhich we discussed a few episodes ago\n我们几集前聊过\n\nThe Apollo guidance computer was the first computer to use them, a huge paradigm shift\n阿波罗导航计算机 首先使用了集成电路\n\nNASA was also the only place that could afford them\nNASA 是唯一负担得起集成电路的组织\n\nInitially each chip cost around $50\n最初，一个芯片差不多50美金\n\nAnd the guidance computer needed thousands of them.\n导航计算机需要上千个芯片\n\nBut by paying that price, the Americans were able to beat the soviets to the moon\n但美国也因此成功登月，打败苏联\n\nThanks, thought-bubble\n谢了 思想泡泡\n\nAlthough the Apollo Guidance computer is credited\n虽然人们经常把集成电路的发展 \\N 归功于阿波罗导航计算机\n\nwith spurring the development and adoption of integrated circuits\n虽然人们经常把集成电路的发展 \\N 归功于阿波罗导航计算机\n\nIt was a low volume, product there are only 17 Apollo missions after all.\n但它们的产量很低，一共只有 17 次阿波罗任务\n\nit was actually military applications\n实际上是军事 大大推进了集成电路发展\n\nEspecially the minuteman and polaris nuclear missile systems\n特别是洲际导弹和核弹，使集成电路大规模生产\n\nThat allowed integrated circuits to become a mass-produced item\n特别是洲际导弹和核弹，使集成电路大规模生产\n\nThis rapid Advancement was further accelerated by the U.S.\n美国建造强大计算机时，也进一步推进了集成电路\n\nBuilding and buying huge powerful computers\n美国建造强大计算机时，也进一步推进了集成电路\n\nOften called supercomputers, because they were frequently\n一般叫\"超级计算机\"，\\N 因为它们经常比全球最快电脑还快10倍以上\n\n10 times faster than any other computer on the planet, upon their release.\n一般叫\"超级计算机\"，\\N 因为它们经常比全球最快电脑还快10倍以上\n\nbut these machines built by companies like CDC, Cray and IBM were also\n但 CDC，Cray，IBM 制造的计算机非常昂贵\n\nsuper in cost, and pretty much only governments could afford to buy them.\n几乎只有政府负担得起\n\nin the U.S. these machines went to government Agencies like the NSA.\n这些计算机用于政府机构，比如美国国家安全局\n\nand government research labs like Lawrence Livermore and Los Alamos National laboratories\n以及实验室比如  \\N 劳伦斯·利弗莫尔 实验室 \\N  洛斯·阿拉莫斯 国家实验室\n\nInitially the U.S. semiconductor industry boomed\n最初，美国的半导体行业 \\N 靠高利润政府合同起步\n\nbuoyed by High profit government contracts\n最初，美国的半导体行业 \\N 靠高利润政府合同起步\n\nHowever this meant that most U.S.companies overlooked\n因此忽略了消费者市场，因为利润小\n\nthe consumer market where profit margins were small\n因此忽略了消费者市场，因为利润小\n\nthe Japanese Semiconductor industry came to dominate this niche\n因此日本半导体行业在1950和1960年代 \\N 靠低利润率占领了消费者市场\n\nby having to operate with lean profit margins in the 1950s and 60s\n因此日本半导体行业在1950和1960年代 \\N 靠低利润率占领了消费者市场\n\nthe Japanese had invested heavily in manufacturing capacity\n日本人投入大量资金，大量制造以达到规模经济\n\nto achieve economies of scale\n日本人投入大量资金，大量制造以达到规模经济\n\nin research to improve quality and Yields and in automation to keep manufacturing costs low.\n同时研究技术，提高质量和产量 \\N 以及用自动化来降低成本\n\nin the 1970s with the Space Race and cold war subsiding\n1970年代，太空竞赛和冷战逐渐消退 \\N 高利润的政府合同变少\n\npreviously juicy defense contracts began to dry up.\n1970年代，太空竞赛和冷战逐渐消退 \\N 高利润的政府合同变少\n\nand American semi-conductor and electronics companies found it harder to compete.\n美国的半导体和电子设备公司发现更难竞争了\n\nit didn't help the many computing components had been commoditized\n虽然很多计算机组件商品化了，但并没有什么帮助\n\nDRAM was DRAM\nDRAM 就是 DRAM\n\nSo why buy expensive Intel memory when you could buy the same chip for less from Hitachi?\n能从日立买便宜的，干嘛要从英特尔买贵的？\n\nThroughout the 1970s U.S. companies began to downsize,\n1970年代 美国公司开始缩小，合并，或直接倒闭\n\nconsolidate or outright fail.\n1970年代 美国公司开始缩小，合并，或直接倒闭\n\nIntel had to lay off a third of its workforce in 1974\n1974年 英特尔不得不裁员三分之一\n\nand even the storied Fairchild semiconductor\n知名的仙童半导体也在 1979 年濒临倒闭 \\N 被其他公司收购了\n\nwas acquired in 1979 after near bankruptcy\n知名的仙童半导体也在 1979 年濒临倒闭 \\N 被其他公司收购了\n\nto survive many of these companies began to outsource their manufacturing in a bid to reduce costs.\n为了生存，很多公司把生产外包出去，降低成本\n\nIntel withdrew from its main product category, Memory IC\n英特尔不再把精力放在 内存集成电路 \\N 而是把精力放在处理器\n\nand decided to refocus on processes.\n英特尔不再把精力放在 内存集成电路 \\N 而是把精力放在处理器\n\nWhich ultimately saved the company.\n这个决定最后挽救了公司\n\nThis low and U.S.\n美国公司的无力 \\N 导致 夏普 和 卡西欧 这样的日本公司\n\nelectronics industry allowed Japanese companies like Sharp and Casio\n美国公司的无力 \\N 导致 夏普 和 卡西欧 这样的日本公司\n\nto dominate the breakout computing product of the 1970s.\n占领了1970年代的主流产品\n\nHandheld electronic calculators.\n手持计算器\n\nby using integrated circuits, these could be made small and cheap.\n因为集成电路，计算机又小又便宜\n\nThey replaced expensive desktop adding machines you find in offices.\n取代了办公室里昂贵的桌面计算器\n\nFor most people it was the first time they didn't have to do math on paper, or use a slide rule\n对大多数人 \\N 这是他们第一次不必用纸笔和计算尺来做计算\n\nThey were an instant hit, selling by the millions.\n手持计算机因此大卖\n\nThis further drove down the cost of integrated circuits\n进一步降低了集成电路的成本\n\nand led to the development and widespread use of micro processors.\n使得微处理器被广泛使用\n\nlike the Intel 4004 we've discussed previously\n比如之前讨论过的 Intel 4004\n\nThis chip was built by Intel in 1971\nIntel 在1971年 \\N 应日本计算器公司 Busicom 的要求做了这个芯片\n\nat the request of Japanese calculator company Busicom.\nIntel 在1971年 \\N 应日本计算器公司 Busicom 的要求做了这个芯片\n\nSoon, Japanese electronics were everywhere.\n很快，日本电子产品到处都是\n\nfrom televisions of VCRs to digital wristwatches and Walkmans\n从电视到手表到随身听\n\nthe availability of inexpensive microprocessor\n而廉价的微处理器，也催生了全新的产品，比如街机游戏\n\nSpawned in entirely new products like video arcades,\n而廉价的微处理器，也催生了全新的产品，比如街机游戏\n\nthe world got Pong in 1972 and Breakout in 1976.\n1972年诞生了Pong，1976年诞生了打砖块\n\nas cost continued to plummet\n因为成本不断下降\n\nsoon it became possible for regular people to afford computing devices\n很快，普通人也买得起计算机了\n\nduring this time we see the emergence of the first successful home computers\n这段期间，第一批家用电脑开始出现，比如1975年的 Altair 8800\n\nlike the 1975 Altair 8800\n这段期间，第一批家用电脑开始出现，比如1975年的 Altair 8800\n\nand also the first home gaming consoles\n以及第一款家用游戏机，比如1977年的Atari 2600\n\nlike the Atari 2600 in 1977,\n以及第一款家用游戏机，比如1977年的Atari 2600\n\nHome, now I repeat that, Home.\n家用！我再说一遍 家用！\n\nThat seems like a small thing today.\n如今没什么大不了的.\n\nBut this was the dawn of a whole new era in computing.\n但那时是计算机的全新时代\n\nin just three decades, computers have evolved from\n在短短三十年内，计算机从大到人类可以在 CPU 里走来走去\n\nmachines where you could literally walk inside of the CPU.\n在短短三十年内，计算机从大到人类可以在 CPU 里走来走去\n\nassuming you had government clearance\n当然，你要有政府许可你这样做.\n\nto the point where a child could play with a handheld toy\n发展到小到小孩都能拿住的手持玩具，而且微处理器还快得多.\n\nContaining a microprocessor many times faster,\n发展到小到小孩都能拿住的手持玩具，而且微处理器还快得多.\n\nCritically, this dramatic evolution would have been but without two powerful forces at play\n这种巨大变化是由两种力量推动的：政府和消费者\n\nGovernments and Consumers.\n这种巨大变化是由两种力量推动的：政府和消费者\n\nGovernment funding like the United States provided during the cold war\n政府资金，比如冷战期间美国投入的钱\n\nenabled early adoption of many nascent computing technologies\n推动了计算机的早期发展\n\nThis funding helped flow entire Industries relate into computing long enough\n并且让计算机行业活得足够久，使得技术成熟到可以商用\n\nfor the technology to mature and become commercially feasible.\n并且让计算机行业活得足够久，使得技术成熟到可以商用\n\nThen businesses and ultimately consumers, provided the demand to take it mainstream.\n然后是公司，最后是消费者，把计算机变成了主流\n\nThe cold war may be over, but this relationship continues today\n冷战虽然结束了，但这种关系今天仍在继续\n\nGovernments are still funding science research.\n政府依然在资助科学研究\n\nintelligence agencies are still buying supercomputers.\n情报机构依然在超级计算机\n\nhumans are still being launched into space.\n人类仍然被发射到太空里\n\nAnd you're still buying TV, Xbox, Playstation, Laptop and Smartphone\n而你依然在买电视，Xbox，Playstation，笔记本电脑和手机\n\nand for these reasons,\n因此，计算机会继续飞速发展\n\nComputing continues to advance a lightning pace.\n因此，计算机会继续飞速发展\n\nI'll see you next week\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/25. 个人计算机革命-The Personal Computer Revolution.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nAs we discussed last week, the idea of having a computer all to yourself a personal\n上周说过\"个人计算机\"的概念 \\N 在计算机发展的头 30 年难以想象\n\ncomputer was elusive for the first three decades of electronic computing.\n上周说过\"个人计算机\"的概念 \\N 在计算机发展的头 30 年难以想象\n\nIt was just way too expensive for a computer to be owned and used by one single person.\n如果只让一个人用，成本实在太高\n\nBut, by the early 1970s, all the required components had fallen into place to build\n但到 70 年代初，各种组件的成本都下降了 \\N 可以做出低成本  同时性能足够强大的计算机\n\na low cost, but still usefully powerful computer.\n但到 70 年代初，各种组件的成本都下降了 \\N 可以做出低成本  同时性能足够强大的计算机\n\nNot a toy, but a tool.\n不是玩具级计算机，是真正能用的计算机\n\nMost influential in this transition was the advent of single-chip CPUs,\n这个转变中 \\N 最有影响力的是 单芯片 CPU 的出现\n\nwhich were surprisingly powerful, yet small and inexpensive.\n强大 + 体积小 + 便宜\n\nAdvances in integrated circuits also offered low-cost solid-state memory,\n集成电路的进步，也提供了低成本固态存储器\n\nboth for computer RAM and ROM.\n可以用于计算机的 RAM 和 ROM\n\nSuddenly it was possible to have an entire computer on one circuit board,\n忽然间 \\N 把整台计算机做到一张电路板上成为可能\n\ndramatically reducing manufacturing costs.\n大大地降低了制造成本\n\nAdditionally, there was cheap and reliable computer storage,\n而且，那时有便宜可靠的储存介质 \\N 比如磁带和软盘\n\nlike magnetic tape cassettes and floppy disks.\n而且，那时有便宜可靠的储存介质 \\N 比如磁带和软盘\n\nAnd finally, the last ingredient was low cost displays, often just repurposed televisions.\n最后是 低成本的显示器 \\N 通常是电视机稍作改装而成\n\nIf you blended these four ingredients together in the 1970s, you got,\n如果在 1970 年代 \\N 将这四种原料混在一起\n\nwhat was called a microcomputer,\n就得到了\"微型计算机\"\n\nbecause these things were so tiny compared to \"normal\" computers of that era, the\n因为和那个时代的\"普通\"计算机相比 \\N 这些计算机很小\n\ntypes you'd see in business or universities.\n\"普通\"计算机就是公司或大学里的那种\n\nBut more important than their size was their cost.\n但比大小更重要的是成本\n\nThese were, for the first time, sufficiently cheap.\n这是有史以来第一次，计算机的价格足够低\n\nIt was practical to buy one and only have one person ever use it.\n\"一个人专用\"的想法变得可行\n\nNo time sharing,\n不用划分时间和别人公用计算机\n\nno multi-user logins,  just a single owner and user.\n没有多用户登录，计算机只属于一个人，只有一个用户\n\nThe personal computer era had arrived.\n个人计算机时代到来\n\nComputer cost and performance eventually reached the point\n计算机成本下降+性能提升, 让个人计算机成为可能\n\nwhere personal computing became viable.\n计算机成本下降+性能提升, 让个人计算机成为可能\n\nBut, it's hard to define exactly when that happened.\n但这个时间点很难准确定义, 并没有一个具体时间点\n\nThere's no one point in time.\n但这个时间点很难准确定义, 并没有一个具体时间点\n\nAnd as such, there are many contenders for the title of \"first\" personal computer,\n因此\"第一台个人计算机\"这个名号，有很多竞争者\n\nlike the Kenback-1 and MCM/70.\n比如 Kenback-1 和 MCM/70\n\nLess disputed, however, is the first commercially successful personal computer: The Altair 8800.\n不过第一台取得商业成功的个人计算机 \\N 争议较小：Altair 8800\n\nThis machine debuted on the cover of Popular Electronics in 1975,\n首次亮相在 1975 年《Popular Electronics》封面\n\nand was sold as a $439 kit that you built yourself.\n售价 $439 美元，需要自己组装\n\nInflation adjusted, that's about $2,000 today,\n计算通货膨胀后，相当如今的 2000 美元左右\n\nwhich isn't chump change, but extremely cheap for a computer in 1975.\n不算小钱，但比起 1975 年的其它计算机，算是非常便宜了\n\nTens of thousands of kits were sold to computer hobbyists,\n各种需要自己组装的组件包  \\N卖给了计算机爱好者\n\nand because of its popularity, there were soon all sorts of nifty add-ons available...\n因为买的人多，很快相关产品出现了\n\nthings like extra memory, a paper tape reader and even a teletype interface.\n比如内存，纸带读取器，甚至电传接口\n\nThis allowed you, for example, to load a longer, more complicated program from punch tape,\n让你可以从纸带上读取更长更复杂的程序\n\nand then interact with it using a teletype terminal.\n然后用电传终端交互\n\nHowever, these programs still had to be written in machine code,\n但程序还是要用 机器码 写\n\nwhich was really low level and nasty, even for hardcore computer enthusiasts.\n写起来很麻烦，即使计算机爱好者也讨厌写\n\nThis problem didn't escape a young Bill Gates and Paul Allen,\n这没有吓跑年轻的比尔·盖茨和保罗·艾伦\n\nwho were 19 and 22 respectively.\n他们当时是19岁和22岁\n\nThey contacted MITS, the company making the Altair 8800,\n他们联系了制造 Altair 8800 的 MITS 公司\n\nsuggesting the computer would be more attractive to hobbyists\n建议说，如果能运行 BASIC 程序 \\N 会对爱好者更有吸引力\n\nif it could run programs written in BASIC,\n建议说，如果能运行 BASIC 程序 \\N 会对爱好者更有吸引力\n\na popular and simple programming language.\nBASIC 是一门更受欢迎更简单的编程语言\n\nTo do this, they needed to write a program that converted BASIC instructions\n为此，他们需要一个程序 \\N 把 BASIC 代码转成可执行机器码\n\ninto native machine code, what's called an interpreter.\n这叫 解释器 (interpreter)\n\nThis is very similar to a compiler,\n\"解释器\"和\"编译器\"类似\n\nbut happens as the programs runs instead of beforehand.\n区别是\"解释器\"运行时转换\\N而\"编译器\"提前转换\n\nLet's go to the thought bubble!\n让我们进入思想泡泡！\n\nMITS was interested,\nMITS 表示感兴趣\n\nand agreed to meet Bill and Paul for a demonstration.\n同意与 Bill 和 Paul 见个面，让他们演示一下\n\nProblem is, they hadn't written the interpreter yet.\n问题是，他们还没写好解释器\n\nSo, they hacked it together in just a few weeks\n所以他们花了几个星期赶工 \\N 而且还不是在 Altair 8800 上写的\n\nwithout even an Altair 8800 to develop on,\n所以他们花了几个星期赶工 \\N 而且还不是在 Altair 8800 上写的\n\nfinishing the final piece of code on the plane.\n最后在飞机上完成了代码\n\nThe first time they knew their code worked was at MITS headquarters\n他们在墨西哥 阿尔伯克基（城市） \\N 的 MITS 总部做演示时，才知道代码可以成功运行\n\nin Albuquerque, New Mexico, for the demo.\n他们在墨西哥 阿尔伯克基（城市） \\N 的 MITS 总部做演示时，才知道代码可以成功运行\n\nFortunately, it went well and MITS agreed to distribute their software.\n幸运的是进展顺利 \\N MITS 同意在计算机上搭载他们的软件\n\nAltair BASIC became the newly formed Microsoft's first product.\nAltair BASIC 成了微软的第一个产品\n\nAlthough computer hobbyists existed prior to 1975,\n虽然1975年之前就有计算机爱好者\n\nthe Altair 8800 really jump-started the movement.\n但 Altair 8800 大量催生了更多计算机爱好者\n\nEnthusiast groups formed, sharing knowledge and software and passion about computing.\n爱好者们组成各种小组 \\N 分享知识，软件，以及对计算机的热爱\n\nMost legendary among these is the Homebrew Computer Club,\n最具传奇色彩的小组是\"家酿计算机俱乐部\"\n\nwhich met for the first time in March 1975\n第一次小组聚会在1975年3月\n\nto see a review unit of the Altair 8800, one of the first to ship to California.\n看一台第一批运来加州的 Altair 8800\n\nAt that first meeting was 24-year-old Steve Wozniak, who was so inspired by\n第一次聚会上，24岁的 Steve Wozniak  \\N 被 Altair 8800 大大激励\n\nthe Altair 8800 that he set out to design his own computer.\n开始想设计自己的计算机\n\nIn May 1976, he demonstrated his prototype to the Club\n1976年5月，他向小组展示了原型机\n\nand shared the schematics with interested members.\n并且把电路图分享给感兴趣的其他会员\n\nUnusual for the time, it was designed to connect to a TV and offered a text interface\n他的设计不同寻常 \\N 要连到电视显示，并提供文本界面\n\na first for a low-cost computer.\n在低成本计算机上还是第一次见\n\nInterest was high, and shortly after fellow club member and college friend Steve Jobs\n同是俱乐部成员和大学朋友的 史蒂夫·乔布斯\n\nsuggested that instead of just sharing the designs for free,\n建议说与其免费分享设计，不如直接出售装好的主板\n\nthey should just sell an assembled motherboard.\n建议说与其免费分享设计，不如直接出售装好的主板\n\nHowever, you still had to add your own keyboard, power supply, and enclosure.\n但用户依然需要自己加键盘，电源和机箱\n\nIt went on sale in July 1976 with a price tag of $666.66.\n1976年7月开始发售，价格$666.66美元\n\nIt was called the Apple-I, and it was Apple Computer's first product.\n它叫 Apple-I ，苹果计算机公司的第一个产品\n\nThanks thought bubble!\n谢了 思想泡泡\n\nLike the Altair 8800, the Apple-I was sold as a kit.\n就像 Altair 8800 一样，Apple-I 也是作为套件出售\n\nIt appealed to hobbyists,\nApple-I 吸引了业余爱好者 \\N 不介意机器买回来自己组装\n\nwho didn't mind tinkering and soldering,\nApple-I 吸引了业余爱好者 \\N 不介意机器买回来自己组装\n\nbut consumers and businesses weren't interested.\n但个人消费者和公司对 Apple-I 不感兴趣\n\nThis changed in 1977,\n这在 1977 年发生变化 \\N 市场上有了三款开箱即用的计算机\n\nwith the release of three game-changing computers,  that could be used right out of the box.\n这在 1977 年发生变化 \\N 市场上有了三款开箱即用的计算机\n\nFirst was the Apple II,\n第一款是 Apple-II\n\nApple's earliest product that sold as a complete system\n苹果公司第一个提供全套设备的产品\n\nthat was professionally designed and manufactured.\n设计和制造工艺都是专业的\n\nIt also offered rudimentary color graphics and sound output,\n它还提供了简单彩色图形和声音输出\n\namazing features for a low cost machine.\n这些功能对低成本机器非常了不起\n\nThe Apple II series of computers sold by the millions and quickly\nApple-II 卖了上百万套\n\npropelled Apple to the forefront of the personal computing industry.\n把苹果公司推到了个人计算机行业的前沿\n\nThe second computer was the TRS-80 Model I,\n第二款是\"TRS-80 1型\"\n\nmade by the Tandy Corporation\n由 Tandy 公司生产\n\nand sold by RadioShack hence the \"TRS\"\n由 Radioshack 销售，所以叫 TRS\n\nAlthough less advanced than the Apple II,\n虽然不如 Apple-II 先进 \\N 但因为价格只有一半，所以卖得很火爆\n\nit was half the cost and sold like hot cakes.\n虽然不如 Apple-II 先进 \\N 但因为价格只有一半，所以卖得很火爆\n\nFinally, there was the Commodore PET 2001,\n最后一款是 Commodore PET 2001\n\nwith a unique all-in-one design\n有一体化设计\n\nthat combined computer, monitor, keyboard and tape drive into one device,\n集成了计算机，显示器，键盘和磁带驱动器\n\naimed to appeal to consumers.\n目标是吸引普通消费者\n\nIt started to blur the line between computer and appliance.\n计算机和家用电器之间的界限开始变得模糊\n\nThese three computers became known as the 1977 Trinity.\n这3台计算机被称为1977年的\"三位一体\"\n\nThey all came bundled with BASIC interpreters,\n它们都自带了 BASIC 解释器\n\nallowing non-computer-wizards to create programs.\n让不那么精通计算机的人也能用 BASIC 写程序\n\nThe consumer software industry also took off,\n针对消费者的软件行业 开始腾飞\n\noffering games and productivity tools for personal computers,\n市场上出现了各种 \\N 针对个人计算机的游戏和生产力工具\n\nlike calculators and word processors.\n比如计算器和文字处理器\n\nThe killer app of the era was 1979's VisiCalc,\n最火的是 1979 年的 VisiCalc\n\nthe first spreadsheet program\n第一个电子表格程序\n\nwhich was infinitely better than paper\n比纸好无数倍\n\nand the forbearer of programs like Microsoft Excel and Google Sheets.\n是微软 Excel 和 Google Sheets 的老祖先\n\nBut perhaps the biggest legacy of these computers was their marketing,\n但这些计算机带来的最大影响 \\N 也许是他们的营销策略\n\nthey were the first to be targeted at households, and not just businesses and hobbyists.\n它们针对普通消费者 \\N 而不是企业和爱好者\n\nAnd for the first time in a substantial way,\n这是第一次大规模地\n\ncomputers started to appear in homes, and also small businesses and schools.\n计算机出现在家庭，小公司，以及学校中\n\nThis caught the attention of the biggest computer company on the planet, IBM, who had seen its\n这引起了全球最大计算机公司 IBM 的注意\n\nshare of the overall computer market shrink from 60% in 1970 to around 30% by 1980.\n其市场份额从1970年的60％ \\N 在1980年降到了30％左右\n\nThis was mainly because IBM had ignored the microcomputer market,\n因为IBM忽略了增长的\"微型计算机\"市场\n\nwhich was growing at about 40% annually.\n这个市场每年增长约40％\n\nAs microcomputers evolved into personal computers, IBM knew it needed to get in on the action.\n随着微型计算机演变成个人计算机 \\N IBM 知道他们需要采取行动\n\nBut to do this, it would have to radically rethink its computer strategy and design.\n但要做到这一点 \\N 公司要从根本上重新思考战略和设计\n\nIn 1980, IBM's least-expensive computer, the 5120, cost roughly ten thousand dollars,\n1980年 IBM 最便宜的计算机 \\N \"5120\"的价格大概是一万美元\n\nwhich was never going to compete with the likes of the Apple II.\n永远也没法和 Apple-II 这样的计算机竞争\n\nThis meant starting from scratch.\n意味着要从头开始\n\nA crack team of twelve engineers, later nicknamed the dirty dozen,\n一个由十二名工程师组成的精干团队（后来叫\"肮脏十二人\"）\n\nwere sent off to offices in Boca Raton, Florida,\n被派往佛罗里达州的 \\N 博卡拉顿（Boca Raton）办公室\n\nto be left alone and put their talents to work.\n让他们独立工作\n\nShielded from IBM internal politics, they were able to design a machine as they desired.\n不受 IBM 内部的政治斗争干扰 \\N 他们想怎么设计怎么设计\n\nInstead of using IBM proprietary CPUs, they chose Intel chips.\n没用 IBM 的 CPU，选了 Intel 的芯片\n\nInstead of using IBM's prefered operating system, CP/M,\n也没用 IBM 的首选操作系统 CP/M\n\nthey licenced Microsoft's Disk Operating System: DOS\n而是用了微软的 DOS\n\nand so on, from the screen to the printer.\n依此类推，从屏幕到打印机都这样自由选择\n\nFor the first time, IBM divisions had to compete with outside firms\nIBM 第一次不得不与外部公司竞争\n\nto build hardware and software for the new computer.\n来给新计算机做硬件和软件\n\nThis radical break from the company tradition of in-house development kept costs low\n这和 IBM 的传统做法不同：自己做硬件来节省成本\n\nand brought partner firms into the fold.\n然后和其它公司合作\n\nAfter just a year of development,\n经过短短一年\n\nthe IBM Personal Computer, or IBM PC was released.\nIBM 个人计算机发布了，简称 IBM PC\n\nIt was an immediate success,\n产品立马取得了成功\n\nespecially with businesses that had long trusted the IBM brand.\n长期信任 IBM 品牌的企业买了很多\n\nBut, most influential to its ultimate success was that the computer featured an open architecture,\n但最有影响力的是 \\N 它使用 \"开放式架构\"\n\nwith good documentation and expansion slots,\n有良好的文档和扩展槽\n\nallowing third parties to create new hardware and peripherals for the platform.\n使得第三方可以做硬件/外设\n\nThat included things like graphics cards, sounds cards, external hard drives, joysticks,\n包括显卡，声卡，外置硬盘，游戏控制杆 \\N 以及无数其它组件\n\nand countless other add-ons.\n包括显卡，声卡，外置硬盘，游戏控制杆 \\N 以及无数其它组件\n\nThis spurred innovation, and also competition, resulting in a huge ecosystem of products.\n这刺激了创新，激发了竞争，产生了巨大的生态系统\n\nThis open architecture became known as \"IBM Compatible\".\n这个开放架构叫 IBM Compatible\"（IBM 兼容）\n\nIf you bought an \"IBM Compatible\" computer, it meant you\n意味着如果买了\"IBM兼容\"的计算机\n\ncould use that huge ecosystem of software and hardware.\n你可以用庞大生态系统中的其它软硬件\n\nBeing an open architecture also meant that competitor companies could follow the standard\n开放架构也意味着 竞争对手公司可以遵循这个标准\n\nand create their own IBM Compatible computers.\n做出自己的\"IBM 兼容\"计算机\n\nSoon, Compaq and Dell were selling their own PC clones...\n很快，康柏和戴尔也开始卖 PC\n\nAnd Microsoft was happy to license MS-DOS to them,\n微软很乐意把 MS-DOS 授权给他们\n\nquickly making it the most popular PC operating system.\n使 DOS 迅速成为最受欢迎的 PC 操作系统\n\nIBM alone sold two million PCs in the first three years, overtaking Apple.\n仅在前三年 \\N IBM就卖出了200万台 PC ，超过了苹果\n\nWith a large user base, software and hardware developers concentrated\n有了庞大用户群，软件和硬件开发人员 \\N 把精力放在\"IBM 兼容\"平台，因为潜在用户更多\n\ntheir efforts on IBM Compatible platforms, there were just more users to sell to.\n有了庞大用户群，软件和硬件开发人员 \\N 把精力放在\"IBM 兼容\"平台，因为潜在用户更多\n\nThen, people wishing to buy a computer bought the one with the\n同时，想买计算机的人 \\N 也会看哪种计算机的软硬件选择更多\n\nmost software and hardware available, and this effect snowballed.\n就像雪球效应一样\n\nCompanies producing non-IBM-compatible computers, often with superior specs,\n而那些生产非\"IBM兼容\"计算机的公司 （一般性能更好）\n\nfailed.\n都失败了\n\nOnly Apple kept significant market share without IBM compatibility.\n只有苹果公司在没有\"IBM兼容\"的情况下 \\N 保持了足够市场份额\n\nApple ultimately chose to take the opposite approach a \"closed architecture\" proprietary\n苹果公司最终选了相反的方式：\"封闭架构\"\n\ndesigns that typically prevent people from adding new hardware to their computers.\n即自己设计一切，用户一般无法加新硬件到计算机中\n\nThis meant that Apple made its own computers, with its own operating system, and often its\n意味着苹果公司要做自己的计算机，自己的操作系统\n\nown peripherals, like displays, keyboards, and printers.\n还有自己的外围设备，如显示器，键盘和打印机\n\nBy controlling the full stack, from hardware to software,\n通过控制整个范围，从硬件到软件\n\nApple was able to control the user experience and improve reliability.\n苹果能控制用户体验并提高可靠性\n\nThese competing business strategies were the genesis of the \"Mac\" versus \"PC\" division\n不同的商业策略是\"Mac vs PC 谁更好\"这种争论的起源\n\nthat still exists today... which is a misnomer, because they're both personal computers!\n这些争论如今还存在 \\N 不过\"Mac vs PC\"用词不对，因为它们都是个人计算机！\n\nBut whatever.\n但是随便啦\n\nTo survive the onslaught of low-cost PCs,\n为了在低成本个人计算机的竞争冲击下生存下来\n\nApple needed to up its game,\n苹果需要提高自身水平 \\N 提供比 PC 和 DOS 更好的用户体验\n\nand offer a user experience that PCs and DOS couldn't.\n苹果需要提高自身水平 \\N 提供比 PC 和 DOS 更好的用户体验\n\nTheir answer was the Macintosh, released in 1984.\n他们的答案是 Macintosh，于 1984 年发布\n\nThis ground breaking, reasonably-low-cost, all-in-one computer\n一台突破性 价格适中的一体式计算机 \\N 用的不是命令行界面，而是图形界面\n\nbooted not a command-line text-interface, but rather a graphical user interface,\n一台突破性 价格适中的一体式计算机 \\N 用的不是命令行界面，而是图形界面\n\nour topic for next week. See you then.\n我们下周讨论图形界面. 到时见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/26. 图形用户界面-Graphical User Interfaces.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨 我是 Carrie Anne 欢迎收看计算机科学速成课\n\nWe ended last episode with the 1984 release of Apple's Macintosh personal computer.\n我们上集最后 \\N 谈了苹果在1984年发布的 Macintosh\n\nIt was the first computer a regular person could buy with a graphical user interface\n这是普通人可以买到的 \\N 第一台带图形用户界面的计算机\n\nand a mouse to interact with it.\n还带一个鼠标\n\nThis was a radical evolution from the command line interfaces\n那时的计算机全是命令行 \\N 图形界面是个革命性进展\n\nfound on all other personal computers of the era.\n那时的计算机全是命令行 \\N 图形界面是个革命性进展\n\nInstead of having to remember...\n不必记住或猜正确的命令\n\nor guess...  the right commands to type in,\n我们不必记住或猜测正确的命令\n\na graphical user interface shows you what functions are possible.\n图形界面直接显示了，你可以做什么\n\nYou just have to look around the screen for what you want to do.\n只要在屏幕上找选项就行了\n\nIt's a \"point and click\" interface.\n这是一个\"选择并点击\"的界面\n\nAll of a sudden, computers were much more intuitive.\n突然间计算机更直观了\n\nAnybody, not just hobbyists or computer scientists,\n不只是爱好者或科学家能用计算机 \\N 任何人都可以用计算机解决问题\n\ncould figure things out all by themselves.\n不只是爱好者或科学家能用计算机 \\N 任何人都可以用计算机解决问题\n\nThe Macintosh is credited with taking Graphical User Interfaces, or GUIs, mainstream,\n人们认为是 Macintosh \\N 把图形用户界面（GUI）变成主流\n\nbut in reality they were the result of many decades of research.\n但实际上图形界面是数十年研究的成果\n\nIn previous episodes, we discussed some early interactive graphical applications,\n前几集，我们讨论了早期的交互式图形程序\n\nlike Sketchpad and Spacewar!, both made in 1962.\n比如 Sketchpad 和太空战争 \\N 都是1962年制作的\n\nBut these were one-off programs,\n但都是一次性项目，不是整合良好的体验\n\nand not whole integrated computing experiences.\n但都是一次性项目，不是整合良好的体验\n\nArguably, the true forefather of modern GUIs was Douglas Engelbart.\n现代图形界面的先驱 \\N 可以说是 道格拉斯·恩格尔巴特\n\nLet's go to the thought bubble!\n让我们进入思想泡泡！\n\nDuring World War 2, while Engelbart was stationed in the Philippines as a radar operator,\n二战期间 \\N 恩格尔巴特 驻扎在菲律宾做雷达操作员\n\nhe read Vannevar Bush's article on the Memex.\n他读了 万尼瓦尔·布什 的 Memex 文章\n\nThese ideas inspired him,\n这些文章启发了他\n\nand when his Navy service ended,\n当他海军服役结束时\n\nhe returned to school, completing a Ph.D. in 1955 at U.C. Berkeley.\n他回到学校  \\N 1955年在 UCB 取得博士学位\n\nHeavily involved in the emerging computing scene,\n他沉溺于新兴的计算机领域\n\nhe collected his thoughts in a seminal 1962 report,\n他在1962年一份开创性报告中 \\N 汇集了各种想法\n\ntitled: \"Augmenting Human Intellect\".\n报告名为：\"增强人类智力\"\n\nEngelbart believed that the complexity of the problems facing mankind\n恩格尔巴特认为，人类面临的问题 \\N 比解决问题的能力增长得更快\n\nwas growing faster than our ability to solve them.\n恩格尔巴特认为，人类面临的问题 \\N 比解决问题的能力增长得更快\n\nTherefore, finding ways to augment our intellect\n因此，找到增强智力的方法 \\N 似乎是必要且值得一做的目标\n\nwould seem to be both a necessary and a desirable goal.\n因此，找到增强智力的方法 \\N 似乎是必要且值得一做的目标\n\nHe saw that computers could be useful beyond just automation,\n他构想计算机不仅做自动化工作\n\nand be essential interactive tools for future knowledge workers to tackle complex problems.\n也可以成为未来知识型员工 \\N 应对复杂问题的工具\n\nFurther inspired by Ivan Sutherland's recently demonstrated Sketchpad,\n伊凡·苏泽兰 的\"几何画板\" \\N 进一步启发了 恩格尔巴特\n\nEngelbart set out to make his vision a reality, recruiting a team to build the oN-Line System.\n他决定动手把愿景变为现实 \\N 开始招募团队来做 oN-Line System\n\nHe recognized that a keyboard alone was insufficient\n他意识到如果只有键盘 \\N 对他想搭建的程序来说是不够的\n\nfor the type of applications he was hoping to enable.\n他意识到如果只有键盘 \\N 对他想搭建的程序来说是不够的\n\nIn his words:\n用他的话说：\n\n\"We envisioned problem-solvers using computer-aided working stations to augment their efforts.\n\"我们设想人们用计算机辅助工作站来增强工作\n\nThey required the ability to interact with information displays\n用户需要和屏幕上的信息互动\n\nusing some sort of device to move [a cursor] around the screen.\"\n用某种设备在屏幕上移动[光标]\"\n\nAnd in 1964, working with colleague Bill English,\n1964年，和同事比尔·英格利希的共同努力下\n\nhe created the very first computer mouse.\n他创造了第一个计算机鼠标，尾部有一根线\n\nThe wire came from the bottom of the device\n他创造了第一个计算机鼠标，尾部有一根线\n\nand looked very much like a rodent and the nickname stuck.\n看起来很像老鼠 \\N 因此\"鼠标\"这个名字沿用了下来\n\nThanks thought bubble!\n谢了思想泡泡！\n\nIn 1968, Engelbart demonstrated his whole system at the Fall Joint Computer Conference,\n1968年 恩格尔巴特 \\N 在\"秋季计算机联合会议\"展示了他的系统\n\nin what's often referred to as \"the mother of all demos\".\n这次演示 被视为如今所有演示的祖先\n\nThe demo was 90 minutes long and demonstrated many features of modern computing:\n演示有90分钟 \\N 展现了现代计算机的许多功能：\n\nbitmapped graphics,\n包括 位图图像\n\nvideo conferencing,\n视频会议\n\nword processing,\n文字处理\n\nand collaborative real-time editing of documents.\n和 实时协作编辑文件\n\nThere were also precursors to modern GUIs,\n还有现代图形界面的原型  比如鼠标和多窗口\n\nlike the mouse and multiple windows\n还有现代图形界面的原型  比如鼠标和多窗口\n\n- although they couldn't overlap.\n- 不过窗口不能重叠\n\nIt was way ahead of its time,\n远远先于那个时代\n\nand like many products with that label, it ultimately failed,\n就像其它\"跨时代\"的产品一样，它最终失败了\n\nat least commercially.\n至少商业上是这样\n\nBut its influence on computer researchers of the day was huge.\n但它对当时的计算机研究者影响巨大\n\nEngelbart was recognized for this watershed moment in computing with a Turing Award in 1997.\n恩格尔巴特 因此获得1997年图灵奖\n\nFederal funding started to reduce in the early 1970s,\n政府资金在 1970 年代初开始减少\n\nwhich we discussed two episodes ago.\n我们在两集前说过\\N（第24集：冷战和消费主义）\n\nAt that point, many of Engelbart's team, including Bill English,\n那时，恩格尔巴特团队里的许多人，包括比尔·英格利希\n\nleft and went to Xerox's newly formed Palo Alto Research Center,\n去了施乐公司新成立的\"帕洛阿尔托研究中心\"\n\nmore commonly known as Xerox PARC.\n更为人熟知的名字是 Xerox PARC\n\nIt was here that the first true GUI computer was developed:\n他们在这里开发了第一台带真正 GUI 的计算机：\n\nthe Xerox Alto, finished in 1973.\n施乐奥托  于1973年完成\n\nFor the computer to be easy to use,\n为了让计算机易于使用，需要的不只是花哨的图形\n\nit needed more than just fancy graphics.\n为了让计算机易于使用，需要的不只是花哨的图形\n\nIt needed to be built around a concept that people were already familiar with,\n还要借助一些人们已经熟悉的概念\n\nso they could immediately recognize how to use the interface with little or no training.\n让人们不用培训 就能很快明白如何使用\n\nXerox's answer was to treat the 2D screen like the top of a desk or desktop.\n施乐的答案是将2D屏幕当作\"桌面\"\n\nJust like how you can have many papers laid out on a desk,\n就像桌面上放很多文件一样\n\na user could have several computer programs open at once.\n用户可以打开多个程序 \\N 每个程序都在一个框里，叫\"窗口\"\n\nEach was contained in their own frame,\n用户可以打开多个程序 \\N 每个程序都在一个框里，叫\"窗口\"\n\nwhich offered a view onto the application called a window.\n用户可以打开多个程序 \\N 每个程序都在一个框里，叫\"窗口\"\n\nAlso like papers on a desk,\n就像桌上的文件一样\n\nthese windows could overlap, blocking the items behind them.\n窗口可以重叠，挡住后面的东西\n\nAnd there were desk accessories, like a calculator and clock,\n还有桌面配件，比如计算器和时钟\n\nthat the user could place on the screen and move around.\n用户可以把配件在屏幕上四处移动\n\nIt wasn't an exact copy of a desktop though.\n它不是现实桌面的完美复制，而是用桌面这种隐喻\n\nInstead, it was a metaphor of a desktop.\n它不是现实桌面的完美复制，而是用桌面这种隐喻\n\nFor this reason, surprisingly, it's called the Desktop Metaphor.\n因此叫\"桌面隐喻\"\n\nThere are many ways to design an interface like this,\n有很多方法来设计界面 \\N 但 Alto 团队用窗口，图标，菜单和指针来做\n\nbut the Alto team did it with windows, icons, menus, and a pointer\n有很多方法来设计界面 \\N 但 Alto 团队用窗口，图标，菜单和指针来做\n\n- what's called a WIMP interface.\n- 因此叫 WIMP 界面\n\nIt's what most desktop GUIs use today.\n如今大部分图形界面都用这个\n\nIt also offered a basic set of widgets,\n它还提供了一套基本部件\n\nreusable graphical building blocks, things like buttons, checkboxes, sliders, and tabs\n可复用的基本元素 \\N 比如按钮，打勾框，滑动条和标签页\n\nwhich were also drawn from real world objects to make them familiar.\n这些也来自现实世界，让人们有熟悉感\n\nGUI applications are constructed from these widgets,\nGUI 程序就是这些小组件组成的\n\nso let's try coding a simple example using this new programming paradigm.\n让我们试着写一个简单例子\n\nFirst, we have to tell the operating system that we need a new window to be created for our app.\n首先，我们必须告诉操作系统 \\N 为程序创建一个窗口\n\nWe do this through a GUI API.\n我们通过 GUI API 实现 \\N 需要指定窗口的名字和大小\n\nWe need to specify the name of the window and also its size.\n我们通过 GUI API 实现 \\N 需要指定窗口的名字和大小\n\nLet's say 500 by 500 pixels.\n假设是 500×500 像素\n\nNow, let's add some widgets - a text box and a button.\n现在再加一些小组件，一个文本框和一个按钮\n\nThese require a few parameters to create.\n创建它们需要一些参数\n\nFirst, we need to specify what window they should appear in,\n首先要指定出现在哪个窗口 \\N 因为程序可以有多个窗口\n\nbecause apps can have multiple windows.\n首先要指定出现在哪个窗口 \\N 因为程序可以有多个窗口\n\nWe also need to specify the default text, the X and Y location in the window, and a width and height.\n还要指定默认文字\\N 窗口中的 X,Y 位置  以及宽度和高度\n\nOk, so now we've got something that looks like a GUI app,\n好，现在我们有个 \\N 看起来像 GUI 程序的东西\n\nbut has no functionality.\n但它还没有功能\n\nIf you click the \"roll\" button, nothing happens.\n如果点 Roll 按钮，什么也不会发生\n\nIn previous examples we've discussed,\n在之前的例子中，代码是从上到下执行的\n\nthe code pretty much executes from top to bottom.\n在之前的例子中，代码是从上到下执行的\n\nGUIs, on the other hand, use what's called event-driven programming;\n但 GUI 是 \"事件驱动编程\"\n\ncode can fire at any time, and in different orders, in response to events.\n代码可以在任意时间执行 以响应事件\n\nIn this case, it's user driven events,\n这里是用户触发事件 \\N 比如点击按钮，选一个菜单项，或滚动窗口\n\nlike clicking on a button, selecting a menu item, or scrolling a window.\n这里是用户触发事件 \\N 比如点击按钮，选一个菜单项，或滚动窗口\n\nOr if a cat runs across your keyboard,\n或一只猫踩过键盘\n\nit's a bunch of events all at once!\n就会一次触发好多事件！\n\nLet's say that when the user clicks the \"roll\" button,\n假设当用户点 Roll 按钮\n\nwe want to randomly generate a number between 1 and 20,\n我们产生1到20之间的随机数\n\nand then show that value in our text box.\n然后在文本框中，显示这个数字\n\nWe can write a function that does just that.\n我们可以写一个函数来做\n\nWe can even get a little fancy and say if we get the number 20,\n我们还可以让它变有趣些，假设随机数是 20 \\N 就把背景颜色变成血红色！\n\nset the background color of the window to blood red!\n我们还可以让它变有趣些，假设随机数是 20 \\N 就把背景颜色变成血红色！\n\nThe last thing we need to do is hook this code up\n最后，把代码与\"事件\"相连 \\N 每次点按钮时  都触发代码\n\nso that it's triggered each time our button is clicked.\n最后，把代码与\"事件\"相连 \\N 每次点按钮时  都触发代码\n\nTo do this, we need to specify that our function \"handles\" this event for our button,\n那么，要设置事件触发时 \\N 由哪个函数来处理\n\nby adding a line to our initialize function.\n我们可以在初始化函数中，加一行代码来实现\n\nThe type of event, in this case, is a click event,\n我们要处理的，是\"点击\"事件 \\N 然后函数会处理这个事件\n\nand our function is the event handler for that event.\n我们要处理的，是\"点击\"事件 \\N 然后函数会处理这个事件\n\nNow we're done.\n现在完成了\n\nWe can click that button all day long,\n可以点按钮点上一整天 \\N 每次都会执行 rollD20 函数\n\nand each time, our \"roll D20\" function gets dispatched and executed.\n可以点按钮点上一整天 \\N 每次都会执行 rollD20 函数\n\nThis is exactly what's happening behind the scenes\n这就是程序背后的原理\n\nwhen you press the little bold button in a text editor, or select shutdown from a dropdown menu\n在编辑器里点 粗体  或菜单里选 关机 \\N 一个处理该事件的函数会触发\n\n- a function linked to that event is firing.\n在编辑器里点 粗体  或菜单里选 关机 \\N 一个处理该事件的函数会触发\n\nHope I don't roll a 20.\n希望不会随机到 20\n\nAhhhh!\n啊！！！\n\nOk, back to the Xerox Alto!\n好，现在回到施乐奥托！\n\nRoughly 2000 Altos were made, and used at Xerox and given to University labs.\n大约制作了2000台奥托\\N 有的在施乐公司内部用，有的送给大学实验室\n\nThey were never sold commercially.\n从来没有商业出售过\n\nInstead, the PARC team kept refining the hardware and software,\n然而，PARC 团队不断完善硬件和软件\n\nculminating in the Xerox Star system, released in 1981.\n最终于1981年发布了 施乐之星系统\n\nThe Xerox Star extended the desktop metaphor.\n施乐之星扩展了\"桌面隐喻\"\n\nNow, files looked like pieces of paper,\n现在文件看起来就像一张纸 \\N 还可以存在文件夹里\n\nand they could be stored in little folders,\n现在文件看起来就像一张纸 \\N 还可以存在文件夹里\n\nall of which could sit on your desktop, or be put away into digital filing cabinets.\n这些都可以放桌面上，或数字文件柜里\n\nIt's a metaphor that sits ontop of the underlying file system.\n这样来隐喻底层的文件系统\n\nFrom a user's perspective, this is a new level of abstraction!\n从用户角度来看，是一层新抽象！\n\nXerox, being in the printing machine business, also advanced text and graphics creation tools.\n施乐卖的是印刷机 \\N 但在文本和图形制作工具领域也有领先\n\nFor example, they introduced the terms: cut, copy and paste.\n例如，他们首先使用了\\N  \"剪切\"\"复制\"\"粘贴\"这样的术语\n\nThis metaphor was drawn\n这个比喻来自编辑打字机文件\n\nfrom how people dealt with making edits in documents written on typewriters.\n这个比喻来自编辑打字机文件\n\nYou'd literally cut text out with scissors, and then paste it, with glue,\n真的是剪刀\"剪切\" \\N 然后胶水\"粘贴\" 到另一个文件\n\ninto the spot you wanted in another document.\n真的是剪刀\"剪切\" \\N 然后胶水\"粘贴\" 到另一个文件\n\nThen you'd photocopy the page to flatten it back down into a single layer,\n然后再复印一次，新文件就是一层了\n\nmaking the change invisible.\n看不出编辑的痕迹\n\nThank goodness for computers!\n感谢计算机的出现！\n\nThis manual process was moot with the advent of word processing software,\n文字处理软件出现后 \\N 这种手工做法就消失了\n\nwhich existed on platforms like the Apple II and Commodore PET.\nApple II 和 Commodore PET 上有文字处理软件\n\nBut Xerox went way beyond the competition\n但施乐在这点上走的更远\n\nwith the idea that whatever you made on the computer\n无论你在计算机上做什么 \\N 文件打印出来应该长得一样\n\nshould look exactly like the real world version, if you printed it out.\n无论你在计算机上做什么 \\N 文件打印出来应该长得一样\n\nThey dubbed this What-You-See-Is-What-You-Get or WYSIWYG.\n他们叫这个\"所见即所得\"\n\nUnfortunately, like Engelbart's oN-Line System,\n不幸的是，就像恩格尔巴特的 oN-Line System\n\nthe Xerox Star was ahead of its time.\n施乐之星也领先于那个时代，销售量不高\n\nSales were sluggish\n施乐之星也领先于那个时代，销售量不高\n\nbecause it had a price tag equivalent to nearly $200,000 today for an office setup.\n因为在办公室里配一个，相当如今20万美元\n\nIt also didn't help that the IBM PC launched that same year,\nIBM 同年推出了 IBM PC\n\nfollowed by a tsunami of cheap \"IBM Compatible\" PC Clones.\n之后便宜的\"IBM兼容\"计算机席卷市场\n\nBut the great ideas that PARC researchers had been cultivating\n但 PARC 研究人员花了十几年做的这些 \\N 没有被浪费\n\nand building for almost a decade didn't go to waste.\n但 PARC 研究人员花了十几年做的这些 \\N 没有被浪费\n\nIn December of 1979, a year and a half before the Xerox Star shipped,\n1979年12月，施乐之星出货前一年半\n\na guy you may have heard of visited: Steve Jobs.\n有个人去施乐公司参观 \\N 你可能听说过这个人：史蒂夫·乔布斯\n\nThere's a lot of lore surrounding this visit,\n这次参观有很多传闻\n\nwith many suggesting that Steve Jobs and Apple stole Xerox's ideas.\n许多人认为\\N 乔布斯和苹果偷走了施乐的创意\n\nBut that simply isn't true.\n但那不是事实\n\nIn fact, Xerox approached Apple, hoping to partner with them.\n事实上是施乐公司主动找苹果，希望合作\n\nUltimately, Xerox was able to buy a million dollar stake in Apple\n最终施乐还买了苹果的一百万美元股份\n\nbefore its highly anticipated I.P.O.\n在苹果备受瞩目的 首次公开募股(IPO) 前买的\n\n-but it came with an extra provision:\n但一个额外条款是：\n\n\"disclose everything cool going on at Xerox PARC\".\n\"公布一切施乐研究中心正在进行的酷工作\"\n\nSteve knew they had some of the greatest minds in computing,\n史蒂夫知道他们很厉害\n\nbut he wasn't prepared for what he saw.\n但他完全没预想到这些\n\nThere was a demonstration of Xerox's graphical user interface,\n其中有个演示是\n\nrunning on a crisp, bitmapped display,\n一个清晰的位图显示器上，运行着施乐公司的图形界面 \\N 操作全靠鼠标直观进行\n\nall driven with intuitive mouse input.\n一个清晰的位图显示器上，运行着施乐公司的图形界面 \\N 操作全靠鼠标直观进行\n\nSteve later said, \"It was like a veil being lifted from my eyes.\n史蒂夫后来说：\"就像拨开了眼前的一层迷纱\n\nI could see the future of what computing was destined to be.\"\n我可以看到计算机产业的未来\"\n\nSteve returned to Apple with his engineering entourage,\n史蒂夫和随行的工程师回到苹果公司，开始开发新功能\n\nand they got to work inventing new features,\n史蒂夫和随行的工程师回到苹果公司，开始开发新功能\n\nlike the menu bar and a trash can to store files to be deleted;\n比如菜单栏和垃圾桶，垃圾桶存删除文件\n\nit would even bulge when full - again with the metaphors.\n满了甚至会膨胀 - 再次使用了隐喻\n\nApple's first product with a graphical user interface, and mouse,\n苹果第一款有图形界面和鼠标的产品\n\nwas the Apple Lisa, released in 1983.\n是 1983 年发行的 Apple Lisa\n\nIt was a super advanced machine, with a super advanced price\n一台超级先进的机器，标了\"超级先进\"的价格\n\n- almost 25 thousand dollars today.\n- 差不多是如今的 25000 美元\n\nThat was significantly cheaper than the Xerox Star,\n虽然比施乐之星便宜不少\n\nbut it turned out to be an equal flop in the market.\n但在市场上同样失败\n\nLuckily, Apple had another project up its sleeve:\n幸运的是，苹果还有另一个项目：\n\nThe Macintosh, released a year later, in 1984.\nMacintosh，于 1984 年发布\n\nIt had a price of around 6,000 dollars today - a quarter of the Lisa's cost.\n价格大约是如今的6000美元 - Lisa 的四分之一\n\nAnd it hit the mark, selling 70,000 units in the first 100 days.\n它成功了，开售100天就卖了7万台\n\nBut after the initial craze, sales started to falter,\n但在最初的狂潮后，销售额开始波动\n\nand Apple was selling more of its Apple II computers than Macs.\n苹果公司卖的 Apple II 比 Mac 多\n\nA big problem was that no one was making software for this new machine\n一个大问题是：没人给这台新机器做软件\n\nwith it's new radical interface.\n一个大问题是：没人给这台新机器做软件\n\nAnd it got worse. The competition caught up fast.\n之后情况变得更糟，竞争对手赶上来了\n\nSoon, other personal computers had primitive,\n不久，其它价格只有 Mac 几分之一的个人计算机 \\N 有了原始但可用的图形界面\n\nbut usable graphical user interfaces on computers a fraction of the cost.\n不久，其它价格只有 Mac 几分之一的个人计算机 \\N 有了原始但可用的图形界面\n\nConsumers ate it up, and so did PC software developers.\n消费者认可它们， PC 软件开发者也认可\n\nWith Apple's finances looking increasingly dire,\n随着苹果的财务状况日益严峻 \\N 以及和苹果新 CEO 约翰·斯卡利 的关系日益紧张\n\nand tensions growing with Apple's new CEO, John Sculley,\n随着苹果的财务状况日益严峻 \\N 以及和苹果新 CEO 约翰·斯卡利 的关系日益紧张\n\nSteve Jobs was ousted.\n史蒂夫乔布斯被赶出了苹果公司\n\nA few months later, Microsoft released Windows 1.0.\n几个月后，微软发布了 Windows 1.0\n\nIt may not have been as pretty as Mac OS,\n它也许不如 Mac OS 漂亮\n\nbut it was the first salvo in what would become a bitter rivalry\n但让微软在市场中站稳脚跟 \\N 奠定了统治地位\n\nand near dominance of the industry by Microsoft.\n但让微软在市场中站稳脚跟 \\N 奠定了统治地位\n\nWithin ten years, Microsoft Windows was running on almost 95% of personal computers.\n十年内，95％的个人计算机上都有微软的 Windows\n\nInitially, fans of Mac OS could rightly claim superior graphics and ease-of-use.\n最初，Mac OS 的爱好者还可以说\\N  Mac 有卓越的图形界面和易用性\n\nThose early versions of Windows were all built on top of DOS,\nWindows 早期版本都是基于 DOS \\N 而 DOS 设计时 没想过运行图形界面\n\nwhich was never designed to run GUIs.\nWindows 早期版本都是基于 DOS \\N 而 DOS 设计时 没想过运行图形界面\n\nBut, after Windows 3.1,\n但 Windows 3.1 之后\n\nMicrosoft began to develop a new consumer-oriented OS\n微软开始开发新的，\\N 面向消费者的 GUI 操作系统\n\nwith upgraded GUI called Windows 95.\n叫 Windows 95\n\nThis was a significant rewrite that offered much more than just polished graphics.\n这是一个意义非凡的版本 \\N 不仅提供精美的界面\n\nIt also had advanced features Mac OS didn't have,\n还有 Mac OS 没有的高级功能\n\nlike program multitasking and protected memory.\n比如\"多任务\"和\"受保护内存\"\n\nWindows 95 introduced many GUI elements still seen in Windows versions today,\nWindows 95 引入了许多 \\N 如今依然见得到的 GUI 元素\n\nlike the Start menu, taskbar, and Windows Explorer file manager.\n比如开始菜单，任务栏和 Windows 文件管理器\n\nMicrosoft wasn't infallible though.\n不过微软也失败过\n\nLooking to make the desktop metaphor even easier and friendlier,\n为了让桌面更简单友好 \\N 微软开发了一个产品叫 Microsoft Bob\n\nit worked on a product called Microsoft Bob,\n为了让桌面更简单友好 \\N 微软开发了一个产品叫 Microsoft Bob\n\nand it took the idea of using metaphors to an extreme.\n将比喻用到极致\n\nNow you had a whole virtual room on your screen,\n现在屏幕上有了一个虚拟房间\n\nwith applications embodied as objects that you could put on tables and shelves.\n程序是物品，可以放在桌子和书架上\n\nIt even came with a crackling fireplace and a virtual dog to offer assistance.\n甚至还有噼啪作响的壁炉 \\N 和提供帮助的虚拟狗狗\n\nAnd you see those doors on the sides?\n你看到那边的门没？\n\nYep, those went to different rooms in your computer\n是的，那些门通往不同房间 \\N 房间里有不同程序\n\nwhere different applications were available.\n是的，那些门通往不同房间 \\N 房间里有不同程序\n\nAs you might have guessed,\n你可能猜到了，它没有获得成功\n\nit was not a success.\n你可能猜到了，它没有获得成功\n\nThis is a great example of how the user interfaces we enjoy today\n这是一个好例子，说明如今的用户界面\n\nare the product of what's essentially natural selection.\n是自然选择后的结果\n\nWhether you're running Windows, Mac, Linux, or some other desktop GUI,\n无论你用的是 \\N Windows，Mac，Linux 或其他 GUI\n\nit's almost certainly an evolved version of the WIMP paradigm first introduced on the Xerox Alto.\n几乎都是施乐奥托 WIMP 的变化版\n\nAlong the way, a lot of bad ideas were tried, and failed.\n一路上，人们试了各种做法并失败了\n\nEverything had to be invented, tested, refined, adopted or dropped.\n一切都必须发明，测试，改进，适应或抛弃\n\nToday, GUIs are everywhere and while they're good,\n如今，图形界面无处不在 \\N 使用体验一般只是可以接受，而不是非常好\n\nthey are not always great.\n如今，图形界面无处不在 \\N 使用体验一般只是可以接受，而不是非常好\n\nNo doubt you've experienced design-related frustrations\n你肯定体验过差劲的设计\n\nafter downloading an application, used someone else's phone,\n比如下载了很烂的 App，用过别人糟糕的手机\n\nor visited a website. And for this reason,\n或者看到过很差的网站，因此\n\ncomputer scientists and interface designers continue to work hard\n计算机科学家和界面设计师 \\N 会继续努力工作\n\nto craft computing experiences that are both easier and more powerful.\n做出更好更强大的界面\n\nUltimately, working towards Engelbart's vision of augmenting human intellect.\n朝着恩格尔巴特\"增强人类智能\"的愿景努力\n\nI'll see you next week.\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/27. 3D 图形-3D Graphics.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nOver the past five episodes,\n在过去五集\n\nwe've worked up from text-based teletype interfaces to pixelated bitmapped graphics.\n我们从基于电传打字机的命令行界面 \\N 讲到图形怎么显示到屏幕上\n\nThen, last episode,we covered Graphical User Interfaces and all\n再到上集的 图形用户界面（GUI）\n\ntheir \"Ooey Gooey\" richness.\n以及图形界面的美味\n\nAll of these examples have been 2D. But of course \"we are living in a 3D world\n之前的例子都是2D, 但我们生活的世界是3D的\n\nand I'm a 3 dimensional girl!\n我也是个三维 girl~\n\nSo today, we're going to talk about some fundamental methods in 3D computer graphics\n所以今天，我们讲3D图形的基础知识\n\nand how you render them onto a 2D screen.\n以及如何渲染 3D 图形到 2D 屏幕上\n\nAs we discussed in episode 24 we can write functions that draw a line between any two points like A and B.\n24集中说过 \\N 可以写一个函数，从A到B画一条线\n\nBy manipulating the X and Y coordinates of points A and B, we can manipulate the line.\n通过控制 A 和 B 的(X,Y)坐标，可以控制一条线\n\nIn 3D graphics, points have not just two coordinates, but three -- X, Y and Z.\n在3D图像中, 点的坐标不再是两点, 而是三点, X,Y,Z\n\nOr \"zee\" but I'm going to say \"zed\".\n或读\"Zee\"，但我之后会读成\"Zed\"\n\nOf course, we don't have X/Y/Z coordinates on a 2D computer screen\n当然，2D的电脑屏幕上\\N不可能有 XYZ 立体坐标轴\n\nso graphics algorithms are responsible for \"flattening\" 3D coordinates onto a 2D plane.\n所以有图形算法 \\N 负责把3D坐标\"拍平\"显示到2D屏幕上\n\nThis process is known as 3D Projection.\n这叫\"3D投影\"\n\nOnce all of the points have been converted from 3D to 2D\n所有的点都从3D转成2D后\n\nwe can use the regular 2D line drawing function to connect the dots… literally.\n就可以用画2D线段的函数 来连接这些点\n\nThis is called Wireframe Rendering.\n这叫 \"线框渲染\"\n\nImagine building a cube out of chopsticks, and shining a flashlight on it.\n想象用筷子做一个立方体，然后用手电筒照它\n\nThe shadow it casts onto your wall - its projection - is flat.\n墙上的影子就是投射，是平的\n\nIf you rotate the cube around\n如果旋转立方体\n\nyou can see it's a 3D object, even though it's a flat projection.\n投影看起来会像 3D 物体，尽管是投影面是平的\n\nThis transformation from 3D to 2D is exactly what your computer is doing\n电脑也是这样3D转2D\n\njust with a lot more math… and less chopsticks.\n只不过用大量数学，而不是筷子\n\nThere are several types of 3D Projection.\n3D投影有好几种\n\nWhat you're seeing right now is an Orthographic Projection\n你现在看到的，叫 正交投影\n\nwhere, for example, the parallel sides in the cube appear as parallel in the projection.\n立方体的各个边，在投影中互相平行\n\nIn the real 3D world through, parallel lines converge as they get further from the viewer\n在真实3D世界中,平行线段会在远处收敛于一点\n\nlike a road going to the horizon.\n就像远处的马路汇聚到一点\n\nThis type of 3D projection is called Perspective Projection .\n这叫 透视投射\n\nIt's the same process, just with different math.\n过程是类似的，只是数学稍有不同\n\nSometimes you want perspective and sometimes you don't --\n有时你想要透视投影，有时不想\n\nthe choice is up to the developer.\n具体取决于开发人员\n\nSimple shapes, like cubes, are easily defined by straight lines.\n如果想画立方体这种简单图形，直线就够了\n\nBut for more complex shapes, triangles are better\n但更复杂的图形，三角形更好\n\n-- what are called polygons in 3D graphics.\n在3D图形学中 \\N 我们叫三角形\"多边形\"(Polygons)\n\nLook at this beautiful teapot made out of polygons.\n看看这个多边形组成的 漂亮茶壶\n\nA collection of polygons like this is a mesh\n一堆多边形的集合叫 网格\n\nThe denser the mesh, the smoother the curves and the finer the details.\n网格越密，表面越光滑，细节越多\n\nBut, that also increases the polygon count, which means more work for the computer\n但意味着更多计算量\n\nGame designers have to carefully balance model fidelity vs. polygon count,\n游戏设计者要平衡角色的真实度 \\N 和多边形数量\n\nbecause if the count goes too high\n如果数量太多 \\N 帧率会下降到肉眼可感知，用户会觉得卡\n\nthe framerate of an animation drops below what users perceive as smooth.\n如果数量太多 \\N 帧率会下降到肉眼可感知，用户会觉得卡\n\nFor this reason, there are algorithms for simplifying meshes.\n因此有算法用来简化网格\n\nThe reason triangles are used,\n之所以三角形更常用 \\N 而不是用正方形，或其它更复杂的图形\n\nand not squares, or polygons, or some other more complex shape\n之所以三角形更常用 \\N 而不是用正方形，或其它更复杂的图形\n\nis simplicity:\n是因为三角形的简单性\n\nthree points in space unambiguously define a plane.\n空间中  三点定义一个平面\n\nIf you give me three points in a 3D space, I can draw a plane through it\n如果给3个3D点，我能画出一个平面\n\nthere is only one.. single.. answer.\n而且只有这一个答案\n\nThis isn't guaranteed to be true for shapes with four or more points.\n4个或多于4个点就不一定了\n\nAlso two points aren't enough to define a plane, only a line,\n而2个点不够定义平面，只能定义线段\n\nso three is the perfect and minimal number. Triangles for the win!\n所以3是最完美的数字，三角形万岁\n\nWireframe rendering is cool and all - sorta retro - but of course 3D graphics can also be filled.\n线框渲染 虽然很酷，但3D图像需要填充\n\nThe classic algorithm for doing this is called Scanline Rendering,\n填充图形的经典算法叫 扫描线渲染 (Scanline Rendering) \\N 于1967年诞生在犹他州大学\n\nfirst developed in 1967 at the University of Utah\n填充图形的经典算法叫 扫描线渲染 (Scanline Rendering) \\N 于1967年诞生在犹他州大学\n\nFor a simple example, let's consider just one polygon.\n为了例子简单，我们只看一个多边形\n\nOur job here is to figure out how this polygon translates to filled pixels on a computer screen\n我们要思考 \\N 这个多边形如何转成一块填满像素的区域\n\nso let's first overlay a grid of pixels to fill\n我们先铺一层像素网格\n\nThe scanline algorithm starts by reading the three points that make up the polygon\n扫描线算法 先读多边形的3个点\n\nand finding the lowest and highest Y values.  It will only consider rows between these two points.\n找最大和最小的Y值，只在这两点间工作\n\nThen, the algorithm works down one row at a time.\n然后算法从上往下，一次处理一行\n\nIn each row, it calculates where a line running through\n计算每一行和多边形相交的2个点\n\nthe center of a row - intersects with the side of the polygon.\n计算每一行和多边形相交的2个点\n\nBecause polygons are triangles, if you intersect one line, you have to intersect with another.\n因为是三角形,如果相交一条边, 必然相交另一条\n\nIt's guaranteed!\n因为是三角形,如果相交一条边, 必然相交另一条\n\nThe job of the scanline algorithm is to fill in the pixels between the two intersections.\n扫描线算法 会填满2个相交点之间的像素\n\nLet's see how this works.\n来看个具体例子\n\nOn the first row we look at we intersect here and here.\n第一行 相交于这里和这里\n\nThe algorithm then colors in all pixels between those two intersections.\n算法把两点间填满颜色\n\nAnd this just continues, row by row, which is why it's called Scan... Line... Rendering.\n然后下一行，再下一行，所以叫 扫描..线..渲染\n\nWhen we hit the bottom of the polygon, we're done.\n扫到底部就完成了\n\nThe rate at which a computer fills in polygons is called the fillrate.\n填充的速度叫 fillrate（填充速率）\n\nAdmittedly, this is a pretty ugly filled polygon. It has what are known as \"Jaggies\" rough edges.\n当然 这样的三角形比较丑，边缘满是锯齿\n\nThis effect is less pronounced when using smaller pixels.\n当像素较小时 就不那么明显\n\nBut nonetheless, you see these in games all the time, especially on lower powered platforms.\n但尽管如此 \\N 你肯定在游戏里见过这种效果，特别是低配电脑\n\nOne method to soften this effect is Antialiasing.\n一种减轻锯齿的方法叫\\N  抗锯齿(Antialiasing)\n\nInstead of filling pixels in a polygon with the same color,\n与其每个像素都涂成一样的颜色\n\nwe can adjust the color based on how much the polygon cuts through each pixel\n可以判断多边形切过像素的程度，来调整颜色\n\nIf a pixel is entirely inside of a polygon,it gets fully colored.\n如果像素在多边形内部，就直接涂颜色\n\nBut if the polygon only grazes a pixel, it'll get a lighter shade.\n如果多边形划过像素，颜色就浅一些\n\nThis feathering of the edges is much more pleasant to the eyes.\n这种边缘羽化的效果 看着更舒服些\n\nAntialiasing is used all over the place, including in 2D graphics, like fonts and icons.\n抗锯齿 被广泛使用，比如字体和图标\n\nIf you lean in real close to your monitor..\n如果你把脸贴近屏幕\n\nCloser, Closer.\n近点..再近点\n\nYou'll see all the fonts in your browser are Antialiased. So smooth!\n你能看到浏览器里字体是抗锯齿的，超平滑\n\nIn a 3D scene, there are polygons that are part objects in the back, near the front,and just about everywhere.\n在3D场景中，多边形到处都是\n\nOnly some are visible,\n但只有一部分能看见\n\nbecause some objects are hidden behind other objects in the scene\n因为其它的被挡住了\n\n-- what's called occlusion .\n这叫 遮挡\n\nThe most straightforward way to handle this is to use a sort algorithm,\n最直接的处理办法是用排序算法\n\nand arrange all the polygons in the scene from farthest to nearest, then render them in that order.\n从远到近排列，然后从远到近渲染\n\nThis is called the Painter's Algorithm , because painters also have to start with the background\n这叫 画家算法 因为画家也是先画背景\n\nand then increasingly work up to foreground elements.\n然后再画更近的东西\n\nConsider this example scene with three overlapping polygons.\n看这个例子，有3个重叠的多边形\n\nTo make things easier to follow, we're going to color the polygons differently.\n为了简单，我们画成不同颜色\n\nAlso for simplicity, we'll assume these polygons are all parallel to the screen\n同时，假设3个多边形都和屏幕平行\n\nbut in a real program, like a game,\n但在实际应用中, 比如游戏里\\N多边形可能是倾斜的\n\nthe polygons can be tilted in 3D space.\n但在实际应用中, 比如游戏里\\N多边形可能是倾斜的\n\nOur three polygons, A B and C… are at distance 20, 12 and 14.\n3个多边形A,B,C，距离20,12,14\n\nThe first thing the Painter's Algorithm does is sort all the polygons, from farthest to nearest.\n画家算法的第一件事，是从远到近排序\n\nNow that they're in order, we can use scanline rendering to fill each polygon, one at a time.\n现在有序了，我们可以用 扫描线算法 填充多边形，一次填一个\n\nWe start with Polygon A, the farthest one away.\n我们从最远的A开始\n\nThen we repeat the process for the next farthest polygon, in this case, C.\n然后重复这个过程，填充第二远的C\n\nAnd then we repeat this again, for Polygon B.\n然后是 B\n\nNow we're all done, and you can see the ordering is correct. The polygons that are closer, are in front!\n现在完成了，可以看到顺序是对的，近的多边形在前面！\n\nAn alternative method for handling occlusion is called Z-Buffering .\n还有一种方法叫 深度缓冲\n\nIt achieves the same output as before, but with a different algorithm.\n它和之前的算法做的事情一样，但方法不同\n\nLet's go back to our previous example, before it was sorted.\n我们回到之前的例子，回到排序前的状态\n\nThat's because this algorithm doesn't need to sort any polygons, which makes it faster.\n因为这个算法不用排序，所以速度更快\n\nIn short, Z-buffering keeps track of the closest distance\n简而言之，Z-buffering 算法会记录\n\nto a polygon for every pixel in the scene.\n场景中每个像素和摄像机的距离\n\nIt does this by maintaining a Z-Buffer, which is just a matrix of values that sits in memory.\n在内存里存一个数字矩阵\n\nAt first, every pixel is initialized to infinity.\n首先，每个像素的距离被初始化为\"无限大\"\n\nThen Z-buffering starts with the first polygon in its list. In this case, that's A.\n然后 Z-buffering 从列表里第一个多边形开始处理，也就是A\n\nIt follows the same logic as the scanline algorithm, but instead of coloring in pixels,\n它和扫描线算法逻辑相同，但不是给像素填充颜色\n\nit checks the distance of the polygon versus what's recorded in its Z-Buffer.\n而是把多边形的距离\\N和 Z-Buffer 里的距离进行对比\n\nIt records the lower of the two values.\n它总是记录更低的值\n\nFor our Polygon A, with a distance of 20, it wins against infinity every time.\nA距离20，20小于\"无限大\"，所以缓冲区记录20\n\nWhen it's done with Polygon A, it moves on to the next polygon in its list, and the same thing happens.\n算完A之后算下一个，以此类推\n\nNow, because we didn't sort the polygons,\n因为没对多边形排序\n\nit's not always the case that later polygons overwrite high values.\n所以后处理的多边形并不总会覆盖前面的\n\nIn the case of Polygon C,\n对于多边形C\n\nonly some of the values in the Z-buffer get new minimum distances.\n缓冲区里只有一部分值会被多边形C的距离值覆盖\n\nThis completed Z-buffer is used in conjunction with a fancier version of scanline rendering\nZ缓冲区完成后，会和\"扫描线\"算法的改进高级版配合使用\n\nthat not only tests for line intersection,\n不仅可以勘测到线的交叉点\n\nbut also does a look up to see if that pixel will even be visible in the final scene.\n还可以知道某像素是否在最终场景中可见\n\nIf it's not, the algorithm skips it and moves on.\n如果不可见，扫描线算法会跳过那个部分\n\nAn interesting problem arises when two polygons have the same distance,\n当两个多边形距离相同时 \\N 会出现一个有趣问题\n\nlike if Polygon A and B are both at a distance of 20. Which one do you draw on top?\n比如多边形 A 和 B 距离都是 20, 哪个画上面?\n\nPolygons are constantly being shuffled around in memory and changing their access order.\n多边形会在内存中移来移去，访问顺序会不断变化\n\nPlus, rounding errors are inherent in floating point computations.\n另外,计算浮点数有舍入误差\n\nSo, which one gets drawn on top is often unpredictable.\n所以哪一个画在上面, 往往是不可预测的\n\nThe result is a flickering effect called Z-Fighting, which if you've played 3D games no doubt encountered.\n导致出现 Z-fighting 效果 \\N 如果你玩过3D游戏，肯定见过\n\nSpeaking of glitches, another common optimization in 3D graphics is called Back-Face Culling.\n说起 故障，3D游戏中有个优化叫 背面剔除\n\nIf you think about it, a triangle has two sides, a front and a back.\n你想想,三角形有两面,正面和背面\n\nWith something like the head of an avatar, or the ground in a game,\n游戏角色的头部或地面，只能看到朝外的一面\n\nyou should only ever see one side -- the side facing outwards.\n游戏角色的头部或地面，只能看到朝外的一面\n\nSo to save processing time, the back-side of polygons are often ignored in the rendering pipeline\n所以为了节省处理时间，会忽略多边形背面\n\nwhich cuts the number of polygon faces to consider in half.\n减了一半多边形面数\n\nThis is great, except when there's a bug that lets you get inside of those objects,and look outwards.\n这很好,但有个bug是 如果进入模型内部往外看\n\nThen the avatar head or ground becomes invisible.\n头部和地面会消失\n\nMoving on. We need to talk about lighting -- also known as shading\n继续，我们讲灯光，也叫 明暗处理\n\nbecause if it's a 3D scene, the lighting should vary over the surface of objects.\n因为3D场景中, 物体表面应该有明暗变化\n\nLet's go back to our teapot mesh.\n我们回到之前的茶壶网格\n\nWith scanline rendering coloring in all the polygons, our teapot looks like this.\n用\"扫描线\"算法渲染所有多边形后，茶壶看起来像这样\n\nNot very 3D.\n没什么 3D 感\n\nSo, let's add some lighting to enhance the realism!\n我们来加点灯光，提高真实感\n\nAs an example, we'll pick 3 polygons from different parts of our teapot.\n为了举例，我们从茶壶上挑3个不同位置的多边形\n\nUnlike our previous examples, we're now going to consider how these polygons are oriented in 3D space\n和之前的例子不同，这次要考虑这些多边形面对的方向\n\nthey're no longer parallel to the screen, but rather tilted in different 3D directions.\n它们不平行于屏幕，而是面对不同方向\n\nThe direction they face is called the Surface Normal ,\n他们面对的方向叫 \" 表面法线 \"\n\nand we can visualize that direction with a little 3D arrow that's perpendicular to the polygon's surface.\n我们可以用一个垂直于表面的小箭头\\N来显示这个方向\n\nNow let's add a light source.\n现在加个光源\n\nEach polygon is going to be illuminated a different amount. Some will appear brighter\n每个多边形被照亮的程度不同 有的更亮\n\nbecause their angle causes more light to be reflected towards the viewer.\n因为面对的角度\\N导致更多光线反射到观察者\n\nFor example, the bottom-most polygon is tilted downwards,\n举个例子，底部的多边形向下倾斜\n\naway from the light source, which means it's going to be dark.\n远离光源，所以更暗一些\n\nIn a similar way, the rightmost polygon is slightly facing away from the light,\n类似的，最右的多边形更背对光源\n\nso it will be partially illuminated.\n所以只有部分照亮\n\nAnd finally, there's the upper-left polygon.\n最后是左上角的多边形\n\nIts angle means that it will reflect light from the light source towards our view.\n因为它面对的角度  意味着会把光线反射到我们这里\n\nSo, it'll appear bright.\n所以会显得更亮\n\nIf we do this for every polygon, our teapot looks like this which is much more realistic!\n如果对每个多边形执行同样的步骤，看上去会更真实!\n\nThis approach is called Flat Shading, and it's the most basic lighting algorithm.\n这叫 平面着色，是最基本的照明算法\n\nUnfortunately, it also makes all those polygon boundaries really noticeable\n不幸的是，这使多边形的边界非常明显，看起来不光滑\n\nand the mesh doesn't look smooth.\n不幸的是，这使多边形的边界非常明显，看起来不光滑\n\nFor this reason, more advanced lighting algorithms were developed,\n因此开发了更多算法\n\nsuch as Gouraud Shading and Phong Shading .\n比如 高洛德着色 和 冯氏着色\n\nInstead of coloring in polygons using just one colour,\n不只用一种颜色给整个多边形上色\n\nthey vary the colour across the surface in clever ways,\n而是以巧妙的方式改变颜色\n\nwhich results in much nicer output.\n得到更好的效果\n\nWe also need to talk about textures ,\n我们还要说下\" 纹理 \"\n\nwhich in graphics refers to the look of a surface,rather than its feel.\n纹理在图形学中指外观，而不是手感\n\nLike with lighting, there are many algorithms with all sorts of fancy effects.\n就像照明算法一样，\\N 纹理也有多种算法，来做各种花哨效果\n\nThe simplest is texture mapping .\n最简单的是 纹理映射\n\nTo visualize this process,let's go back to our single polygon.\n为了理解纹理映射，回到单个多边形\n\nWhen we're filling this in, using scanline rendering,\n用\"扫描线算法\"填充时\n\nwe can look up what color to use at every pixel according to a texture image saved in memory.\n可以看看内存内的纹理图像 决定像素用什么颜色\n\nTo do this, we need a mapping between the polygon's coordinates and the texture's coordinates.\n为了做到这点，\\N 需要把多边形坐标和纹理坐标对应起来\n\nLet's jump to the first pixel that scanline rendering needs to fill in.\n我们来看看\"扫描线算法\"要填充的第一个像素\n\nThe texturing algorithm will consult the texture in memory,\n纹理算法会查询纹理\n\ntake the average color from the corresponding region, and fill the polygon accordingly.\n从相应区域取平均颜色，并填充多边形\n\nThis process repeats for all pixels in the polygon, and that's how we get textures.\n重复这个过程，就可以获得纹理\n\nIf you combine all the techniques we've talked about this episode, you get a wonderfully funky little teapot.\n如果结合这集提到的所有技巧 \\N 会得到一个精美的小茶壶\n\nAnd this teapot can sit in an even bigger scene, comprised of millions of polygons.\n这个茶壶可以放进更大的场景里 \\N 场景由上百万个多边形组成\n\nRendering a scene like this takes a fair amount of computation.\n渲染这样的场景需要大量计算\n\nBut importantly, it's the same type of calculations being performed\n但重要的是，再大的场景，过程都是一样的 \\N 一遍又一遍，处理所有多边形\n\nover and over and over again for many millions of polygons –\n但重要的是，再大的场景，过程都是一样的 \\N 一遍又一遍，处理所有多边形\n\nscanline filling, antialiasing, lighting, and texturing.\n扫描线填充, 抗锯齿, 光照, 纹理化\n\nHowever there are a couple of ways to make this much faster!\n然而，有几种方法可以加速渲染\n\nFirst off, we can speed things up by having special hardware\n首先，我们可以为这种特定运算 \\N 做专门的硬件来加快速度，让运算快如闪电\n\nwith extra bells and whistles just for these specific types of computations, making them lightning fast.\n首先，我们可以为这种特定运算 \\N 做专门的硬件来加快速度，让运算快如闪电\n\nAnd secondly,we can divide up a 3D scene into many smaller parts,\n其次，我们可以把3D场景分解成多个小部分\n\nand then render all the pieces in parallel,rather than sequentially.\n然后并行渲染，而不是按顺序渲染\n\nCPU's aren't designed for this, so they aren't particularly fast.\nCPU不是为此设计的，因此图形运算不快\n\nSo, computer engineers created special processors just for graphics\n所以，计算机工程师为图形做了专门的处理器\n\n– a GPU, or Graphics Processing Unit.\n叫 GPU \"图形处理单元\"\n\nThese can be found on graphics cards inside of your computer, along with RAM reserved for graphics.\nGPU 在显卡上，周围有专用的 RAM\n\nThis is where all the meshes and textures live,\n所有网格和纹理都在里面\n\nallowing them to be accessed super fast by many different cores of the GPU all at once.\n让 GPU 的多个核心可以高速访问\n\nA modern graphics card, like a GeForce GTX 1080 TI,\n现代显卡，如 GeForce GTX 1080 TI\n\ncontains 3584 processing cores, offering massive parallelization.\n有3584个处理核心，提供大规模并行处理\n\nIt can process hundreds of millions of polygons every second!\n每秒处理上亿个多边形！\n\nOk, that concludes our whistle stop tour of 3D graphics.\n好了，本集对3D图形的介绍到此结束\n\nNext week, we switch topics entirely.\n下周我们聊全新的主题\n\nI'll ping you then.\n我到时会 ping 你~\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/28. 计算机网络-Computer Networks.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nThe internet is amazings\n互联网太棒啦\n\nIn just a few keystrokes, we can stream videos on Youtube -- Hello!\n键盘敲几下就能在 Youtube 直播--哈喽！\n\n- read articles on Wikipedia,\n在维基百科上阅读文章\n\norder supplies on amazon, video chat with friends, and tweet about the weather.\n在亚马逊买东西  和朋友视频  发一条天气推特\n\nWithout a doubt, the ability for computers, and their users, to send and receive information\n毫无疑问，\\N 用户在全球网络中发送和接收信息的能力\n\nover a global telecommunications network forever changed the world.\n永远改变了这个世界\n\n150 years ago, sending a letter from London to California would have taken two to three\n150年前 发一封信件从伦敦到加州 要花2~3周\n\nweeks, and that’s if you paid for express mail.\n而且还是特快邮件\n\nToday, that email takes a fraction of a second.\n如今 电子邮件只要几分之一秒.\n\nThis million fold improvement in latency, that’s the time it takes for a message to\n\"时延\"改善了上百万倍 \\N (时延指传播一条信息所需的时间)\n\ntransfer, juiced up the global economy helping the modern world to\n振兴了全球经济 \\N 帮助现代世界在遍布全球的光纤中快速发展\n\nmove at the speed of light on fiber optic cables spanning the globe.\n振兴了全球经济 \\N 帮助现代世界在遍布全球的光纤中快速发展\n\nYou might think that computers and networks always went hand in hand, but actually most\n你可能觉得计算机和网络密切相关，但事实上，\n\ncomputers pre-1970 were humming away all alone.\n1970年以前 大多数计算机是独立运行的\n\nHowever, as big computers began popping up everywhere,\n然而 因为大型计算机开始随处可见\n\nand low cost machines started to show up on people’s desks,\n廉价机器开始出现在书桌上\n\nit became increasingly useful to share data and resources,\n分享数据和资源渐渐变得有用起来\n\nand the first networks of computers appeared.\n首个计算机网络出现了\n\nToday, we’re going to start a three-episode arc on how computer networks came into being\n今天起，我们花3集视频讲网络是如何发展成现在的样子\n\nand the fundamental principles and techniques that power them.\n以及支撑它们的基础原理和技术\n\nThe first computer networks appeared in the 1950s and 60s.\n第一个计算机网络出现在1950~1960年代\n\nThey were generally used within an organization – like a company or research lab\n通常在公司或研究室内部使用，为了方便信息交换\n\nto facilitate the exchange of information between different people and computers.\n通常在公司或研究室内部使用，为了方便信息交换\n\nThis was faster and more reliable than the previous method of having someone walk a pile\n比把纸卡或磁带送到另一栋楼里更快速可靠\n\nof punch cards, or a reel of magnetic tape, to a computer on the other side of a building\n比把纸卡或磁带送到另一栋楼里更快速可靠\n\n‒ which was later dubbed a sneakernet.\n这叫\"球鞋网络\"\n\nA second benefit of networks was the ability to share physical resources.\n第二个好处是能共享物理资源\n\nFor example, instead of each computer having its own printer,\n举个例子，与其每台电脑配一台打印机\n\neveryone could share one attached to the network.\n大家可以共享一台联网的打印机\n\nIt was also common on early networks to have large, shared, storage drives,\n早期网络也会共享存储空间\n\nones too expensive to have attached to every machine.\n因为每台电脑都配存储器太贵了\n\nThese relatively small networks of close-by computers\n计算机近距离构成的小型网络 \\N 叫局域网， 简称LAN\n\nare called Local Area Networks, or LANs.\n计算机近距离构成的小型网络 \\N 叫局域网， 简称LAN\n\nA LAN could be as small as two machines in the same room,\n局域网能小到是同一个房间里的两台机器\n\nor as large as a university campus with thousands of computers.\n或大到校园里的上千台机器\n\nAlthough many LAN technologies were developed and deployed,\n尽管开发和部署了很多不同 LAN 技术\n\nthe most famous and successful was Ethernet, developed in the\n其中最著名和成功的是\"以太网\"  , 开发于1970年代 \\N 在施乐的\"帕洛阿尔托研究中心\"诞生, 今日仍被广泛使用\n\nearly 1970s at Xerox PARC, and still widely used today.\n其中最著名和成功的是\"以太网\"  , 开发于1970年代 \\N 在施乐的\"帕洛阿尔托研究中心\"诞生, 今日仍被广泛使用\n\nIn its simplest form, a series of computers are connected to a single, common ethernet cable.\n以太网的最简单形式是：一条以太网电线连接数台计算机\n\nWhen a computer wants to transmit data to another computer,\n当一台计算机要传数据给另一台计算机时\n\nit writes the data, as an electrical signal, onto the cable.\n它以电信号形式，将数据传入电缆\n\nOf course, because the cable is shared, every computer plugged into the network sees the\n当然 因为电缆是共享的  \\N 连在同一个网络里的其他计算机也看得到数据\n\ntransmission, but doesn’t know if data is intended for them or another computer.\n但不知道数据是给它们的，还是给其他计算机的\n\nTo solve this problem, Ethernet requires that each computer has a unique\n为了解决这个问题 以太网需要每台计算机有唯一的 \\N 媒体访问控制地址 简称 MAC地址\n\nMedia Access Control address, or MAC address.\n为了解决这个问题 以太网需要每台计算机有唯一的 \\N 媒体访问控制地址 简称 MAC地址\n\nThis unique address is put into a header that prefixes any data sent over the network.\n这个唯一的地址放在头部，作为数据的前缀发送到网络中\n\nSo, computers simply listen to the ethernet cable,\n所以，计算机只需要监听以太网电缆 \\N 只有看到自己的 MAC 地址，才处理数据\n\nand only process data when they see their address in the header.\n所以，计算机只需要监听以太网电缆 \\N 只有看到自己的 MAC 地址，才处理数据\n\nThis works really well; every computer made today comes with its own unique MAC address\n这运作得很好 现在制造的每台计算机都自带唯一的MAC地址\n\nfor both Ethernet and WiFi.\n用于以太网和无线网络\n\nThe general term for this approach is Carrier Sense Multiple Access, or CSMA for short.\n多台电脑共享一个传输媒介，\\N 这种方法叫 \"载波侦听多路访问\" 简称\"CSMA\"\n\nThe \"carrier\", in this case, is any shared transmission medium that carries data\n载体(carrier)指运输数据的共享媒介\n\ncopper wire in the case of ethernet, and the air carrying radio waves for WiFi.\n以太网的\"载体\"是铜线 \\N  WiFi 的\"载体\"是传播无线电波的空气\n\nMany computers can simultaneously sense the carrier,\n很多计算机同时侦听载体\n\nhence the \"Sense\" and \"Multiple Access\",\n所以叫\"侦听\"和\"多路访问\"\n\nand the rate at which a carrier can transmit data is called its Bandwidth.\n而载体传输数据的速度 叫\"带宽\"\n\nUnfortunately, using a shared carrier has one big drawback.\n不幸的是 使用共享载体有个很大的弊端\n\nWhen network traffic is light, computers can simply wait for silence on the carrier,\n当网络流量较小时 计算机可以等待载体清空\n\nand then transmit their data.\n然后传送数据\n\nBut, as network traffic increases, the probability that\n但随着网络流量上升 两台计算机想同时写入数据的概率也会上升\n\ntwo computers will attempt to write data at the same time also increases.\n但随着网络流量上升 两台计算机想同时写入数据的概率也会上升\n\nThis is called a collision, and the data gets all garbled up,\n这叫冲突 数据全都乱套了\n\nlike two people trying to talk on the phone at the same time.\n就像两个人同时在电话里讲话\n\nFortunately, computers can detect these collisions by listening to the signal on the wire.\n幸运的是 计算机能够通过监听电线中的信号检测这些冲突\n\nThe most obvious solution is for computers to stop transmitting,\n最明显的解决办法是停止传输\n\nwait for silence, then try again.\n等待网络空闲, 然后再试一遍\n\nProblem is, the other computer is going to try that too,\n问题是 其他计算机也打算这样做\n\nand other computers on the network that have been waiting for the\n其他等着的计算机可能在任何停顿间隙闯入\n\ncarrier to go silent will try to jump in during any pause.\n其他等着的计算机可能在任何停顿间隙闯入\n\nThis just leads to more and more collisions.\n导致越来越多冲突\n\nSoon, everyone is talking over one another and has a backlog of things they need to say,\n很快，每个人都一个接一个地讲话 而且有一堆事要说\n\nlike breaking up with a boyfriend over a family holiday dinner.\n就像在家庭聚餐中和男朋友分手一样\n\nTerrible idea!\n馊主意！\n\nEthernet had a surprisingly simple and effective fix.\n以太网有个超简单有效的解决方法\n\nWhen transmitting computers detect a collision,\n当计算机检测到冲突 就会在重传之前等待一小段时间\n\nthey wait for a brief period before attempting to re-transmit.\n当计算机检测到冲突 就会在重传之前等待一小段时间\n\nAs an example, let’s say 1 second.\n因为要举例，假设是 1 秒好了\n\nOf course, this doesn’t work if all the computers use the same wait duration\n当然 如果所有计算机用同样的等待时间 是不行的\n\n-- they’ll just collide again one second later.\n它们会在一秒后再次冲突\n\nSo, a random period is added: one computer might wait 1.3 seconds,\n所以加入一个随机时间 一台计算机可能等1.3秒\n\nwhile another waits 1.5 seconds.\n另一台计算机等待1.5秒\n\nWith any luck, the computer that waited 1.3 seconds will wake up,\n要是运气好 等1.3秒的计算机会醒来\n\nfind the carrier to be silent, and start transmitting.\n发现载体是空闲的 然后开始传输\n\nWhen the 1.5 second computer wakes up a moment later, it’ll see the carrier is in use,\n当1.5秒的计算机醒来后 会发现载体被占用 \\N 会等待其他计算机完成\n\nand will wait for the other computer to finish.\n当1.5秒的计算机醒来后 会发现载体被占用 \\N 会等待其他计算机完成\n\nThis definitely helps, but doesn’t totally solve the problem, so an extra trick is used.\n这有用 但不能完全解决问题 所以要用另一个小技巧\n\nAs I just explained, if a computer detects a collision while transmitting,\n正如我刚才说的 \\N如果一台计算机在传输数据期间检测到冲突\n\nit will wait 1 second, plus some random extra time.\n会等一秒+随机时间\n\nHowever, if it collides again, which suggests network congestion,\n然而 如果再次发生冲突 表明有网络拥塞\n\ninstead of waiting another 1 second, this time it will wait 2 seconds.\n这次不等1秒，而是等2秒\n\nIf it collides again, it’ll wait 4 seconds, and then 8, and then 16,\n如果再次发生冲突 等4秒 然后8秒 16秒等等\n\nand so on, until it’s successful.\n直到成功传输\n\nWith computers backing off, the rate of collisions goes down,\n因为计算机的退避 冲突次数降低了 \\N 数据再次开始流动起来 网络变得顺畅\n\nand data starts moving again, freeing up the network.\n因为计算机的退避 冲突次数降低了 \\N 数据再次开始流动起来 网络变得顺畅\n\nFamily dinner saved!\n家庭晚餐有救啦！\n\nThis \"backing off\" behavior using an exponentially growing wait time is called\n这种指数级增长等待时间的方法叫：\n\nExponential Backoff.\n指数退避\n\nBoth Ethernet and WiFi use it, and so do many transmission protocols.\n以太网和WiFi都用这种方法 很多其他传输协议也用\n\nBut even with clever tricks like Exponential Backoff,\n但即便有了\"指数退避\"这种技巧\n\nyou could never have an entire university’s\n想用一根网线链接整个大学的计算机还是不可能的\n\nworth of computers on one shared ethernet cable.\n想用一根网线链接整个大学的计算机还是不可能的\n\nTo reduce collisions and improve efficiency,\n为了减少冲突+提升效率\n\nwe need to shrink the number of devices on any given shared carrier\n我们需要减少同一载体中设备的数量 \\N 载体和其中的设备总称 \"冲突域\"\n\n-- what’s called the Collision Domain.\n我们需要减少同一载体中设备的数量 \\N 载体和其中的设备总称 \"冲突域\"\n\nLet go back to our earlier Ethernet example, where we had six computers on one shared cable,\n让我们回到之前以太网的例子  一根电缆连6台计算机\n\na.k.a. one collision domain.\n也叫一个冲突域\n\nTo reduce the likelihood of collisions, we can break this network\n为了减少冲突  我们可以用交换机把它拆成两个冲突域\n\ninto two collision domains by using a Network Switch.\n为了减少冲突  我们可以用交换机把它拆成两个冲突域\n\nIt sits between our two smaller networks, and only passes data between them if necessary.\n交换机位于两个更小的网络之间 \\N 必要时才在两个网络间传数据\n\nIt does this by keeping a list of what MAC addresses are on what side of the network.\n交换机会记录一个列表 \\N 写着哪个 MAC 地址在哪边网络\n\nSo if A wants to transmit to C, the switch doesn’t forward the data to the other network\n如果A想传数据给C \\N 交换机不会把数据转发给另一边的网络\n\n– there’s no need.\n没必要\n\nThis means if E wants to transmit to F at the same time, the network is wide open, and\n如果E想同一时间传数据给F，网络仍然是空的\n\ntwo transmissions can happen at once.\n两个传输可以同时发生\n\nBut, if F wants to send data to A, then the switch passes it through,\n但如果F想发数据给A  数据会通过交换机\n\nand the two networks are both briefly occupied.\n两个网络都会被短暂占用\n\nThis is essentially how big computer networks are constructed,\n大的计算机网络也是这样构建的\n\nincluding the biggest one of all – The Internet –\n包括最大的网络 - 互联网\n\nwhich literally inter-connects a bunch of smaller networks,\n也是多个连在一起的稍小一点网络\n\nallowing inter-network communication.\n使不同网络间可以传递信息\n\nWhat’s interesting about these big networks,\n这些大型网络有趣之处是\n\nis that there’s often multiple paths to\n从一个地点到另一个地点通常有多条路线\n\nget data from one location to another.\n从一个地点到另一个地点通常有多条路线\n\nAnd this brings us to another fundamental networking topic, routing.\n这就带出了另一个话题 路由\n\nThe simplest way to connect two distant computers, or networks,\n连接两台相隔遥远的计算机或网路，最简单的办法 \\N 是分配一条专用的通信线路\n\nis by allocating a communication line for their exclusive use.\n连接两台相隔遥远的计算机或网路，最简单的办法 \\N 是分配一条专用的通信线路\n\nThis is how early telephone systems worked.\n早期电话系统就是这样运作的\n\nFor example, there might be 5 telephone lines running between Indianapolis and Missoula.\n假设\"印第安纳波利斯\"和\"米苏拉\"之间，有五条电话线\n\nIf John picked up the phone wanting to call Hank, in the 1910s,\n如果在1910年代，John 想打电话给 Hank\n\nJohn would tell a human operator where he wanted to call,\nJohn要告诉操作员他想打到什么地方\n\nand they’d physically connect John’s phone line into\n然后工作人员手动将 John 的电话连到 \\N 通往米苏拉的未使用线路\n\nan unused line running to Missoula.\n然后工作人员手动将 John 的电话连到 \\N 通往米苏拉的未使用线路\n\nFor the length of the call, that line was occupied, and if all 5 lines were already\n通话期间 这条线就被占用了 如果五条线都被占用了 \\N John 要等待某条线空出来\n\nin use, John would have to wait for one to become free.\n通话期间 这条线就被占用了 如果五条线都被占用了 \\N John 要等待某条线空出来\n\nThis approach is called Circuit Switching,\n这叫 \"电路交换\"\\N因为是把电路连接到正确目的地\n\nbecause you’re literally switching whole\n这叫 \"电路交换\"\\N因为是把电路连接到正确目的地\n\ncircuits to route traffic to the correct destination.\n这叫 \"电路交换\"\\N因为是把电路连接到正确目的地\n\nIt works fine, but it’s relatively inflexible and expensive,\n能用倒是能用 \\N 但不灵活而且价格昂贵 因为总有闲置的线路\n\nbecause there’s often unused capacity.\n能用倒是能用 \\N 但不灵活而且价格昂贵 因为总有闲置的线路\n\nOn the upside, once you have a line to yourself – or if you have the money to buy one for\n好处是 如果有一条专属于自己的线路 \\N 你可以最大限度地随意使用，无需共享\n\nyour private use – you can use it to its full capacity, without having to share.\n好处是 如果有一条专属于自己的线路 \\N 你可以最大限度地随意使用，无需共享\n\nFor this reason, the military, banks and other high importance operations\n因此军队, 银行和其他一些机构\n\nstill buy dedicated circuits to connect their data centers.\n依然会购买专用线路来连接数据中心\n\nAnother approach for getting data from one place to another is Message Switching,\n传输数据的另一个方法是 \"报文交换\"\n\nwhich is sort of like how the postal system works.\n\"报文交换\" 就像邮政系统一样\n\nInstead of dedicated route from A to B, messages are passed through several stops.\n不像之前A和B有一条专有线路 \\N 消息会经过好几个站点\n\nSo if John writes a letter to Hank,\n如果 John 写一封信给 Hank\n\nit might go from Indianapolis to Chicago, and then\n信件可能从\"印第安纳波利斯\"到\"芝加哥\"\n\nhop to Minneapolis, then Billings, and then finally make it to Missoula.\n然后\"明尼阿波利斯\" 然后\"比林斯\" 最后到\"米苏拉\"\n\nEach stop knows where to send it next\n每个站点都知道下一站发哪里 \\N 因为站点有表格，记录到各个目的地，信件该怎么传\n\nbecause they keep a table of where to pass letters given a destination address.\n每个站点都知道下一站发哪里 \\N 因为站点有表格，记录到各个目的地，信件该怎么传\n\nWhat’s neat about Message Switching is that it can use different routes,\n报文交换的好处是 可以用不同路由 \\N 使通信更可靠更能容错\n\nmaking communication more reliable and fault-tolerant.\n报文交换的好处是 可以用不同路由 \\N 使通信更可靠更能容错\n\nSticking with our mail example,\n回到邮件的例子\n\nif there’s a blizzard in Minneapolis grinding things to a halt,\n如果\"明尼阿波利斯\"有暴风雪中断了通信 \\N \"芝加哥\"可以传给\"奥马哈\"\n\nthe Chicago mail hub can decide to route the letter through Omaha instead.\n如果\"明尼阿波利斯\"有暴风雪中断了通信 \\N \"芝加哥\"可以传给\"奥马哈\"\n\nIn our example, cities are acting like network routers.\n在这个例子里，城市就像路由器一样\n\nThe number of hops a message takes along a route is called the hop count.\n消息沿着路由跳转的次数 \\N 叫\"跳数\"(hop count)\n\nKeeping track of the hop count is useful because it can help identify routing problems.\n记录跳数很有用，因为可以分辨出路由问题\n\nFor example, let’s say Chicago thinks the fastest route to Missoula is through Omaha,\n举例，假设芝加哥认为 \\N 去米苏拉的最快路线是 奥马哈\n\nbut Omaha thinks the fastest route is through Chicago.\n但奥马哈认为 \\N 去米苏拉的最快路线是 芝加哥\n\nThat's bad, because both cities are going to look at the destination address, Missoula,\n这就糟糕了\\N 因为2个城市看到目的地是米苏拉\n\nand end up passing the message back and forth between them, endlessly.\n结果报文会在2个城市之间\\N不停传来传去\n\nNot only is this wasting bandwidth, but it’s a routing error that needs to get fixed!\n不仅浪费带宽 而且这个路由错误需要修复!\n\nThis kind of error can be detected because the hop count is\n这种错误会被检测到，因为跳数记录在消息中 \\N 而且传输时会更新跳数\n\nstored with the message and updated along its journey.\n这种错误会被检测到，因为跳数记录在消息中 \\N 而且传输时会更新跳数\n\nIf you start seeing messages with high hop counts,\n如果看到某条消息的跳数很高 \\N 就知道路由肯定哪里错了\n\nyou can bet something has gone awry in the routing!\n如果看到某条消息的跳数很高 \\N 就知道路由肯定哪里错了\n\nThis threshold is the Hop Limit.\n这叫\"跳数限制\"\n\nA downside to Message Switching is that messages are sometimes big.\n报文交换的缺点之一是有时候报文比较大\n\nSo, they can clog up the network, because the whole message has to be transmitted from\n会堵塞网络 因为要把整个报文从一站传到下一站后 \\N 才能继续传递其他报文\n\none stop to the next before continuing on its way.\n会堵塞网络 因为要把整个报文从一站传到下一站后 \\N 才能继续传递其他报文\n\nWhile a big file is transferring, that whole link is tied up.\n传输一个大文件时  整条路都阻塞了\n\nEven if you have a tiny, one kilobyte email trying to get through,\n即便你只有一个1KB的电子邮件要传输 \\N 也只能等大文件传完，或是选另一条效率稍低的路线\n\nit either has to wait for the big file transfer to finish or take a less efficient route.\n即便你只有一个1KB的电子邮件要传输 \\N 也只能等大文件传完，或是选另一条效率稍低的路线\n\nThat’s bad.\n这就糟了\n\nThe solution is to chop up big transmissions into many small pieces, called packets.\n解决方法是 将大报文分成很多小块，叫\"数据包\"\n\nJust like with Message Switching, each packet contains a destination address on the network,\n就像报文交换 每个数据包都有目标地址 \\N 因此路由器知道发到哪里\n\nso routers know where to forward them.\n就像报文交换 每个数据包都有目标地址 \\N 因此路由器知道发到哪里\n\nThis format is defined by the \"Internet Protocol\", or IP for short,\n报文具体格式由\"互联网协议\"定义，简称 IP \\N 这个标准创建于 1970 年代\n\na standard created in the 1970s.\n报文具体格式由\"互联网协议\"定义，简称 IP \\N 这个标准创建于 1970 年代\n\nEvery computer connected to a network gets an IP Address.\n每台联网的计算机都需要一个IP地址\n\nYou’ve probably seen these as four, 8-bit numbers written with dots in between.\n你可能见过，以点分隔的4组数字\n\nFor example,172.217.7.238 is an IP Address for one of Google’s servers.\n例如 172.217.7.238 是 Google 其中一个服务器的IP地址\n\nWith millions of computers online, all exchanging data,\n数百万台计算机在网络上不断交换数据 \\N 瓶颈的出现和消失是毫秒级的\n\nbottlenecks can appear and disappear in milliseconds.\n数百万台计算机在网络上不断交换数据 \\N 瓶颈的出现和消失是毫秒级的\n\nNetwork routers are constantly trying to balance the load across whatever routes they know\n路由器会平衡与其他路由器之间的负载 \\N 以确保传输可以快速可靠，这叫\"阻塞控制\"\n\nto ensure speedy and reliable delivery, which is called congestion control.\n路由器会平衡与其他路由器之间的负载 \\N 以确保传输可以快速可靠，这叫\"阻塞控制\"\n\nSometimes different packets from the same message take different routes through a network.\n有时，同一个报文的多个数据包 \\N 会经过不同线路\n\nThis opens the possibility of packets arriving at their destination out of order,\n到达顺序可能会不一样，这对一些软件是个问题\n\nwhich is a problem for some applications.\n到达顺序可能会不一样，这对一些软件是个问题\n\nFortunately, there are protocols that run on top of IP,\n幸运的是，在 IP 之上还有其他协议\n\nlike TCP/IP, that handle this issue.\n比如 TCP/IP, 可以解决乱序问题\n\nWe’ll talk more about that next week.\n我们下周会讲\n\nChopping up data into small packets,\n将数据拆分成多个小数据包，然后通过灵活的路由传递\n\nand passing these along flexible routes with spare capacity,\n将数据拆分成多个小数据包，然后通过灵活的路由传递\n\nis so efficient and fault-tolerant, it’s what the whole internet runs on today.\n非常高效且可容错，如今互联网就是这么运行的\n\nThis routing approach is called Packet Switching.\n这叫\"分组交换\"\n\nIt also has the nice property of being decentralized,\n有个好处是 它是去中心化的\n\nwith no central authority or single point of failure.\n没有中心权威机构  没有单点失败问题\n\nIn fact, the threat of nuclear attack is why\n事实上 因为冷战期间有核攻击的威胁，所以创造了分组交换\n\npacket switching was developed during the cold war!\n事实上 因为冷战期间有核攻击的威胁，所以创造了分组交换\n\nToday, routers all over the globe work cooperatively to find efficient routings,\n如今，全球的路由器协同工作，找出最高效的线路\n\nexchanging information with each other using special protocols,\n用各种标准协议运输数据\n\nlike the Internet Control Message Protocol (ICMP)\n比如 \"因特网控制消息协议\"(ICMP)\n\nand the Border Gateway Protocol (BGP).\n和 \"边界网关协议\"(BGP)\n\nThe world's first packet-switched network,\n世界上第一个分组交换网络\n\nand the ancestor to the modern internet, was the ARPANET,\n以及现代互联网的祖先是 ARPANET\n\nnamed after the US agency that funded it,\n名字来源于赞助这个项目的机构，美国高级研究计划局\n\nthe Advanced Research Projects Agency.\n名字来源于赞助这个项目的机构，美国高级研究计划局\n\nHere’s what the entire ARPANET looked like in 1974.\n这是 1974 年整个 ARPANET 的样子\n\nEach smaller circle is a location,\n每个小圆表示一个地点 \\N 比如大学或实验室，那里运行着一个路由器\n\nlike a university or research lab, that operated a router.\n每个小圆表示一个地点 \\N 比如大学或实验室，那里运行着一个路由器\n\nThey also plugged in one or more computers\n并且有一台或多台计算机\n\n– you can see PDP-1’s, IBM System 360s,\n能看到 \"PDP-1\" 和\"IBM 360系统\"\n\nand even an ATLAS in London connected over a satellite link.\n甚至还有一个伦敦的 ATLAS \\N 是通过卫星连到网络里的\n\nObviously the internet has grown by leaps and bounds in the decades since.\n显然 互联网在这几十年间发展迅速\n\nToday, instead of a few dozen computers online, it’s estimated to be nearing 10 billion.\n如今不再只有几十台计算机联网 \\N 据估计 有接近100亿台联网设备\n\nAnd it continues to grow rapidly,\n而且互联网会继续快速发展\n\nespecially with the advent of wifi-connected refrigerators, thermostat\n特别是如今各种智能设备层出不穷 \\N 比如联网冰箱，恒温器\n\nand other smart appliances, forming an \"internet of things\".\n以及其他智能家电，它们组成了\"物联网\"\n\nSo that’s part one – an overview of computer networks.\n第一部分到此结束  \\N 我们对计算机网络进行了概览\n\nIs it a series of tubes?\n网络是一堆管子组成的吗？\n\nWell, sort of.\n额 算是吧\n\nNext week we’ll tackle some higher-level transmission protocols,\n下周我们会讨论一些高级传输协议\n\nslowly working our way up to the World Wide Web.\n然后讲万维网\n\nI’ll see you then!\n到时见啦\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/29. 互联网-The Internet.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nAs we talked about last episode, your computer is connected to a large, distributed network,\n上集讲到，你的计算机和一个巨大的分布式网络连在一起\n\ncalled The Internet.\n这个网络叫互联网\n\nI know this because you’re watching a YouTube video,\n你现在就在网上看视频呀\n\nwhich is being streamed over that very internet.\n你现在就在网上看视频呀\n\nIt’s arranged as an ever-enlarging web of interconnected devices.\n互联网由无数互联设备组成，而且日益增多\n\nFor your computer to get this video,\n计算机为了获取这个视频 \\N 首先要连到局域网，也叫 LAN\n\nthe first connection is to your local area network, or LAN,\n计算机为了获取这个视频 \\N 首先要连到局域网，也叫 LAN\n\nwhich might be every device in your house that’s connected to your wifi router.\n你家 WIFI 路由器连着的所有设备，组成了局域网.\n\nThis then connects to a Wide Area Network, or WAN,\n局域网再连到广域网，广域网也叫 WAN\n\nwhich is likely to be a router run by your Internet Service Provider, or ISP，\nWAN 的路由器一般属于你的\"互联网服务提供商\"，简称 ISP\n\ncompanies like Comcast, AT&T or Verizon.\n比如 Comcast，AT&T 和 Verizon 这样的公司\n\nAt first, this will be a regional router, like one for your neighborhood,\n广域网里，先连到一个区域性路由器，这路由器可能覆盖一个街区。\n\nand then that router connects to an even bigger WAN,\n然后连到一个更大的 WAN，可能覆盖整个城市\n\nmaybe one for your whole city or town.\n然后连到一个更大的 WAN，可能覆盖整个城市\n\nThere might be a couple more hops, but ultimately you’ll connect to the backbone of the internet\n可能再跳几次，但最终会到达互联网主干\n\nmade up of gigantic routers with super high-bandwidth connections running between them.\n互联网主干由一群超大型、带宽超高路由器组成\n\nTo request this video file from YouTube,\n为了从 YouTube 获得这个视频，\n\na packet had to work its way up to the backbone,\n数据包（packet）要先到互联网主干\n\ntravel along that for a bit, and then work its way back down to a YouTube server that had the file.\n沿着主干到达有对应视频文件的 YouTube 服务器\n\nThat might be four hops up, two hops across the backbone,\n数据包从你的计算机跳到 Youtube 服务器，可能要跳个10次，\n\nand four hops down, for a total of ten hops.\n先跳4次到互联网主干，2次穿过主干，\\N主干出来可能再跳4次，然后到 Youtube 服务器\n\nIf you’re running Windows, Mac OS or Linux, you can see the route data takes to different\n如果你在用 Windows, Mac OS 或 Linux系统，可以用 traceroute 来看跳了几次\n\nplaces on the internet by using the traceroute program on your computer.\n如果你在用 Windows, Mac OS 或 Linux系统，可以用 traceroute 来看跳了几次\n\nInstructions in the Doobly Doo.\n更多详情看视频描述（YouTube原视频下）\n\nFor us here at the Chad & Stacey Emigholz Studio in Indianapolis,\n我们在\"印第安纳波利斯\"的 Chad&Stacy Emigholz 工作室，\\N 访问加州的 DFTBA 服务器，\n\nthe route to the DFTBA server in California goes through 11 stops.\n经历了11次中转\n\nWe start at 192.168.0.1 -- that's the IP address for my computer on our LAN.\n从 192.168.0.1 出发，这是我的电脑在 局域网（LAN）里的 IP 地址\n\nThen there’s the wifi router here at the studio,\n然后到工作室的 WIFI 路由器\n\nthen a series of regional routers, then we get onto the backbone,\n然后穿过一个个地区路由器，到达主干.\n\nand then we start working back down to the computer hosting \"DFTBA.com”,\n然后从主干出来，又跳了几次，到达\"DFTBA.com”的服务器\n\nwhich has the IP address 104.24.109.186.\nIP 地址是 104.24.109.186.\n\nBut how does a packet actually get there?\n但数据包*到底*是怎么过去的？\n\nWhat happens if a packet gets lost along the way?\n如果传输时数据包被弄丢了，会发生什么？\n\nIf I type \"DFTBA.com” into my web browser, how does it know the server’s address?\n如果在浏览器里输 \"DFTBA.com\"，浏览器怎么知道服务器的地址多少？\n\nThese are our topics for today!\n我们今天会讨论这些话题.\n\nAs we discussed last episode, the internet is a huge distributed network\n上集说过，互联网是一个巨型分布式网络 \\N 会把数据拆成一个个数据包来传输\n\nthat sends data around as little packets.\n上集说过，互联网是一个巨型分布式网络 \\N 会把数据拆成一个个数据包来传输\n\nIf your data is big enough, like an email attachment,\n如果要发的数据很大，比如邮件附件 \\N 数据会被拆成多个小数据包\n\nit might get broken up into many packets.\n如果要发的数据很大，比如邮件附件 \\N 数据会被拆成多个小数据包\n\nFor example, this video stream is arriving to your computer right now\n举例，你现在看的这个视频 \\N 就是一个个到达你电脑的数据包\n\nas a series of packets, and not one gigantic file.\n而不是一整个大文件发过来\n\nInternet packets have to conform to a standard called the Internet Protocol, or IP.\n数据包（packet）想在互联网上传输 \\N 要符合\"互联网协议\"的标准，简称 IP\n\nIt’s a lot like sending physical mail through the postal system\n就像邮寄手写信一样，邮寄是有标准的\\N 每封信需要一个地址，而且地址必须是独特的\n\n– every letter needs a unique and legible address written on it,\n就像邮寄手写信一样，邮寄是有标准的\\N 每封信需要一个地址，而且地址必须是独特的\n\nand there are limits to the size and weight of packages.\n并且大小和重量是有限制的\n\nViolate this, and your letter won’t get through.\n违反这些规定，信件就无法送达.\n\nIP packets are very similar.\nIP 数据包也是如此\n\nHowever, IP is a very low level protocol\n因为 IP 是一个非常底层的协议\n\n– there isn’t much more than a destination address in a packet’s header\n数据包的头部（或者说前面）只有目标地址\n\nwhich is the metadata that’s stored in front of the data payload.\n头部存 \"关于数据的数据\" \\N 也叫 元数据(metadata)\n\nThis means that a packet can show up at a computer, but the computer may not know\n这意味着当数据包到达对方电脑 \\N 对方不知道把包交给哪个程序，是交给 Skype 还是使命召唤？\n\nwhich application to give the data to; Skype or Call of Duty.\n这意味着当数据包到达对方电脑 \\N 对方不知道把包交给哪个程序，是交给 Skype 还是使命召唤？\n\nFor this reason, more advanced protocols were developed that sit on top of IP.\n因此需要在 IP 之上，开发更高级的协议.\n\nOne of the simplest and most common is the User Datagram Protocol, or UDP.\n这些协议里 \\N 最简单最常见的叫\"用户数据报协议\"，简称 UDP\n\nUDP has its own header, which sits inside the data payload.\nUDP 也有头部，这个头部位于数据前面\n\nInside of the UDP header is some useful, extra information.\n头部里包含有用的信息\n\nOne of them is a port number.\n信息之一是端口号\n\nEvery program wanting to access the internet will\n每个想访问网络的程序 \\N 都要向操作系统申请一个端口号.\n\nask its host computer’s Operating System to be given a unique port.\n每个想访问网络的程序 \\N 都要向操作系统申请一个端口号.\n\nLike Skype might ask for port number 3478.\n比如 Skype 会申请端口 3478\n\nWhen a packet arrives to the computer, the Operating System\n当一个数据包到达时 \\N 接收方的操作系统会读 UDP 头部，读里面的端口号\n\nwill look inside the UDP header and read the port number.\n当一个数据包到达时 \\N 接收方的操作系统会读 UDP 头部，读里面的端口号\n\nThen, if it sees, for example, 3478, it will give the packet to Skype.\n如果看到端口号是 3478，就把数据包交给 Skype\n\nSo to review, IP gets the packet to the right computer,\n总结：\\NIP 负责把数据包送到正确的计算机 \\N UDP 负责把数据包送到正确的程序\n\nbut UDP gets the packet to the right program running on that computer.\n总结：\\NIP 负责把数据包送到正确的计算机 \\N UDP 负责把数据包送到正确的程序\n\nUDP headers also include something called a checksum,\nUDP 头部里还有\"校验和\"，用于检查数据是否正确\n\nwhich allows the data to be verified for correctness.\nUDP 头部里还有\"校验和\"，用于检查数据是否正确\n\nAs the name suggests, it does this by checking the sum of the data.\n正如\"校验和\"这个名字所暗示的 \\N 检查方式是把数据求和来对比\n\nHere’s a simplified version of how this works.\n以下是个简单例子\n\nLet's imagine the raw data in our UDP packet is\n假设 UDP 数据包里 \\N 原始数据是 89 111 33 32 58 41\n\n89 111 33 32 58 and 41.\n假设 UDP 数据包里 \\N 原始数据是 89 111 33 32 58 41\n\nBefore the packet is sent, the transmitting computer calculates the checksum\n在发送数据包前 \\N 电脑会把所有数据加在一起，算出\"校验和\"\n\nby adding all the data together: 89 plus 111 plus 33 and so on.\n89+111+33+... 以此类推\n\nIn our example, this adds up to a checksum of 364.\n得到 364，这就是\"校验和\".\n\nIn UDP, the checksum value is stored in 16 bits.\nUDP 中，\\N\"校验和\"以 16 位形式存储 (就是16个0或1)\n\nIf the sum exceeds the maximum possible value, the upper-most bits overflw,\n如果算出来的和，超过了 16 位能表示的最大值 \\N 高位数会被扔掉，保留低位\n\nand only the lower bits are used.\n如果算出来的和，超过了 16 位能表示的最大值 \\N 高位数会被扔掉，保留低位\n\nNow, when the receiving computer gets this packet,\n当接收方电脑收到这个数据包\n\nit repeats the process, adding up all the data.\n它会重复这个步骤 \\N 把所有数据加在一起，89+111+33... 以此类推\n\n89 plus 111 plus 33 and so on.\n它会重复这个步骤 \\N 把所有数据加在一起，89+111+33... 以此类推\n\nIf that sum is the same as the checksum sent in the header, all is well.\n如果结果和头部中的校验和一致 \\N 代表一切正常\n\nBut, if the numbers don’t match, you know that the data got corrupted\n如果不一致，数据肯定坏掉了\n\nat some point in transit, maybe because of a power fluctuation or faulty cable.\n也许传输时碰到了功率波动，或电缆出故障了\n\nUnfortunately, UDP doesn’t offer any mechanisms to fix the data, or request a new copy\n不幸的是，UDP 不提供数据修复或数据重发的机制\n\nreceiving programs are alerted to the corruption, but typically just discard the packet.\n接收方知道数据损坏后，一般只是扔掉.\n\nAlso, UDP provides no mechanisms to know if packets are getting through\n而且，UDP 无法得知数据包是否到达.\n\na sending computer shoots the UDP packet off,\n发送方发了之后，无法知道数据包是否到达目的地\n\nbut has no confirmation it ever gets to its destination successfully.\n发送方发了之后，无法知道数据包是否到达目的地\n\nBoth of these properties sound pretty catastrophic, but some applications are ok with this,\n这些特性听起来很糟糕，但是有些程序不在意这些问题\n\nbecause UDP is also really simple and fast.\n因为 UDP 又简单又快.\n\nSkype, for example, which uses UDP for video chat, can handle corrupt or missing packets.\n拿 Skype 举例 \\N 它用 UDP 来做视频通话，能处理坏数据或缺失数据\n\nThat’s why sometimes if you’re on a bad internet connection,\n所以网速慢的时候 Skype 卡卡的 \\N 因为只有一部分数据包到了你的电脑\n\nSkype gets all glitchy – only some of the UDP packets are making it to your computer.\n所以网速慢的时候 Skype 卡卡的 \\N 因为只有一部分数据包到了你的电脑\n\nBut this approach doesn’t work for many other types of data transmission.\n但对于其他一些数据，这个方法不适用.\n\nLike, it doesn’t really work if you send an email, and it shows up with the middle missing.\n比如发邮件，\\N 邮件不能只有开头和结尾 没有中间.\n\nThe whole message really needs to get there correctly!\n邮件要完整到达收件方\n\nWhen it \"absolutely, positively needs to get there”,\n如果\"所有数据必须到达\" \\N 就用\"传输控制协议\"，简称 TCP\n\nprograms use the Transmission Control Protocol, or TCP,\n如果\"所有数据必须到达\" \\N 就用\"传输控制协议\"，简称 TCP\n\nwhich like UDP, rides inside the data payload of IP packets.\nTCP 和 UDP 一样，头部也在存数据前面\n\nFor this reason, people refer to this combination of protocols as TCP/IP.\n因此，人们叫这个组合 TCP/IP\n\nLike UDP, the TCP header contains a destination port and checksum.\n就像 UDP ，TCP 头部也有\"端口号\"和\"校验和\"\n\nBut, it also contains fancier features, and we’ll focus on the key ones.\n但 TCP 有更高级的功能，我们这里只介绍重要的几个\n\nFirst off, TCP packets are given sequential numbers.\n1. TCP 数据包有序号\n\nSo packet 15 is followed by packet 16, which is followed by 17, and so on...\n15号之后是16号，16号之后是17号，以此类推 \\N 发上百万个数据包也是有可能的.\n\nfor potentially millions of packets sent during that session.\n15号之后是16号，16号之后是17号，以此类推 \\N 发上百万个数据包也是有可能的.\n\nThese sequence numbers allow a receiving computer to put the packets into the correct order,\n序号使接收方可以把数据包排成正确顺序，即使到达时间不同.\n\neven if they arrive at different times across the network.\n序号使接收方可以把数据包排成正确顺序，即使到达时间不同.\n\nSo if an email comes in all scrambled, the TCP implementation in your computer’s operating\n哪怕到达顺序是乱的，TCP 协议也能把顺序排对\n\nsystem will piece it all together correctly.\n哪怕到达顺序是乱的，TCP 协议也能把顺序排对\n\nSecond, TCP requires that once a computer has correctly received a packet\n2. TCP 要求接收方的电脑收到数据包 \\N 并且\"校验和\"检查无误后（数据没有损坏）\\N 给发送方发一个确认码，代表收到了\n\n– and the data passes the checksum – that it send back an acknowledgement,\n2. TCP 要求接收方的电脑收到数据包 \\N 并且\"校验和\"检查无误后（数据没有损坏）\\N 给发送方发一个确认码，代表收到了\n\nor \"ACK” as the cool kids say, to the sending computer.\n\"确认码\" 简称 ACK \\N 得知上一个数据包成功抵达后，发送方会发下一个数据包\n\nKnowing the packet made it successfully, the sender can now transmit the next packet.\n\"确认码\" 简称 ACK \\N 得知上一个数据包成功抵达后，发送方会发下一个数据包\n\nBut this time, let’s say, it waits, and doesn’t get an acknowledgement packet back.\n假设这次发出去之后，没收到确认码 \\N 那么肯定哪里错了\n\nSomething must be wrong. If enough time elapses,\n如果过了一定时间还没收到确认码 \\N 发送方会再发一次\n\nthe sender will go ahead and just retransmit the same packet.\n如果过了一定时间还没收到确认码 \\N 发送方会再发一次\n\nIt’s worth noting here  that the original packet might have actually gotten there,\n注意 数据包可能的确到了\n\nbut the acknowledgment is just really delayed.\n只是确认码延误了很久，或传输中丢失了\n\nOr perhaps it was the acknowledgment that was lost.\n只是确认码延误了很久，或传输中丢失了\n\nEither way, it doesn’t matter, because the receiver has those sequence numbers,\n但这不碍事 因为收件方有序列号\n\nand if a duplicate packet arrives, it can be discarded.\n如果收到重复的数据包就删掉\n\nAlso, TCP isn’t limited to a back and forth conversation – it can send many packets,\n还有，TCP 不是只能一个包一个包发\n\nand have many outstanding ACKs, which increases bandwidth significantly, since you aren’t\n可以同时发多个数据包，收多个确认码 \\N 这大大增加了效率，不用浪费时间等确认码\n\nwasting time waiting for acknowledgment packets to return.\n可以同时发多个数据包，收多个确认码 \\N 这大大增加了效率，不用浪费时间等确认码\n\nInterestingly, the success rate of ACKs, and also the round trip time\n有趣的是，确认码的成功率和来回时间 \\N 可以推测网络的拥堵程度\n\nbetween sending and acknowledging, can be used to infer network congestion.\n有趣的是，确认码的成功率和来回时间 \\N 可以推测网络的拥堵程度\n\nTCP uses this information to adjust how aggressively it sends packets –\nTCP 用这个信息，调整同时发包数量，解决拥堵问题\n\na mechanism for congestion control.\nTCP 用这个信息，调整同时发包数量，解决拥堵问题\n\nSo, basically, TCP can handle out-of-order packet delivery, dropped packets\n简单说，TCP 可以处理乱序和丢失数据包，丢了就重发.\n\n– including retransmission – and even throttle its transmission rate according to available bandwidth.\n还可以根据拥挤情况自动调整传输率\n\nPretty awesome!\n相当厉害！\n\nYou might wonder why anyone would use UDP when TCP has all those nifty features.\n你可能会奇怪，既然 TCP 那么厉害，还有人用 UDP 吗？\n\nThe single biggest downside are all those acknowledgment packets\nTCP 最大的缺点是 \\N 那些\"确认码\"数据包把数量翻了一倍\n\n– it doubles the number of messages on the network,\nTCP 最大的缺点是 \\N 那些\"确认码\"数据包把数量翻了一倍\n\nand yet, you're not transmitting any more data.\n但并没有传输更多信息\n\nThat overhead, including associated delays, is sometimes not worth the improved robustness,\n有时候这种代价是不值得的 \\N 特别是对时间要求很高的程序，比如在线射击游戏\n\nespecially for time-critical applications, like Multiplayer First Person Shooters.\n有时候这种代价是不值得的 \\N 特别是对时间要求很高的程序，比如在线射击游戏\n\nAnd if it’s you getting lag-fragged you’ll definitely agree!\n如果你玩游戏很卡，你也会觉得这样不值!\n\nWhen your computer wants to make a connection to a website, you need two things\n当计算机访问一个网站时 \\N 需要两个东西：1.IP地址 2.端口号\n\n- an IP address and a port.\n当计算机访问一个网站时 \\N 需要两个东西：1.IP地址 2.端口号\n\nLike port 80, at 172.217.7.238.\n例如 172.217.7.238 的 80 端口 \\N 这是谷歌的 IP 地址和端口号\n\nThis example is the IP address and port for the Google web server.\n例如 172.217.7.238 的 80 端口 \\N 这是谷歌的 IP 地址和端口号\n\nIn fact, you can enter this into your browser’s address bar, like so,\n事实上，你可以输到浏览器里，然后你会进入谷歌首页\n\nand you’ll end up on the google homepage.\n事实上，你可以输到浏览器里，然后你会进入谷歌首页\n\nThis gets you to the right destination,\n有了这两个东西就能访问正确的网站 \\N 但记一长串数字很讨厌\n\nbut remembering that long string of digits would be really annoying.\n有了这两个东西就能访问正确的网站 \\N 但记一长串数字很讨厌\n\nIt’s much easier to remember: google.com.\ngoogle.com 比一长串数字好记\n\nSo the internet has a special service that maps these domain names to addresses.\n所以互联网有个特殊服务 \\N 负责把域名和 IP 地址一一对应\n\nIt’s like the phone book for the internet.\n就像专为互联网的电话簿 \\N 它叫\"域名系统\"，简称 DNS\n\nAnd it’s called the Domain Name System, or DNS for short.\n就像专为互联网的电话簿 \\N 它叫\"域名系统\"，简称 DNS\n\nYou can probably guess how it works.\n它的运作原理你可能猜到了\n\nWhen you type something like \"youtube.com” into your web browser,\n在浏览器里输 youtube.com \\N 浏览器会去问 DNS 服务器，它的 IP 地址是多少\n\nit goes and asks a DNS server – usually one provided by your ISP – to lookup the address.\n一般 DNS 服务器 \\N 是互联网供应商提供的\n\nDNS consults its huge registry, and replies with the address... if one exists.\nDNS 会查表，如果域名存在，就返回对应 IP 地址.\n\nIn fact, if you try mashing your keyboard, adding \".com”, and then hit enter in your\n如果你乱敲键盘加个.com 然后按回车\n\nbrowser, you’ll likely be presented with an error that says DNS failed.\n你很可能会看到 DNS 错误\n\nThat’s because that site doesn’t exist, so DNS couldn’t give your browser an address.\n因为那个网站不存在，所以 DNS 无法返回给你一个地址\n\nBut, if DNS returns a valid address, which it should for \"YouTube.com”, then your\n如果你输的是有效地址，比如 youtube.com \\N DNS 按理会返回一个地址\n\nbrowser shoots off a request over TCP for the website’s data.\n然后浏览器会给这个 IP 地址 \\N 发 TCP 请求\n\nThere’s over 300 million registered domain names, so to make out DNS Lookup a little\n如今有三千万个注册域名，所以为了更好管理\n\nmore manageable, it’s not stored as one gigantically long list,\nDNS 不是存成一个超长超长的列表，而是存成树状结构\n\nbut rather in a tree data structure.\nDNS 不是存成一个超长超长的列表，而是存成树状结构\n\nWhat are called Top Level Domains, or TLDs, are at the very top.\n顶级域名（简称 TLD）在最顶部，比如 .com 和 .gov\n\nThese are huge categories like .com and .gov.\n顶级域名（简称 TLD）在最顶部，比如 .com 和 .gov\n\nThen, there are lower level domains that sit below that, called second level domains; Examples\n下一层是二级域名，比如 .com 下面有 \\N google.com 和 dftba.com\n\nunder .com include google.com and dftba.com.\n下一层是二级域名，比如 .com 下面有 \\N google.com 和 dftba.com\n\nThen, there are even lower level domains, called subdomains,\n再下一层叫子域名，\\N 比如 images.google.com, store.dftba.com\n\nlike images.google.com, store.dftba.com.\n再下一层叫子域名，\\N 比如 images.google.com, store.dftba.com\n\nAnd this tree is absolutely HUGE!\n这个树超！级！大！\n\nLike I said, more than 300 million domain names, and that's just second level domain\n我前面说的\"三千万个域名\"只是二级域名 \\N 不是所有子域名\n\nnames, not all the sub domains.\n我前面说的\"三千万个域名\"只是二级域名 \\N 不是所有子域名\n\nFor this reason, this data is distributed across many DNS servers,\n因此，这些数据散布在很多 DNS 服务器上\n\nwhich are authorities for different parts of the tree.\n不同服务器负责树的不同部分\n\nOkay, I know you’ve been waiting for it...\n好了 我知道你肯定在等这个梗：\n\nWe’ve reached a new level of abstraction!\n我们到了一层新抽象！\n\nOver the past two episodes, we’ve worked up from electrical signals on wires,\n过去两集里 \\N 我们讲了线路里的电信号，以及无线网络里的无线信号\n\nor radio signals transmitted through the air in the case of wireless networks.\n过去两集里 \\N 我们讲了线路里的电信号，以及无线网络里的无线信号\n\nThis is called the Physical Layer.\n这些叫\"物理层\"\n\nMAC addresses, collision detection,\n而\"数据链路层\"负责操控\"物理层\"，\\N 数据链路层有：媒体访问控制地址（MAC），碰撞检测，\n\nexponential backoff and similar low level protocols that\n而\"数据链路层\"负责操控\"物理层\"，\\N 数据链路层有：媒体访问控制地址（MAC），碰撞检测，\n\nmediate access to the physical layer are part of the Data Link Layer.\n指数退避，以及其他一些底层协议\n\nAbove this is the Network Layer,\n再上一层是\"网络层\"\n\nwhich is where all the switching and routing technologies that we discussed operate.\n负责各种报文交换和路由\n\nAnd today, we mostly covered the Transport layer, protocols like UDP and TCP,\n而今天，我们讲了\"传输层\"里一大部分， 比如 UDP 和 TCP 这些协议,\n\nwhich are responsible for point to point data transfer between computers,\n负责在计算机之间进行点到点的传输\n\nand also things like error detection and recovery when possible.\n而且还会检测和修复错误\n\nWe’ve also grazed the Session Layer –\n我们还讲了一点点\"会话层\"\n\nwhere protocols like TCP and UDP are used to open a connection,\n\"会话层\"会使用 TCP 和 UDP 来创建连接，传递信息，然后关掉连接\n\npass information back and forth, and then close the connection when finished\n\"会话层\"会使用 TCP 和 UDP 来创建连接，传递信息，然后关掉连接\n\n– what’s called a session.\n这一整套叫\"会话\"\n\nThis is exactly what happens when you, for example, do a DNS Lookup, or request a webpage.\n查询 DNS 或看网页时，就会发生这一套流程\n\nThese are the bottom five layers of the Open System Interconnection (OSI) model,\n这是 开放式系统互联通信参考模型(OSI) 的底下5层\n\na conceptual framework for compartmentalizing all these different network processes.\n这个概念性框架 把网络通信划分成多层\n\nEach level has different things to worry about and solve,\n每一层处理各自的问题\n\nand it would be impossible to build one huge networking implementation.\n如果不分层 \\N 直接从上到下捏在一起实现网络通信，是完全不可能的\n\nAs we’ve talked about all series, abstraction allows computer scientists and engineers to\n抽象使得科学家和工程师能分工同时改进多个层 \\N 不被整体复杂度难倒.\n\nbe improving all these different levels of the stack simultaneously,\n抽象使得科学家和工程师能分工同时改进多个层 \\N 不被整体复杂度难倒.\n\nwithout being overwhelmed by the full complexity.\n抽象使得科学家和工程师能分工同时改进多个层 \\N 不被整体复杂度难倒.\n\nAnd amazingly, we’re not quite done yet\n而且惊人的是！我们还没讲完呢！\n\nThe OSI model has two more layers, the Presentation Layer and the Application Layer,\nOSI 模型还有两层，\"表示层\"和\"应用程序层\"\n\nwhich include things like web browsers, Skype,\n其中有浏览器，Skype，HTML解码，在线看电影等\n\nHTML decoding, streaming movies and more.\n其中有浏览器，Skype，HTML解码，在线看电影等\n\nWhich we’ll talk about next week.  See you then.\n我们下周说，到时见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/30. 万维网-The World Wide Web.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nOver the past two episodes, we’ve delved into the wires, signals, switches, packets,\n前两集我们深入讨论了电线 信号 交换机 数据包 \\N 路由器以及协议，它们共同组成了互联网.\n\nrouters and protocols that make up the internet.\n前两集我们深入讨论了电线 信号 交换机 数据包 \\N 路由器以及协议，它们共同组成了互联网.\n\nToday we’re going to move up yet another level of abstraction\n今天我们向上再抽象一层，来讨论万维网\n\nand talk about the World Wide Web.\n今天我们向上再抽象一层，来讨论万维网\n\nThis is not the same thing as the Internet,\n万维网(World Wide Web) \\N 和互联网(Internet)不是一回事\n\neven though people often use the two terms interchangeably.\n尽管人们经常混用这两个词\n\nThe World Wide Web runs on top of the internet,\n万维网在互联网之上运行\n\nin the same way that Skype, Minecraft or Instagram do.\n互联网之上还有 Skype, Minecraft 和 Instagram\n\nThe Internet is the underlying plumbing that conveys the data for all these different applications.\n互联网是传递数据的管道，各种程序都会用，\n\nAnd The World Wide Web is the biggest of them all\n其中传输最多数据的程序是万维网\n\n– a huge distributed application running on millions of servers worldwide,\n分布在全球数百万个服务器上\n\naccessed using a special program called a web browser.\n可以用\"浏览器\"来访问万维网\n\nWe’re going to learn about that, and much more, in today’s episode.\n这集我们会深入讲解万维网\n\nThe fundamental building block of the World Wide Web – or web for short\n万维网的最基本单位，是单个页面\n\n– is a single page.\n万维网的最基本单位，是单个页面\n\nThis is a document, containing content, which can include links to other pages.\n页面有内容，也有去往其他页面的链接 \\N 这些链接叫\"超链接\"\n\nThese are called hyperlinks.\n页面有内容，也有去往其他页面的链接 \\N 这些链接叫\"超链接\"\n\nYou all know what these look like: text or images that you can click,\n你们都见过：可以点击的文字或图片，把你送往另一个页面\n\nand they jump you to another page.\n你们都见过：可以点击的文字或图片，把你送往另一个页面\n\nThese hyperlinks form a huge web of interconnected information,\n这些超链接形成巨大的互联网络\n\nwhich is where the whole thing gets its name.\n这就是\"万维网\"名字的由来\n\nThis seems like such an obvious idea.\n现在说起来觉得很简单，但在超链接做出来之前\n\nBut before hyperlinks were implemented,\n现在说起来觉得很简单，但在超链接做出来之前\n\nevery time you wanted to switch to another piece of information on a computer,\n计算机上每次想看另一个信息时\n\nyou had to rummage through the file system to find it, or type it into a search box.\n你需要在文件系统中找到它 \\N 或是把地址输入搜索框\n\nWith hyperlinks, you can easily flow from one related topic to another.\n有了超链接，你可以在相关主题间轻松切换\n\nThe value of hyperlinked information was conceptualized by Vannevar Bush way back in 1945.\n超链接的价值早在 1945 年 \\N 就被 Vannevar Bush 意识到了\n\nHe published an article describing a hypothetical machine called a Memex,\n在第 24 集中我们说过，他发过一篇文章 \\N 描述一个假想的机器 Memex\n\nwhich we discussed in Episode 24.\n在第 24 集中我们说过，他发过一篇文章 \\N 描述一个假想的机器 Memex\n\nBush described it as \"associative indexing... whereby any item may be caused\nBush的形容是\"关联式索引.. 选一个物品会引起\n\nat will to select another immediately and automatically.\"\n另一个物品被立即选中\"\n\nHe elaborated: \"The process of tying two things together is the important thing...\n他解释道：\"将两样东西联系在一起的过程十分重要\n\nthereafter, at any time, when one of those items is in view,\n在任何时候，当其中一件东西进入视线\n\nthe other [item] can be instantly recalled merely by tapping a button.\"\n只需点一下按钮，立马就能回忆起另一件\"\n\nIn 1945, computers didn’t even have screens, so this idea was way ahead of its time!\n1945年的时候计算机连显示屏都没有，\\N 所以这个想法非常超前！\n\nText containing hyperlinks is so powerful,\n因为文字超链接是如此强大\n\nit got an equally awesome name: hypertext!\n它得到了一个同样厉害的名字：\"超文本\"！\n\nWeb pages are the most common type of hypertext document today.\n如今超文本最常指向的，是另一个网页\n\nThey’re retrieved and rendered by web browsers\n然后网页由浏览器渲染，我们待会会讲\n\nwhich we'll get to in a few minutes.\n然后网页由浏览器渲染，我们待会会讲\n\nIn order for pages to link to one another, each hypertext page needs a unique address.\n为了使网页能相互连接，每个网页需要一个唯一的地址\n\nOn the web, this is specified by a Uniform Resource Locator, or URL for short.\n这个地址叫 \"统一资源定位器\"，简称 URL\n\nAn example web page URL is thecrashcourse.com/courses.\n一个网页URL的例子是 \"thecrashcourse.com/courses\"\n\nLike we discussed last episode, when you request a site,\n就像上集讨论的，当你访问一个网站时\n\nthe first thing your computer does is a DNS lookup.\n计算机首先会做\"DNS查找\"\n\nThis takes a domain name as input – like \"thecrashcourse.com\"\n\"DNS查找\"的输入是一个域名 \\N 比如 thecrashcourse.com\n\nand replies back with the corresponding computer’s IP address.\nDNS 会输出对应的IP地址\n\nNow, armed with the IP address of the computer you want,\n现在有了IP地址 \\N 你的浏览器会打开一个 TCP 连接到这个 IP 地址\n\nyour web browser opens a TCP connection to a computer\n现在有了IP地址 \\N 你的浏览器会打开一个 TCP 连接到这个 IP 地址\n\nthat’s running a special piece of software called a web server.\n这个地址运行着\"网页服务器\"\n\nThe standard port number for web servers is port 80.\n网页服务器的标准端口是 80 端口\n\nAt this point, all your computer has done is connect to\n这时，你的计算机连到了 \\N thecrashcourse.com 的服务器\n\nthe web server at the address thecrashcourse.com\n这时，你的计算机连到了 \\N thecrashcourse.com 的服务器\n\nThe next step is to ask that web server for the \"courses\" hypertext page.\n下一步是向服务器请求\"courses\"这个页面\n\nTo do this, it uses the aptly named Hypertext Transfer Protocol, or HTTP.\n这里会用\"超文本传输协议\"(HTTP)\n\nThe very first documented version of this spec, HTTP 0.9, created in 1991,\nHTTP的第一个标准，HTTP 0.9，创建于1991年\n\nonly had one command – \"GET\".\n只有一个指令，\"GET\" 指令\n\nFortunately, that’s pretty much all you need.\n幸运的是，对当时来说也够用\n\nBecause we’re trying to get the \"courses\" page,\n因为我们想要的是\"courses\"页面\n\nwe send the server the following command– GET /courses.\n我们向服务器发送指令:\"GET /courses\"\n\nThis command is sent as raw ASCII text to the web server,\n该指令以\"ASCII编码\"发送到服务器\n\nwhich then replies back with the web page hypertext we requested.\n服务器会返回该地址对应的网页 \\N 然后浏览器会渲染到屏幕上\n\nThis is interpreted by your computer's web browser and rendered to your screen.\n服务器会返回该地址对应的网页 \\N 然后浏览器会渲染到屏幕上\n\nIf the user follows a link to another page, the computer just issues another GET request.\n如果用户点了另一个链接，计算机会重新发一个GET请求\n\nAnd this goes on and on as you surf around the website.\n你浏览网站时，这个步骤会不断重复\n\nIn later versions, HTTP added status codes,\n在之后的版本，HTTP添加了状态码\n\nwhich prefixed any hypertext that was sent following a GET request.\n状态码放在请求前面\n\nFor example, status code 200 means OK – I’ve got the page and here it is!\n举例，状态码 200 代表 \"网页找到了,给你\"\n\nStatus codes in the four hundreds are for client errors.\n状态码400~499代表客户端出错\n\nLike, if a user asks the web server for a page that doesn’t exist,\n比如网页不存在，就是可怕的404错误\n\nthat’s the dreaded 404 error!\n比如网页不存在，就是可怕的404错误\n\nWeb page hypertext is stored and sent as plain old text,\n\"超文本\"的存储和发送都是以普通文本形式\n\nfor example, encoded in ASCII or UTF-16, which we talked about in Episodes 4 and 20.\n举个例子，编码可能是 ASCII 或 UTF-16  \\N 我们在第4集和第20集讨论过\n\nBecause plain text files don’t have a way to specify what’s a link and what’s not,\n因为如果只有纯文本 \\N 无法表明什么是链接，什么不是链接\n\nit was necessary to develop a way to \"mark up\" a text file with hypertext elements.\n所以有必要开发一种标记方法\n\nFor this, the Hypertext Markup Language was developed.\n因此开发了 超文本标记语言（HTML)\n\nThe very first version of HTML version 0.8, created in 1990,\nHTML 第一版的版本号是 0.8，创建于 1990 年\n\nprovided 18 HTML commands to markup pages.\n有18种HTML指令\n\nThat’s it!\n仅此而已\n\nLet’s build a webpage with these!\n我们来做一个网页吧！\n\nFirst, let’s give our web page a big heading.\n首先，给网页一个大标题\n\nTo do this, we type in the letters \"h1\", which indicates the start of a first level\n我们输 h1 代表一级标题，然后用<>括起来\n\nheading, and we surround that in angle brackets.\n我们输 h1 代表一级标题，然后用<>括起来\n\nThis is one example of an HTML tag.\n这就是一个HTML标签\n\nThen, we enter whatever heading text we want.\n然后输入想要的标题\n\nWe don’t want the whole page to be a heading.\n我们不想一整页都是标题 \\N 所以加 </h1> 作为结束标签\n\nSo, we need to \"close\" the \"h1\" tag like so, with a little slash in the front.\n我们不想一整页都是标题 \\N 所以加 </h1> 作为结束标签\n\nNow lets add some content.\n现在来加点内容\n\nVisitors may not know what Klingons are, so let’s make that word a hyperlink to the\n读者可能不知道\"克林贡\"是什么，所以我们给这个词\n\nKlingon Language Institute for more information.\n加一个超链接到\"克林贡语言研究院\"\n\nWe do this with an \"A\" tag, inside of which we include an attribute\n我们用 <a> 标签来做，它有一个 href 属性\n\nthat specifies a hyperlink reference.\n说明链接指向哪里，当点击链接时就会进入那个网页\n\nThat’s the page to jump to if the link is clicked.\n说明链接指向哪里，当点击链接时就会进入那个网页\n\nAnd finally, we need to close the A tag.\n最后用 </a> 关闭标签\n\nNow lets add a second level heading, which uses an \"h2\" tag.\n接下来用 <h2> 标签做二级标题\n\nHTML also provides tags to create lists.\nHTML也有做列表的标签\n\nWe start this by adding the tag for an ordered list.\n我们先写<ol> \\N 代表 有序列表（ordered list）\n\nThen we can add as many items as we want,\n然后想加几个列表项目  就加几个 \\N 用 <li> 包起来就行\n\nsurrounded in \"<li>\" tags, which stands for list item.\n然后想加几个列表项目  就加几个 \\N 用 <li> 包起来就行\n\nPeople may not know what a bat'leth is, so let’s make that a hyperlink too.\n读者可能不知道Bat'leth是什么，那么也加上超链接\n\nLastly, for good form, we need to close the ordered list tag.\n最后，为了保持良好格式，用</ol>代表列表结束\n\nAnd we’re done – that’s a very simple web page!\n这就完成了 - 一个很简单的网页！\n\nIf you save this text into notepad or textedit, and name it something like \"test.html\",\n如果把这些文字存入记事本或文本编辑器，\\N 然后文件取名\"test.html\"\n\nyou should be able to open it by dragging it into your computer’s web browser.\n就可以拖入浏览器打开\n\nOf course, today’s web pages are a tad more sophisticated.\n当然，如今的网页更复杂一些\n\nThe newest version of HTML, version 5, has over a hundred different tags –\n最新版的 HTML，HTML5，有100多种标签\n\nfor things like images, tables, forms and buttons.\n图片标签，表格标签，表单标签，按钮标签，等等\n\nAnd there are other technologies we’re not going to discuss, like Cascading Style Sheets\n还有其他相关技术就不说了\\N 比如 层叠样式表 (CSS)\n\nor CSS and JavaScript, which can be embedded into HTML pages and do even fancier things.\n和 JavaScript，这俩可以加进网页，做一些更厉害的事\n\nThat brings us back to web browsers.\n让我们回到浏览器\n\nThis is the application on your computer that lets you talk with all these web servers.\n网页浏览器可以和网页服务器沟通\n\nBrowsers not only request pages and media,\n浏览器不仅获取网页和媒体，获取后还负责显示.\n\nbut also render the content that’s being returned.\n浏览器不仅获取网页和媒体，获取后还负责显示.\n\nThe first web browser, and web server,\n第一个浏览器和服务器\n\nwas written by (now Sir) Tim Berners-Lee over the course of two months in 1990.\n是 Tim Berners-Lee 在 1990 年写的，一共花了2个月\n\nAt the time, he was working at CERN in Switzerland.\n那时候他在瑞士的\"欧洲核子研究所\"工作\n\nTo pull this feat off, he simultaneously created several of the fundamental web standards\n为了做出来，他同时建立了几个最基本的网络标准\n\nwe discussed today: URL, HTML and HTTP.\nURL, HTML 和 HTTP.\n\nNot bad for two months work!\n两个月能做这些很不错啊！\n\nAlthough to be fair, he’d been researching hypertext systems for over a decade.\n不过公平点说，他研究超文本系统已经有十几年了\n\nAfter initially circulating his software amongst colleagues at CERN,\n和同事在 CERN 内部使用一阵子后\n\nit was released to the public in 1991.\n在 1991 年发布了出去\n\nThe World Wide Web was born.\n万维网就此诞生\n\nImportantly, the web was an open standard,\n重要的是，万维网有开放标准\n\nmaking it possible for anyone to develop new web servers and browsers.\n大家都可以开发新服务器和新浏览器\n\nThis allowed a team at the University of Illinois at Urbana-Champaign to\n因此\"伊利诺伊大学香槟分校\"的一个小组\n\ncreate the Mosaic web browser in 1993.\n在 1993 年做了 Mosaic 浏览器\n\nIt was the first browser that allowed graphics to be embedded alongside text;\n第一个可以在文字旁边显示图片的浏览器\n\nprevious browsers displayed graphics in separate windows.\n之前浏览器要单开一个新窗口显示图片\n\nIt also introduced new features like bookmarks, and had a friendly GUI interface,\n还引进了书签等新功能，界面友好，使它很受欢迎\n\nwhich made it popular.\n还引进了书签等新功能，界面友好，使它很受欢迎\n\nEven though it looks pretty crusty, it’s recognizable as the web we know today!\n尽管看上去硬邦邦的，但和如今的浏览器长的差不多\n\nBy the end of the 1990s, there were many web browsers in use,\n1990年代末有许多浏览器面世\n\nlike Netscape Navigator, Internet Explorer, Opera, OmniWeb and Mozilla.\nNetscape Navigator, Internet Explorer \\N Opera, OmniWeb, Mozilla\n\nMany web servers were also developed,\n也有很多服务器面世\n\nlike Apache and Microsoft’s Internet Information Services (IIS).\n比如 Apache 和 微软互联网信息服务(IIS)\n\nNew websites popped up daily, and web mainstays\n每天都有新网站冒出来，如今的网络巨头\n\nlike Amazon and eBay were founded in the mid-1990s.\n比如亚马逊和 eBay，创始于 1990 年代中期\n\nIt was a golden era!\n那是个黄金时代！\n\nThe web was flourishing and people increasingly needed ways to find things.\n随着万维网日益繁荣，人们越来越需要搜索\n\nIf you knew the web address of where you wanted to go –\n如果你知道网站地址 \\N 比如 ebay.com，直接输入浏览器就行\n\nlike ebay.com – you could just type it into the browser.\n如果你知道网站地址 \\N 比如 ebay.com，直接输入浏览器就行\n\nBut what if you didn’t know where to go?\n如果不知道地址呢？\n\nLike, you only knew that you wanted pictures of cute cats.\n比如想找可爱猫咪的图片\n\nRight now!\n现在就要！\n\nWhere do you go?\n去哪里找呢？\n\nAt first, people maintained web pages\n起初人们会维护一个目录，链接到其他网站\n\nwhich served as directories hyperlinking to other websites.\n起初人们会维护一个目录，链接到其他网站\n\n\"Most famous among these was \"Jerry and David's guide to the World Wide Web\",\n其中最有名的叫\"Jerry和David的万维网指南\"\n\nrenamed Yahoo in 1994.\n1994年改名为Yahoo\n\nAs the web grew, these human-edited directories started to get unwieldy,\n随着网络越来越大，人工编辑的目录变得不便利\n\nand so search engines were developed.\n所以开发了搜索引擎\n\nLet’s go to the thought bubble!\n让我们进入思想泡泡!\n\nThe earliest web search engine that operated like the ones we use today, was JumpStation,\n长的最像现代搜索引擎的最早搜素引擎，叫JumpStation\n\ncreated by Jonathon Fletcher in 1993 at the University of Stirling.\n由Jonathon Fletcher于1993年在斯特林大学创建\n\nThis consisted of three pieces of software that worked together.\n它有 3 个部分\n\nThe first was a web crawler, software that followed all the links it could find on the web;\n第一个是爬虫，一个跟着链接到处跑的软件\n\nanytime it followed a link to a page that had new links,\n每当看到新链接，就加进自己的列表里\n\nit would add those to its list.\n每当看到新链接，就加进自己的列表里\n\nThe second component was an ever enlarging index,\n第二个部分是不断扩张的索引\n\nrecording what text terms appeared on what pages the crawler had visited.\n记录访问过的网页上，出现过哪些词\n\nThe final piece was a search algorithm that consulted the index;\n最后一个部分，是查询索引的搜索算法\n\nfor example, if I typed the word \"cat\" into JumpStation,\n举个例子，如果我在 JumpStation 输入\"猫\"\n\nevery webpage where the word \"cat\" appeared would come up in a list.\n每个有\"猫\"这个词的网页都会出现\n\nEarly search engines used very simple metrics to rank order their search results, most often\n早期搜索引擎的排名方式 非常简单\n\njust the number of times a search term appeared on a page.\n取决于 搜索词在页面上的出现次数\n\nThis worked okay, until people started gaming the system,\n刚开始还行，直到有人开始钻空子\n\nlike by writing \"cat\" hundreds of times on their web pages just to steer traffic their way.\n比如在网页上写几百个\"猫\"，把人们吸引过来\n\nGoogle’s rise to fame was in large part\n谷歌成名的一个很大原因是 \\N 创造了一个聪明的算法来规避这个问题\n\ndue to a clever algorithm that sidestepped this issue.\n谷歌成名的一个很大原因是 \\N 创造了一个聪明的算法来规避这个问题\n\nInstead of trusting the content on a web page,\n与其信任网页上的内容 \\N 搜索引擎会看其他网站 有没有链接到这个网站\n\nthey looked at how other websites linked to that page.\n与其信任网页上的内容 \\N 搜索引擎会看其他网站 有没有链接到这个网站\n\nIf it was a spam page with the word cat over and over again, no site would link to it.\n如果只是写满\"猫\"的垃圾网站，没有网站会指向它\n\nBut if the webpage was an authority on cats, then other sites would likely link to it.\n如果有关于猫的有用内容，有网站会指向它\n\nSo the number of what are called \"backlinks\", especially from reputable sites,\n所以这些\"反向链接\"的数量，特别是有信誉的网站\n\nwas often a good sign of quality.\n代表了网站质量\n\nThis started as a research project called BackRub at Stanford University in 1996, before\nGoogle 一开始时是 1996 年斯坦福大学 \\N 一个叫 BackRub 的研究项目\n\nbeing spun out, two years later, into the Google we know today.\n两年后分离出来，演变成如今的谷歌\n\nThanks thought bubble!\n谢谢思想泡泡！\n\nFinally, I want to take a second to talk about a term you’ve probably heard a lot recently,\n最后 我想讲一个词，你最近可能经常听到\n\n\"Net Neutrality\".\n网络中立性\n\nNow that you’ve built an understanding of packets, internet routing, and the World Wide\n现在你对数据包，路由和万维网，有了个大体概念\n\nWeb, you know enough to understand the essence, at least the technical essence, of this big debate.\n足够你理解这个争论的核心点，至少从技术角度\n\nIn short, network neutrality is the principle that\n简单说\"网络中立性\"是\n\nall packets on the internet should be treated equally.\n应该平等对待所有数据包\n\nIt doesn’t matter if the packets are my email or you streaming this video,\n不论这个数据包是我的邮件，或者是你在看视频\n\nthey should all chug along at the same speed and priority.\n速度和优先级应该是一样的\n\nBut many companies would prefer that their data arrive to you preferentially.\n但很多公司会乐意让它们的数据优先到达\n\nTake for example, Comcast, a large ISP that also owns many TV channels,\n拿 Comcast 举例，它们不但是大型互联网服务提供商\\N 而且拥有多家电视频道\n\nlike NBC and The Weather Channel, which are streamed online.\n比如 NBC 和 The Weather Channel，可以在线看.\n\nNot to pick on Comcast, but in the absence of Net Neutrality rules,\n我不是特意找Comcast麻烦 \\N 但要是没有网络中立性\n\nthey could for example say that they want their content to be delivered silky smooth, with high priority…\nComcast 可以让自己的内容优先到达 \\N 节流其他线上视频\n\nBut other streaming videos are going to get throttled,\nComcast 可以让自己的内容优先到达 \\N 节流其他线上视频\n\nthat is, intentionally given less bandwidth and lower priority.\n节流(Throttled) 意思是故意给更少带宽和更低优先级\n\nAgain I just want to reiterate here this is just conjecture.\n再次重申，这只是举例，不是说 Comcast 很坏\n\nAt a high level, Net Neutrality advocates argue that giving internet providers this\n支持网络中立性的人说 \\N 没有中立性后，服务商可以推出提速的\"高级套餐\"\n\nability to essentially set up tolls on the internet – to provide premium packet delivery\n支持网络中立性的人说 \\N 没有中立性后，服务商可以推出提速的\"高级套餐\"\n\nplants the seeds for an exploitative business model.\n给剥削性商业模式埋下种子\n\nISPs could be gatekeepers to content, with strong incentives to not play nice with competitors.\n互联网服务供应商成为信息的\"守门人\"，\\N 它们有着强烈的动机去碾压对手\n\nAlso, if big companies like Netflix and Google can pay to get special treatment,\n另外，Netflix和Google这样的大公司可以花钱买特权\n\nsmall companies, like start-ups, will be at a disadvantage, stifling innovation.\n而小公司，比如刚成立的创业公司，\\N 会处于劣势，阻止了创新\n\nOn the other hand, there are good technical reasons why you might\n另一方面，从技术原因看\n\nwant different types of data to flow at different speeds.\n也许你会希望不同数据传输速度不同\n\nThat skype call needs high priority,\n你希望Skype的优先级更高，邮件晚几秒没关系\n\nbut it’s not a big deal if an email comes in a few seconds late.\n你希望Skype的优先级更高，邮件晚几秒没关系\n\nNet-neutrality opponents also argue that market forces and competition would discourage bad\n而反对\"网络中立性\"的人认为，市场竞争会阻碍不良行为\n\nbehavior, because customers would leave ISPs that are throttling sites they like.\n如果供应商把客户喜欢的网站降速 \\N 客户会离开供应商\n\nThis debate will rage on for a while yet, and as we always encourage on Crash Course,\n这场争辩还会持续很久，\\N 就像我们在 Crash Course 其他系列中说过\n\nyou should go out and learn more\n你应该自己主动了解更多信息\n\nbecause the implications of Net Neutrality are complex and wide-reaching.\n因为\"网络中立性\"的影响十分复杂而且广泛\n\nI’ll see you next week.\n我们下周再见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/31. 计算机安全-Cybersecurity.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nOver the last three episodes, we’ve talked about how computers have become interconnected,\n过去3集 我们讲了计算机如何互连\n\nallowing us to communicate near-instantly across the globe.\n让我们能瞬时跨全球沟通\n\nBut, not everyone who uses these networks is going to play by the rules,\n但不是每个使用网络的人都会规规矩矩  不损害他人利益\n\nor have our best interests at heart.\n但不是每个使用网络的人都会规规矩矩  不损害他人利益\n\nJust as how we have physical security like locks, fences\n就像现实世界中我们用锁和栅栏保证物理安全\n\nand police officers to minimize crime in the real world,\n有警察减少犯罪\n\nwe need cybersecurity to minimize crime and harm in the virtual world.\n我们需要网络安全减少虚拟世界中的犯罪\n\nComputers don’t have ethics.\n计算机没有道德观念\n\nGive them a formally specified problem and\n只要给计算机写清具体问题  它们很乐意地闪电般算出答案\n\nthey’ll happily pump out an answer at lightning speed.\n只要给计算机写清具体问题  它们很乐意地闪电般算出答案\n\nRunning code that takes down a hospital’s computer systems\n破坏医院计算机系统的代码 和 保持病人心跳的代码 \\N 对计算机来说没有区别\n\nis no different to a computer than code that keeps a patient's heart beating.\n破坏医院计算机系统的代码 和 保持病人心跳的代码 \\N 对计算机来说没有区别\n\nLike the Force, computers can be pulled to the light side or the dark side.\n就像\"原力\"一样 \\N 计算机可以被拉到\"光明面\"或\"黑暗面\"\n\nCybersecurity is like the Jedi Order, trying to bring peace and justice to the cyber-verse.\n网络安全就像 绝地武士团 \\N 给网络世界带来和平与正义\n\nThe scope of cybersecurity evolves as fast as the capabilities of computing,\n计算机安全的范围，和计算能力的发展速度一样快\n\nbut we can think of it as a set of techniques to protect the secrecy,\n我们可以把计算机安全，看成是保护系统和数据的：\n\nintegrity and availability of computer systems and data against threats.\n保密性，完整性和可用性\n\nLet’s unpack those three goals:\n我们逐个细说：\n\nSecrecy, or confidentiality, means that only authorized people\n\"保密性\"是只有有权限的人 \\N 才能读取计算机系统和数据\n\nshould be able to access or read specific computer systems and data.\n\"保密性\"是只有有权限的人 \\N 才能读取计算机系统和数据\n\nData breaches, where hackers reveal people’s credit card information,\n黑客泄露别人的信用卡信息，就是攻击保密性.\n\nis an attack on secrecy.\n黑客泄露别人的信用卡信息，就是攻击保密性.\n\nIntegrity means that only authorized people\n\"完整性\"是只有有权限的人 \\N 才能使用和修改系统和数据\n\nshould have the ability to use or modify systems and data.\n\"完整性\"是只有有权限的人 \\N 才能使用和修改系统和数据\n\nHackers who learn your password and send e-mails masquerading as you, is an integrity attack.\n黑客知道你的邮箱密码，假冒你发邮件\\N 就是攻击\"完整性\"\n\nAnd availability means that authorized people should\n\"可用性\"是有权限的人 \\N 应该随时可以访问系统和数据\n\nalways have access to their systems and data.\n\"可用性\"是有权限的人 \\N 应该随时可以访问系统和数据\n\nThink of Denial of Service Attacks, where hackers overload a website\n拒绝服务攻击(DDOS) 就是黑客\n\nwith fake requests to make it slow or unreachable for others.\n发大量的假请求到服务器，让网站很慢或者挂掉\n\nThat’s attacking the service’s availability.\n这就是攻击\"可用性\"\n\nTo achieve these three general goals, security experts start with\n为了实现这三个目标，安全专家会从 \\N 抽象层面想象\"敌人\"可能是谁，这叫\"威胁模型分析\"\n\na specification of who your \"enemy\" is, at an abstract level, called a threat model.\n为了实现这三个目标，安全专家会从 \\N 抽象层面想象\"敌人\"可能是谁，这叫\"威胁模型分析\"\n\nThis profiles attackers: their capabilities, goals, and probable means of attack\n模型会对攻击者有个大致描述：\\N 能力如何，目标可能是什么，可能用什么手段\n\n– what’s called, awesomely enough, an attack vector.\n攻击手段又叫\"攻击矢量\"\n\nThreat models let you prepare against specific threats, rather than\n\"威胁模型分析\"让你能为特定情境做准备\n\nbeing overwhelmed by all the ways hackers could get to your systems and data.\n不被可能的攻击手段数量所淹没 \\N 因为手段实在有太多种了\n\nAnd there are many, many ways.\n不被可能的攻击手段数量所淹没 \\N 因为手段实在有太多种了\n\nLet’s say you want to \"secure\" physical access to your laptop.\n假设你想确保笔记本计算机的\"物理安全\" \\N 你的威胁模型是\"好管闲事的室友\"\n\nYour threat model is a nosy roommate.\n假设你想确保笔记本计算机的\"物理安全\" \\N 你的威胁模型是\"好管闲事的室友\"\n\nTo preserve the secrecy, integrity and availability of your laptop,\n为了保证保密性，完整性和可用性 \\N 你可以藏在脏兮兮的洗衣篮里\n\nyou could keep it hidden in your dirty laundry hamper.\n为了保证保密性，完整性和可用性 \\N 你可以藏在脏兮兮的洗衣篮里\n\nBut, if your threat model is a mischievous younger sibling\n但如果威胁模型是调皮的兄弟姐妹，知道你喜欢藏哪里\n\nwho knows your hiding spots,\n但如果威胁模型是调皮的兄弟姐妹，知道你喜欢藏哪里\n\nthen you’ll need to do more: maybe lock it in a safe.\n那么你需要更多保护：比如锁在保险箱里\n\nIn other words, how a system is secured depends heavily on who it’s being secured against.\n换句话说，要怎么保护，具体看对抗谁\n\nOf course, threat models are typically a bit more formally defined than just \"nosy roommate\".\n当然，威胁模型通常比\"好管闲事的室友\"更正式一些\n\nOften you’ll see threat models specified in terms of technical capabilities.\n通常威胁模型分析里 会以能力水平区分\n\nFor example, \"someone who has physical access to your laptop along with unlimited time\".\n比如\"某人可以物理接触到笔记本计算机，而且时间无限\"\n\nWith a given threat model, security architects need to come up\n在给定的威胁模型下，安全架构师要\n\nwith a solution that keeps a system secure –\n提供解决方案，保持系统安全\n\nas long as certain assumptions are met,\n只要某些假设不被推翻\n\nlike no one reveals their password to the attacker.\n比如没人会告诉攻击者密码\n\nThere are many methods for protecting computer systems, networks and data.\n保护计算机系统，网络和数据的方法有很多\n\nA lot of security boils down to two questions:\n很多安全问题可以总结成2个问题：\n\nwho are you, and what should you have access to?\n你是谁？你能访问什么？\n\nClearly, access should be given to the right people, but refused to the wrong people.\n权限应该给合适的人，拒绝错误的人\n\nLike, bank employees should be able to open ATMs to restock them, but not me…\n比如银行员工可以打开取款机来补充现金。\\N 但我不应该有权限打开\n\nbecause I’d take it all... all of it!\n因为我会把钱拿走 全拿走！\n\nThat ceramic cat collection doesn’t buy itself!\n陶瓷猫收藏品可不会从天上掉下来哟！\n\nSo, to differentiate between right and wrong people, we use authentication\n所以，为了区分谁是谁，\\N 我们用 \"身份认证\"(authentication)\n\n- the process by which a computer understands who it’s interacting with.\n- 让计算机得知使用者是谁\n\nGenerally, there are three types, each with their own pros and cons:\n身份认证有三种，各有利弊：\n\nWhat you know.\n你知道什么\n\nWhat you have.\n你有什么\n\nAnd what you are.\n你是什么\n\nWhat you know authentication is based on knowledge of a secret that\n\"你知道什么\" 是基于某个秘密\n\nshould be known only by the real user and the computer,\n只有用户和计算机知道\n\nfor example, a username and password.\n比如 用户名和密码\n\nThis is the most widely used today because it’s the easiest to implement.\n这是如今使用最广泛的，因为最容易实现\n\nBut, it can be compromised if hackers guess or otherwise come to know your secret.\n但如果黑客通过猜测或其他方式，知道你的密码，就惨了\n\nSome passwords are easy for humans to figure out, like 12356 or qwerty.\n有些密码很容易猜中，比如12356或qwerty\n\nBut, there are also ones that are easy for computers.\n但有些密码对计算机很容易\n\nConsider the PIN: 2580.\n比如PIN码：2580\n\nThis seems pretty difficult to guess – and it is – for a human.\n看起来很难猜中 - 起码对人类来说是这样\n\nBut there are only ten thousand possible combinations of 4-digit PINs.\n但4位数字，只有一万种可能\n\nA computer can try entering 0000, then try 0001, and then 0002,\n一台计算机可以尝试0000，然后0001，然后0002，\n\nall the way up to 9999... in a fraction of a second.\n然后到9999，不到一秒内试完\n\nThis is called a brute force attack, because it just tries everything.\n这叫\"暴力攻击\"，因为只是试遍一切可能\n\nThere’s nothing clever to the algorithm.\n这种算法没什么聪明的地方\n\nSome computer systems lock you out, or have you wait a little, after say three wrong attempts.\n如果你错误尝试3次，\\N 有些系统会阻止你继续尝试，或让你等一会儿\n\nThat’s a common and reasonable strategy,\n这个策略普遍而且合理\n\nand it does make it harder for less sophisticated attackers.\n对于一般的攻击者确实很难\n\nBut think about what happens if hackers have already taken over\n但假设黑客控制了\n\ntens of thousands of computers, forming a botnet.\n数以万计的计算机，形成一个僵尸网络\n\nUsing all these computers, the same pin – 2580 –\n用这么多计算机尝试密码 2580\n\ncan be tried on many tens of thousands of bank accounts simultaneously.\n同时尝试很多银行账户\n\nEven with just a single attempt per account, they’ll very likely\n即使每个账户只试一次，也很可能\n\nget into one or more that just happen to use that PIN.\n碰到某个账户刚好用这个 PIN\n\nIn fact, we’ve probably guessed the pin of someone watching this video!\n事实上，看视频的某人可能刚好用这个 PIN\n\nIncreasing the length of PINs and passwords can help,\n增加密码长度有帮助\n\nbut even 8 digit PINs are pretty easily cracked.\n但即使8位数字的PIN码也很容易破解\n\nThis is why so many websites now require you to use a mix of upper and lowercase letters,\n这就是为什么现在很多网站 要求大写+小写字母\n\nspecial symbols, and so on – it explodes the number of possible password combinations.\n还有特殊符号等，大大增加可能的密码\n\nAn 8-digit numerical PIN only has a hundred million combinations\n8位数字的PIN只有一亿种组合\n\n– computers eat that for breakfast!\n对计算机轻而易举\n\nBut an 8-character password with all those funky things mixed in\n但包含各种字符的8位长度密码\n\nhas more than 600 trillion combinations.\n有超过600万亿种组合\n\nOf course, these passwords are hard for us mere humans to remember,\n当然，这些密码会难以记住，\n\nso a better approach is for websites to let us pick something more memorable,\n所以更好的方法是 选一些更好记的东西\n\nlike three words joined together:\n比如三个单词连在一起：\n\n\"green brothers rock\" or \"pizza tasty yum\".\n\"格林兄弟好厉害\"或\"披萨尝起来好好吃\"\n\nEnglish has around 100,000 words in use,\n英文大约有10万个单词\n\nso putting three together would give you roughly\n所以三个单词连一起大概有\n\n1 quadrillion possible passwords. Good luck trying to guess that!\n1亿亿种可能，想猜中的话，祝你好运！\n\nI should also note here that using non-dictionary words\n另外使用不在字典内的单词\n\nis even better against more sophisticated kinds of attacks,\n被猜中的可能性更低\n\nbut we don’t have time to get into that here.\n但我们没时间细说这个\n\nComputerphile has a great video on choosing a password - link in the dooblydoo.\nComputerphile 频道有个视频讲怎么选择好密码 - \\N 链接请看 Youtube 描述\n\nWhat you have authentication, on the other hand,\n\"你有什么\"这种验证方式\n\nis based on possession of a secret token that only the real user has.\n是基于用户有特定物体\n\nAn example is a physical key and lock.\n比如钥匙和锁\n\nYou can only unlock the door if you have the key.\n如果你有钥匙，就能开门\n\nThis escapes this problem of being \"guessable\".\n这避免了被人\"猜中\"的问题\n\nAnd they typically require physical presence,\n而且通常需要人在现场\n\nso it’s much harder for remote attackers to gain access.\n所以远程攻击就更难了\n\nSomeone in another country can’t gain access to your front door in Florida\n另一个国家的人，得先来佛罗里达州\n\nwithout getting to Florida first.\n才能到你家前门\n\nBut, what you have authentication can be compromised if an attacker is physically close.\n但如果攻击者离你比较近，那么也不安全\n\nKeys can be copied, smartphones stolen, and locks picked.\n钥匙可以被复制，手机可能被偷，锁可以撬开\n\nFinally, what you are authentication is based on... you!\n最后，\"你是什么\"这种验证，是基于你\n\nYou authenticate by presenting yourself to the computer.\n把特征展示给计算机进行验证\n\nBiometric authenticators, like fingerprint readers and iris scanners are classic examples.\n生物识别验证器，\\N 比如指纹识别器和虹膜扫描仪就是典型例子\n\nThese can be very secure, but the best technologies are still quite expensive.\n这些非常安全，但最好的识别技术仍然很贵\n\nFurthermore, data from sensors varies over time.\n而且，来自传感器的数据每次会不同\n\nWhat you know and what you have authentication have the nice property of being deterministic\n\"你知道什么\"和\"你有什么\"。这两种验证是\"确定性\"的\n\n– either correct or incorrect.\n- 要么正确，要么错误\n\nIf you know the secret, or have the key, you’re granted access 100% of the time.\n如果你知道密码，或有钥匙，那么100％能获得访问权限\n\nIf you don’t, you get access zero percent of the time.\n如果没有，就绝对进不去\n\nBiometric authentication, however, is probabilistic.There’s some chance the system won’t recognize you…\n但\"生物识别\"是概率性的，系统有可能认不出你\n\nmaybe you’re wearing a hat or the lighting is bad.\n可能你戴了帽子，或者光线不好\n\nWorse, there’s some chance the system will recognize the wrong person as you\n更糟的是，系统可能把别人错认成你\n\n– like your evil twin!\n比如你的邪恶双胞胎\n\nOf course, in production systems, these chances are low, but not zero.\n当然，在现实世界中几率很低，但不是零\n\nAnother issue with biometric authentication is it can’t be reset.\n生物认证的另一个问题是无法重设\n\nYou only have so many fingers, so what happens if an attacker compromises your fingerprint data?\n你只有这么多手指，如果攻击者拿到你的指纹数据怎么办\n\nThis could be a big problem for life.\n你一辈子都麻烦了\n\nAnd, recently, researchers showed it’s possible to forge your iris\n最近还有研究人员表示，拍个照都有可能伪造虹膜\n\njust by capturing a photo of you, so that’s not promising either.\n所以也不靠谱\n\nBasically, all forms of authentication have strengths and weaknesses,\n所有认证方法都有优缺点，\n\nand all can be compromised in one way or another.\n它们都可以被攻破\n\nSo, security experts suggest using two or more forms of authentication\n所以，对于重要账户，\\N 安全专家建议用两种或两种以上的认证方式\n\nfor important accounts.\n所以，对于重要账户，\\N 安全专家建议用两种或两种以上的认证方式\n\nThis is known as two-factor or multi-factor authentication.\n这叫\"双因素\"或\"多因素\"认证\n\nAn attacker may be able to guess your password or steal your phone:\n攻击者可能猜出你密码，或偷走你的手机：\n\nbut it’s much harder to do both.\n但两个都做到，会比较难\n\nAfter authentication comes Access Control.\n\"身份验证\"后，就来到了\"访问控制\"\n\nOnce a system knows who you are, it needs to know what you should be able to access,\n一旦系统知道你是谁，它需要知道你能访问什么，\n\nand for that there’s a specification of who should be able to see, modify and use what.\n因此应该有个规范，\\N 说明谁能访问什么，修改什么，使用什么。\n\nThis is done through Permissions or Access Control Lists (ACL),\n这可以通过\"权限\"或\"访问控制列表\"（ACL）来实现\n\nwhich describe what access each user has for every file, folder and program on a computer.\n其中描述了用户对每个文件，文件夹和程序的访问权限\n\n\"Read\" permission allows a user to see the contents of a file,\n\"读\"权限允许用户查看文件内容，\n\n\"write\" permission allows a user to modify the contents,\n\"写\"权限允许用户修改内容，\n\nand \"execute\" permission allows a user to run a file, like a program.\n\"执行\"权限允许用户运行文件，比如程序\n\nFor organizations with users at different levels of access privilege\n有些组织需要不同层级的权限\n\n– like a spy agency – it’s especially important for Access Control Lists\n比如间谍机构，\"访问控制列表\"的正确配置非常重要\n\nto be configured correctly to ensure secrecy, integrity and availability.\n以确保保密性，完整性和可用性\n\nLet’s say we have three levels of access: public, secret and top secret.\n假设我们有三个访问级别：公开，机密，绝密\n\nThe first general rule of thumb is that people shouldn’t be able to \"read up\".\n第一个普遍的好做法是，\\N 用户不能\"读上\", 不能读等级更高的信息\n\nIf a user is only cleared to read secret files, they shouldn’t be able to read top secret\n如果用户能读\"机密\"文件\\N 那么不应该有权限读\"绝密\"文件\n\nfiles, but should be able to access secret and public ones.\n但能访问\"机密\"和\"公开\"文件\n\nThe second general rule of thumb is that people shouldn’t be able to \"write down\".\n第二个法则是用户不能\"写下\"\n\nIf a member has top secret clearance, then they should be able to\n如果用户等级是\"绝密\"\n\nwrite or modify top secret files, but not secret or public files.\n那么能写入或修改\"绝密\"文件，\\N 但不能修改\"机密\"或\"公共\"文件\n\nIt may seem weird that even with the highest clearance,\n听起来好像很奇怪 \\N 有最高等级也不能改等级更低的文件\n\nyou can’t modify less secret files.\n听起来好像很奇怪 \\N 有最高等级也不能改等级更低的文件\n\nBut, it guarantees that there’s no accidental leakage of\n但这样确保了\"绝密\" \\N 不会意外泄露到\"机密\"文件或\"公共\"文件里\n\ntop secret information into secret or public files.\n但这样确保了\"绝密\" \\N 不会意外泄露到\"机密\"文件或\"公共\"文件里\n\nThis \"no read up, no write down\" approach is called the Bell-LaPadula model.\n这个\"不能向上读，不能向下写\"的方法\\N 叫 Bell-LaPadula 模型\n\nIt was formulated for the U.S. Department of Defense’s Multi-Level Security policy.\n它是为美国国防部\"多层安全政策\"制定的\n\nThere are many other models for access control – like the Chinese Wall model and Biba model.\n还有许多其他的访问控制模型 - 比如\"中国墙\"模型和\"比伯\"模型\n\nWhich model is best depends on your use-case.\n哪个模型最好，取决于具体情况\n\nAuthentication and access control help a computer determine who you are\n\"身份验证\"和\"访问控制\"帮助计算机知道\"你是谁\"\n\nand what you should access,\n以及\"你可以访问什么\"，\n\nbut depend on being able to trust the hardware and software\n但做这些事情的软硬件必须是可信的\n\nthat run the authentication and access control programs.\n但做这些事情的软硬件必须是可信的\n\nThat’s a big dependence.\n这个依赖很重要\n\nIf an attacker installs malicious software – called malware\n如果攻击者给计算机装了恶意软件\n\n– compromising the host computer’s operating system,\n- 控制了计算机的操作系统\n\nhow can we be sure security programs don’t have a backdoor that let attackers in?\n我们怎么确定安全程序没有给攻击者留后门？\n\nThe short answer is… we can’t.\n短回答是...无法确定\n\nWe still have no way to guarantee the security of a program or computing system.\n我们仍然无法保证程序或计算机系统的安全\n\nThat’s because even while security software might be \"secure\" in theory,\n因为安全软件在理论上可能是\"安全的\"\n\nimplementation bugs can still result in vulnerabilities.\n实现时可能会不小心留下漏洞\n\nBut, we do have techniques to reduce the likelihood of bugs,\n但我们有办法减少漏洞出现的可能性\n\nlike quickly find and patch bugs when they do occur,\n比如一找到就马上修复\n\nand mitigate damage when a program is compromised.\n以及当程序被攻破时尽可能减少损害\n\nMost security errors come from implementation error.\n大部分漏洞都是具体实现的时候出错了\n\nTo reduce implementation error, reduce implementation.\n为了减少执行错误，减少执行\n\nOne of the holy grails of system level security is a \"security kernel\"\n系统级安全的圣杯之一是\"安全内核\"\n\nor a \"trusted computing base\": a minimal set of operating system software\n或\"可信计算基础\"：一组尽可能少的操作系统软件\n\nthat’s close to provably secure.\n安全性都是接近可验证的\n\nA challenge in constructing these security kernels is deciding what should go into it.\n构建安全内核的挑战在于 决定内核应该有什么\n\nRemember, the less code, the better!\n记住，代码越少越好！\n\nEven after minimizing code bloat, it would be great to \"guarantee\"\n在最小化代码数量之后，\\N 要是能\"保证\"代码是安全的，会非常棒\n\nthat’s code is written in secure.\n在最小化代码数量之后，\\N 要是能\"保证\"代码是安全的，会非常棒\n\nFormally verifying the security of code is an active area of research.\n正式验证代码的安全性 是一个活跃的研究领域\n\nThe best we have right now is a process called Independent Verification and Validation.\n我们现在最好的手段，叫\"独立安全检查和质量验证\"\n\nThis works by having code audited by a crowd of security-minded developers.\n让一群安全行业内的软件开发者来审计代码\n\nThis is why security code is almost always open-sourced.\n这就是为什么安全型代码几乎都是开源的\n\nIt’s often difficult for people who wrote the original code to find bugs,\n写原始代码的人通常很难找到错误\n\nbut external developers, with fresh eyes and different expertise, can spot problems.\n但外部开发人员有新鲜的眼光 \\N和不同领域的专业知识，可以发现问题.\n\nThere are also conferences where like-minded hackers and security experts\n另外还有一些安全大会，安全专家可以相互认识，分享想法.\n\ncan mingle and share ideas,\n另外还有一些安全大会，安全专家可以相互认识，分享想法.\n\nthe biggest of which is DEF CON, held annually in Las Vegas.\n一年一次在拉斯维加斯举办的 DEF CON \\N 是全球最大的安全大会\n\nFinally, even after reducing code and auditing it,\n最后，即便尽可能减少代码 并进行了安全审计\n\nclever attackers are bound to find tricks that let them in.\n聪明的攻击者还是会找到方法入侵\n\nWith this in mind, good developers should take the approach that,\n因为如此，优秀的开发人员\n\nnot if, but when their programs are compromised,\n应该计划当程序被攻破后，\\N如何限制损害，控制损害的最大程度\n\nthe damage should be limited and contained,\n应该计划当程序被攻破后，\\N如何限制损害，控制损害的最大程度\n\nand not let it compromise other things running on the computer.\n并且不让它危害到计算机上其他东西\n\nThis principle is called isolation.\n这叫\"隔离\"\n\nTo achieve isolation, we can \"sandbox\" applications.\n要实现隔离，我们可以\"沙盒\"程序\n\nThis is like placing an angry kid in a sandbox; when the kid goes ballistic,\n这好比把生气的小孩放在沙箱里，\n\nthey only destroy the sandcastle in their own box,\n他们只能摧毁自己的沙堡，不会影响到其他孩子\n\nbut other kids in the playground continue having fun.\n他们只能摧毁自己的沙堡，不会影响到其他孩子\n\nOperating Systems attempt to sandbox applications\n操作系统会把程序放到沙盒里\n\nby giving each their own block of memory that others programs can’t touch.\n方法是给每个程序独有的内存块，其他程序不能动\n\nIt’s also possible for a single computer to run multiple Virtual Machines, essentially\n一台计算机可以运行多个虚拟机\n\nsimulated computers, that each live in their own sandbox.\n虚拟机模拟计算机，每个虚拟机都在自己的沙箱里\n\nIf a program goes awry, worst case is that it crashes or\n如果一个程序出错，最糟糕的情况是它自己崩溃\n\ncompromises only the virtual machine on which it’s running.\n或者搞坏它处于的虚拟机\n\nAll other Virtual Machines running on the computer are isolated and unaffected.\n计算机上其他虚拟机是隔离的，不受影响\n\nOk, that’s a broad overview of some key computer security topics.\n好，一些重要安全概念的概览 \\N 我们到此就介绍完了\n\nAnd I didn’t even get to network security, like firewalls.\n我都还没讲网络安全，比如防火墙\n\nNext episode, we’ll discuss some methods\n下集我们会讨论  黑客侵入系统的一些方法\n\nhackers use to get into computer systems.\n下集我们会讨论  黑客侵入系统的一些方法\n\nAfter that, we’ll touch on encryption.\n然后我们学加密\n\nUntil then, make your passwords stronger, turn on 2-factor authentication,\n在此之前，别忘了加强你的密码，打开两步验证\n\nand NEVER click links in unsolicited emails!\n永远不要点可疑邮件\n\nI’ll see you next week.\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/32. 黑客&攻击-Hackers & Cyber Attacks.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode, we talked about the basics of computer security,\n上集我们讲了计算机安全的基础知识，\n\nprinciples and techniques used to keep computer systems safe and sound.\n包括各种原则和技术\n\nBut, despite our best efforts, the news is full of stories of individuals, companies\n但尽管尽了最大努力，新闻上还是各种 \\N 个人，公司，政府被黑客攻击的故事\n\nand governments getting cyberattacked by hackers, people who,\n但尽管尽了最大努力，新闻上还是各种 \\N 个人，公司，政府被黑客攻击的故事\n\nwith their technical knowledge, break into computer systems.\n那些黑客凭技术知识 闯入计算机系统\n\nNot all hackers are bad though.\n不是所有黑客都是坏人\n\nThere are hackers who hunt for bugs and try to close security holes\n有些黑客会寻找并修复软件漏洞 \\N 让系统更安全\n\nin software to make systems safer and more resilient.\n有些黑客会寻找并修复软件漏洞 \\N 让系统更安全\n\nThey’re often hired by companies and governments to perform security evaluations.\n他们经常被公司和政府雇来做安全评估\n\nThese hackers are called White Hats, they’re the good guys.\n这些黑客叫\"白帽子\"，他们是好人\n\nOn the flip side, there are Black Hats, malicious hackers with\n另一方面，也有\"黑帽\"黑客，他们窃取，\n\nintentions to steal, exploit and sell computer vulnerabilities and data.\n利用和销售计算机漏洞和数据\n\nHackers’ motivations also differ wildly.\n黑客的动机有很多种\n\nSome hack for amusement and curiosity,\n有些是好玩和好奇\n\nwhile cybercriminals hack most often for monetary gain.\n而网络罪犯一般是为了钱\n\nAnd then there are hacktivists, who use their skills to promote a social or political goal.\n还有的叫\"黑客行动主义者\"，\\N 通过黑客手段影响社会或达到政治目的\n\nAnd that’s just the tip of the iceberg.\n这只是冰山一角\n\nBasically, the stereotypical view of a hacker as some unpopular kid sitting in a dark room\n一般对黑客的刻板印象是 \\N 某个不受欢迎的小孩在黑暗的房间里\n\nfull of discarded pizza boxes probably better describes John Green in college than it does hackers.\n到处都是吃完的比萨盒，这个印象是错的，\\N形容约翰·格林的宿舍还更贴切些\n\nToday, we’re not going to teach you how to be a hacker.\n今天，我们不会教你如何成为黑客\n\nInstead, we’ll discuss some classic examples of how hackers\n而是讨论一些入侵原理，给你一个大概概念\n\nbreak into computer systems to give you an idea of how it’s done.\n而是讨论一些入侵原理，给你一个大概概念\n\nThe most common way hackers get into computer systems isn’t\n黑客入侵最常见的方式\n\nby hacking at all; it’s by tricking users into letting them in.\n不是通过技术，而是欺骗别人\n\nThis is called social engineering, where a person is manipulated into divulging confidential\n这叫\"社会工程学\"，欺骗别人让人泄密信息\n\ninformation, or configuring a computer system so that it permits entry by attackers.\n或让别人配置电脑系统，变得易于攻击\n\nThe most common type of attack is phishing, which you most often encounter as an email\n最常见的攻击是网络钓鱼，你可能见过\n\nasking you to login to an account on a website, say your bank.\n银行发邮件叫你点邮件里的链接，登陆账号\n\nYou’ll be asked to click a link in the email, which takes you to a site that looks legit\n然后你会进入一个像官网的网站\n\nto the casual observer, but is really an evil clone.\n但实际上是个假网站\n\nWhen you enter your username and password, that information goes straight to the hackers,\n当你输入用户名和密码时，信息会发给黑客，\n\nwho then can login to the real website as you.\n然后黑客就可以假扮你登陆网站\n\nBad news!\n坏消息！\n\nEven with a 1/10th of one percent success rate, a million phishing emails might yield\n即使成功率只有1/1000，发一百万封钓鱼邮件\n\na thousand compromised accounts.\n也有一千个帐户中招\n\nAnother social engineering attack is pretexting, where attackers call up, let's say a company,\n另一种方法叫 假托(Pretexting)，\\N 攻击者给某个公司打电话\n\nand then confidently pretend to be from their IT department.\n假装是IT部门的人\n\nOften attackers will call a first number, and then ask to be transferred to a second,\n攻击者的第一通电话一般会叫人转接\n\nso that the phone number appears to be internal to the company.\n这样另一个人接的时候，电话看起来像内部的\n\nThen, the attacker can instruct an unwitting user to configure their computer in a compromising\n然后让别人把电脑配置得容易入侵\n\nway, or get them to reveal confidential details, like passwords or network configurations.\n或让他们泄露机密信息，比如密码或网络配置\n\nSorry, one sec…\n不好意思，等一下\n\nOh. Hey, it's Susan from It.\n嘿，我是 IT 部门的苏珊\n\nWe’re having some network issues down here, can you go ahead and check a setting for me?\"\n我们遇到一些网络问题，你能帮我检查一个配置吗？\n\n... and it begins.\n然后就开始了\n\nAttackers can be very convincing, especially with a little bit\n只要预先做一点研究，攻击者可以装得很像真的\n\nof research beforehand to find things like key employees’ names.\n比如关键员工的名字\n\nIt might take ten phone calls to find an victim, but you only need one to get in.\n也许要10通电话才能找到一个受害者，\\N 但只要一个人上当就够了\n\nEmails are also a common delivery mechanism for trojan horses,\n邮件里带\"木马\"也是常见手段\n\nprograms that masquerade as harmless attachments, like a photo or invoice,\n木马会伪装成无害的东西，比如照片或发票\n\nbut actually contain malicious software, called malware.\n但实际上是恶意软件\n\nMalware can take many forms.\n恶意软件有很多种\n\nSome might steal your data, like your banking credentials.\n有的会偷数据，比如银行凭证\n\nOthers might encrypt your files and demand a ransom, what's known as ransomware.\n有的会加密文件，交赎金才解密，也就是\"勒索软件\"\n\nIf they can’t run malware or get a user to let them in,\n如果攻击者无法用木马或电话欺骗\n\nattackers have to force their way in through other means.\n攻击者只能被迫用其他手段\n\nOne method, which we briefly discussed last episode, is to brute force a password\n方法之一是暴力尝试，我们上集讨论过\n\ntry every combination of password until you gain entry.\n尝试所有可能的密码，直到进入系统\n\nMost modern systems defend against this type of attack by having you wait incrementally\n大多数现代系统会加长等待时间，来抵御这种攻击\n\nlonger periods of time following each failed attempt,\n每次失败就加长等待时间\n\nor even lock you out entirely after a certain number of tries.\n甚至失败超过一定次数后，完全锁住\n\nOne recent hack to get around this is called NAND Mirroring,\n最近出现一种攻破方法叫 \"NAND镜像\"\n\nwhere if you have physical access to the computer,\n如果能物理接触到电脑\n\nyou can attach wires to the device's memory chip\n可以往内存上接几根线\n\nand make a perfect copy of its contents.\n复制整个内存\n\nWith this setup, you can try a series of passwords, until the device starts making you wait.\n复制之后，暴力尝试密码，直到设备让你等待\n\nWhen this happens, you just reflash the memory with the original copy you made,\n这时只要把复制的内容覆盖掉内存\n\nessentially resetting it, allowing you to try more passwords immediately, with no waiting.\n本质上重置了内存，就不用等待，可以继续尝试密码了\n\nThis technique was shown to be successful on an iPhone 5C,\n这项方法在 iPhone 5C 上管用\n\nbut many newer devices include mechanisms to thwart this type of attack.\n更新的设备有机制阻止这种攻击\n\nIf you don’t have physical access to a device,\n如果你无法物理接触到设备\n\nyou have to find a way to hack it remotely, like over the internet.\n就必须远程攻击，比如通过互联网.\n\nIn general, this requires an attacker to find and take advantage of a bug in a system, and\n远程攻击一般需要攻击者利用系统漏洞\n\nsuccessfully utilizing a bug to gain capabilities or access is called an exploit.\n来获得某些能力或访问权限，这叫\"漏洞利用\"(Exploit)\n\nOne common type of exploit is a buffer overflow.\n一种常见的漏洞利用叫\"缓冲区溢出\"\n\nBuffers are a general term for a block of memory reserved for storing data.\n\"缓冲区\"是一种概称，指预留的一块内存空间\n\nWe talked about video buffers for storing pixel data in Episode 23.\n我们在第23集，讨论过存像素数据的视频缓冲区\n\nAs a simple example, we can imagine an operating system’s login prompt,\n举个简单例子，假设我们在系统登陆界面\n\nwhich has fields for a username and password.\n要输入用户名和密码\n\nBehind the scenes, this operating system uses buffers for storing the text values that are entered.\n在幕后，系统用缓冲区存输入的值\n\nFor illustration, let's say these buffers were specified to be of size ten.\n假设缓冲区大小是10\n\nIn memory, the two text buffers would look something like this:\n两个文本缓冲区看起来会像这样：\n\nOf course, the operating system is keeping track of a lot more than just a username and\n当然，操作系统记录的远不止用户名和密码\n\npassword, so there’s going to be data stored both before and after in memory.\n所以缓冲区前后 肯定有其他数据\n\nWhen a user enters a username and password, the values are copied into the buffers,\n当用户输入用户名和密码时，这些值会复制到缓冲区\n\nwhere they can be verified.\n然后验证是否正确\n\nA buffer overflow attack does exactly what the name suggests: overflows the buffer.\n\"缓冲区溢出\"正如名字所暗示的：它会溢出缓冲区\n\nIn this case, any password longer than ten characters\n在这个例子中，超过十个字符的密码\n\nwill overwrite adjacent data in memory.\n会覆盖掉相邻的数据\n\nSometimes this will just cause a program or operating system to crash,\n有时只会让程序或系统崩溃，\n\nbecause important values are overwritten with gobbledygook.\n因为重要值被垃圾数据覆盖了\n\nCrashing a system is bad, and maybe that’s all that\n系统崩溃是坏事\n\na mischievous hacker wants to do, be a nuisance.\n但也许恶作剧黑客就只是想系统崩溃，当个讨厌鬼\n\nBut attackers can also exploit this bug more cleverly by injecting purposeful new values\n但攻击者可以更巧妙地利用这个漏洞(bug)，\\N 注入有意义的新值\n\ninto a program’s memory, for example, setting an \"is admin\" variable to true.\n到程序的内存中，比如把\"is_admin\"的值改成true\n\nWith the ability to arbitrarily manipulate a program’s memory,\n有了任意修改内存的能力，\n\nhackers can bypass things like login prompts,\n黑客可以绕过\"登录\"之类的东西，\n\nand sometimes even use that program to hijack the whole system.\n甚至使用那个程序劫持整个系统\n\nThere are many methods to combat buffer overflow attacks.\n有很多方法阻止缓冲区溢出\n\nThe easiest is to always test the length of input before copying it into a buffer,\n最简单的方法是，复制之前先检查长度，\n\ncalled bounds checking.\n这叫 \"边界检查\"\n\nMany modern programming languages implement bounds checking automatically.\n许多现代编程语言自带了边界检查\n\nPrograms can also randomize the memory location of variables,\n程序也会随机存放变量在内存中的位置，\n\nlike our hypothetical \"is admin\" flag,\n比如我们之前假设的\"is_admin\"\n\nso that hackers don’t know what memory location to overwrite,\n这样黑客就不知道应该覆盖内存的哪里\n\nand are more likely to crash the program than gain access.\n导致更容易让程序崩溃，而不是获得访问权限\n\nPrograms can also leave unused space after buffers,\n程序也可以在缓冲区后，留一些不用的空间\n\nand keep an eye on those values to see if they change;\n然后跟踪里面的值，看是否发生变化\n\nif they do, they know an attacker is monkeying around with memory.\n如果发生了变化，说明有攻击者在乱来\n\nThese regions are called canaries, named after the small birds miners\n这些不用的内存空间叫\"金丝雀\"，因为以前矿工会带\n\nused to take underground to warn them of dangerous conditions.\n金丝雀下矿，金丝雀会警告危险\n\nAnother classic hack is code injection.\n另一种经典手段叫\"代码注入\"\n\nIt’s most commonly used to attack websites that use databases,\n最常用于攻击用数据库的网站，\n\nwhich pretty much all big websites do.\n几乎所有大网站都用数据库\n\nWe won’t be covering databases in this series,\n我们这个系列中不会讲解数据库，\n\nso here’s a simple example to illustrate this type of attack.\n所以以下是个简单例子\n\nWe’ll use Structured Query Language, S-Q-L, also called sequel, a popular database API.\n我们会用\"结构化查询语言\"，也叫SQL，\\N 一种流行的数据库API\n\nLet’s imagine our login prompt is now running on a webpage.\n假设网页上有登录提示\n\nWhen a user clicks \"login\", the text values are sent to a server, which executes code\n当用户点击\"登录\"时，值会发到服务器\n\nthat checks if that username exists, and if it does, verifies the password matches.\n服务器会运行代码，检查用户名是否存在，\\N 如果存在，看密码是否匹配\n\nTo do this, the server will execute code, known as a SQL query,\n为了做检查，服务器会执行一段叫 \"SQL查询\" 的代码\n\nthat looks something like this.\n看起来像这样\n\nFirst, it needs to specify what data we’re retrieving from the database.\n首先，语句要指定从数据库里查什么数据\n\nIn this case, we want to fetch the password.\n在这个例子中，我们想查的是密码 (password)  \\N (SELECT password)\n\nThe server also needs to specify from what place in the database\n还要指定从哪张表查数据 \\N (FROM users)\n\nto retrieve the value from.\n还要指定从哪张表查数据 \\N (FROM users)\n\nIn this case, let’s imagine all the users’ data is stored\n在这个例子里，\\N 我们假设所有用户数据都存在 \"users\" 表里\n\nin a data structure called a table labeled \"users\".\n在这个例子里，\\N 我们假设所有用户数据都存在 \"users\" 表里\n\nFinally, the server doesn’t want to get back a giant list of passwords for every user\n最后，服务器不想每次取出一个巨大密码列表，\\N 包含所有用户密码\n\nin the database, so it specifies that it only wants data for the account\n所以用 username = '用户名'\\N 代表只要这个用户\n\nwhose username equals a certain value.\n所以用 username = '用户名'\\N 代表只要这个用户\n\nThat value is copied into the SQL query by the server, based on what the user typed in,\n用户输的值会复制到\"SQL查询\"\n\nso the actual command that’s sent to the SQL database would look something like this,\n所以实际发到 SQL 数据库的命令，是这样的.\n\nwhere username='philbin'\nWhere username='philbin'\n\nNote also that SQL commands end with a semicolon.\n还要注意，SQL命令以分号结尾\n\nSo how does someone hack this?\n那怎么破解这个？\n\nBy sending in a malicious username, with embedded SQL commands!\n做法是把\"SQL命令\"输入到用户名里！\n\nLike, we could send the server this funky username:\n比如我们可以发这个奇怪的用户名：\n\nWhen the server copies this text into the SQL Query, it ends up looking like this:\n当服务器把值复制到SQL查询中，会变成这样：\n\nAs I mentioned before, semicolons are used to separate commands,\n正如之前提的，分号用于分隔命令，\n\nso the first command that gets executed is this:\n所以第一条被执行的命令是：\n\nIf there is a user named ‘whatever’, the database will return the password.\n如果有个用户叫\"whateer\"，数据库将返回密码\n\nOf course, we have no idea what ‘whatever’s’ password is,\n当然，我们不知道密码是什么\n\nso we’ll get it wrong and the server will reject us.\n所以会出错，服务器会拒绝我们\n\nIf there’s no user named ‘whatever’, the database will return\n如果没有一个用户叫\"whatever\"，数据库会返回 \\N 空密码或直接错误，服务器也会拒绝我们\n\nno password or provide an error, and the server will again reject us.\n如果没有一个用户叫\"whatever\"，数据库会返回 \\N 空密码或直接错误，服务器也会拒绝我们\n\nEither way, we don’t care, because it’s the next SQL command we’re interested in:\n总之 我们不在乎，\\N 我们感兴趣的是下一个SQL命令：\n\n\"drop table users\" – a command that we injected by manipulating the username field.\n\"drop table users\" - 我们注入的命令\n\nThis command instructs the SQL database to delete the table containing all user data.\n这条命令的意思是  删掉 users 这张表\n\nWiped clean!\n全删干净！\n\nWhich would cause a lot of headaches at a place like a bank... or really anywhere.\n这会造成很多麻烦，不管是银行或什么其他地方\n\nAnd notice that we didn’t even break into the system –\n注意，我们甚至不需要侵入系统\n\nit’s not like we correctly guessed a username and password.\n我们没有猜到正确的用户名和密码\n\nEven with no formal access, we were able to create mayhem by exploiting a bug.\n即使没有正式访问权限，还是可以利用 bug 来制造混乱\n\nThis is a very simple example of code injection,\n这是代码注入的一个简单例子，\n\nwhich almost all servers today have defenses against.\n如今几乎所有服务器都会防御这种手段\n\nWith more sophisticated attacks, it’s possible to add records to the database\n如果指令更复杂一些，也许可以添加新记录到数据库\n\n– like a new administrator account –\n- 比如一个新管理员帐户 -\n\nor even get the database to reveal data, allowing hackers\n甚至可以让数据库泄露数据，使得黑客\n\nto steal things like credit card numbers, social security numbers\n窃取信用卡号码，社会安全号码\n\nand all sorts of nefarious goodies.\n以及各种其他信息\n\nBut we’re not going to teach you how to do that.\n但我们不会教你具体怎么做\n\nAs with buffer overflows, programmers should always assume input coming from the outside\n就像缓冲区溢出攻击一样，应该总是假设外部数据\n\nto be potentially dangerous, and examine it carefully.\n是危险的，应该好好检查\n\nMost username and password forms on the web don’t let you\n很多用户名和密码表单，不让你输入\n\ninclude special symbols like semicolons or quotes as a first level of defense.\n特殊字符，比如分号或者括号，作为第一道防御\n\nGood servers also sanitize input by removing or\n好的服务器也会清理输入\n\nmodifying special characters before running database queries.\n比如修改或删除特殊字符，然后才放到数据库查询语句里\n\nWorking exploits are often sold or shared online.\n管用的漏洞利用(Exploits)一般会在网上贩卖或分享\n\nThe more prevalent the bug, or the more damaging the exploit,\n如果漏洞很流行，或造成的危害很大\n\nthe higher the price or prestige it commands.\n价格会越高，或者名气越大\n\nEven governments sometimes buy exploits,\n有时甚至政府也会买漏洞利用\n\nwhich allow them to compromise computers for purposes like spying.\n让他们侵入系统做间谍工作\n\nWhen a new exploitable bug is discovered that the software creators weren’t aware of,\n当软件制造者不知道软件有新漏洞被发现了\n\nit’s called a zero day vulnerability.\n那么这个漏洞叫 \"零日漏洞\"\n\nBlack Hat Hackers rush to use the exploit for maximum benefit\n黑帽黑客经常赶时间，抢在白帽程序员做出补丁之前\n\nbefore white hat programmers release a patch for the bug.\n尽可能利用漏洞\n\nThis is why it’s so important to keep your computer’s software up to date;\n所以保持系统更新非常重要\n\na lot of those downloads are security patches.\n很多更新都是安全性补丁\n\nIf bugs are left open on enough systems, it allows hackers to\n如果有足够多的电脑有漏洞\n\nwrite a program that jump from computer to computer automatically\n让恶意程序可以在电脑间互相传播\n\nwhich are called worms.\n那么叫\"蠕虫\"\n\nIf a hacker can take over a large number of computers, they can be used together,\n如果黑客拿下大量电脑，这些电脑可以组成\n\nto form what’s called a botnet.\n\"僵尸网络\"\n\nThis can have many purposes, like sending huge volumes of spam,\n可以用于很多目的，比如发大量垃圾邮件，\n\nmining bitcoins using other people's computing power and electricity,\n用别人电脑的计算能力和电费挖 Bitcoin，\n\nand launching Distributed Denial of Service or DDoS attacks against servers.\n或发起\"拒绝服务攻击\"简称DDoS，攻击服务器\n\nDDoS is where all the computers in the botnet send a flood of dummy messages.\nDDoS 就是僵尸网络里的所有电脑发一大堆垃圾信息\n\nThis can knock services offline, either to force owners\n堵塞服务器，要么迫使别人交钱消灾\n\nto pay a ransom or just to be evil.\n或纯粹为了作恶\n\nDespite all of the hard working white hats, exploits documented online,\n尽管白帽黑客非常努力工作，漏洞利用的文档都在网上，\n\nand software engineering best practices, cyberattacks happen on a daily basis.\n编写软件有很多\"最佳实践\"，网络攻击每天都在发生\n\nThey cost the global economy roughly half a trillion dollars annually,\n每年损害全球经济差不多5000亿\n\nand that figure will only increase as we become more reliant on computing systems.\n并且随着我们越来越依赖计算机系统，这个数字只会增加.\n\nThis is especially worrying to governments, as infrastructure is increasingly computer-driven,\n这使得政府非常担心，因为基础设施越来越电脑化\n\nlike powerplants, the electrical grid, traffic lights, water treatment plants, oil refineries,\n比如电力厂，电网，交通灯，水处理厂，炼油厂\n\nair traffic control, and lots of other key systems.\n空管，还有很多其他关键系统\nMany experts predict that the next major war will be fought in cyberspace,\n很多专家预测下一次大战会主要是网络战争\n\nwhere nations are brought to their knees not by physical attack,\n国家不是被物理攻击打败\n\nbut rather crippled economically and infrastructurally through cyberwarfare.\n而是因为网络战争导致经济和基础设施崩溃\n\nThere may not be any bullets fired, but the potential for lives lost is still very high...\n也许不会发射一颗子弹，但是人员伤亡的可能性依然很高\n\nmaybe even higher than conventional warfare.\n甚至可能高于传统战争\n\nSo, we should all adopt good cybersecurity practices.\n所以大家都应该知道一些方法保证网络安全\n\nAnd, as a community interconnected over the internet,\n全球社区因为互联网而互相连接，\n\nwe should ensure our computers are secured against those\n我们应该确保自己的电脑安全\n\nwho wish to use their great potential for harm.\n抵御其他想做坏事的人\n\nSo maybe stop ignoring that update notification?\n也许不要再忽略更新提示？\n\nI’ll see you next week.\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/33. 加密-Cryptography.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the past two episodes, we’ve talked a lot about computer security.\n在过去两集，我们聊了很多计算机安全话题\n\nBut the fact is, there’s no such thing as a perfectly, 100% secure, computer system.\n但事实是 世上不存在100%安全的系统\n\nThere will always be bugs and security experts know that.\n总会有漏洞存在，而且安全专家知道这一点\n\nSo system architects employ a strategy called defence in depth\n所以系统架构师会部署\"多层防御\"\n\nwhich uses many layers of varying security mechanisms to frustrate attackers.\n用多层不同的安全机制来阻碍攻击者\n\nIt’s a bit like how castles are designed\n有点像城堡的设计一样\n\nfirst you’ve got to dodge the archers\n首先要避开弓箭手\n\nthen cross the moat, scale the walls, avoid the hot oil, get over the ramparts, and defeat the guards\n穿过护城河,翻过城墙,避开热油,打败守卫\n\nbefore you get to the throne room\n才能达到王座\n\nbut in this case we’re talking about one of the most common forms of computer security\n不过我们这里要说的是，计算机安全中最常见的防御形式\n\nCryptography\n密码学\n\nThe word cryptography comes from the roots ‘crypto’ and ‘graphy’, roughly translating to \"secret writing\".\n密码学(cryptography) 一词 \\N 来自 crypto 和 graphy，大致翻译成\"秘密写作\"\n\nIn order to make information secret, you use a cipher – an algorithm that converts plain text into ciphertext\n为了加密信息，要用加密算法(Cipher) 把明文转为密文\n\nwhich is gibberish unless you have a key that lets you undo the cipher.\n除非你知道如何解密，不然密文看起来只是一堆乱码\n\nThe process of making text secret is called encryption\n把明文转成密文叫\"加密\"(encryption)\n\nand the reverse process is called decryption\n把密文恢复回明文叫\"解密\"(decryption)\n\nCiphers have been used long before computers showed up.\n加密算法早在计算机出现前就有了\n\nJulius Caesar used what’s now called a Caesar cipher, to encrypt private correspondence.\n朱利叶斯·凯撒 用如今我们叫\"凯撒加密\"的方法 来加密私人信件\n\nHe would shift the letters in a message forward by three places.\n他会把信件中的字母 向前移动三个位置\n\nSo, A became D, and the word \"brutus\" became this: \"euxwxv\".\n所以A会变成D，brutus变成euxwxv\n\nTo decipher the message, recipients had to know both the algorithm and the number to shift by, which acted as the key.\n为了解密，接收者要知道 \\N 1. 用了什么算法 2. 要偏移的字母位数\n\nThe Caesar cipher is one example of a larger class of techniques called substitution ciphers.\n有一大类算法叫\"替换加密\"，凯撒密码是其中一种\n\nThese replace every letter in a message with\\Nsomething else according to a translation.\n算法把每个字母替换成其他字母\n\nA big drawback of basic substitution ciphers is that letter frequencies are preserved.\n但有个巨大的缺点是，字母的出现频率是一样的\n\nFor example, E is the most common letter in English\n举个例子，E在英语中是最常见的字母\n\nso if your cipher translates E to an X\n如果把E加密成X\n\nthen X will show up the most frequently in the ciphertext.\n那么密文中 X 的出现频率会很高\n\nA skilled cryptanalyst can work backwards from these kinds of statistics to figure out the message.\n熟练的密码破译师可以从统计数据中发现规律，进而破译密码\n\nIndeed, it was the breaking of a substitution cipher that led to the execution of Mary Queen of Scots,in 1587 for plotting to kill Queen Elizabeth.\n1587年，正因为一个\"替换加密\"的密文被破译，\\n导致杀伊丽莎白女王的阴谋暴露，使得玛丽女王被处决\n\nAnother fundamental class of techniques are permutation ciphers.\n另一类加密算法叫 \"移位加密\"\n\nLet’s look at a simple example, called a columnar transposition cipher.\n我们来看一个简单例子叫 \"列移位加密\"\n\nHere, we take a message, and fill the letters into a grid.\n我们把明文填入网格\n\nIn this case, we’ve chosen 5 by 5\n网格大小我们这里选择 5x5\n\nTo encrypt our message, we read out the characters in a different order\n为了加密信息，我们换个顺序来读\n\nlet’s say from the bottom left, working upwards, one column at a time.\n比如从左边开始，从下往上，一次一列。\n\nThe new letter ordering, what’s called a permutation, is the encrypted message.\n加密后字母的排列不同了\n\nThe ordering direction, as well as the 5 by 5 grid size, serves as the key.\n解密的关键是，知道读取方向和网格大小是5x5\n\nLike before, if the cipher and key are known, a recipient can reverse the process to reveal the original message.\n就像之前，如果接收者知道密文和加密方法 \\N 才能解密得到原始消息\n\nBy the 1900s, cryptography was mechanized in the form of encryption machines.\n到了1900年代，人们用密码学做了加密机器\n\nThe most famous was the German Enigma, used by the Nazis to encrypt their wartime communications.\n其中最有名的是德国的英格玛（Enigma）\\N 纳粹在战时用英格玛加密通讯信息\n\nAs we discussed back in Episode 15, the Enigma was a typewriter-like machine, with a keyboard and lampboard, both showing the full alphabet.\n正如第15集中说过，Enigma 是一台像打字机的机器，\\N 有键盘和灯板，两者都有完整的字母表\n\nAbove that, there was a series of configurable rotors that were the key to the Enigma’s encryption capability.\n而且它有一系列\"转子\"(rotros) ，是加密的关键\n\nFirst, let’s look at just one rotor.\n首先，我们只看一个转子\n\nOne side had electrical contacts for all 26 letters.\n它一面有26个接触点，代表26个字母\n\nThese connected to the other side of the rotor using cross-crossing wires that swapped one letter for another.\n然后线会连到另一面，替换字母\n\nIf ‘H’ went in, ‘K’ might come out the other side.\n如果输入'H'，'K'会从另一边出来\n\nIf \"K’ went in, ‘F’ might come out, and so on.\n如果输入'K'，'F'会从另一边出来，以此类推\n\nThis letter swapping behavior should sound familiar: it’s a substitution cipher!\n这个字母替换过程你应该听起来很熟悉：它是\"替换加密\"!\n\nBut, the Enigma was more sophisticated becauseit used three or more rotors in a row, each feeding into the next.\n但英格玛(Enigma)更复杂一些，因为它有3个或更多转子，\\N 一个转子的输出作为下一个转子的输入。\n\nRotors could also be rotated to one of 26 possible starting positions\n转子还有26个起始位置\n\nand they could be inserted in different orders, providinga lot of different substitution mappings.\n还可以按不同顺序放入转子，提供更多字母替换映射\n\nFollowing the rotors was a special circuit called a reflector.\n转子之后是一个叫\"反射器\"的特殊电路\n\nInstead of passing the signal on to another rotor, it connected every pin to another,\n它每个引脚会连到另一个引脚\n\nand sent the electrical signal back through the rotors.\n并把信号发回给转子\n\nFinally, there was a plug board at the front of the machine\n最后，机器前方有一个插板\n\nthat allowed letters coming from the keyboard to be optionally swapped,\n可以把输入键盘的字母预先进行替换\n\nadding another level of complexity.\n又加了一层复杂度\n\nWith our simplified circuit, let’s encrypta letter on this example enigma configuration.\n让我们用这里的简化版电路，加密一些字母\n\nIf we press the ‘H’ key, electricity flows through the plugboard, then the rotors\n如果我们按下\"H\"键，电流会先通过插板，然后通过转子\n\nhits the reflector, comes back through the rotorsand plugboard, and illuminates the letter ‘L’ on the lampboard.\n到达反射器，然后回来转子，回来插板，并照亮键盘灯板的字母\"L\"。\n\nSo H is encrypted to L.\nH 就加密成了 L\n\nNote that the circuit can flow both ways –\n注意, 电路是双向的\n\nso if we typed the letter ‘L’, ‘H’ would light up.\n所以如果我们按下 L，H 会亮起来\n\nIn other words, it’s the same process for encrypting and decrypting;\n换句话说，加密和解密的步骤是一样的\n\nyou just have to make sure the sending and receiving machineshave the same initial configuration.\n你只需要确保 发送机和接收机的初始配置一样就行\n\nIf you look carefully at this circuit, you’ll notice it’s impossible for a letter to be encrypted as itself\n如果你有仔细观察，会注意到字母加密后一定会变成另一个字母\n\nwhich turned out to be a fatal cryptographic weakness.\n之后这成为最大的弱点\n\nFinally, to prevent the Enigma from being a simple substitution cipher\n最后，为了让英格玛不只是简单的\"替换加密\"\n\nevery single time a letter was entered, the rotors advanced by one spot, sort of like an odometer in a car.\n每输入一个字母，转子会转一格，有点像汽车里程表。\n\nSo if you entered the text A-A-A, it might come out as B-D-K, where the substitution mapping changed with every key press.\n如果你输入A-A-A，可能会变成B-D-K，\\n映射会随着每次按键而改变\n\nThe Enigma was a tough cookie to crack, for sure.\n英格玛当然是一块难啃的骨头\n\nBut as we discussed in Episode 15, Alan Turingand and his colleagues\n但正如我们第15集中说的，艾伦·图灵和同事\n\nat Bletchley Park were able to break Enigma codes and largely automate the process.\n破解了英格玛加密，并把大部分破解流程做成了自动化\n\nBut with the advent of computers, cryptography moved from hardware into software.\n但随着计算机出现，加密从硬件转往软件\n\nOne of the earliest software ciphers to become widespread\n早期加密算法中，应用最广泛的\n\nwas the Data Encryption Standard developed by IBM and the NSA in 1977\n是 IBM 和 NSA 于1977年开发的\"数据加密标准\"\n\nDES, as it was known, originally used binary keys that were 56 bits long,\nDES最初用的是56 bit长度的二进制密钥，\n\nwhich means that there are 2 to the 56, or about 72 quadrillion different keys.\n意味着有2的56次方，或大约72千万亿个不同密钥\n\nBack in 1977, that meant that nobody – except perhaps the NSA –\n在1977年时，也许 NSA 有这能力，\n\nhad enough computing power to brute-force all possible keys.\n但没有其他人有足够计算能力 来暴力破解所有可能密钥。\n\nBut, by 1999, a quarter-million dollar computer could try every possible DES key in just two days, rendering the cipher insecure.\n但到1999年，一台25万美元的计算机能在两天内 \\N 把 DES 的所有可能密钥都试一遍，让 DES 算法不再安全\n\nSo, in 2001, the Advanced Encryption Standard(AES) was finalized and published.\n因此 2001 年出了：高级加密标准（AES）\n\nAES is designed to use much bigger keys – 128,192 or 256 bits in size – making brute force attacks much, much harder.\nAES 用更长的密钥 - 128位/192位/256位 - 让暴力破解更加困难\n\nFor a 128-bit keys, you'd need trillions of years to try every combination, even if you used every single computer on the planet today.\n128位的密钥，哪怕用现在地球上的所有计算机\\N 也要上万亿年才能试遍所有组合\n\nSo you better get started!\n你最好赶紧开始!\n\nAES chops data up into 16-byte blocks, and then applies a series of substitutions and permutations,\nAES将数据切成一块一块，每块16个字节，\\N 然后用密钥进行一系列替换加密和移位加密\n\nbased on the key value plus some other operations to obscure the message,\n再加上一些其他操作，进一步加密信息\n\nand this process is repeated ten or more times for each block.\n每一块数据，会重复这个过程10次或以上\n\nYou might be wondering: why only ten rounds?\n你可能想知道：为什么只重复10次？\n\nOr why only 128 bit keys, and not ten thousand bit keys?\n为什么用128位密钥，而不是10000位？\n\nWell, it’s a performance tradeoff.\n这其实是基于性能的权衡\n\nIf it took hours to encrypt and send an email,or minutes to connect to a secure website, people wouldn't use it\n如果要花几小时加密和发邮件，或几分钟载入网站，没人愿意用\n\nAES balances performance and security to provide practical cryptography.\nAES 在性能和安全性间取得平衡\n\nToday, AES is used everywhere, from encrypting files on iPhones\n如今AES被广泛使用，比如iPhone上加密文件\n\nand transmitting data over WiFi with WPA2 to accessing websites using HTTPS.\n用 WPA2 协议在 WiFi 中访问 HTTPS 网站\n\nSo far, the cryptographic techniques we’ve discussed rely on keys that are known by both sender and recipient.\n到目前为止 我们讨论过的加密技术\\N 依赖于发送者和接收者都知道密钥\n\nThe sender encrypts a message using a key, and the recipient decrypts it using the same key.\n发件人用密钥加密，收件人用相同的密钥解密\n\nIn the old days, keys would be shared by voice, or physically;\n以前，密钥可以口头约定，或依靠物品\n\nfor example, the Germans distributed codebooks with daily settings for their Enigma machines.\n比如德国人给英格玛配了密码本，上面有每天的配置\n\nBut this strategy could never work in the internet era.\n但互联网时代没法这样做\n\nImagine having to crack open a codebook to connect to youtube\n你能想象 要打开密码本才能访问 YouTube 吗？\n\nWhat’s needed is a way for a server to send a secret key over the public internet to a user wishing to connect securely.\n我们需要某种方法 在公开的互联网上传递密钥给对方\n\nIt seems like that wouldn’t be secure, because if the key is sent in the open and intercepted by a hacker\n这看起来好像不安全，如果密钥被黑客拦截了\n\ncouldn’t they use that to decrypt all communication between the two?\n黑客不就能解密通信了吗？\n\nThe solution is key exchange!\n解决方案是 \"密钥交换\"！\n\n– An algorithm that lets two computers agreeon a key without ever sending one.\n密钥交换是一种不发送密钥，\\N 但依然让两台计算机在密钥上达成共识的算法\n\nWe can do this with one-way functions –\n我们可以用\"单向函数\"来做\n\nmathematical operations that are very easy to do in one direction, but hard to reverse.\n单项函数是一种数学操作，很容易算出结果，\\N 但想从结果逆向推算出输入非常困难\n\nTo show you how one-way functions work, let’ s use paint colors as an analogy.\n为了让你明白单项函数，我们拿颜色作比喻\n\nIt’s easy to mix paint colors together, but it’s not so easy to figure\n将颜色混合在一起很容易，\n\nout the constituent colors that were used to make a mixed paint color.\n但想知道混了什么颜色很难\n\nYou’d have to test a lot of possibilities to figure it out.\n要试很多种可能才知道\n\nIn this metaphor, our secret key is a unique shade of paint.\n用这个比喻，那么我们的密钥是一种独特的颜色\n\nFirst, there’s a public paint color that everyone can see.\n首先，有一个公开的颜色，所有人都可以看到\n\nThen, John and I each pick a secret paint color.\n然后，约翰和我各自选一个秘密颜色，只有自己知道.\n\nTo exchange keys, I mix my secret paint color with the public paint color.\n为了交换密钥，我把我的 秘密颜色 和 公开颜色 混在一起\n\nThen, I send that mixed color to John by anymeans – mail, carrier pigeon, whatever.\n然后发给约翰，可以写信发，用信鸽发，什么方式都行.\n\nJohn does the same – mixing his secret paint color with the public color, then sending that to me.\n约翰也这样做，把他的秘密颜色和公开颜色混在一起，然后发我\n\nWhen I receive John’s color, I simply add my private color to create a blend of all three paints.\n我收到约翰的颜色之后，把我的秘密颜色加进去，\\N  现在3种颜色混合在一起\n\nJohn does the same with my mixed color.\nJohn 也一样做\n\nAnd Voila!\n瞧!\n\nWe both end up with the same paint color!\n我们有了一样的颜色\n\nWe can use this as a shared secret, even though we never sent each other our individual secret colors.\n我们可以把这个颜色当密钥，尽管我们从来没有给对方发过这颜色\n\nA snooping outside observer would know partial information, but they’d find it very difficult to figure out our shared secret color.\n外部窥探者可以知道部分信息，但无法知道最终颜色\n\nOf course, sending and mixing paint colors isn’t going to work well for transmitting computer data.\n当然，计算机要传输数据时，混合颜料和发颜料不太合适\n\nBut luckily, mathematical one-way functions are perfect,\n但幸运的是，数学单向函数是完美的\n\nand this is what Diffie-Hellman Key Exchange uses.\n我们可以用 \"迪菲-赫尔曼密钥交换\"\n\nIn Diffie-Hellman, the one-way function is modular exponentiation.\n在 Diffie-Hellman 中，单向函数是模幂运算\n\nThis means taking one number, the base, to the power of another number,\n意思是先做幂运算，拿一个数字当底数，拿一个数字当指数，比如 A\n\nb\n\nthe exponent, and taking the remainder when dividing by a third number, the modulus.\n然后除以第三个数字，最后拿到我们想要的余数\n\nSo, for example, if we wanted to calculate 3 to the 5th power, modulo 31,\n举个例子，假设我们想算3的5次方，模31\n\nwe would calculate 3 to the 5th, which is 243,\n我们先算3的5次方，得到243\n\nthen take the remainder when divided by 31, which is 26.\n\\N然后除31，取余数，得到26\n\nThe hard part is figuring out the exponent given only the result and the base.\n重点是  如果只给余数和基数。很难得知指数是多少\n\nIf I tell you I raised 3 to some secret number, modulo 31, and got 7 as the remainder\n如果我告诉你，3的某次方 模31，余数是7\n\nyou'd have to test a lot of exponents to know which one I picked.\n你要试很多次，才能知道次方是多少\n\nIf we make these numbers big, say hundreds of digits long,\n如果把数字变长一些，比如几百位长\n\nthen finding the secret exponent is nearly impossible.\n想找到秘密指数是多少，几乎是不可能的。\n\nNow let’s talk about how Diffie-Hellman\n现在我们来讨论 Diffie-Hellman 是怎么\n\nuses modular exponentiation to calculate a shared key.\n用模幂运算 算出双方共享的密钥\n\nFirst, there's a set of public values – the base and the modulus,\n首先，我们有公开的值 - 基数和模数\n\nthat, like our public paint color, everyone gets to know... even the bad guys!\n就像公开的油漆颜色，所有人都看的到，甚至坏人!\n\nTo send a message securely to John, I would pick a secret exponent: X.\n为了安全向 John 发信息，我选一个秘密指数：X\n\nThen, I’d calculate B to the power of X, modulo M.\n然后算  B^X mod M 的结果\n\nI send this big number over to John.\n然后把这个大数字发给 John.\n\nJohn does the same, picking a secret exponent Y, and sending me B to the Y modulo M.\nJohn 也一样做，选一个秘密指数Y，然后把 B^Y mod M 的结果发我\n\nTo create a shared secret key,\n为了算出 双方共用的密钥\n\nI take what John sent me, and take it to the power of X, my secret exponent.\n我把 John 给我的数，用我的秘密指数 X，进行模幂运算 (看上图)\n\nThis is mathematically equivalent to B to the XY modulus M.\n数学上相等于  B的XY次方 模M\n\nJohn does the same, taking what I sent to him to the power of Y, and we both end up with the exact same number!\nJohn也一样做，拿我给他的数 进行模幂运算，最终得到一样的数\n\nIt’s a secret shared key, even though we never sent each other our secret number.\n双方有一样的密钥，即使我们从来没给对方发过各自的秘密指数\n\nWe can use this big number as a shared key for encrypted communication, using something like AES for encryption.\n我们可以用这个大数字当密钥，用 AES 之类的加密技术来加密通信\n\nDiffie-Hellman key exchange is one method for establishing a shared key.\n\"Diffie-Hellman 密钥交换\"是建立共享密钥的一种方法。\n\nThese keys that can be used by both sender and receiver, to encrypt and decrypt messages\n双方用一样的密钥加密和解密消息，这叫\"对称加密\", 因为密钥一样\n\nare called symmetric keys because the key is the same on both sides.\n双方用一样的密钥加密和解密消息，这叫\"对称加密\", 因为密钥一样\n\nThe Caesar Cipher, Enigma and AES are all symmetric encryption.\n凯撒加密，英格玛，AES 都是\"对称加密\"\n\nThere’s also asymmetric encryption, where there are two different keys\n还有\"非对称加密\"，有两个不同的密钥\n\nmost often one that’s public and another that’s private.\n一个是公开的，另一个是私有的\n\nSo, people can encrypt a message using a public key that\n人们用公钥加密消息 \\N 只有有私钥的人能解密\n\nonly the recipient, with their private key, can decrypt.\n人们用公钥加密消息 \\N 只有有私钥的人能解密\n\nIn other words, knowing the public key only lets you encrypt, but not decrypt – it’s asymmetric!\n换句话说，知道公钥只能加密但不能解密 \\N - 它是\"不对称\"的！\n\nSo, think about boxes with padlocks that you can open with a key.\n想象一个可以锁上的盒子\n\nTo receive a secure message, I can give a sender a box and padlock.\n为了收到安全的信息，我们可以给别人箱子和锁\n\nThey put their message in it and lock it shut.\n别人把信息放箱子，然后锁起来\n\nNow, they can send that box back to me and only I can open it, with my private key.\n把盒子寄回给我，只有我的钥匙能打开\n\nAfter locking the box, neither the sender,\n上锁后，如果发件人或其他人想打开盒子 \\N 除了暴力尝试没有其他办法.\n\nnor anyone else who finds the box, can open it without brute force.\n上锁后，如果发件人或其他人想打开盒子 \\N 除了暴力尝试没有其他办法.\n\nIn the same way, a digital public key can encrypt something that can only be decrypted with a private key.\n和盒子例子一样，公钥加密后只能私钥来解密.\n\nThe reverse is possible too: encrypting something with a\n反过来也是可以的：私钥加密后 用公钥解密\n\nprivate key that can be decrypted with a public key.\n反过来也是可以的：私钥加密后 用公钥解密\n\nThis is used for signing, where a server encrypts data using their private key.\n这种做法用于签名，服务器可以用私钥加密，\n\nAnyone can decrypt it using the server's public key.\n任何人都可以用服务器的公钥解密\n\nThis acts like an unforgeable signature,\n就像一个不可伪造的签名\n\nas only the owner, using their private key, can encrypt.\n因为只有私钥的持有人 能加密\n\nIt proves that you're getting data from the right server or person, and not an imposter.\n这能证明数据来自正确的服务器或个人，而不是某个假冒者\n\nThe most popular asymmetric encryption technique used today is RSA,\n目前最流行的\"非对称加密\"技术是 RSA\n\nnamed after its inventors: Rivest, Shamir and Adleman.\n名字来自发明者： Rivest, Shamir, Adleman.\n\nSo, now you know all the \"key\" parts of modern cryptography:\n现在你学会了现代密码学的所有\"关键\"部分：\n\nsymmetric encryption, key exchange and public-key cryptography.\n对称加密，密钥交换，公钥密码学\n\nWhen you connect to a secure website, like your bank,\n当你访问一个安全的网站，比如银行官网\n\nthat little padlock icon means that your computer has used public key cryptography\n绿色锁图标代表 用了公钥密码学\n\nto verify the server key exchange to establish a secret temporary key,\n验证服务器的密钥，然后建立临时密钥\n\nand symmetric encryption to protect all the back-and-forth communication from prying eyes.\n然后用对称加密保证通信安全\n\nWhether you're buying something online, sending emails to BFFs,\n不管你是网上购物，发邮件给朋友，还是看猫咪视频\n\nor just browsing cat videos\n不管你是网上购物，发邮件给朋友，还是看猫咪视频\n\ncryptography keeps all that safe, private and secure.\n密码学都在保护你的隐私和安全\n\nThanks cryptography!\n谢啦密码学！\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/34. 机器学习&人工智能-Machine Learning & Artificial Intelligence.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nAs we've touched on many times in this series,\n我们之前说过 \\N 计算机很擅长存放，整理，获取和处理大量数据\n\ncomputers are incredible at storing, organizing,\n我们之前说过 \\N 计算机很擅长存放，整理，获取和处理大量数据\n\nfetching and processing huge volumes of data.\n我们之前说过 \\N 计算机很擅长存放，整理，获取和处理大量数据\n\nThat's perfect for things like e-commerce websites with millions of items for sale,\n很适合有上百万商品的电商网站\n\nand for storing billions of health records for quick access by doctors.\n或是存几十亿条健康记录，方便医生看.\n\nBut what if we want to use computers not just to fetch and display data,\n但如果想根据数据做决定呢？\n\nbut to actually make decisions about data?\n但如果想根据数据做决定呢？\n\nThis is the essence of machine learning\n这是机器学习的本质\n\nalgorithms that give computers the ability to learn from data,\n机器学习算法让计算机可以从数据中学习，\\N 然后自行做出预测和决定\n\nand then make predictions and decisions.\n机器学习算法让计算机可以从数据中学习，\\N 然后自行做出预测和决定\n\nComputer prosgrams with this ability\n能自我学习的程序很有用 \\N 比如判断是不是垃圾邮件\n\nare extremely useful in answering questions like Is an email spam?\n能自我学习的程序很有用 \\N 比如判断是不是垃圾邮件\n\nDoes a person's heart have arrhythmia?\n这人有心律失常吗？\n\nor what video should youtube recommend after this one?\nYouTube 的下一个视频该推荐哪个？\n\nWhile useful, we probably wouldn't describe these programs as \"intelligent\"\n虽然有用，但我们不会说它有人类一般的智能\n\nin the same way we think of human intelligence.\n虽然有用，但我们不会说它有人类一般的智能\n\nSo, even though the terms are often interchanged,\n虽然 AI 和 ML 这两词经常混着用\n\nmost computer scientists would say that machine learning is a set of techniques\n大多数计算机科学家会说 \\N机器学习是为了实现人工智能这个更宏大目标的技术之一\n\nthat sits inside the even more ambitious goal of Artificial Intelligence,\n大多数计算机科学家会说 \\N机器学习是为了实现人工智能这个更宏大目标的技术之一\n\nor AI for short.\n人工智能简称 AI\n\nMachine Learning and AI algorithms tend to be pretty sophisticated.\n机器学习和人工智能算法一般都很复杂\n\nSo rather than wading into the mechanics of how they work,\n所以我们不讲具体细节  重点讲概念\n\nwe're going to focus on what the algorithms do conceptually.\n所以我们不讲具体细节  重点讲概念\n\nLet's start with a simple example:\n我们从简单例子开始：\n\ndeciding if a moth is a Luna Moth or an Emperor Moth.\n判断飞蛾是\"月蛾\"还是\"帝蛾\"\n\nThis decision process is called classification,\n这叫\"分类\"\n\nand an algorithm that does it is called a classifier.\n做分类的算法叫 \"分类器\"\n\nAlthough there are techniques that can use raw data for training\n虽然我们可以用 照片和声音 来训练算法\n\n- like photos and sounds -\n虽然我们可以用 照片和声音 来训练算法\n\nmany algorithms reduce the complexity of real world objects\n很多算法会减少复杂性\n\nand phenomena into what are called features.\n把数据简化成 \"特征\"\n\nFeatures are values that usefully characterize the things we wish to classify.\n\"特征\"是用来帮助\"分类\"的值\n\nFor our moth example, we're going to use two features: \"wingspan\" and \"mass\".\n对于之前的飞蛾分类例子\\N 我们用两个特征:\"翼展\"和\"重量\"\n\nIn order to train our machine learning classifier to make good predictions,\n为了训练\"分类器\"做出好的预测，\n\nwe're going to need training data.\n我们需要\"训练数据\"\n\nTo get that,\n为了得到数据\n\nwe'd send an entomologist out into a forest to collect data for both luna and emperor moths.\n我们派昆虫学家到森林里 收集\"月蛾\"和\"帝蛾\"的数据\n\nThese experts can recognize different moths,\n专家可以认出不同飞蛾，\n\nso they not only record the feature values,\n所以专家不只记录特征值，还会把种类也写上\n\nbut also label that data with the actual moth species.\n所以专家不只记录特征值，还会把种类也写上\n\nThis is called labeled data.\n这叫 \"标记数据\"\n\nBecause we only have two features,\n因为只有两个特征\n\nit's easy to visualize this data in a scatterplot.\n很容易用散点图把数据视觉化\n\nHere, I've plotted data for 100 Emperor Moths in red and 100 Luna Moths in blue.\n红色标了100个帝蛾\\N 蓝色标了100个月蛾\n\nWe can see that the species make two groupings, but.\n可以看到大致分成了两组\n\nthere's some overlap in the middle\n但中间有一定重叠\n\nso it's not entirely obvious how to best separate the two.\n所以想完全区分两个组比较困难\n\nThat's what machine learning algorithms do\n所以机器学习算法登场\n\n- find optimal separations!\n- 找出最佳区分\n\nI'm just going to eyeball it\n我用肉眼大致估算下\n\nand say anything less than 45 millimeters in wingspan is likely to be an Emperor Moth.\n然后判断 翼展小于45毫米的 很可能是帝蛾\n\nWe can add another division that says additionally mass must be less than .75\n可以再加一个条件，重量必须小于.75\n\nin order for our guess to be Emperor Moth.\n才算是帝蛾。\n\nThese lines that chop up the decision space are called decision boundaries.\n这些线叫 \"决策边界\"\n\nIf we look closely at our data,\n如果仔细看数据\n\nwe can see that 86 emperor moths would correctly end up inside the emperor decision region,\n86只帝蛾在正确的区域\n\nbut 14 would end up incorrectly in luna moth territory.\n但剩下14只在错误的区域\n\nOn the other hand, 82 luna moths would be correct,\n另一方面，82只月蛾在正确的区域\n\nwith 18 falling onto the wrong side.\n18个在错误的区域\n\nA table, like this, showing where a classifier gets things right and wrong\n这里有个表 记录正确数和错误数\n\nis called a confusion matrix...\n这表叫\"混淆矩阵\"\n\nwhich probably should have also been the title of the last two movies in the Matrix Trilogy!\n\"黑客帝国三部曲\"的后两部也许该用这个标题\n\nNotice that there's no way for us to draw lines that give us 100% accuracy.\n注意我们没法画出 100% 正确分类的线\n\nIf we lower our wingspan decision boundary,\n降低翼展的决策边界，会把更多\"帝蛾\"误分类成\"月蛾\"\n\nwe misclassify more Emperor moths as Lunas.\n降低翼展的决策边界，会把更多\"帝蛾\"误分类成\"月蛾\"\n\nIf we raise it, we misclassify more Luna moths.\n如果提高，会把更多月蛾分错类.\n\nThe job of machine learning algorithms,\n机器学习算法的目的\n\nat a high level,\n机器学习算法的目的\n\nis to maximize correct classifications while minimizing errors\n是最大化正确分类 + 最小化错误分类\n\nOn our training data, we get 168 moths correct, and 32 moths wrong,\n在训练数据中，有168个正确，32个错误\n\nfor an average classification accuracy of 84%.\n平均准确率84％\n\nNow, using these decision boundaries,\n用这些决策边界\n\nif we go out into the forest and encounter an unknown moth,\n如果我们进入森林，碰到一只不认识的飞蛾，\n\nwe can measure its features and plot it onto our decision space.\n我们可以测量它的特征, 并绘制到决策空间上\n\nThis is unlabeled data.\n这叫 \"未标签数据\"\n\nOur decision boundaries offer a guess as to what species the moth is.\n决策边界可以猜测飞蛾种类\n\nIn this case, we'd predict it's a Luna Moth.\n这里我们预测是\"月蛾\"\n\nThis simple approach, of dividing the decision space up into boxes,\n这个把决策空间 切成几个盒子的简单方法\n\ncan be represented by what's called a decision tree,\n可以用\"决策树\"来表示\n\nwhich would look like this pictorially or could be written in code using If-Statements, like this.\n画成图像，会像左侧 \\N 用 if 语句写代码，会像右侧\n\nA machine learning algorithm that produces decision trees\n生成决策树的 机器学习算法\n\nneeds to choose what features to divide on\n需要选择用什么特征来分类\n\nand then for each of those features, what values to use for the division.\n每个特征用什么值\n\nDecision Trees are just one basic example of a machine learning technique.\n\"决策树\"只是机器学习的一个简单例子\n\nThere are hundreds of algorithms in computer science literature today.\n如今有数百种算法，而且新算法不断出现\n\nAnd more are being published all the time.\n如今有数百种算法，而且新算法不断出现\n\nA few algorithms even use many decision trees working together to make a prediction.\n一些算法甚至用多个\"决策树\"来预测\n\nComputer scientists smugly call those Forests\n计算机科学家叫这个\"森林\"，因为有多颗树嘛\n\nbecause they contain lots of trees.\n计算机科学家叫这个\"森林\"，因为有多颗树嘛\n\nThere are also non-tree-based approaches,\n也有不用树的方法，比如\"支持向量机\"\n\nlike Support Vector Machines,\n也有不用树的方法，比如\"支持向量机\"\n\nwhich essentially slice up the decision space using arbitrary lines.\n本质上是用任意线段来切分\"决策空间\"\n\nAnd these don't have to be straight lines;\n不一定是直线\n\nthey can be polynomials or some other fancy mathematical function.\n可以是多项式或其他数学函数\n\nLike before, it's the machine learning algorithm's job\n就像之前，机器学习算法负责\n\nto figure out the best lines to provide the most accurate decision boundaries.\n找出最好的线，最准的决策边界\n\nSo far, my examples have only had two features,\n之前的例子只有两个特征，人类也可以轻松做到\n\nwhich is easy enough for a human to figure out.\n之前的例子只有两个特征，人类也可以轻松做到\n\nIf we add a third feature,\n如果加第3个特征，比如\"触角长度\"\n\nlet's say, length of antennae,\n如果加第3个特征，比如\"触角长度\"\n\nthen our 2D lines become 3D planes,\n那么2D线段，会变成3D平面\n\ncreating decision boundaries in three dimensions.\n在三个维度上做决策边界\n\nThese planes don't have to be straight either.\n这些平面不必是直的\n\nPlus, a truly useful classifier would contend with many different moth species.\n而且 真正有用的分类器 会有很多飞蛾种类\n\nNow I think you'd agree this is getting too complicated to figure out by hand\n你可能会同意 现在变得太复杂了\n\nBut even this is a very basic example\n但这也只是个简单例子\n\n- just three features and five moth species.\n- 只有3个特征和5个品种\n\nWe can still show it in this 3D scatter plot.\n我们依然可以用 3D散点图 画出来\n\nUnfortunately, there's no good way to visualize four features at once, or twenty features,\n不幸的是，一次性看4个或20个特征，没有好的方法\n\nlet alone hundreds or even thousands of features.\n更别说成百上千的特征了\n\nBut that's what many real-world machine learning problems face.\n但这正是机器学习要面临的问题\n\nCan YOU imagine trying to figure out the equation for a hyperplane\n你能想象靠手工 在一个上千维度的决策空间里\n\nrippling through a thousand-dimensional decision space?\n给超平面(Hyperplane)找出一个方程吗\n\nProbably not,\n大概不行\n\nbut computers, with clever machine learning algorithms can\n但聪明的机器学习算法可以做到\n\nand they do, all day long, on computers at places like Google, Facebook, Microsoft and Amazon.\nGoogle，Facebook，微软和亚马逊的计算机里\\N 整天都在跑这些算法\n\nTechniques like Decision Trees and Support Vector Machines are strongly rooted in the field of statistics,\n\"决策树\"和\"支持向量机\"这样的技术 \\N 发源自统计学\n\nwhich has dealt with making confident decisions,\n统计学早在计算机出现前，就在用数据做决定\n\nusing data, long before computers ever existed.\n统计学早在计算机出现前，就在用数据做决定\n\nThere's a very large class of widely used statistical machine learning techniques,\n有一大类机器学习算法用了统计学\n\nbut there are also some approaches with no origins in statistics.\n但也有不用统计学的算法\n\nMost notable are artificial neural networks,\n其中最值得注意的是 人工神经网络\n\nwhich were inspired by neurons in our brains!\n灵感来自大脑里的神经元\n\nFor a primer of biological neurons,\n想学习神经元知识的人，可以看这3集\n\ncheck out our three-part overview here,\n想学习神经元知识的人，可以看这3集\n\nbut basically neurons are cells\n神经元是细胞\n\nthat process and transmit messages using electrical and chemical signals.\n用电信号和化学信号 来处理和传输消息\n\nThey take one or more inputs from other cells,\n它从其他细胞 得到一个或多个输入\n\nprocess those signals,\n然后处理信号并发出信号\n\nand then emit their own signal.\n然后处理信号并发出信号\n\nThese form into huge interconnected networks that are able to process complex information.\n形成巨大的互联网络，能处理复杂的信息\n\nJust like your brain watching this youtube video.\n就像你的大脑 在看这个视频\n\nArtificial Neurons are very similar.\n人造神经元很类似\n\nEach takes a series of inputs, combines them, and emits a signal.\n可以接收多个输入，然后整合并发出一个信号\n\nRather than being electrical or chemical signals,\n它不用电信号或化学信号\n\nartificial neurons take numbers in, and spit numbers out.\n而是吃数字进去，吐数字出来\n\nThey are organized into layers that are connected by links,\n它们被放成一层层\n\nforming a network of neurons, hence the name.\n形成神经元网络，因此得名神经网络\n\nLet's return to our moth example to see how neural nets can be used for classification.\n回到飞蛾例子，看如何用神经网络分类\n\nOur first layer - the input layer -\n我们的第一层 - 输入层 -\n\nprovides data from a single moth needing classification.\n提供需要被分类的单个飞蛾数据\n\nAgain, we'll use mass and wingspan.\n同样，这次也用重量和翼展\n\nAt the other end, we have an output layer, with two neurons:\n另一边是输出层，有两个神经元：\n\none for Emperor Moth and another for Luna Moth.\n一个是帝蛾，一个是月蛾\n\nThe most excited neuron will be our classification decision.\n2个神经元里最兴奋的 就是分类结果\n\nIn between, we have a hidden layer,\n中间有一个隐藏层\n\nthat transforms our inputs into outputs, and does the hard work of classification.\n负责把输入变成输出，负责干分类这个重活\n\nTo see how this is done,\n为了看看它是如何分类的\n\nlet's zoom into one neuron in the hidden layer.\n我们放大\"隐藏层\"里的一个神经元\n\nThe first thing a neuron does is multiply each of its inputs by a specific weight,\n神经元做的第一件事  \\N 是把每个输入乘以一个权重\n\nlet's say 2.8 for its first input, and .1 for it's second input.\n假设2.8是第一个输入，0.1是第二个输入。\n\nThen, it sums these weighted inputs together,\n然后它会相加输入\n\nwhich is in this case, is a grand total of 9.74.\n总共是9.74\n\nThe neuron then applies a bias to this result\n然后对这个结果，用一个偏差值处理\n\n- in other words, it adds or subtracts a fixed value,\n意思是 加或减一个固定值\n\nfor example, minus six, for a new value of 3.74.\n比如-6，得到3.74\n\nThese bias and inputs weights are initially set to random values when a neural network is created.\n做神经网络时，这些偏差和权重，\\N一开始会设置成随机值\n\nThen, an algorithm goes in, and starts tweaking all those values to train the neural network,\n然后算法会调整这些值 来训练神经网络\n\nusing labeled data for training and testing.\n使用\"标记数据\"来训练和测试\n\nThis happens over many interactions, gradually improving accuracy\n逐渐提高准确性\n\n- a process very much like human learning.\n- 很像人类学习的过程\n\nFinally, neurons have an activation function, also called a transfer function,\n最后，神经元有激活函数，它也叫传递函数，\n\nthat gets applied to the output, performing a final mathematical modification to the result.\n会应用于输出，对结果执行最后一次数学修改\n\nFor example, limiting the value to a range from negative one and positive one,\n例如，把值限制在-1和+1之间\n\nor setting any negative values to 0.\n或把负数改成0\n\nWe'll use a linear transfer function that passes the value through unchanged,\n我们用线性传递函数，它不会改变值\n\nso 3.74 stays as 3.74.\n所以3.74还是3.74\n\nSo for our example neuron,\n所以这里的例子\n\ngiven the inputs .55 and 82, the output would be 3.74.\n输入0.55和82，输出3.74\n\nThis is just one neuron,\n这只是一个神经元，\n\nbut this process of weighting, summing, biasing\n但加权，求和，偏置，激活函数\n\nand applying an activation function is computed for all neurons in a layer,\n会应用于一层里的每个神经元\n\nand the values propagate forward in the network, one layer at a time.\n并向前传播，一次一层\n\nIn this example, the output neuron with the highest value is our decision:\n数字最高的就是结果：\n\nLuna Moth.\n月蛾\n\nImportantly, the hidden layer doesn't have to be just one layer\n重要的是，隐藏层不是只能有一层，可以有很多层\n\nit can be many layers deep.\n重要的是，隐藏层不是只能有一层，可以有很多层\n\nThis is where the term deep learning comes from.\n\"深度学习\"因此得名\n\nTraining these more complicated networks takes a lot more computation and data.\n训练更复杂的网络 需要更多的计算量和数据\n\nDespite the fact that neural networks were invented over fifty years ago,\n尽管神经网络50多年前就发明了\n\ndeep neural nets have only been practical very recently,\n深层神经网络直到最近才成为可能\n\nthanks to powerful processors,\n感谢强大的处理器和超快的GPU\n\nbut even more so, wicked fast GPUs.\n感谢强大的处理器和超快的GPU\n\nSo, thank you gamers for being so demanding about silky smooth framerates!\n感谢游戏玩家对帧率的苛刻要求！\n\nA couple of years ago, Google and Facebook\n几年前，Google和Facebook\n\ndemonstrated deep neural nets that could find faces in photos as well as humans\n展示了深度神经网络 \\N 在照片中识别人脸的准确率，和人一样高\n\n- and humans are really good at this!\n- 人类可是很擅长这个的！\n\nIt was a huge milestone.\n这是个巨大的里程碑\n\nNow deep neural nets are driving cars,\n现在有深层神经网络开车，翻译，诊断医疗状况等等\n\ntranslating human speech,\n现在有深层神经网络开车，翻译，诊断医疗状况等等\n\ndiagnosing medical conditions and much more.\n现在有深层神经网络开车，翻译，诊断医疗状况等等\n\nThese algorithms are very sophisticated,\n这些算法非常复杂，但还不够\"聪明\"\n\nbut it's less clear if they should be described as \"intelligent\".\n这些算法非常复杂，但还不够\"聪明\"\n\nThey can really only do one thing like classify moths, find faces, or translate languages.\n它们只能做一件事，分类飞蛾，找人脸，翻译\n\nThis type of AI is called Weak AI or Narrow AI.\n这种AI叫\"弱AI\"或\"窄AI\"，只能做特定任务\n\nIt's only intelligent at specific tasks.\n这种AI叫\"弱AI\"或\"窄AI\"，只能做特定任务\n\nBut that doesn't mean it's not useful;\n但这不意味着它没用\n\nI mean medical devices that can make diagnoses,\n能自动做出诊断的医疗设备，\n\nand cars that can drive themselves are amazing!\n和自动驾驶的汽车真是太棒了！\n\nBut do we need those computers to compose music\n但我们是否需要这些计算机来创作音乐\n\nand look up delicious recipes in their free time?\n在空闲时间找美味食谱呢？\n\nProbably not.\n也许不要\n\nAlthough that would be kinda cool.\n如果有的话 还挺酷的\n\nTruly general-purpose AI, one as smart and well-rounded as a human,\n真正通用的，像人一样聪明的AI，叫 \"强AI\"\n\nis called Strong AI.\n真正通用的，像人一样聪明的AI，叫 \"强AI\"\n\nNo one has demonstrated anything close to human-level artificial intelligence yet.\n目前没人能做出来 接近人类智能的 AI\n\nSome argue it's impossible,\n有人认为不可能做出来\n\nbut many people point to the explosion of digitized knowledge\n但许多人说 数字化知识的爆炸性增长\n\n- like Wikipedia articles, web pages, and Youtube videos -\n- 比如维基百科，网页和Youtube视频 -\n\nas the perfect kindling for Strong AI.\n是\"强 AI\"的完美引燃物\n\nAlthough you can only watch a maximum of 24 hours of youtube a day,\n你一天最多只能看24小时的 YouTube \\N 计算机可以看上百万小时\n\na computer can watch millions of hours.\n你一天最多只能看24小时的 YouTube \\N 计算机可以看上百万小时\n\nFor example, IBM's Watson consults and synthesizes information from 200 million pages of content,\n比如，IBM 的沃森吸收了 2 亿个网页的内容\n\nincluding the full text of Wikipedia.\n包括维基百科的全文\n\nWhile not a Strong AI, Watson is pretty smart,\n虽然不是\"强AI\" 但沃森也很聪明 \\N 在2011年的知识竞答中碾压了人类\n\nand it crushed its human competition in Jeopardy way back in 2011.\n虽然不是\"强AI\" 但沃森也很聪明 \\N 在2011年的知识竞答中碾压了人类\n\nNot only can AIs gobble up huge volumes of information,\nAI不仅可以吸收大量信息 \\N 也可以不断学习进步，而且一般比人类快得多\n\nbut they can also learn over time, often much faster than humans.\nAI不仅可以吸收大量信息 \\N 也可以不断学习进步，而且一般比人类快得多\n\nIn 2016, Google debuted AlphaGo,\n2016 年 Google 推出 AlphaGo\n\na Narrow AI that plays the fiendishly complicated board game Go.\n一个会玩围棋的窄AI\n\nOne of the ways it got so good and able to beat the very best human players,\n它和自己的克隆版下无数次围棋 \\N 从而打败最好的人类围棋选手\n\nwas by playing clones of itself millions and millions of times.\n它和自己的克隆版下无数次围棋 \\N 从而打败最好的人类围棋选手\n\nIt learned what worked and what didn't,\n学习什么管用，什么不管用 \\N 自己发现成功的策略\n\nand along the way, discovered successful strategies all by itself.\n学习什么管用，什么不管用 \\N 自己发现成功的策略\n\nThis is called Reinforcement Learning,\n这叫 \"强化学习\" 是一种很强大的方法\n\nand it's a super powerful approach.\n这叫 \"强化学习\" 是一种很强大的方法\n\nIn fact, it's very similar to how humans learn.\n和人类的学习方式非常类似\n\nPeople don't just magically acquire the ability to walk...\n人类不是天生就会走路，是上千小时的试错学会的\n\nit takes thousands of hours of trial and error to figure it out.\n人类不是天生就会走路，是上千小时的试错学会的\n\nComputers are now on the cusp of learning by trial and error,\n计算机现在才刚学会反复试错来学习\n\nand for many narrow problems,\n对于很多狭窄的问题，强化学习已被广​​泛使用\n\nreinforcement learning is already widely used.\n对于很多狭窄的问题，强化学习已被广​​泛使用\n\nWhat will be interesting to see, is if these types of learning techniques can be applied more broadly,\n有趣的是，如果这类技术可以更广泛地应用\n\nto create human-like, Strong AIs that learn much like how kids learn, but at super accelerated rates.\n创造出类似人类的\"强AI\" \\N 能像人类小孩一样学习，但学习速度超快\n\nIf that happens, there are some pretty big changes in store for humanity\n如果这发生了，对人类可能有相当大的影响\n\n- a topic we'll revisit later.\n- 我们以后会讨论\n\nThanks for watching. See you next week.\n感谢收看.  我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/35. 计算机视觉-Computer Vision.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨 我是Carrie Anne，欢迎收看计算机科学速成课\n\nToday, let's start by thinking about how important vision can be.\n今天 我们来思考视觉的重要性\n\nMost people rely on it to prepare food,\n大部分人靠视觉来做饭\n\nwalk around obstacles,\n越过障碍\n\nread street signs,\n读路牌\n\nwatch videos like this,\n看视频\n\nand do hundreds of other tasks.\n以及无数其它任务\n\nVision is the highest bandwidth sense,\n视觉是信息最多的感官 \\N 比如周围的世界是怎样的，如何和世界交互\n\nand it provides a firehose of information about the state of the world and how to act on it.\n视觉是信息最多的感官 \\N 比如周围的世界是怎样的，如何和世界交互\n\nFor this reason, computer scientists have been trying to give computers vision for half a century,\n因此半个世纪来\\N 计算机科学家一直在想办法让计算机有视觉\n\nbirthing the sub-field of computer vision.\n因此诞生了\"计算机视觉\"这个领域\n\nIts goal is to give computers the ability\n目标是让计算机理解图像和视频\n\nto extract high-level understanding from digital images and videos.\n目标是让计算机理解图像和视频\n\nAs everyone with a digital camera or smartphone knows,\n用过相机或手机的都知道 \\N 可以拍出有惊人保真度和细节的照片\n\ncomputers are already really good at capturing photos with incredible fidelity and detail\n用过相机或手机的都知道 \\N 可以拍出有惊人保真度和细节的照片\n\n- much better than humans in fact.\n- 比人类强得多\n\nBut as computer vision professor Fei-Fei Li recently said,\n但正如计算机视觉教授 李飞飞 最近说的\n\n\"Just like to hear is the not the same as to listen.\n\"听到\"不等于\"听懂\"\n\nTo take pictures is not the same as to see.\"\n\"看到\"不等于\"看懂\"\n\nAs a refresher, images on computers are most often stored as big grids of pixels.\n复习一下，图像是像素网格\n\nEach pixel is defined by a color, stored as a combination of three additive primary colors:\n每个像素的颜色  通过三种基色定义：红，绿，蓝\n\nred, green and blue.\n每个像素的颜色  通过三种基色定义：红，绿，蓝\n\nBy combining different intensities of these three colors,\n通过组合三种颜色的强度 \\N 可以得到任何颜色, 也叫 RGB 值\n\nwe can represent any color.  what's called a RGB value,\n通过组合三种颜色的强度 \\N 可以得到任何颜色, 也叫 RGB 值\n\nPerhaps the simplest computer vision algorithm\n最简单的计算机视觉算法\n\n- and a good place to start -\n最合适拿来入门的\n\nis to track a colored object, like a bright pink ball.\n是跟踪一个颜色物体，比如一个粉色的球\n\nThe first thing we need to do is record the ball's color.\n首先，我们记下球的颜色，保存最中心像素的 RGB 值\n\nFor that, we'll take the RGB value of the centermost pixel.\n首先，我们记下球的颜色，保存最中心像素的 RGB 值\n\nWith that value saved, we can give a computer program an image,\n然后给程序喂入图像，让它找最接近这个颜色的像素\n\nand ask it to find the pixel with the closest color match.\n然后给程序喂入图像，让它找最接近这个颜色的像素\n\nAn algorithm like this might start in the upper right corner,\n算法可以从左上角开始，逐个检查像素\n\nand check each pixel, one at time,\n算法可以从左上角开始，逐个检查像素\n\ncalculating the difference from our target color.\n计算和目标颜色的差异\n\nNow, having looked at every pixel,\n检查了每个像素后，最贴近的像素，很可能就是球\n\nthe best match is very likely a pixel from our ball.\n检查了每个像素后，最贴近的像素，很可能就是球\n\nWe're not limited to running this algorithm on a single photo;\n不只是这张图片 \\N 我们可以在视频的每一帧图片跑这个算法\n\nwe can do it for every frame in a video,\n不只是这张图片 \\N 我们可以在视频的每一帧图片跑这个算法\n\nallowing us to track the ball over time.\n跟踪球的位置\n\nOf course, due to variations in lighting, shadows, and other effects,\n当然，因为光线，阴影和其它影响\n\nthe ball on the field is almost certainly not going to be the exact same RGB value as our target color,\n球的颜色会有变化，不会和存的 RGB 值完全一样\n\nbut merely the closest match.\n但会很接近\n\nIn more extreme cases, like at a game at night,\n如果情况更极端一些 \\N 比如比赛是在晚上，追踪效果可能会很差\n\nthe tracking might be poor.\n如果情况更极端一些 \\N 比如比赛是在晚上，追踪效果可能会很差\n\nAnd if one of the team's jerseys used the same color as the ball,\n如果球衣的颜色和球一样，算法就完全晕了\n\nour algorithm would get totally confused.\n如果球衣的颜色和球一样，算法就完全晕了\n\nFor these reasons, color marker tracking and similar algorithms are rarely used,\n因此很少用这类颜色跟踪算法\n\nunless the environment can be tightly controlled.\n除非环境可以严格控制\n\nThis color tracking example was able to search pixel-by-pixel,\n颜色跟踪算法是一个个像素搜索 \\N 因为颜色是在一个像素里\n\nbecause colors are stored inside of single pixels.\n颜色跟踪算法是一个个像素搜索 \\N 因为颜色是在一个像素里\n\nBut this approach doesn't work for features larger than a single pixel,\n但这种方法 不适合占多个像素的特征\n\nlike edges of objects, which are inherently made up of many pixels.\n比如物体的边缘，是多个像素组成的.\n\nTo identify these types of features in images,\n为了识别这些特征，算法要一块块像素来处理\n\ncomputer vision algorithms have to consider small regions of pixels,\n为了识别这些特征，算法要一块块像素来处理\n\ncalled patches.\n每一块都叫\"块\"\n\nAs an example, let's talk about an algorithm that finds vertical edges in a scene,\n举个例子，找垂直边缘的算法\n\nlet's say to help a drone navigate safely through a field of obstacles.\n假设用来帮无人机躲避障碍\n\nTo keep things simple, we're going to convert our image into grayscale,\n为了简单，我们把图片转成灰度 \\N 不过大部分算法可以处理颜色\n\nalthough most algorithms can handle color.\n为了简单，我们把图片转成灰度 \\N 不过大部分算法可以处理颜色\n\nNow let's zoom into one of these poles to see what an edge looks like up close.\n放大其中一个杆子，看看边缘是怎样的\n\nWe can easily see where the left edge of the pole starts,\n可以很容易地看到 杆子的左边缘从哪里开始\n\nbecause there's a change in color that persists across many pixels vertically.\n因为有垂直的颜色变化\n\nWe can define this behavior more formally by creating a rule\n我们可以弄个规则说\n\nthat says the likelihood of a pixel being a vertical edge\n某像素是垂直边缘的可能性 \\N 取决于左右两边像素的颜色差异程度\n\nis the magnitude of the difference in color\n某像素是垂直边缘的可能性 \\N 取决于左右两边像素的颜色差异程度\n\nbetween some pixels to its left and some pixels to its right.\n某像素是垂直边缘的可能性 \\N 取决于左右两边像素的颜色差异程度\n\nThe bigger the color difference between these two sets of pixels,\n左右像素的区别越大，这个像素越可能是边缘\n\nthe more likely the pixel is on an edge.\n左右像素的区别越大，这个像素越可能是边缘\n\nIf the color difference is small, it's probably not an edge at all.\n如果色差很小，就不是边缘\n\nThe mathematical notation for this operation looks like this\n这个操作的数学符号 看起来像这样\n\nit's called a kernel or filter.\n这叫\"核\"或\"过滤器\"\n\nIt contains the values for a pixel-wise multiplication,\n里面的数字用来做像素乘法\n\nthe sum of which is saved into the center pixel.\n总和 存到中心像素里\n\nLet's see how this works for our example pixel.\n我们来看个实际例子\n\nI've gone ahead and labeled all of the pixels with their grayscale values.\n我已经把所有像素转成了灰度值\n\nNow, we take our kernel, and center it over our pixel of interest.\n现在把\"核\"的中心，对准感兴趣的像素\n\nThis specifies what each pixel value underneath should be multiplied by.\n这指定了每个像素要乘的值\n\nThen, we just add up all those numbers.\n然后把所有数字加起来\n\nIn this example, that gives us 147.\n在这里，最后结果是 147\n\nThat becomes our new pixel value.\n成为新像素值\n\nThis operation, of applying a kernel to a patch of pixels,\n把 核 应用于像素块，这种操作叫\"卷积\"\n\nis call a convolution.\n把 核 应用于像素块，这种操作叫\"卷积\"\n\nNow let's apply our kernel to another pixel.\n现在我们把\"核\"应用到另一个像素\n\nIn this case, the result is 1. Just 1.\n结果是 1\n\nIn other words, it's a very small color difference, and not an edge.\n色差很小，不是边缘\n\nIf we apply our kernel to every pixel in the photo,\n如果把\"核\"用于照片中每个像素\n\nthe result looks like this,\n结果会像这样\n\nwhere the highest pixel values are where there are strong vertical edges.\n垂直边缘的像素值很高\n\nNote that horizontal edges, like those platforms in the background,\n注意，水平边缘（比如背景里的平台）\n\nare almost invisible.\n几乎看不见\n\nIf we wanted to highlight those features,\n如果要突出那些特征\n\nwe'd have to use a different kernel\n要用不同的\"核\"\n\n- one that's sensitive to horizontal edges.\n用对水平边缘敏感的\"核\"\n\nBoth of these edge enhancing kernels are called Prewitt Operators,\n这两个边缘增强的核叫\"Prewitt 算子\"\n\nnamed after their inventor.\n以发明者命名\n\nThese are just two examples of a huge variety of kernels,\n这只是众多\"核\"的两个例子\n\nable to perform many different image transformations.\n\"核\"能做很多种图像转换\n\nFor example, here's a kernel that sharpens images.\n比如这个\"核\"能锐化图像\n\nAnd here's a kernel that blurs them.\n这个\"核\"能模糊图像\n\nKernels can also be used like little image cookie cutters that match only certain shapes.\n\"核\"也可以像饼干模具一样，匹配特定形状\n\nSo, our edge kernels looked for image patches\n之前做边缘检测的\"核\"\n\nwith strong differences from right to left or up and down.\n会检查左右或上下的差异\n\nBut we could also make kernels that are good at finding lines, with edges on both sides.\n但我们也可以做出 擅长找线段的\"核\"\n\nAnd even islands of pixels surrounded by contrasting colors.\n或者包了一圈对比色的区域\n\nThese types of kernels can begin to characterize simple shapes.\n这类\"核\"可以描述简单的形状\n\nFor example, on faces, the bridge of the nose tends to be brighter than the sides of the nose,\n比如鼻梁往往比鼻子两侧更亮\n\nresulting in higher values for line-sensitive kernels.\n所以线段敏感的\"核\"对这里的值更高\n\nEyes are also distinctive\n眼睛也很独特\n\n- a dark circle sounded by lighter pixels -\n- 一个黑色圆圈被外层更亮的一层像素包着\n\na pattern other kernels are sensitive to.\n有其它\"核\"对这种模式敏感\n\nWhen a computer scans through an image,\n当计算机扫描图像时，最常见的是用一个窗口来扫\n\nmost often by sliding around a search window,\n当计算机扫描图像时，最常见的是用一个窗口来扫\n\nit can look for combinations of features indicative of a human face.\n可以找出人脸的特征组合\n\nAlthough each kernel is a weak face detector by itself,\n虽然每个\"核\"单独找出脸的能力很弱 \\N 但组合在一起会相当准确\n\ncombined, they can be quite accurate.\n虽然每个\"核\"单独找出脸的能力很弱 \\N 但组合在一起会相当准确\n\nIt's unlikely that a bunch of face-like features will cluster together if they're not a face.\n不是脸但又有一堆脸的特征在正确的位置，\\N 这种情况不太可能\n\nThis was the basis of an early and influential algorithm\n这是一个早期很有影响力的算法的基础\n\ncalled Viola-Jones Face Detection.\n叫 维奥拉·琼斯 人脸检测算法\n\nToday, the hot new algorithms on the block are Convolutional Neural Networks.\n如今的热门算法是 \"卷积神经网络\"\n\nWe talked about neural nets last episode, if you need a primer.\n我们上集谈了神经网络，如果需要可以去看看\n\nIn short, an artificial neuron\n总之，神经网络的最基本单位，是神经元\n\n- which is the building block of a neural network -\n总之，神经网络的最基本单位，是神经元\n\ntakes a series of inputs, and multiplies each by a specified weight,\n它有多个输入，然后会把每个输入 乘一个权重值\n\nand then sums those values all together.\n然后求总和\n\nThis should sound vaguely familiar, because it's a lot like a convolution.\n听起来好像挺耳熟，因为它很像\"卷积\"\n\nIn fact, if we pass a neuron 2D pixel data, rather than a one-dimensional list of inputs,\n实际上，如果我们给神经元输入二维像素\n\nit's exactly like a convolution.\n完全就像\"卷积\"\n\nThe input weights are equivalent to kernel values,\n输入权重等于\"核\"的值\n\nbut unlike a predefined kernel,\n但和预定义\"核\"不同\n\nneural networks can learn their own useful kernels\n神经网络可以学习对自己有用的\"核\"\n\nthat are able to recognize interesting features in images.\n来识别图像中的特征\n\nConvolutional Neural Networks use banks of these neurons to process image data,\n\"卷积神经网络\"用一堆神经元处理图像数据\n\neach outputting a new image, essentially digested by different learned kernels.\n每个都会输出一个新图像，\\N 本质上是被不同的\"核\"处理了\n\nThese outputs are then processed by subsequent layers of neurons,\n输出会被后面一层神经元处理\n\nallowing for convolutions on convolutions on convolutions.\n卷积卷积再卷积\n\nThe very first convolutional layer might find things like edges,\n第一层可能会发现\"边缘\"这样的特征\n\nas that's what a single convolution can recognize, as we've already discussed.\n单次卷积可以识别出这样的东西，之前说过\n\nThe next layer might have neurons that convolve on those edge features\n下一层可以在这些基础上识别\n\nto recognize simple shapes, comprised of edges, like corners.\n比如由\"边缘\"组成的角落\n\nA layer beyond that might convolve on those corner features,\n然后下一层可以在\"角落\"上继续卷积\n\nand contain neurons that can recognize simple objects,\n下一些可能有识别简单物体的神经元\n\nlike mouths and eyebrows.\n比如嘴和眉毛\n\nAnd this keeps going, building up in complexity,\n然后不断重复，逐渐增加复杂度\n\nuntil there's a layer that does a convolution that puts it together:\n直到某一层把所有特征放到一起：\n\neyes, ears, mouth, nose, the whole nine yards,\n眼睛，耳朵，嘴巴，鼻子\n\nand says \"ah ha, it's a face!\"\n然后说：\"啊哈，这是脸！\"\n\nConvolutional neural networks aren't required to be many layers deep,\n\"卷积神经网络\"不是非要很多很多层\n\nbut they usually are, in order to recognize complex objects and scenes.\n但一般会有很多层，来识别复杂物体和场景\n\nThat's why the technique is considered deep learning.\n所以算是\"深度学习\"\n\nBoth Viola-Jones and Convolutional Neural Networks can be applied to many image recognition problems,\n\"维奥拉·琼斯\"和\"卷积神经网络\"\\N 不只是认人脸，还可以识别手写文字\n\nbeyond faces, like recognizing handwritten text,\n\"维奥拉·琼斯\"和\"卷积神经网络\"\\N 不只是认人脸，还可以识别手写文字\n\nspotting tumors in CT scans and monitoring traffic flow on roads.\n在 CT 扫描中发现肿瘤，监测马路是否拥堵\n\nBut we're going to stick with faces.\n但我们这里接着用人脸举例\n\nRegardless of what algorithm was used, once we've isolated a face in a photo,\n不管用什么算法，识别出脸之后\n\nwe can apply more specialized computer vision algorithms to pinpoint facial landmarks,\n可以用更专用的计算机视觉算法 \\N 来定位面部标志\n\nlike the tip of the nose and corners of the mouth.\n比如鼻尖和嘴角\n\nThis data can be used for determining things like if the eyes are open,\n有了标志点，判断眼睛有没有张开就很容易了\n\nwhich is pretty easy once you have the landmarks\n有了标志点，判断眼睛有没有张开就很容易了\n\nit's just the distance between points.\n只是点之间的距离罢了\n\nWe can also track the position of the eyebrows;\n也可以跟踪眉毛的位置\n\ntheir relative position to the eyes can be an indicator of surprise, or delight.\n眉毛相对眼睛的位置  可以代表惊喜或喜悦\n\nSmiles are also pretty straightforward to detect based on the shape of mouth landmarks.\n根据嘴巴的标志点，检测出微笑也很简单\n\nAll of this information can be interpreted by emotion recognition algorithms,\n这些信息可以用\"情感识别算法\"来识别\n\ngiving computers the ability to infer when you're happy, sad, frustrated, confused and so on.\n让电脑知道你是开心，忧伤，沮丧，困惑等等\n\nIn turn, that could allow computers to intelligently adapt their behavior...\n然后计算机可以做出合适的行为.\n\nmaybe offer tips when you're confused,\n比如当你不明白时 给你提示\n\nand not ask to install updates when you're frustrated.\n你心情不好时，就不弹更新提示了\n\nThis is just one example of how vision can give computers the ability to be context sensitive,\n这只是计算机通过视觉感知周围的一个例子\n\nthat is, aware of their surroundings.\n这只是计算机通过视觉感知周围的一个例子\n\nAnd not just the physical surroundings\n不只是物理环境 - 比如是不是在上班，或是在火车上\n\n- like if you're at work or on a train -\n不只是物理环境 - 比如是不是在上班，或是在火车上\n\nbut also your social surroundings\n还有社交环境 - 比如是朋友的生日派对，还是正式商务会议\n\n- like if you're in a formal business meeting versus a friend's birthday party.\n还有社交环境 - 比如是朋友的生日派对，还是正式商务会议\n\nYou behave differently in those surroundings, and so should computing devices,\n你在不同环境会有不同行为，计算机也应如此\n\nif they're smart.\n如果它们够聪明的话...\n\nFacial landmarks also capture the geometry of your face,\n面部标记点 也可以捕捉脸的形状\n\nlike the distance between your eyes and the height of your forehead.\n比如两只眼睛之间的距离，以及前额有多高\n\nThis is one form of biometric data,\n做生物识别\n\nand it allows computers with cameras to recognize you.\n让有摄像头的计算机能认出你\n\nWhether it's your smartphone automatically unlocking itself when it sees you,\n不管是手机解锁 还是政府用摄像头跟踪人\n\nor governments tracking people using CCTV cameras,\n不管是手机解锁 还是政府用摄像头跟踪人\n\nthe applications of face recognition seem limitless.\n人脸识别有无限应用场景\n\nThere have also been recent breakthroughs in landmark tracking for hands and whole bodies,\n另外  跟踪手臂和全身的标记点，最近也有一些突破\n\ngiving computers the ability to interpret a user's body language,\n让计算机理解用户的身体语言\n\nand what hand gestures they're frantically waving at their internet connected microwave.\n比如用户给联网微波炉的手势\n\nAs we've talked about many times in this series,\n正如系列中常说的，抽象是构建复杂系统的关键\n\nabstraction is the key to building complex systems,\n正如系列中常说的，抽象是构建复杂系统的关键\n\nand the same is true in computer vision.\n计算机视觉也是一样\n\nAt the hardware level, you have engineers building better and better cameras,\n硬件层面，有工程师在造更好的摄像头 \\N 让计算机有越来越好的视力\n\ngiving computers improved sight with each passing year,\n硬件层面，有工程师在造更好的摄像头 \\N 让计算机有越来越好的视力\n\nwhich I can't say for myself.\n我自己的视力却不能这样\n\nUsing that camera data,\n用来自摄像头的数据  可以用视觉算法找出脸和手\n\nyou have computer vision algorithms crunching pixels to find things like faces and hands.\n用来自摄像头的数据  可以用视觉算法找出脸和手\n\nAnd then, using output from those algorithms,\n然后可以用其他算法接着处理，解释图片中的东西\n\nyou have even more specialized algorithms for interpreting things\n然后可以用其他算法接着处理，解释图片中的东西\n\nlike user facial expression and hand gestures.\n比如用户的表情和手势\n\nOn top of that, there are people building novel interactive experiences,\n有了这些，人们可以做出新的交互体验\n\nlike smart TVs and intelligent tutoring systems,\n比如智能电视和智能辅导系统 \\N 会根据用户的手势和表情来回应\n\nthat respond to hand gestures and emotion.\n比如智能电视和智能辅导系统 \\N 会根据用户的手势和表情来回应\n\nEach of these levels are active areas of research,\n这里的每一层都是活跃的研究领域\n\nwith breakthroughs happening every year.\n每年都有突破，这只是冰山一角\n\nAnd that's just the tip of the iceberg.\n每年都有突破，这只是冰山一角\n\nToday, computer vision is everywhere\n如今 计算机视觉无处不在\n\n- whether it's barcodes being scanned at stores,\n- 商店里扫条形码 \\N 等红灯的自动驾驶汽车\n\nself-driving cars waiting at red lights,\n- 商店里扫条形码 \\N 等红灯的自动驾驶汽车\n\nor snapchat filters superimposing mustaches.\n或是 Snapchat 里添加胡子的滤镜\n\nAnd, the most exciting thing is that computer scientists are really just getting started,\n令人兴奋的是  一切才刚刚开始\n\nenabled by recent advances in computing, like super fast GPUs.\n最近的技术发展，比如超快的GPU，\\N 会开启越来越多可能性\n\nComputers with human-like ability to see is going to totally change how we interact with them.\n视觉能力达到人类水平的计算机 \\N 会彻底改变交互方式\n\nOf course, it'd also be nice if they could hear and speak,\n当然，如果计算机能听懂我们然后回话，就更好了\n\nwhich we'll discuss next week. I'll see you then.\n我们下周讨论  到时见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/36. 自然语言处理-Natural Language Processing.ass.txt",
    "content": "Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨 我是Carrie Anne，欢迎收看计算机科学速成课\n\nLast episode we talked about computer vision\n上集我们讨论了计算机视觉 - 让电脑能看到并理解\n\n- giving computers the ability to see and understand visual information.\n上集我们讨论了计算机视觉 - 让电脑能看到并理解\n\nToday we're going to talk about how to give computers the ability to understand language.\n今天我们讨论  怎么让计算机理解语言\n\nYou might argue they've always had this capability.\n你可能会说：计算机已经有这个能力了\n\nBack in Episodes 9 and 12,\n在第9和第12集\n\nwe talked about machine language instructions,\n我们聊了机器语言和更高层次的编程语言\n\nas well as higher-level programming languages.\n我们聊了机器语言和更高层次的编程语言\n\nWhile these certainly meet the definition of a language,\n虽然从定义来说 它们也算语言\n\nthey also tend to have small vocabularies and follow highly structured conventions.\n但词汇量一般很少，而且非常结构化\n\nCode will only compile and run if it's 100 percent free of spelling and syntactic errors.\n代码只能在拼写和语法完全正确时，编译和运行\n\nOf course, this is quite different from human languages\n当然，这和人类语言完全不同 \\N - 人类语言叫\"自然语言\"\n\n- what are called natural languages -\n当然，这和人类语言完全不同 \\N - 人类语言叫\"自然语言\"\n\ncontaining large, diverse vocabularies,\n自然语言有大量词汇\n\nwords with several different meanings,\n有些词有多种含义\n\nspeakers with different accents,\n不同口音\n\nand all sorts of interesting word play.\n以及各种有趣的文字游戏\n\nPeople also make linguistic faux pas when writing and speaking,\n人们在写作和说话时也会犯错\n\nlike slurring words together, leaving out key details so things are ambiguous,\n比如单词拼在一起发音 \\N 关键细节没说 导致意思模糊两可\n\nand mispronouncing things.\n以及发错音\n\nBut, for the most part, humans can roll right through these challenges.\n但大部分情况下，另一方能理解\n\nThe skillful use of language is a major part of what makes us human.\n人类有强大的语言能力\n\nAnd for this reason,\n因此，让计算机拥有语音对话的能力\n\nthe desire for computers to understand and speak our language\n因此，让计算机拥有语音对话的能力\n\nhas been around since they were first conceived.\n这个想法从构思计算机时就有了\n\nThis led to the creation of Natural Language Processing, or NLP,\n\"自然语言处理\"因此诞生，简称 NLP\n\nan interdisciplinary field combining computer science and linguistics.\n结合了计算机科学和语言学的 一个跨学科领域\n\nThere's an essentially infinite number of ways to arrange words in a sentence.\n单词组成句子的方式有无限种\n\nWe can't give computers a dictionary of all possible sentences\n我们没法给计算机一个字典，包含所有可能句子\n\nto help them understand what humans are blabbing on about.\n让计算机理解人类在嘟囔什么\n\nSo an early and fundamental NLP problem was deconstructing sentences into bite-sized pieces,\n所以 NLP 早期的一个基本问题是 \\N 怎么把句子切成一块块\n\nwhich could be more easily processed.\n这样更容易处理\n\nIn school, you learned about nine fundamental types of English words:\n上学时，老师教你 英语单词有九种基本类型：\n\nnouns, pronouns, articles, verbs, adjectives,\n名词，代词，冠词，动词，形容词\n\nadverbs, prepositions, conjunctions, and interjections.\n副词，介词，连词和感叹词\n\nThese are called parts of speech.\n这叫\"词性\"\n\nThere are all sorts of subcategories too,\n还有各种子类，比如\n\nlike singular vs. plural nouns and superlative vs. comparative adverbs,\n单数名词 vs 复数名词 \\N 副词最高级 vs 副词比较级\n\nbut we're not going to get into that.\n但我们不会深入那些.\n\nKnowing a word's type is definitely useful,\n了解单词类型有用\n\nbut unfortunately, there are a lot words that have multiple meanings - like \"rose\" and \"leaves\",\n但不幸的是，很多词有多重含义 比如 rose 和 leaves\n\nwhich can be used as nouns or verbs.\n可以用作名词或动词\n\nA digital dictionary alone isn't enough to resolve this ambiguity,\n仅靠字典，不能解决这种模糊问题\n\nso computers also need to know some grammar.\n所以电脑也要知道语法\n\nFor this, phrase structure rules were developed, which encapsulate the grammar of a language.\n因此开发了 \"短语结构规则\" 来代表语法规则\n\nFor example, in English there's a rule\n例如，英语中有一条规则\n\nthat says a sentence can be comprised of a noun phrase followed by a verb phrase.\n句子可以由一个名词短语和一个动词短语组成\n\nNoun phrases can be an article, like \"the\",\n名词短语可以是冠词，如 the\n\nfollowed by a noun or they can be an adjective followed by a noun.\n然后一个名词，或一个形容词后面跟一个名词\n\nAnd you can make rules like this for an entire language.\n你可以给一门语言制定出一堆规则\n\nThen, using these rules, it's fairly easy to construct what's called a parse tree,\n用这些规则，可以做出\"分析树\"\n\nwhich not only tags every word with a likely part of speech,\n它给每个单词标了可能是什么词性\n\nbut also reveals how the sentence is constructed.\n也标明了句子的结构\n\nThese smaller chunks of data allow computers to more easily access,\n数据块更小 更容易处理\n\nprocess and respond to information.\n数据块更小 更容易处理\n\nEquivalent processes are happening every time you do a voice search,\n每次语音搜索，都有这样的流程\n\nlike: \"where's the nearest pizza\".\n比如 \"最近的披萨在哪里\"\n\nThe computer can recognize that this is a \"where\" question,\n计算机能明白这是\"哪里\"（where）的问题\n\nknows you want the noun \"pizza\",\n知道你想要名词\"披萨\"（pizza）\n\nand the dimension you care about is \"nearest\".\n而且你关心的维度是\"最近的\"（nearest）\n\nThe same process applies to \"what is the biggest giraffe?\" or \"who sang thriller?\"\n\"最大的长颈鹿是什么？\"或\"Thriller是谁唱的？\" \\N 也是这样处理\n\nBy treating language almost like lego,\n把语言像乐高一样拆分，方便计算机处理\n\ncomputers can be quite adept at natural language tasks.\n把语言像乐高一样拆分，方便计算机处理\n\nThey can answer questions and also process commands,\n计算机可以回答问题 以及处理命令\n\nlike \"set an alarm for 2:20\"\n比如\"设 2:20 的闹钟\"\n\nor \"play T-Swizzle on spotify\".\n或\"用 Spotify 播放 T-Swizzle\"\n\nBut, as you've probably experienced, they fail when you start getting too fancy,\n但你可能体验过，如果句子复杂一点\n\nand they can no longer parse the sentence correctly, or capture your intent.\n计算机就没法理解了\n\nHey Siri... me thinks the mongols doth roam too much,\n嘿Siri ...... 俺觉得蒙古人走得太远了\n\nwhat think ye on this most gentle mid-summer's day?\n在这个最温柔的夏日的日子里，你觉得怎么样？\n\nSiri: I'm not sure I got that.\nSiri：我没明白\n\nI should also note that phrase structure rules, and similar methods that codify language,\n还有，\"短语结构规则\"和其他把语言结构化的方法\n\ncan be used by computers to generate natural language text.\n可以用来生成句子\n\nThis works particularly well when data is stored in a web of semantic information,\n数据存在语义信息网络时，这种方法特别有效\n\nwhere entities are linked to one another in meaningful relationships,\n实体互相连在一起\n\nproviding all the ingredients you need to craft informational sentences.\n提供构造句子的所有成分\n\nSiri: Thriller was released in 1983 and sung by Michael Jackson\nSiri：Thriller 于1983年发行，由迈克尔杰克逊演唱\n\nGoogle's version of this is called Knowledge Graph.\nGoogle 版的叫\"知识图谱\"\n\nAt the end of 2016,\n在2016年底\n\nit contained roughly seventy billion facts about, and relationships between, different entities.\n包含大概七百亿个事实，以及不同实体间的关系\n\nThese two processes, parsing and generating text,\n处理, 分析, 生成文字 \\N 是聊天机器人的最基本部件\n\nare fundamental components of natural language chatbots\n处理, 分析, 生成文字 \\N 是聊天机器人的最基本部件\n\n- computer programs that chat with you.\n- 聊天机器人就是能和你聊天的程序\n\nEarly chatbots were primarily rule-based,\n早期聊天机器人大多用的是规则.\n\nwhere experts would encode hundreds of rules mapping what a user might say,\n专家把用户可能会说的话，和机器人应该回复什么，\\N 写成上百个规则\n\nto how a program should reply.\n专家把用户可能会说的话，和机器人应该回复什么，\\N 写成上百个规则\n\nObviously this was unwieldy to maintain and limited the possible sophistication.\n显然，这很难维护，而且对话不能太复杂.\n\nA famous early example was ELIZA, created in the mid-1960s at MIT.\n一个著名早期例子叫 Eliza\\N 1960年代中期 诞生于麻省理工学院\n\nThis was a chatbot that took on the role of a therapist,\n一个治疗师聊天机器人\n\nand used basic syntactic rules to identify content in written exchanges,\n它用基本句法规则 来理解用户打的文字\n\nwhich it would turn around and ask the user about.\n然后向用户提问\n\nSometimes, it felt very much like human-human communication,\n有时候会感觉像和人类沟通一样\n\nbut other times it would make simple and even comical mistakes.\n但有时会犯简单 甚至很搞笑的错误\n\nChatbots, and more advanced dialog systems,\n聊天机器人和对话系统\n\nhave come a long way in the last fifty years, and can be quite convincing today!\n在过去五十年发展了很多，如今可以和真人很像!\n\nModern approaches are based on machine learning,\n如今大多用机器学习\n\nwhere gigabytes of real human-to-human chats are used to train chatbots.\n用上GB的真人聊天数据 来训练机器人\n\nToday, the technology is finding use in customer service applications,\n现在聊天机器人已经用于客服回答\n\nwhere there's already heaps of example conversations to learn from.\n客服有很多对话可以参考\n\nPeople have also been getting chatbots to talk with one another,\n人们也让聊天机器人互相聊天\n\nand in a Facebook experiment, chatbots even started to evolve their own language.\n在 Facebook 的一个实验里，\\N 聊天机器人甚至发展出自己的语言\n\nThis experiment got a bunch of scary-sounding press,\n很多新闻把这个实验 报导的很吓人\n\nbut it was just the computers crafting a simplified protocol to negotiate with one another.\n但实际上只是计算机 \\N 在制定简单协议来帮助沟通\n\nIt wasn't evil, it's was efficient.\n这些语言不是邪恶的，而是为了效率\n\nBut what about if something is spoken\n但如果听到一个句子\n\n- how does a computer get words from the sound?\n- 计算机怎么从声音中提取词汇？\n\nThat's the domain of speech recognition,\n这个领域叫\"语音识别\"\n\nwhich has been the focus of research for many decades.\n这个领域已经重点研究了几十年\n\nBell Labs debuted the first speech recognition system in 1952,\n贝尔实验室在1952年推出了第一个语音识别系统\n\nnicknamed Audrey, the automatic digit recognizer.\n绰号 Audrey，自动数字识别器\n\nIt could recognize all ten numerical digits,\n如果你说得够慢，它可以识别全部十位数字\n\nif you said them slowly enough.\n如果你说得够慢，它可以识别全部十位数字\n\n5\n\n9\n\n7？\n\nThe project didn't go anywhere\n这个项目没有实际应用，因为手输快得多\n\nbecause it was much faster to enter telephone numbers with a finger.\n这个项目没有实际应用，因为手输快得多\n\nTen years later, at the 1962 World's Fair,\n十年后，1962年的世界博览会上\n\nIBM demonstrated a shoebox-sized machine capable of recognizing sixteen words.\nIBM展示了一个鞋盒大小的机器，能识别16个单词\n\nTo boost research in the area,\n为了推进\"语音识别\"领域的研究\n\nDARPA kicked off an ambitious five-year funding initiative in 1971,\nDARPA 在1971年启动了一项雄心勃勃的五年筹资计划\n\nwhich led to the development of Harpy at Carnegie Mellon University.\n之后诞生了卡内基梅隆大学的 Harpy\n\nHarpy was the first system to recognize over a thousand words.\nHarpy 是第一个可以识别1000个单词以上的系统\n\nBut, on computers of the era,\n但那时的电脑\n\ntranscription was often ten or more times slower than the rate of natural speech.\n语音转文字，经常比实时说话要慢十倍或以上\n\nFortunately, thanks to huge advances in computing performance in the 1980s and 90s,\n幸运的是，1980,1990年代 计算机性能的大幅提升\n\ncontinuous, real-time speech recognition became practical.\n实时语音识别变得可行\n\nThere was simultaneous innovation in the algorithms for processing natural language,\n同时也出现了处理自然语言的新算法\n\nmoving from hand-crafted rules,\n不再是手工定规则\n\nto machine learning techniques\n而是用机器学习\n\nthat could learn automatically from existing datasets of human language.\n从语言数据库中学习\n\nToday, the speech recognition systems with the best accuracy are using deep neural networks,\n如今准确度最高的语音识别系统 用深度神经网络\n\nwhich we touched on in Episode 34.\n我们在第34集讲过\n\nTo get a sense of how these techniques work,\n为了理解原理\n\nlet's look at some speech, specifically,\n我们来看一些对话声音\n\nthe acoustic signal.\n我们来看一些对话声音\n\nLet's start by looking at vowel sounds,\n先看元音\n\nlike aaaaa and eeeeee.\n比如 a 和 e\n\nThese are the waveforms of those two sounds, as captured by a computer's microphone.\n这是两个声音的波形\n\nAs we discussed in Episode 21 - on Files and File Formats -\n我们在第21集（文件格式）说过\n\nthis signal is the magnitude of displacement,\n这个信号来自 麦克风内部隔膜震动的频率\n\nof a diaphragm inside of a microphone, as sound waves cause it to oscillate.\n这个信号来自 麦克风内部隔膜震动的频率\n\nIn this view of sound data, the horizontal axis is time,\n在这个视图中，横轴是时间\n\nand the vertical axis is the magnitude of displacement, or amplitude.\n竖轴是隔膜移动的幅度，或者说振幅\n\nAlthough we can see there are differences between the waveforms,\n虽然可以看到2个波形有区别\n\nit's not super obvious what you would point at to say,\n但不能看出\n\n\"ah ha! this is definitely an eeee sound\".\n\"啊！这个声音肯定是 e\"\n\nTo really make this pop out, we need to view the data in a totally different way:\n为了更容易识别，我们换个方式看：\n\na spectrogram.\n谱图\n\nIn this view of the data, we still have time along the horizontal axis,\n这里横轴还是时间\n\nbut now instead of amplitude on the vertical axis,\n但竖轴不是振幅\n\nwe plot the magnitude of the different frequencies that make up each sound.\n而是不同频率的振幅\n\nThe brighter the color, the louder that frequency component.\n颜色越亮，那个频率的声音越大\n\nThis conversion from waveform to frequencies is done with a very cool algorithm called\n这种波形到频率的转换 是用一种很酷的算法做的\n\na Fast Fourier Transform.\n快速傅立叶变换（FFT）\n\nIf you've ever stared at a stereo system's EQ visualizer,\n如果你盯过立体声系统的 EQ 可视化器\n\nit's pretty much the same thing.\n它们差不多是一回事\n\nA spectrogram is plotting that information over time.\n谱图是随着时间变化的\n\nYou might have noticed that the signals have a sort of ribbed pattern to them\n你可能注意到，信号有种螺纹图案\n\nthat's all the resonances of my vocal tract.\n那是我声道的回声\n\nTo make different sounds,\n为了发出不同声音\n\nI squeeze my vocal chords, mouth and tongue into different shapes,\n我要把声带，嘴巴和舌头变成不同形状\n\nwhich amplifies or dampens different resonances.\n放大或减少不同的共振\n\nWe can see this in the signal, with areas that are brighter, and areas that are darker.\n可以看到有些区域更亮，有些更暗\n\nIf we work our way up from the bottom, labeling where we see peaks in the spectrum\n如果从底向上看，标出高峰\n\n- what are called formants -\n- 叫\"共振峰\"  -\n\nwe can see the two sounds have quite different arrangements.\n可以看到有很大不同\n\nAnd this is true for all vowel sounds.\n所有元音都是如此\n\nIt's exactly this type of information that lets computers recognize spoken vowels,\n这让计算机可以识别元音\n\nand indeed, whole words.\n然后识别出整个词\n\nLet's see a more complicated example,\n让我们看一个更复杂的例子\n\nlike when I say: \"she.. was.. happy\"\n当我说\"她..很开心\"的时候\n\nWe can see our \"eee\" sound here, and \"aaa\" sound here.\n可以看到 e 声，和 a 声\n\nWe can also see a bunch of other distinctive sounds,\n以及其它不同声音\n\nlike the \"shh\" sound in \"she\",\n比如 she 中的 shh 声\n\nthe \"wah\" and \"sss\" in \"was\", and so on.\nwas 中的 wah 和 sss，等等\n\nThese sound pieces, that make up words,\n这些构成单词的声音片段\n\nare called phonemes.\n叫\"音素\"\n\nSpeech recognition software knows what all these phonemes look like.\n语音识别软件 知道这些音素\n\nIn English, there are roughly forty-four,\n英语有大概44种音素\n\nso it mostly boils down to fancy pattern matching.\n所以本质上变成了音素识别\n\nThen you have to separate words from one another,\n还要把不同的词分开\n\nfigure out when sentences begin and end...\n弄清句子的开始和结束点\n\nand ultimately, you end up with speech converted into text,\n最后把语音转成文字\n\nallowing for techniques like we discussed at the beginning of the episode.\n使这集视频开头里讨论的那些技术成为可能\n\nBecause people say words in slightly different ways,\n因为口音和发音错误等原因\n\ndue to things like accents and mispronunciations,\n人们说单词的方式略有不同\n\ntranscription accuracy is greatly improved when combined with a language model,\n所以结合语言模型后，语音转文字的准确度会大大提高\n\nwhich contains statistics about sequences of words.\n里面有单词顺序的统计信息\n\nFor example \"she was\" is most likely to be followed by an adjective, like \"happy\".\n比如：\"她\"后面很可能跟一个形容词，\\N 比如\"很开心\"\n\nIt's uncommon for \"she was\" to be followed immediately by a noun.\n\"她\"后面很少是名词\n\nSo if the speech recognizer was unsure between, \"happy\" and \"harpy\",\n如果不确定是 happy 还是 harpy，会选 happy\n\nit'd pick \"happy\",\n如果不确定是 happy 还是 harpy，会选 happy\n\nsince the language model would report that as a more likely choice.\n因为语言模型认为可能性更高\n\nFinally, we need to talk about Speech Synthesis,\n最后, 我们来谈谈 \"语音合成\"\n\nthat is, giving computers the ability to output speech.\n让计算机输出语音\n\nThis is very much like speech recognition, but in reverse.\n它很像语音识别，不过反过来\n\nWe can take a sentence of text, and break it down into its phonetic components,\n把一段文字，分解成多个声音\n\nand then play those sounds back to back, out of a computer speaker.\n然后播放这些声音\n\nYou can hear this chaining of phonemes very clearly with older speech synthesis technologies,\n早期语音合成技术，可以清楚听到音素是拼在一起的\n\nlike this 1937, hand-operated machine from Bell Labs.\n比如这个1937年贝尔实验室的手动操作机器\n\nSay, \"she saw me\" with no expression.\n不带感情的说\"她看见了我\"\n\nShe saw me.\n她看见了我\n\nNow say it in answer to these questions.\n现在回答问题\n\nWho saw you?\n谁看见你了？\n\nShe saw me.\n她看见了我\n\nWho did she see?\n她看到了谁？\n\nShe saw me.\n她看见了我\n\nDid she see you or hear you?\n她看到你还是听到你说话了？\n\nShe saw me.\n她看见了我\n\nBy the 1980s, this had improved a lot,\n到了1980年代，技术改进了很多\n\nbut that discontinuous and awkward blending of phonemes\n但音素混合依然不够好，产生明显的机器人声\n\nstill created that signature, robotic sound.\n但音素混合依然不够好，产生明显的机器人声\n\nThriller was released in 1983 and sung by Michael Jackson.\nThriller 于1983年发行，迈克尔·杰克逊 演唱.\n\nToday, synthesized computer voices, like Siri, Cortana and Alexa,\n如今，电脑合成的声音，比如 Siri, Cortana, Alexa\n\nhave gotten much better, but they're still not quite human.\n好了很多，但还不够像人\n\nBut we're soo soo close,\n但我们非常非常接近了\n\nand it's likely to be a solved problem pretty soon.\n这个问题很快会被解决\n\nEspecially because we're now seeing an explosion of voice user interfaces on our phones,\n现在语音界面到处都是，手机里\n\nin our cars and homes, and maybe soon, plugged right into our ears.\n汽车里，家里，也许不久之后耳机也会有.\n\nThis ubiquity is creating a positive feedback loop,\n这创造一个正反馈循环\n\nwhere people are using voice interaction more often,\n人们用语音交互的频率会提高\n\nwhich in turn, is giving companies like Google, Amazon and Microsoft\n这又给了谷歌，亚马逊，微软等公司\n\nmore data to train their systems on.\n更多数据来训练语音系统.\n\nWhich is enabling better accuracy,\n提高准确性\n\nwhich is leading to people using voice more,\n准确度高了，人们更愿意用语音交互\n\nwhich is enabling even better accuracy and the loop continues!\n越用越好，越好越用\n\nMany predict that speech technologies will become as common a form of interaction\n很多人预测，语音交互会越来越常见\n\nas screens, keyboards, trackpads and other physical input-output devices that we use today.\n就像如今的屏幕，键盘，触控板等设备\n\nThat's particularly good news for robots,\n这对机器人发展是个好消息\n\nwho don't want to have to walk around with keyboards in order to communicate with humans.\n机器人就不用走来走去时  带个键盘和人类沟通\n\nBut, we'll talk more about them next week. See you then.\n下周我们讲机器人.  到时见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/37. 机器人-Robots.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n嗨，我是 Carrie Anne，欢迎收看计算机速成课\n\nToday we’re going to talk about robots.\n今天 我们要讨论机器人\n\nThe first image that jumps to your mind is probably a humanoid robot,\n你脑中冒出来的第一个印象估计是 类人机器人\n\nlike we usually see in shows or movies.\n经常在电视剧和电影里看到.\n\nSometimes they’re our friends and colleagues,\n有时候它们是朋友和同事\n\nbut more often, they're sinister, apathetic and battle-hardened.\n但更常见的是阴险无情，身经百战\n\nWe also tend to think of robots as a technology of the future.\n我们经常把机器人看成未来科技\n\nBut the reality is: they’re already here – by the millions\n但事实是：机器人时代已经来临了\n\n– and they're our workmates,\n- 它们是同事\n\nhelping us to do things harder, better, faster, and stronger.\n帮我们把困难的工作，做得更快更好\n\nThere are many definitions for robots, but in general,\n机器人的定义有很多种，但总的来说，\n\nthese are machines capable of carrying out a series of actions automatically\n机器人由计算机控制，可以自动执行一系列动作的机器\n\nguided by computer control.\n机器人由计算机控制，可以自动执行一系列动作的机器\n\nHow they look isn’t part of the equation –\n外观并不重要\n\nrobots can be industrial arms that spray paint cars,\n可以是给汽车喷漆的机械臂\n\ndrones that fly, snake-like medical robots that assist surgeons,\n无人机，或辅助外科医生的蛇状机器人\n\nas well as humanoid robotic assistants.\n以及人形机器人\n\nAlthough the term \"robot\" is sometimes\n有时我们叫虚拟人物\"机器人\"\n\napplied to interactive virtual characters,\n有时我们叫虚拟人物\"机器人\"\n\nit’s more appropriate to call these \"bots\", or even better, \"agents.\"\n但叫 bot 甚至 agent 会更合适\n\nThat’s because the term \"robot\" carries a physical connotation\n因为\"机器人\"的潜在含义是  存在于现实世界中的机器\n\na machine that lives in and acts on the real world.\n因为\"机器人\"的潜在含义是  存在于现实世界中的机器\n\nThe word \"robot\" was first used in a 1920 Czech play\nrobot (机器人) 一词 \\N 首次出现在1920年的一部捷克戏剧\n\nto denote artificial, humanoid characters.\n代表人造的类人角色\n\nThe word was derived from \"robota\", the slavic-language word for a forced laborer,\nrobot 源于斯拉夫语词汇 robota  \\N 代表强迫劳动\n\nindicating peasants in compulsory service in feudal, nineteenth century Europe.\n代表农民在十九世纪 \\N 欧洲封建社会的强迫劳动\n\nThe play didn’t go too much into technological details.\n戏剧没讲太多技术细节\n\nBut, even a century later, it’s still a common portrayal:\n但即使一个世纪后，这种描述依然很普遍：\n\nmass-produced, efficient, tireless creatures that look human-esque,\n机器人都是大规模生产，高效不知疲倦，看起来像人的东西\n\nbut are emotionless, indifferent to self-preservation and lack creativity.\n但毫无情感，不会保护自己，没有创造力\n\nThe more general idea of self-operating machines\n更广义的自动运行机器，早在1920年代前就有了\n\ngoes back even further than the 1920s.\n更广义的自动运行机器，早在1920年代前就有了\n\nMany ancient inventors created mechanical devices that\n很多古代发明家 \\N 发明了能自动运行的机械装置\n\nperformed functions automatically,\n很多古代发明家 \\N 发明了能自动运行的机械装置\n\nlike keeping the time and striking bells on the hour.\n比如计时和定时敲钟\n\nThere are plenty of examples of automated animal and humanoid figures,\n有很多装置 有动物和人类的形象 \\N 能跳舞，唱歌，打鼓等\n\nthat would perform dances, sing songs, strike drums and do other physical actions.\n有很多装置 有动物和人类的形象 \\N 能跳舞，唱歌，打鼓等\n\nThese non-electrical and certainly non-electronic machines were called automatons.\n这些不用电，而且肯定没有电子部件的机器，叫\"自动机\"\n\nFor instance, an early automaton created in 1739\n举个例子 \\N 1739年法国人 Jacques de Vaucans 做了个自动机\n\nby the Frenchman Jacques de Vaucanson\n举个例子 \\N 1739年法国人 Jacques de Vaucans 做了个自动机\n\nwas the Canard Digerateur or Digesting Duck,\n法语叫 Canard Digerateur，翻译过来是 \"吃饭鸭\"\n\na machine in the shape of a duck that appeared\n一个像鸭子的机器，能吃东西然后排便\n\nto eat grain and then defecate.\n一个像鸭子的机器，能吃东西然后排便\n\nIn 1739 Voltaire wrote,\n伏尔泰在1739年写\n\n\"Without the voice of le Maure and Vaucanson’s duck,\n\"如果没有吃饭鸭的声音\n\nyou would have nothing to remind you of the glory of France.\"\n还有什么能提醒你法国的荣光呢？\"\n\nOne of the most infamous examples was the \"Mechanical Turk\":\n一个名声很臭的例子是\"土耳其行棋傀儡\"\n\na chess-playing, humanoid automaton.\n一个能下国际象棋的人形机器人\n\nAfter construction in 1770, it toured all over Europe,\n在1770年建造完成后，就在欧洲各地展览\n\nwowing audiences with its surprisingly good chess-playing.\n好棋艺惊叹观众\n\nIt appeared to be a mechanical, artificial intelligence.\n像某种机械人工智能\n\nUnfortunately, it was a hoax – there was a dainty human stuffed inside the machine.\n不幸的是，这是个骗局 - 机器里有人控制\n\nThe first machines controlled by computers emerged in the late 1940s.\n第一台计算机控制的机器，出现在1940年代晚期\n\nThese Computer Numerical Control, or CNC machines,\n这些计算机数控的机器，简称 CNC 机器\n\ncould run programs that instructed a machine to perform a series of operations.\n可以执行一连串 程序指定的操作\n\nThis level of control also enabled the creation of new manufactured goods,\n精细的控制 让我们能生产之前很难做的物品\n\nlike milling a complex propellor design out of a block of aluminum\n比如从一整块铝 加工出复杂的螺旋桨\n\n– something that was difficult to do using standard machine tools,\n- 这用普通机械工具很难做到\n\nand with tolerances too small to be done by hand.\n并且误差容忍度很小，无法手工加工\n\nCNC machines were a huge boon to industry,\nCNC 机器大大推进了制造业\n\nnot just due to increased capability and precision,\n不仅提高了制造能力和精确度 还降低了生产成本\n\nbut also in terms of reducing labor costs by automating human jobs\n不仅提高了制造能力和精确度 还降低了生产成本\n\n– a topic we'll revisit in a later episode.\n- 我们之后会深入讨论这个（第40集）\n\nThe first commercial deployment was a programmable industrial robot\n第一个商业贩卖的 可编程工业机器人\n\ncalled the Unimate, sold to General Motors in 1960\n叫 Unimate，于1960年卖给通用汽车公司\n\nto lift hot pieces of metal from a die casting machine and stack them.\n它可以把压铸机做出来的热金属成品提起来，然后堆起来\n\nThis was the start of the robotics industry.\n机器人行业由此开始\n\nSoon, robots were stacking pallets, welding parts, painting cars and much more.\n很快，机器人开始堆叠货盘，焊接，给汽车喷漆等等\n\nFor simple motions – like a robotic gripper that moves back and forth on a track\n对于简单运动 - 比如机器爪子 在轨道上来回移动\n\na robot can be instructed to move to a particular position,\n可以指示它移动到特定位置\n\nand it'll keep moving in that direction until the desired position is reached\n它会一直朝那个方向移动，直到到达 \\N 然后停下来\n\nat which point it’ll stop.\n它会一直朝那个方向移动，直到到达 \\N 然后停下来\n\nThis behavior can be achieved through a simple control loop.\n这种行为 可以用简单控制回路做\n\nFirst, sense the robot position.\n首先，判断机器人的位置\n\nAre we there yet?\n我们到了吗？\n\nNope.\n没有\n\nSo keep moving.\n那么继续前进\n\nNow sense position again.\n再次判断位置\n\nAre we there yet?\n我们到了吗？\n\nNope, so keep moving.\n没有，所以继续前进\n\nAre we there yet?\n我们到了吗？\n\nYes!\n是的!\n\nSo we can stop moving, and also please be quiet!\n现在可以停下来了，别问了！\n\nBecause we’re trying to minimize the distance between\n因为我们在不断缩小 当前位置和目标位置的距离\n\nthe sensed position and the desired position,\n因为我们在不断缩小 当前位置和目标位置的距离\n\nthis control loop is, more specifically, a negative feedback loop.\n这个控制回路 更准确的叫\"负反馈回路\"\n\nA negative feedback control loop has three key pieces.\n负反馈回路 有三个重要部分\n\nThere’s a sensor, that measures things in the real world,\n首先是一个传感器，可以测量现实中的东西\n\nlike water pressure, motor position, air temperature,\n比如水压，马达位置，气温，\n\nor whatever you’re trying to control.\n或任何你想控制的东西\n\nFrom this measurement, we calculate how far we are from\n根据传感器，计算和目标值相差多大\n\nwhere we want to be – the error.\n得到一个\"错误\"\n\nThe error is then interpreted by a controller,\n然后\"控制器\"会处理这个\"错误\"\n\nwhich decides how to instruct the system to minimize that error.\n决定怎么减小错误\n\nThen, the system acts on the world though pumps, motors,\n然后用泵，电机，加热元件，或其他物理组件来做出动作\n\nheating elements, and other physical actuators.\n然后用泵，电机，加热元件，或其他物理组件来做出动作\n\nIn tightly controlled environments, simple control loops, like this, work OK.\n在严格控制的环境中，这种简单控制回路也够用了\n\nBut in many real world applications, things are a tad more complicated.\n但在很多现实应用中，情况复杂得多\n\nImagine that our gripper is really heavy, and even when the control loop says to stop,\n假设爪子很重，哪怕控制回路叫停了\n\nmomentum causes the gripper to overshoot the desired position.\n惯性让爪子超过了预期位置\n\nThat would cause the control loop to take over again,\n然后控制回路又开始运行\n\nthis time backing the gripper up.\n叫爪子移动回去\n\nA badly tuned control loop might overshoot and overshoot and overshoot,\n一个糟糕的控制回路 可能会让爪子不断来回移动\n\nand maybe even wobble forever.\n甚至永远循环\n\nTo make matters worse, in real world settings,\n更糟糕的是，现实世界中\n\nthere are typically external and variable forces acting on a robot,\n机器人会受到各种外力影响\n\nlike friction, wind and items of different weight.\n比如摩擦力，风，等等\n\nTo handle this gracefully, more sophisticated control logic is needed.\n为了处理这些外力，我们需要更复杂的控制逻辑\n\nA widely used control-loop, feedback mechanism is a\n一个使用广泛的机制，有控制回路和反馈机制。\n\nproportional–integral–derivative controller.\n叫 \"比例-积分-微分控制器\"\n\nThat’s a bit of a mouthful, so people call them PID controllers.\n这个有点绕口，所以一般简称 \"PID控制器\"\n\nThese used to be mechanical devices, but now it’s all done in software.\n它以前是机械设备，现在全是纯软件了\n\nLet’s imagine a robot that delivers coffee.\n想象有一个机器人，端咖啡给客人\n\nIts goal is to travel between customers at two meters per second,\n设计目标是 每秒两米的速度在顾客间穿行\n\nwhich has been determined to be the ideal speed\n这个速度是理想速度\n\nthat’s both safe and expedient.\n安全又合适\n\nOf course, the environment doesn’t always cooperate.\n当然，环境是会变化的\n\nSometimes there’s wind, and sometimes there's uphills and downhills\n有时候有风，有时候有上坡下坡\n\nand all sorts of things that affect the speed of the robot.\n以及其他影响机器人速度的因素\n\nSo, it’s going to have to increase and decrease power\n所以，给马达的动力要加大或减少，以保持目标速度\n\nto its motors to maintain the desired speed.\n所以，给马达的动力要加大或减少，以保持目标速度\n\nUsing the robot's speed sensor, we can keep track of its\n用机器人的速度传感器，我们可以\n\nactual speed and plot that alongside its desired speed.\n把当前速度和目标速度画张图\n\nPID controllers calculate three values from this data.\nPID 控制器根据这些数据，算出3个值\n\nFirst is the proportional value, which is the difference between\n首先是\"比例值\"，就是\"实际值\"和\"理想值\"差多少\n\nthe desired value and the actual value\n首先是\"比例值\"，就是\"实际值\"和\"理想值\"差多少\n\nat the most recent instant in time or the present.\n\"实际值\"可能有一定滞后，或者是实时的。\n\nThis is what our simpler control loop used before.\n之前的简单控制回路，用的就是这个值\n\nThe bigger the gap between actual and desired,\n\"实际值\"和\"理想值\"的差距越大，\n\nthe harder you'll push towards your target.\n就越用力\n\nIn other words, it’s proportional control.\n换句话说，它是\"比例控制\"的\n\nNext, the integral value is computed,\n接下来，算\"积分值\"\n\nwhich is the sum of error over a window of time,\n就是一段时间内 误差的总和\n\nlike the last few seconds.\n比如最近几秒\n\nThis look back helps compensate for steady state errors,\n帮助弥补误差\n\nresulting from things like motoring up a long hill.\n比如上坡时可能就会产生误差\n\nIf this value is large, it means proportional control is not enough,\n如果这个值很大，说明比例控制不够，\n\nand we have to push harder still.\n要继续用力前进\n\nFinally, there’s the derivative value,\n最后有\"导数值\"\n\nwhich is the rate of change between the desired and actual values.\n是期望值与实际值之间的变化率\n\nThis helps account for possible future error,\n有助于解决 未来可能出现的错误，\n\nand is sometimes called \"anticipatory control\".\n有时也叫\"预期控制\"\n\nFor example, if you are screaming in towards your goal too fast,\n比如前进的太快\n\nyou'll need to ease up a little to prevent overshoot.\n要稍微放松一点，避免冲过头\n\nThese three values are summed together, with different relative weights,\n这三个值会一起使用，它们有不同权重\n\nto produce a controller output that’s passed to the system.\n然后用来控制系统\n\nPID controllers are everywhere,\nPID 控制器到处都是\n\nfrom the cruise control in your car,\n比如汽车里的巡航控制\n\nto drones that automatically adjust their rotor speeds to maintain level flight,\n无人机调整螺旋桨速度，以保持水平\n\nas well as more exotic robots,\n以及一些更奇怪的机器人，\n\nlike this one that balances on a ball to move around.\n比如这个用球来平衡和移动的机器人\n\nAdvanced robots often require many control loops running in parallel,\n更高级的机器人一般需要多个控制回路同时运行\n\nworking together, managing everything from robot balance to limb position.\n来保持机器人平衡，调整肢体位置，等等\n\nAs we’ve discussed, control loops are responsible for\n之前说过，控制回路负责\n\ngetting robot attributes  like location to desired values.\n把机器人的属性（比如当前位置）变成期望值\n\nSo, you may be wondering where these values come from.\n你可能好奇这些值 是哪里来的\n\nThis is the responsibility of higher-level robot software,\n这是更高层软件的责任\n\nwhich plans and executes robot actions,\n软件负责做出计划 并让机器人执行动作，\n\nlike plotting a path around sensed obstacles, or breaking down physical tasks,\n比如制定一条路线来绕过障碍物，或者把任务分成一步步\n\nlike picking up a ball, into simple, sequential motions.\n比如把拿起一个球，分解成一个个简单连续动作\n\nUsing these techniques, robots have racked up some impressive achievements\n用这些技术，机器人已经取得不少令人印象深刻的成就\n\n– they've been to the deepest depths of Earth's oceans\n- 它们潜到了海洋最深处\n\nand roved around on Mars for over a decade.\n在火星上跑了十几年\n\nBut interestingly, lots of problems that are trivial for many humans\n但有趣的是，许多对人类来说很简单的任务\n\nhave turned out to be devilishly difficult for robots:\n对机器人很困难：\n\nlike walking on two legs, opening a door, picking up objects\n比如两条腿走路，开门，拿东西时不要捏碎了\n\nwithout crushing them, putting on a t-shirt, or petting a dog.\n或是穿T恤，或是摸狗\n\nThese are tasks you may be able to do without thinking,\n这些你可能想都不用想\n\nbut a supercomputer-powered robot fails at spectacularly.\n但有超级计算机能力的机器人却做不到\n\nThese sorts of tasks are all active areas of robotics research.\n机器人研究领域在全力解决这些问题\n\nArtificial intelligence techniques,\n我们前几集聊过的 人工智能\n\nwhich we discussed a few episodes ago, are perhaps\n我们前几集聊过的 人工智能\n\nthe most promising avenue to overcome these challenges.\n最有可能解决这些问题\n\nFor example, Google has been running an experiment\n例如，谷歌在进行一项实验\n\nwith a series of robotic arms that spend their days\n让一堆机器人手臂把各种东西\n\nmoving miscellaneous objects from one box to another, learning from trial and error.\n从一个盒子拿到另一个盒子，不断试错学习\n\nAfter thousands of hours of practice, the robots had cut their error rate in half.\n经过数千小时的练习，机器人把错误率降低了一半\n\nOf course, unlike humans, robots can run twenty-four hours a day\n不像人类，机器人可以24小时全天运行\n\nand practice with many arms at the same time.\n而且多个手臂同时练习\n\nSo, it may just be a matter of time until they become adept at grasping things.\n所以机器人擅长抓东西只是时间问题\n\nBut, for the time being, toddlers can out-grasp them.\n但现在，小婴儿都比机器人更会抓东西\n\nOne of the biggest and most visible robotic breakthrough\n近年最大的突破之一\n\nin recent years has been self-driving, autonomous cars.\n是无人驾驶汽车\n\nIf you think about it, cars don’t have too many system inputs\n如果你仔细想想，汽车没几个输入\n\n– you can speed up or slow down, and you can steer left or right.\n- 只是加速减速，左转右转\n\nThe tough part is sensing lanes, reading signs,\n难的问题是 判断车道，理解路标\n\nand anticipating and navigating traffic, pedestrians,\n预测车流，车流中穿行，留心行人和骑自行车的。\n\nbicyclists, and a whole host of obstacles.\n以及各种障碍\n\nIn addition to being studded with proximity sensors,\n车上布满了传感器\n\nthese robotic vehicles heavily rely\n无人驾驶汽车非常依赖\n\non Computer Vision algorithms, which we discussed in Episode 35.\n计算机视觉算法，我们在第35集讨论过\n\nWe’re also seeing the emergence of very primitive androids\n现在也开始出现类人机器人\n\n– robots that look and act like humans.\n- 外貌和行为像人类的机器人\n\nArguably, we’re not close on either of those goals,\n不过现在两个目标都没接近（外貌和行为）\n\nas they tend to look pretty weird and act even weirder.\n因为看起来一般怪怪的，行为也怪怪的.\n\nAt least we’ll always have Westworld.\n但至少有《西部世界》可以看看\n\nBut anyway, these remain a tantalizing goal for roboticists\n无论如何，对机器人研究者来说，把各种技术结合起来\n\ncombine many computer science topics\n比如人工智能，计算机视觉和自然语言处理\n\nwe’ve touched on over the last few episodes, like artificial intelligence,\n比如人工智能，计算机视觉和自然语言处理\n\ncomputer vision and natural language processing.\n来让机器人越来越像人，是个诱人的目标\n\nAs for why humans are so fascinated by\n至于人类为什么如此着迷 做出和我们一样的机器人\n\ncreating artificial embodiments of ourselves.\n至于人类为什么如此着迷 做出和我们一样的机器人\n\nyou'll have to go to Crash Course Philosophy for that.\n你得去看《哲学速成课》\n\nAnd for the foreseeable future,\n在未来好一段时间里\n\nrealistic androids will continue to be the stuff of science fiction.\n和人类一样的机器人 依然只能存在科幻小说里。\n\nMilitaries also have a great interest in robots –\n军队也对机器人很有兴趣 -\n\nthey're not only replaceable, but can surpass humans\n因为机器人可以替换，\n\nin attributes like strength, endurance, attention, and accuracy.\n而且力量，耐力，注意力，准确性可以远超人类\n\nBomb disposal robots and reconnaissance drones are fairly common today.\n拆弹机器人和无人侦察机如今很常见\n\nBut fully autonomous, armed-to-the-teeth robots are slowly appearing,\n但完全自主决定，全副武装的机器人也在慢慢出现\n\nlike the Samsung SGR-A1 sentry gun deployed by South Korea.\n比如韩国的三星 SGR-A1 哨兵炮\n\nRobots with the intelligence and capability to take human lives\n有智力并且可以杀人的机器人\n\nare called lethal autonomous weapons.\n叫 \"致命自主武器\"\n\nAnd they’re widely considered a complex and thorny issue.\n这种武器是复杂又棘手的问题\n\nWithout doubt, these systems could save soldiers lives\n毫无疑问，它们可以把士兵从战场带离 挽救生命\n\nby taking them off the battlefield and out of harm’s way.\n毫无疑问，它们可以把士兵从战场带离 挽救生命\n\nIt might even discourage war all together.\n甚至阻止战争的发生\n\nThough it’s worth noting that people said the same thing\n值得注意的是 人们对炸药和核弹也说过一样的话\n\nabout dynamite and nuclear weapons.\n值得注意的是 人们对炸药和核弹也说过一样的话\n\nOn the flip side, we might be creating ruthlessly\n另一方面，我们可能会不小心创造出 \\N 无情又高效的杀人机器\n\nefficient killing machines that don't apply human judgment\n没有人类般的判断力和同情心\n\nor compassion to complex situations.\n没有人类般的判断力和同情心\n\nAnd the fog of war is about as complex and murky as they come.\n战争的硝烟会变得更加黑暗和复杂\n\nThese robots would be taking orders and executing them\n机器人会接受命令并高效执行\n\nas efficiently as they can and sometimes\n机器人会接受命令并高效执行\n\nhuman orders turn out to be really bad.\n但有时人类的命令是错的\n\nThis debate is going to continue for a long time,\n这场辩论会持续很长时间，\n\nand pundits on both sides will grow louder as robotic technology improves.\n而且随着机器人技术的进步，两边的辩论会越来越激烈\n\nIt’s also an old debate –\n这也是个老话题了\n\nthe danger was obvious to science fiction writer Isaac Asimov,\n科幻作家 艾萨克·阿西莫夫 早预见了这种危险\n\nwho introduced a fictional \"Three Laws of Robotics\" in his 1942 short story \"Runaround\".\n他在1942年短篇小说 Runaround 中写了\"机器人三定律\"\n\nAnd then, later he added a zeroth rule.\n之后又加了\"定律0\"\n\nIn short, it’s a code of conduct or moral compass for robots –\n简单说 这些定律指导机器人的行为准则 或者说道德指南\n\nguiding them to do no harm, especially to humans.\n让机器人不要伤害，特别是不要伤害人类\n\nIt’s pretty inadequate for practical application and it leaves plenty of room for equivocation.\n这些规则实践起来相当不足，并且有很多模糊的地方\n\nBut still, Asimov’s laws inspired a ton of science fiction and academic discussion,\n但阿西莫夫三定律 激发了大量科幻小说讨论和学术讨论，\n\nand today there are whole conferences on robot ethics.\n如今有专门讨论机器人伦理的会议\n\nImportantly, Asimov crafted his fictional rules\n重要的是，阿西莫夫写这些虚构规则\n\nas a way to push back on \"Robot as a Menace\" memes\n是为了反对 \"机器人都很邪恶\" 这种常见描述\n\ncommon in fiction from his childhood.\n他童年读的小说里，这样的场景很常见\n\nThese were stories where robots went off the rails,\n机器人脱离控制，然后伤害甚至毁灭创造者\n\nharming or even destroying their creators in the process.\n机器人脱离控制，然后伤害甚至毁灭创造者\n\nAsimov, on the other hand, envisioned robots as useful,\n阿西莫夫认为 机器人有用，可靠，甚至可以让人喜爱\n\nreliable, and even loveable machines.\n阿西莫夫认为 机器人有用，可靠，甚至可以让人喜爱\n\nAnd it’s this duality I want to leave you thinking about today.\n我想让你思考这种两面性\n\nLike many of the technologies we’ve discussed throughout this series,\n我们讨论过的许多技术，有好的一面也有坏的一面\n\nthere are benevolent and malicious uses.\n我们讨论过的许多技术，有好的一面也有坏的一面\n\nOur job is to carefully reflect on computing's potential and peril,\n我们要认真思考计算机的潜力和危害\n\nand wield our inventive talents to improve the state of the world.\n来改善这个世界\n\nAnd robots are one of the most potent reminders of this responsibility.\n而机器人最能提醒我们这一点了\n\nI’ll see you next week.\n我 们 下 周 见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/38. 计算机心理学 - Psychology of Computing.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nSo, over the course of this series,\n在这个系列中，\n\nwe’ve focused almost exclusively on computers –\n我们聊的话题几乎全是计算机-比如电路和算法\n\nthe circuits and algorithms that make them tick.\n我们聊的话题几乎全是计算机-比如电路和算法\n\nBecause...this is Crash Course Computer Science.\n毕竟这是*计算机*速成课\n\nBut ultimately, computers are tools employed by people.\n但归根结底，计算机只是给人用的工具\n\nAnd humans are… well… messy.\n而人类有点... 乱\n\nWe haven’t been designed by human engineers from the ground up\n人类不是被工程师设计的，没有具体性能规格\n\nwith known performance specifications.\n人类不是被工程师设计的，没有具体性能规格\n\nWe can be logical one moment and irrational the next.\n我们一会儿是理性的，一会儿是不理性的\n\nHave you ever gotten angry at your navigation system? Surfed wikipedia aimlessly?\n你有没有对导航生过气？或是漫无目的的刷维基百科？\n\nBegged your internet browser to load faster?\n求浏览器加载快点？\n\nNicknamed your roomba?\n给扫地机器人取名？\n\nThese behaviors are quintessentially human!\n这些是人类行为！\n\nTo build computer systems that are useful, usable and enjoyable,\n为了做出使用愉快的计算机\n\nwe need to understand the strengths and weaknesses of both computers and humans.\n我们需要了解计算机和人类的优缺点\n\nAnd for this reason, when good system designers are creating software,\n优秀的系统设计师在创造软件时\n\nthey employ social, cognitive, behavioral, and perceptual psychology principles.\n会运用社会心理学，认知心理学，\\N 行为心理学，感知心理学的原理\n\nNo doubt you’ve encountered a physical or computer interface\n你肯定见过难用的物理界面/计算机界面 \\N 阻碍你做事\n\nthat was frustrating to use, impeding your progress.\n你肯定见过难用的物理界面/计算机界面 \\N 阻碍你做事\n\nMaybe it was so badly designed that you couldn’t figure it out and just gave up.\n甚至糟糕到放弃使用\n\nThat interface had poor usability.\n那个界面的\"易用度\"很差\n\nUsability is the degree to which a human-made artifact – like software\n\"易用度\"指的是人造物体，比如软件 \\N 达到目的的效率有多高\n\n– can be used to achieve an objective effectively and efficiently.\n\"易用度\"指的是人造物体，比如软件 \\N 达到目的的效率有多高\n\nTo facilitate human work, we need to understand humans\n为了帮助人类工作，我们需要了解人类 \\N  - 怎么看，思考，反应和互动\n\n- from how they see and think, to how they react and interact.\n为了帮助人类工作，我们需要了解人类 \\N  - 怎么看，思考，反应和互动\n\nFor instance, the human visual system has been well studied by Psychologists.\n举个例子，心理学家已经对 \\N 人类的视觉系统做了全面的研究\n\nLike, we know that people are good at ordering intensities of colors.\n我们知道人类擅长给颜色强度排序\n\nHere are three.\n这里有三个颜色\n\nCan you arrange these from lightest to darkest?\n你能从浅色到深色排序吗？\n\nYou probably don’t have to think too much about it.\n你可以轻易做到\n\nBecause of this innate ability, color intensity is a great choice\n所以颜色强度很适合显示连续值\n\nfor displaying data with continuous values.\n所以颜色强度很适合显示连续值\n\nOn the other hand, humans are terrible at ordering colors.\n另一方面，人类很不擅长排序颜色\n\nHere’s another example for you to put in order.\n这是另一个例子\n\nis orange before blue, or after blue?\n把橙色放到蓝色前面还是后面？绿色放哪里？\n\nWhere does green go?\n把橙色放到蓝色前面还是后面？绿色放哪里？\n\nYou might be thinking we could order this by wavelength of light,\n你可能想通过光的波长排序 \\N 就像彩虹一样，但这样太累了\n\nlike a rainbow, but that’s a lot more to think about.\n你可能想通过光的波长排序 \\N 就像彩虹一样，但这样太累了\n\nMost people are going to be much slower and error-prone at ordering.\n大部分人会很慢而且容易出错\n\nBecause of this innate ineptitude of your visual system,\n由于视觉系统天生是这样\n\ndisplaying continuous data using colors can be a disastrous design choice.\n所以用不同颜色显示连续性数据，是个糟糕的选择\n\nYou’ll find yourself constantly referring back to a color legend to compare items.\n你得经常看表格来对比数据\n\nHowever, colors are perfect for when the data is discrete with no ordering,\n然而，如果数据没有顺序，用不同颜色就很合适\n\nlike categorical data.\n比如分类数据\n\nThis might seem obvious, but you’d be amazed at\n也许这些看起来很明显 \\N 但你会惊讶有多少设计把这些基本事情搞错\n\nhow many interfaces get basic things like this wrong.\n也许这些看起来很明显 \\N 但你会惊讶有多少设计把这些基本事情搞错\n\nBeyond visual perception, understanding human cognition helps us\n除了视觉 \\N 理解人类的认知系统能帮我们设计更好的界面\n\ndesign interfaces that align with how the mind works.\n除了视觉 \\N 理解人类的认知系统能帮我们设计更好的界面\n\nLike, humans can read, remember and process information more effectively\n比如，如果信息分块了 \\N 会更容易读，更容易记\n\nwhen it's chunked–that is, when items are put together into small, meaningful groups.\n分块是指把信息分成更小，更有意义的块\n\nHumans can generally juggle seven items, plus-or-minus two, in short-term memory.\n人类的短期记忆能记住5到9个东西\n\nTo be conservative, we typically see groupings of five or less.\n保守一点，分组一般是5个或更少\n\nThat’s why telephone numbers are broken into chunks, like 317, 555, 3897.\n所以电话号码一般分块，比如 317-555-3897\n\nInstead of being ten individual digits that we’d likely forget, it’s three chunks,\n10个连续数可能会忘，分成3块更好记\n\nwhich we can handle better.\n10个连续数可能会忘，分成3块更好记\n\nFrom a computer's standpoint, this needlessly takes more time and space,\n从计算机的角度来看，分块更费时费空间\n\nso it's less efficient.\n效率更低\n\nBut, it’s way more efficient for us humans –\n但这对人类更有效率\n\na tradeoff we almost always make in our favor,\n- 碰到这种抉择时，我们总是以人类优先\n\nsince we’re the ones running the show...for now.\n现在我们还是老大.. 暂时啦\n\nChunking has been applied to computer interfaces for things\n界面设计用了分块 \\N 比如下拉菜单 和带按钮的菜单栏\n\nlike drop-down menu items and menu bars with buttons.\n界面设计用了分块 \\N 比如下拉菜单 和带按钮的菜单栏\n\nIt’d be more efficient for computers to just pack all those together, edge to edge\n对电脑来说，全部挤在一起更有效率\n\n– it’s wasted memory and screen real estate.\n分块浪费内存 浪费屏幕\n\nBut designing interfaces in this way makes them much easier\n但这样设计更容易扫视，记住和访问\n\nto visually scan, remember and access.\n但这样设计更容易扫视，记住和访问\n\nAnother central concept used in interface design is affordances.\n界面设计中另一个重点概念是\"直观功能\"\n\nAccording to Don Norman, who popularized the term in computing,\nDon Norman 让这个词在计算机界流行起来，根据他的说法\n\n\"affordances provide strong clues to the operations of things.\n\"直观功能 为如何操作物体提供线索\n\nPlates are for pushing.\n平板用来推\n\nKnobs are for turning.\n旋钮用来转\n\nSlots are for inserting things into.\n插槽用来插东西\n\n[...] When affordances are taken advantage of, the user knows what to do just by looking:\n[...]直观功能做的好，用户只需要看一眼就知道怎么做：\n\nno picture, label, or instruction needed.\"\n不需要图片，标签或指南来说明\"\n\nIf you’ve ever tried to pull a door handle, only to realize that you have to push it open,\n如果你拉过门把手打不开，然后意识到要推开才对\n\nyou’ve discovered a broken affordance.\n那么你发现了一个坏掉的\"直观功能\"\n\nOn the other hand, a door plate is a better design\n平板是更好的设计\n\nbecause it only gives you the option to push.\n因为只能推开\n\nDoors are pretty straightforward – if you need to put written instructions on them,\n门是简单的东西，如果你要贴指示让人们明白怎么用.\n\nyou should probably go back to the drawing board.\n那么也许你应该重新设计\n\nAffordances are used extensively in graphical user interfaces,\n\"直观功能\"广泛用于图形界面\n\nwhich we discussed in episode 26.\n我们在第26集讨论过\n\nIt’s one of the reasons why computers became so much easier to use than with command lines.\n这是图形界面比命令行更容易用的原因之一\n\nYou don’t have to guess what things on-screen are clickable, because they look like buttons.\n你不用猜测屏幕上什么东西是可点的，\\N 可点的会看起来像按钮\n\nThey pop out, just waiting for you to press them!\n他们弹出来，只是等着你压他们！\n\nOne of my favorite affordances, which suggests to users that an on-screen element is draggable,\n我最喜欢的\"直观功能\"之一，是向用户表明元素是可拖动的\n\nis knurling – that texture added to objects\n\"滚花\" - 一种视觉纹理\n\nto improve grip and show you where to best grab them.\n告诉用户哪里可以拖动\n\nThis idea and pattern was borrowed from real world physical tools.\n这个点子来自现实世界中的工具\n\nRelated to the concept of affordances is the psychology of recognition vs recall.\n和\"直观功能\"相关的一个心理学概念是 \"认出与回想\"\n\nYou know this effect well from tests –\n如果你考过试，肯定感受过这个\n\nit's why multiple choice questions are easier than fill-in-the-blank ones.\n这就是为什么选择题比填空题容易\n\nIn general, human memory is much better when it’s triggered by a sensory cue,\n一般来说，用感觉来触发记忆会容易得多\n\nlike a word, picture or sound.\n比如文字，图片或声音\n\nThat’s why interfaces use icons – pictorial representations of functions\n所以我们用图标代表功能\n\n– like a trash can for where files go to be deleted.\n- 比如\"垃圾桶\"图标 代表里面放着被删除的文件\n\nWe don’t have to recall what that icon does, we just have to recognise the icon.\n我们不用去回想图标的功能是什么，只要能认出来就行了\n\nThis was also a huge improvement over command line interfaces,\n比命令行好得多\n\nwhere you had to rely on your memory for what commands to use.\n命令行得依靠记忆来输命令\n\nDo I have to type \"delete\", or \"remove\", or... \"trash\", or… shoot, it could be anything!\n到底是输入\"删除\"\"移除\"\"垃圾\"还是\"射出\"？\\N 可能是任何命令！\n\nIt’s actually \"rm\" in linux,\n顺带一说，在 Linux 里删除文件的命令是 \"rm\"\n\nbut anyway, making everything easy to discover and learn sometimes means slow to access,\n回到正题，\\N 让所有菜单选项好找好记，有时候意味着用的时候会慢一些\n\nwhich conflicts with another psychology concept: expertise.\n这与另一个心理学概念冲突：\"专业知识\"\n\nAs you gain experience with interfaces, you get faster,\n当你用界面熟悉之后，速度会更快一些\n\nbuilding mental models of how to do things efficiently.\n建立如何高效完成事情的\"心理模型\"\n\nSo, good interfaces should offer multiple paths to accomplish goals.\n所以 好的界面应该提供多种方法来实现目标\n\nA great example of this is copy and paste, which can be found in the edit dropdown menu\n一个好例子是复制粘贴，可以在\"编辑\"的下拉菜单中找到\n\nof word processors, and is also triggered with keyboard shortcuts.\n也可以用快捷键\n\nOne approach caters to novices, while the other caters to experts, slowing down neither.\n一种适合新手，一种适合专家，两者都不耽误\n\nSo, you can have your cake and eat it too!\n鱼和熊掌兼得！\n\nIn addition to making humans more efficient,\n除了让人类做事更高效，\n\nwe'd also like computers to be emotionally intelligent –\n我们也希望电脑能有一点情商\n\nadapting their behavior to respond appropriately\n能根据用户的状态做出合适地反应\n\nto their users' emotional state – also called affect.\n能根据用户的状态做出合适地反应\n\nThat could make experiences more empathetic, enjoyable, or even delightful.\n让使用电脑更加愉快\n\nThis vision was articulated by Rosalind Picard in her 1995 paper on Affective Computing,\nRosalind Picard 在 1995 年关于\"情感计算\"的论文中，阐述了这一愿景\n\nwhich kickstarted an interdisciplinary field combining aspects\n这篇论文开创了心理学，社会科学和计算机科学的跨学科结合\n\nof psychology, social and computer sciences.\n这篇论文开创了心理学，社会科学和计算机科学的跨学科结合\n\nIt spurred work on computing systems that could recognize,\n促进了让计算机理解人类情感的研究\n\ninterpret, simulate and alter human affect.\n促进了让计算机理解人类情感的研究\n\nThis was a huge deal, because we know emotion influences cognition and perception\n这很重要，因为情绪会影响日常活动\n\nin everyday tasks like learning, communication, and decision making.\n比如学习，沟通和决策\n\nAffect-aware systems use sensors, sometimes worn, that capture things like speech and\n情感系统会用传感器，录声音，\n\nvideo of the face, as well as biometrics, like sweatiness and heart rate.\n录像（你的脸）以及生物指标，比如出汗和心率\n\nThis multimodal sensor data is used in conjunction with computational models that represent how\n得到的数据和计算模型结合使用\n\npeople develop and express affective states, like happiness and frustration,\n模型会写明人类如何表达情感，怎么是快乐 怎么是沮丧\n\nand social states, like friendship and trust.\n以及社交状态，比如友谊和信任\n\nThese models estimate the likelihood of a user being in a particular state,\n模型会估算用户的情绪\n\nand figure out how to best respond to that state,\n以及怎样以最好的回应用户\n\nin order to achieve the goals of the system.\n以达到目标\n\nThis might be to calm the user down, build trust, or help them get their homework done.\n比如让用户冷静下来，建立信任，或帮忙完成作业\n\nA study, looking at user affect, was conducted by Facebook in 2012.\nFacebook 在 2012 年进行了一项\"影响用户\"的研究\n\nFor one week, data scientists altered the content\n数据科学家在一个星期内\n\non hundreds of thousands of users' feeds.\n修改了很多用户 时间线上显示的内容\n\nSome people were shown more items with positive content,\n有些人会看到更多积极向上的内容\n\nwhile others were presented with more negative content.\n有些人会看到更多负面消极的内容\n\nThe researchers analyzed people's posts during that week,\n研究人员分析了那一周内人们的发帖\n\nand found that users who were shown more positive content,\n发现看到积极向上内容的用户，\n\ntended to also post more positive content.\n发的帖子往往更正面\n\nOn the other hand, users who saw more negative content, tended to have more negative posts.\n另一方面，看到负面内容的用户，发的内容也更负面\n\nClearly, what Facebook and other services show you\n显然，Facebook和其他网站向你展示的内容\n\ncan absolutely have an affect on you.\n绝对会对你有影响\n\nAs gatekeepers of content, that’s a huge opportunity and responsibility.\n作为信息的守门人，这是巨大的机会 同时也是责任\n\nWhich is why this study ended up being pretty controversial.\n研究结果相当有争议性.\n\nAlso, it raises some interesting questions about\n而且它还产生了一个有趣的问题：\n\nhow computer programs should respond to human communication.\n计算机程序如何回应人类\n\nIf the user is being negative, maybe the computer shouldn’t be\n如果用户的情绪比较负面，也许电脑不应该\n\nannoying by responding in a cheery, upbeat manner.\n以一种烦人的 \"你要振作起来呀\" 的态度回答问题.\n\nOr, maybe the computer should attempt to evoke a positive response,\n或者，也许电脑应该试着积极正面的回应用户\n\neven if it's a bit awkward.\n即使这有点尴尬.\n\nThe \"correct\" behavior is very much an open research question.\n什么行为是\"正确的\"，是个开放性的研究问题\n\nSpeaking of Facebook, it’s a great example of computer-mediated communication, or CMC,\n既然说到Facebook，\\N 这是一个\"以计算机为媒介沟通\"的好例子，简称 \"CMC\"\n\nanother large field of research.\n也是一个很大的研究领域\n\nThis includes synchronous communication – like video calls, where all participants are online\n这包括同步通信 - 所有参与者同时在线进行视频通话\n\nsimultaneously – as well as asynchronous communication – like tweets, emails, and\n以及异步通信 - 比如推特，邮件，\n\ntext messages, where people respond whenever they can or want.\n短信，人们可以随时随地回复信息\n\nResearchers study things like the use of emoticons, rules such as turn-taking,\n研究人员还研究用户怎么用表情包，怎么轮换发言，\n\nand language used in different communication channels.\n以及用不同沟通渠道时，用词有什么区别.\n\nOne interesting finding is that people exhibit higher levels of self-disclosure\n一个有趣的发现是，比起面对面沟通，\n\n– that is, reveal personal information –in computer-mediated conversations,\n人们更愿意在网上透露自己的信息\n\nas opposed to face-to-face interactions.\n人们更愿意在网上透露自己的信息\n\nSo if you want to build a system that knows how many hours a user truly spent\n所以如果想知道用户 \\N 真正花了多少小时看\"大英烘培大赛\"(电视节目)\n\nwatching The Great British Bakeoff, it might be better to build a chatbot\n比起做个带脸的虚拟助理 \\N 做 聊天机器人 是个更好的选择\n\nthan a virtual agent with a face.\n比起做个带脸的虚拟助理 \\N 做 聊天机器人 是个更好的选择\n\nPsychology research has also demonstrated that eye gaze is\n心理学研究也表明，如果想说服，讲课，或引起注意 \\N 眼神注视非常重要\n\nextremely important in persuading, teaching and getting people's attention.\n心理学研究也表明，如果想说服，讲课，或引起注意 \\N 眼神注视非常重要\n\nLooking at others while talking is called mutual gaze.\n在谈话时看着别人叫 相互凝视\n\nThis has been shown to boost engagement and help achieve the goals of a conversation,\n这被证明可以促进参与感 帮助实现谈话目标，\n\nwhether that’s learning, making a friend, or closing a business deal.\n不管是学习，交朋友，还是谈生意\n\nIn settings like a videotaped lecture, the instructor rarely, if ever, looks into the\n在录像讲座中，老师很少直视相机 \\N 一般是看在场学生\n\ncamera, and instead generally looks at the students who are physically present.\n在录像讲座中，老师很少直视相机 \\N 一般是看在场学生\n\nThat’s ok for them, but it means people who\n对他们没问题，但这会让在线看视频的人  没什么参与感\n\nwatch the lectures online have reduced engagement.\n对他们没问题，但这会让在线看视频的人  没什么参与感\n\nIn response, researchers have developed computer vision\n为此，研究人员开发了计算机视觉和图形软件 \\N 来纠正头部和眼睛\n\nand graphics software that can warp the head and eyes,\n为此，研究人员开发了计算机视觉和图形软件 \\N 来纠正头部和眼睛\n\nmaking it appear as though the instructor is looking into the camera\n视频时会觉得对方在直视摄像头，看着他们\n\n– right at the remote viewer.\n视频时会觉得对方在直视摄像头，看着他们\n\nThis technique is called augmented gaze.\n这叫\"增强凝视\"\n\nSimilar techniques have also been applied to video conference calls, to correct for\n类似技术也用于视频会议\n\nthe placement of webcams, which are almost always located above screens.\n纠正摄像头位置，因为摄像头几乎总在屏幕上方\n\nSince you’re typically looking at the video of your conversation partner,\n因为你一般会盯着屏幕上的另一方 \\N 而不是盯着摄像头\n\nrather than directly into the webcam,\n因为你一般会盯着屏幕上的另一方 \\N 而不是盯着摄像头\n\nyou'll always appear to them as though you're looking downwards –\n所以视频里看起来像在向下看\n\nbreaking mutual gaze – which can create all kinds of\n没有相互凝视 - 这会导致各种不幸的副作用，比如权力不平衡\n\nunfortunate social side effects, like a power imbalance.\n没有相互凝视 - 这会导致各种不幸的副作用，比如权力不平衡\n\nFortunately, this can be corrected digitally, and appear to participants\n幸运的是  可以用软件修正\n\nas though you're lovingly gazing into their eyes.\n看起来像在凝视着对方的眼睛\n\nHumans also love anthropomorphizing objects, and computers are no exception,\n人类也喜欢\"拟人化\"的物体，对计算机也不例外\n\nespecially if they move, like our Robots from last episode.\n特别是会动的计算机，比如上集说的机器人\n\nBeyond industrial uses that prevailed over the last century,\n在过去一个世纪，除了工业用途机器人\n\nrobots are used increasingly in medical, education, and entertainment settings,\n有越来越多机器人用于医疗，教育和娱乐 \\N 它们经常和人类互动\n\nwhere they frequently interact with humans.\n有越来越多机器人用于医疗，教育和娱乐 \\N 它们经常和人类互动\n\nHuman-Robot Interaction – or HRI\n人机交互，简称 HRI\n\n– is a field dedicated to studying these interactions,\n- 是一个研究人类和机器人交互的领域，\n\nlike how people perceive different robots behaviors and forms,\n比如人类如何感受 机器人的不同形式和不同行为\n\nor how robots can interpret human social cues to blend in and not be super awkward.\n或是机器人如何明白人类暗示来社交，而不是尴尬的互动\n\nAs we discussed last episode, there’s an ongoing quest to make\n正如上集说的，我们有追求\n\nrobots as human-like in their appearance and interactions as possible.\n把机器人的外表和行为，做得尽可能像人一样\n\nWhen engineers first made robots in the 1940s and 50s, they didn’t look very human at all.\n工程师在1940 1950年代刚开始做机器人时，\\N 看起来完全不像人\n\nThey were almost exclusively industrial machines with no human-likeness.\n是完完全全的工业机器\n\nOver time, engineers got better and better at making human-like robots\n随着时间的推移，工程师越来越擅长做类人机器人\n\n– they gained heads and walked around on two legs,\n它们有头，而且用两条腿走路\n\nbut… they couldn't exactly go to restaurants and masquerade as humans.\n但它们做不到伪装成人类去餐馆点餐\n\nAs people pushed closer and closer to human likeness,\n随着机器人可以做得越来越像人类\n\nreplacing cameras with artificial eyeballs, and covering metal chassis with synthetic flesh,\n用人造眼球代替摄像头，用人工肌肉盖住金属骨架\n\nthings started to get a bit... uncanny...\n事情会开始变得有些.. 奇怪.. \\N 引起一种怪异不安的感觉\n\neliciting an eerie and unsettling feeling.\n事情会开始变得有些.. 奇怪.. \\N 引起一种怪异不安的感觉\n\nThis dip in realism between almost-human and actually-human became known as the uncanny valley.\n这个\"几乎像人类\"和\"真的人类\"之间的小曲线，叫 \"恐怖谷\"\n\nThere’s debate over whether robots should act like humans too.\n对于机器人是否应该有人类一样的行为，也存在争议\n\nLots of evidence already suggests that even if robots don’t act like us,\n很多证据表明，即使机器人的行为不像人类\n\npeople will treat them as though they know our social conventions.\n人类也会用社交习俗对待它们\n\nAnd when they violate these rules – such as not apologizing if they cut in front of\n而当机器人违反习俗时 - 比如插队或踩了脚不道歉 \\N 人们会很生气！\n\nyou or roll over your foot – people get really mad!\n而当机器人违反习俗时 - 比如插队或踩了脚不道歉 \\N 人们会很生气！\n\nWithout a doubt, psychology and computer science are a potent combination,\n毫无疑问，心理学+计算机科学是强大的组合\n\nand have tremendous potential to affect our everyday lives.\n可以影响日常生活的巨大潜力\n\nWhich leaves us with a lot of question, like you might lie to your laptop,\n这也带来了很多开放式问题，比如你可能会对计算机撒谎\n\nbut should your laptop lie to you?\n但计算机应不应该对你撒谎？\n\nWhat if it makes you more efficient or happy?\n如果撒谎能让你更高效更快乐呢？\n\nOr should social media companies curate the content they show you to\n或社交媒体公司 \\N 是否应该精心挑选展示给你的内容\n\nmake you stay on their site longer to make you buy more products?\n让你在网站上多待一会儿，买更多东西？\n\nThey do by the way.\n顺带一说，他们的确有这样做\n\nThese types of ethical considerations aren’t easy to answer, but psychology can at least\n这类道德问题不容易回答，但心理学至少可以\n\nhelp us understand the effects and implications of design choices in our computing systems.\n帮助我们理解不同选择 带来的影响和意义\n\nBut, on the positive side, understanding the psychology behind design\n但从积极的方面来说，了解设计背后的心理学\n\nmight lead to increased accessibility.\n能增加易用性\n\nA greater number of people can understand and use computers\n让更多人可以明白和使用电脑，如今计算机比以往更加直观\n\nnow that they're more intuitive than ever.\n让更多人可以明白和使用电脑，如今计算机比以往更加直观\n\nConference calls and virtual classrooms are becoming more agreeable experiences.\n线上会议和虚拟教室的体验越来越好\n\nAs robot technology continues to improve, the population\n随着机器人技术不断提高，互动也会越来越舒适\n\nwill grow more comfortable in those interactions.\n随着机器人技术不断提高，互动也会越来越舒适\n\nPlus, thanks to psychology, we can all bond over our love of knurling.\n另外，感谢心理学，让我们能分享对\"滚花\"的热爱\n\nI’ll see you next week.\n我们下周见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/39. 教育科技-Educational Technology.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\\N\n\nOne of the most dramatic changes enabled by computing technology\n计算机带来的最大改变之一  \\N 是信息的创造和传播能力\n\nhas been the creation and widespread availability of information.\n计算机带来的最大改变之一  \\N 是信息的创造和传播能力\n\nThere are currently 1.3 billion websites on the internet.\n目前有13亿个网站在互联网上\n\nWikipedia alone has five million English language articles,\n仅维基百科就有500万篇英文文章\n\nspanning everything from the Dancing Plague of 1518\n涵盖从\"1518年的舞蹈瘟疫\"\n\nto proper toilet paper roll orientation.\n到\"正确的纸卷方向\"\n\nEvery day, Google serves up four billion searches to access this information.\n每天，Google提供40亿次搜索来访问这些信息\n\nAnd every minute, 3.5 million videos are viewed on Youtube,\nYoutube上每分钟有350万个视频被观看.\n\nand 400 hours of NEW video get uploaded by users.\n每分钟用户上传400小时的新视频\n\nLots of these views are people watching Gangnam Style and Despacito.\n很多观看量都是 Gangnam Style 和 Despacito\n\nBut another large percentage could be considered educational,\n但剩下的 大部分是教育型内容\n\nlike what you’re doing right now.\n就像你现在看的这个.\n\nThis amazing treasure trove of information can be accessed\n如今只要手机上点几下 就能访问到这些宝藏\n\nwith just a few taps on your smartphone.\n如今只要手机上点几下 就能访问到这些宝藏\n\nAnywhere, anytime.\n任何时间，任何地点\n\nBut, having information available isn’t the same as learning from it.\n但能获取到信息和学习不是一回事\n\nTo be clear, we here at Crash Course we are big fans of interactive in-class learning,\n先说清楚，我们 Crash Course 喜欢互动式课堂学习\n\ndirected conversations, and hands-on experiences as powerful tools for learning.\n课上提问，以及上手实践，它们是很棒的学习途径\n\nBut we also believe in the additive power of educational technology\n但我们也相信教育型技术在课内课外带来的帮助\n\nboth inside and outside the classroom.\n但我们也相信教育型技术在课内课外带来的帮助\n\nSo today we’re going to go a little meta,\n今天我们要在这个教育型视频里 \\N 聊教育型科技\n\nand talk specifically about how computer science\n具体讲解计算机怎么帮助我们学习\n\ncan support learning with educational technology.\n具体讲解计算机怎么帮助我们学习\n\nTechnology, from paper and pencil to recent machine-learning-based intelligent systems,\n从纸和笔 到用机器学习的智能系统，\n\nhas been supporting education for millennia -\n科技几千年来一直在辅助教育\n\neven as early as humans drawing cave paintings\n甚至早期人类 在洞穴里画狩猎场景也是为了后代\n\nto record hunting scenes for posterity.\n甚至早期人类 在洞穴里画狩猎场景也是为了后代\n\nTeaching people at a distance has long been a driver of educational technology.\n远距离教育一直推动着教育科技的发展\n\nFor example, around 50 CE, St. Paul was sending epistles\n例如公元50年左右，圣保罗就发书信 \\N 给亚洲设立的新教堂提供宗教课程\n\nthat offered lessons on religious teachings\n例如公元50年左右，圣保罗就发书信 \\N 给亚洲设立的新教堂提供宗教课程\n\nfor new churches being set up in Asia.\n例如公元50年左右，圣保罗就发书信 \\N 给亚洲设立的新教堂提供宗教课程\n\nSince then, several major waves of technological advances\n从那以后，有几大技术浪潮，自称要改变教育\n\nhave each promised to revolutionize education,\n从那以后，有几大技术浪潮，自称要改变教育\n\nfrom radio and television, to DVDs and laserdiscs.\n从广播和电视，到DVD和光碟\n\nIn fact, as far back as 1913, Thomas Edison predicted,\n事实上，在1913年 托马斯·爱迪生 预测说\n\n\"Books will soon be obsolete in the schools…\n\"书籍很快会过时.. 用影片来教授所有知识是可能的\n\nIt is possible to teach every branch of human knowledge with the motion picture.\n\"书籍很快会过时.. 用影片来教授所有知识是可能的\n\nOur school system will be completely changed in the next ten years.\"\n学校体系将在未来十年彻底改变\"\n\nOf course, you know that didn’t happen.\n当然，他的预测没有成真\n\nBut distributing educational materials in formats like video has become more and more popular.\n但发布教育视频变得越来越流行\n\nBefore we discuss what educational technology research can do for you,\n在讨论教育技术可以帮你做什么之前\n\nthere are some simple things research has shown you can do,\n有研究表明 有些简单事情 \\N 可以显著提高学习效率\n\nwhile watching an educational video like this one,\n有研究表明 有些简单事情 \\N 可以显著提高学习效率\n\nsignificantly increase what you learn and retain.\n有研究表明 有些简单事情 \\N 可以显著提高学习效率\n\nFirst, video is naturally adjustable, so make sure the pacing is right for you,\n1. 把速度调整到适合你，YouTube 的速度设置在右下角\n\nby using the video speed controls.\n1. 把速度调整到适合你，YouTube 的速度设置在右下角\n\nOn YouTube, you can do that in the right hand corner of the screen.\n1. 把速度调整到适合你，YouTube 的速度设置在右下角\n\nYou should be able to understand the video and have enough time to reflect on the content.\n让你能理解视频  有足够的时间思考\n\nSecond, pause!\n2. 暂停！在困难的部分暂停\n\nYou learn more if you stop the video at the difficult parts.\n2. 暂停！在困难的部分暂停\n\nWhen you do, ask yourself questions about what you’ve watched, and see if you can answer.\n问自己一些问题，看能不能回答\n\nOr ask yourself questions about what might be coming up next,\n或想想视频接下来可能讲什么 \\N 然后继续播放，看猜对没有\n\nand then play the video to see if you’re right.\n或想想视频接下来可能讲什么 \\N 然后继续播放，看猜对没有\n\nThird, try any examples or exercises that are presented in the video on your own.\n3. 做视频中的提供的练习\n\nEven if you aren’t a programmer, write pseudocode on paper,\n即使不是程序员，你也可以在纸上写伪代码，或试试学编程\n\nand maybe even give coding a try.\n即使不是程序员，你也可以在纸上写伪代码，或试试学编程\n\nActive learning techniques like these\n这些主动学习的技巧已被证明 \\N 可以把学习效率提升10倍或以上\n\nhave been shown to increase learning by a factor of ten.\n这些主动学习的技巧已被证明 \\N 可以把学习效率提升10倍或以上\n\nAnd if you want more information like this - we’ve got a whole course on it here.\n如果想学学习技巧，有整个系列专门讲这个\n\nThe idea of video as a way to spread quality education\n把高质量教育内容做成视频传播 \\N 在过去一个世纪吸引了很多人\n\nhas appealed to a lot of people over the last century.\n把高质量教育内容做成视频传播 \\N 在过去一个世纪吸引了很多人\n\nWhat’s just the latest incarnation of this idea\n这个老想法的新化身\n\ncame in the form of Massive Open Online Courses, or MOOCs.\n以\"大型开放式在线课程\"（MOOC）的形式出现\n\nIn fact, the New York Times declared 2012 the Year of the MOOC!\n纽约时报宣称 2012 年是 MOOC 年！\n\nA lot of the early forms were just videos of lectures from famous professors.\n很多早期视频 直接录制著名教授上课\n\nBut for a while, some people thought this might mean the end of universities as we know them.\n有段时间，有些人以为大学要终结了\n\nWhether you were worried about this idea or excited by it,\n不管你是担心还是开心，这暂时还没成为现实\n\nthat future also hasn’t really come to pass\n不管你是担心还是开心，这暂时还没成为现实\n\nand most of the hype has dissipated.\n现在热度也淡去了\n\nThis is probably mostly because when you try to scale up learning\n这可能是因为加大规模时 同时教百万名学生\n\nusing technology to include millions of students simultaneously\n这可能是因为加大规模时 同时教百万名学生\n\nwith small numbers of instructional staff - or even none\n但老师数量很少，甚至完全没有老师\n\n- you run into a lot of problems.\n- 会遇到很多问题\n\nFortunately, these problems have intrigued computer scientists and more specifically,\n幸运的是，这引起了计算机科学家，\\N 或具体一点 \"教育科技家\"的兴趣\n\neducational technologists, who are finding ways to solve them.\n他们在想办法解决这些问题\n\nFor example, effective learning involves getting timely and relevant feedback\n比如，为了有效学习，学生要及时获得反馈\n\nbut how do you give good feedback\n但如果有几百万学生，只有一名老师，\n\nwhen you have millions of learners and only one teacher?\n怎么提供好的反馈？\n\nFor that matter, how does a teacher grade a million assignments?\n一个老师怎么给一百万份作业打成绩？\n\nSolving many of these problems means creating hybrid, human-technology systems.\n为了解决问题，很多时候需要把科技和人类都用上\n\nA useful, but controversial insight,\n一种有用 但有些争议的做法是\n\nwas that students could be a great resource to give each other feedback.\n学生互相之间提供反馈\n\nUnfortunately, they’re often pretty bad at doing so –\n不幸的是，学生一般做不好\n\nthey’re neither experts in the subject matter, nor teachers.\n他们既不是专家也不是老师\n\nHowever, we can support their efforts with technology.\n但我们可以用技术来帮助他们\n\nLike, by using algorithms, we can match perfect learning partners together,\n比如通过算法，从数百万个选择里 \\N 匹配出最完美的学习伙伴\n\nout of potentially millions of groupings.\n比如通过算法，从数百万个选择里 \\N 匹配出最完美的学习伙伴\n\nAlso, parts of the grading can be done with automated systems while humans do the rest.\n另外，有些部分可以机器打分，剩下的让人类打分\n\nFor instance, computer algorithms that grade the\n例如，给 SAT 写作部分打分的电脑算法\n\nwriting portions of the SATs have been found to be\n已被证实和人工打分一样准确\n\njust as accurate  as humans hired to grade them by hand.\n已被证实和人工打分一样准确\n\nOther algorithms are being developed that provide personalized learning experiences,\n还有些算法提供个性化学习体验\n\nmuch like Netflix’s personalized movie recommendations or Google’s personalized search results.\n类似于 Netflix 的电影推荐 \\N 或 Google 的个性化搜索结果\n\nTo achieve this, the software needs to understand what a learner knows and doesn’t know.\n为了个性化推荐，\\N 软件需要了解用户知道什么，不知道什么\n\nWith that understanding, the software can present the right material, at the right time,\n在正确的时间提供正确的资料，\n\nto give each particular learner practice on the things that are hardest for them,\n让用户练习没理解的难的部分\n\nrather than what they’re already good at.\n而不是给出用户已经学会的内容\n\nSuch systems – most often powered by Artificial Intelligence –\n这种系统一般用 AI 实现\n\nare broadly called Intelligent Tutoring Systems.\n泛称叫法是\"智能辅导系统\"\n\nLet’s break down a hypothetical system that follows common conventions.\n我们现在讲一个假想的辅导系统\n\nSo, imagine a student is working on this algebra problem in our hypothetical tutoring software.\n假设学生在这个假想的辅导系统中，研究一个代数问题\n\nThe correct next step to solve it, is to subtract both sides by 7.\n正确的下一步是两边-7\n\nThe knowledge required to do this step can be represented by something called a production rule.\n我们可以用 \"判断规则\" 来表示这一步\n\nThese describe procedures as IF-THEN statements.\n用 IF-THEN 语句来描述\n\nThe pseudo code of a production rule for this step would say\n伪代码是\n\nIF there is a constant on the same side as the variable,\n*如果* 变量和常数在同一边\n\nTHEN subtract that constant from both sides.\n*那么* 两侧都减去这个常数\n\nThe cool thing about production rules is that they can also be used\n\"判断规则\" 酷的地方是也可以用来\n\nto represent common mistakes a student might make.\n代表学生的常犯错误\n\nThese production rules are called \"buggy rules\".\n这些\"判断规则\"叫\"错误规则\"\n\nFor example, instead of subtracting the constant,\n例如，学生可能不去减常数\n\nthe student might mistakenly try to subtract the coefficient.\n而是去减系数\n\nNo can do!\n这不行！\n\nIt’s totally possible that multiple competing production rules\n学生做完一个步骤后可能触发多个\"判断规则\"\n\nare triggered after a student completes a step –\n学生做完一个步骤后可能触发多个\"判断规则\"\n\nit may not be entirely clear what misconception has led to a student’s answer.\n系统不能完全弄清 是什么原因让学生选了那个答案\n\nSo, production rules are combined with an algorithm that selects the most likely one.\n所以\"判断规则\"会和算法结合使用，判断可能原因\n\nThat way, the student can be given a helpful piece of feedback.\n让学生得到有用反馈\n\nThese production rules, and the selection algorithm,\n\"判断规则\"+选择算法，组合在一起成为 \"域模型\"\n\ncombine to form what’s called a Domain Model,\n\"判断规则\"+选择算法，组合在一起成为 \"域模型\"\n\nwhich is a formal representation of the knowledge,\n它给知识，解决步骤和一门学科 比如代数，\\N 用一种\"正式写法\"来表示\n\nprocedures and skills of a particular discipline - like algebra.\n它给知识，解决步骤和一门学科 比如代数，\\N 用一种\"正式写法\"来表示\n\nDomain models can be used to assist learners on any individual problem,\n域模型可以用来 帮助学习者解决特定问题\n\nbut they’re insufficient for helping learners move through a whole curriculum\n但它无法带着学习者 \\N 以正确顺序搞定整个学科该上的所有课程\n\nbecause they don’t track any progress over time.\n因为域模型不记录进度\n\nFor that, intelligent tutoring systems build and maintain a student model\n因此智能辅导系统 负责创建和维护学生模型\n\n– one that tracks, among other things, what production rules a student has mastered,\n- 记录学生已经掌握的判断规则\n\nand where they still need practice.\n以及还需练习的生疏部分\n\nThis is exactly what we need to properly personalize the tutor.\n这正是个性化辅导系统需要的。\n\nThat doesn’t sound so hard,\n听起来好像不难，\n\nbut it’s actually a big challenge to figure out what a student knows and doesn’t know\n但只靠学生对一些问题的回答，\\N 来弄清学生知道什么，不知道什么，是很大的挑战\n\nbased only on their answers to problems.\n但只靠学生对一些问题的回答，\\N 来弄清学生知道什么，不知道什么，是很大的挑战\n\nA common technique for figuring this out is Bayesian knowledge tracing.\n\"贝叶斯知识追踪\" 常用来解决这个问题\n\nThe algorithm treats student knowledge as a set of latent variables,\n这个算法把学生的知识 当成一组隐藏变量\n\nwhich are variables whose true value is hidden from\n这些变量的值，对外部是不可见的\n\nan outside observer, like our software.\n比如我们的软件\n\nThis is also true in the physical world,\n这在现实中也是一样的\n\nwhere a teacher would not know for certain whether\n老师无法知道 学生是否完全掌握了某个知识点\n\na student knows something completely.\n老师无法知道 学生是否完全掌握了某个知识点\n\nInstead, they might probe that knowledge using a test\n老师会出考题，测试学生能否答对\n\nto see if the student gets the right answer.\n老师会出考题，测试学生能否答对\n\nSimilarly, Bayesian knowledge tracing updates its estimate of the students’ knowledge\n同样，\"贝叶斯知识追踪\" \\N 会看学生答题的正确度，更新学生掌握程度的估算值\n\nby observing the correctness of each interaction using that skill.\n同样，\"贝叶斯知识追踪\" \\N 会看学生答题的正确度，更新学生掌握程度的估算值\n\nTo do this, the software maintains four probabilities..\n它会记录四个概率\n\nFirst is the probability that a student has learned how to do a particular skill.\n首先是 \"学生已经学会的概率\"\n\nFor example, the skill of subtracting constants from both sides of an algebraic equation.\n比如从代数方程的两边减去常数\n\nLet’s say our student correctly subtracts both sides by 7.\n假设学生正确将两边-7\n\nBecause she got the problem correct,\n做对了\n\nwe might assume she knows how to do this step.\n我们可以假设她知道怎么做\n\nBut there’s also the possibility that the student got it correct by accident,\n但也有可能她是瞎蒙的\n\nand doesn’t actually understand how to solve the problem.\n没有真的学会怎么解决问题\n\nThis is the probability of guess.\n这叫 \"瞎猜的概率\"\n\nSimilarly, if the student gets it wrong,\n类似的，如果学生答错了，\n\nyou might assume that she doesn’t know how to do the step.\n你可能会假设她不会做\n\nBut, there’s also the possibility that she knows it,\n但她可能知道答案，只是不小心犯了个错\n\nbut made a careless error or other slip-up.\n但她可能知道答案，只是不小心犯了个错\n\nThis is called the probability of slip.\n这叫 \"失误的概率\"\n\nThe last probability that Bayesian knowledge tracing calculates\n最后一个概率\n\nis the probability that the student started off the problem\n是学生一开始不会做，\\N 但是在解决问题的过程中，学会了怎么做\n\nnot knowing how to do the step, but learned how to do\n是学生一开始不会做，\\N 但是在解决问题的过程中，学会了怎么做\n\nit as a result of working through the problem.\n是学生一开始不会做，\\N 但是在解决问题的过程中，学会了怎么做\n\nThis is called the probability of transit.\n这叫 \"做题过程中学会的概率\"\n\nThese four probabilities are used in a set of equations that update the student model,\n有一组方程，会用这四个概率，更新学生模型\n\nkeeping a running assessment for each skill the student is supposed to know.\n对学生应该学会的每项技能进行持续评估\n\nThe first equation asks:\n第一个等式问：\n\nwhat’s the probability that the student has learned a particular skill\n学生已经知道某技能的概率是多少？\n\nwhich takes into account the probability that it was\n等式里有\n\nalready learned previously and the probability of transit.\n\"之前已经学会的概率\"和\"做题过程中学会的概率\"\n\nLike a teacher, our estimate of this probability that it was already learned previously\n就像老师一样，\"之前已经学会的概率\"\n\ndepends on whether we observe a student getting a question correct or incorrect,\n取决于学生回答问题正确与否，\n\nand so we have these two equations to pick from.\n回答正确和错误分别有2个公式\n\nAfter we compute the right value, we plug it into our first equation,\n算出结果之后，我们把结果放到第一个方程\n\nupdating the probability that a student has learned a particular skill,\n更新\"之前已经学会的概率\"\n\nwhich then gets stored in their student model.\n然后存到学生模型里.\n\nAlthough there are other approaches,\n虽然存在其他方法，\n\nintelligent tutoring systems often use Bayesian knowledge tracing\n但\"智能辅导系统\"通常用 贝叶斯知识追踪\n\nto support what’s called mastery learning, where students practice skills,\n让学生练习技能，直到掌握\n\nuntil they’re deeply understood.\n让学生练习技能，直到掌握\n\nTo do this most efficiently, the software selects the\n为了高效做到这点，软件要选择合适的问题\n\nbest problems to present to the student to achieve mastery,\n呈现给学生，让学生学\n\nwhat’s called adaptive sequencing,\n这叫：自适应式程序\n\nwhich is one form of personalization.\n个性化算法的形式之一\n\nBut, our example is still just dealing with data from one student.\n但我们的例子只是一个学生的数据\n\nInternet-connected educational apps or sites\n现在有 App 或网站\n\nnow allow teachers and researchers the ability\n让教师和研究人员 收集上百万学习者的数据\n\nto collect data from millions of learners.\n让教师和研究人员 收集上百万学习者的数据\n\nFrom that data, we can discover things like common pitfalls and where students get frustrated.\n从数据中可以发现常见错误\\N 一般哪里难倒学生\n\nBeyond student responses to questions,\n除了学生的回答，还可以看回答前暂停了多久\n\nthis can be done by looking at how long they pause\n除了学生的回答，还可以看回答前暂停了多久\n\nbefore entering an answer, where they speed up a video,\n哪个部分加速视频，\n\nand how they interact with other students on discussion forums.\n以及学生如何在论坛和其他人互动\n\nThis field is called Educational Data Mining,\n这个领域叫 \"教育数据挖掘\"\n\nand it has the ability to use all those face palms and \"ah ha\" moments\n它能用上学生所有的\"捂脸\"和\"啊哈\"时刻\n\nto help improve personalized learning in the future.\n帮助改善未来的个性化学习\n\nSpeaking of the future, educational technologists have often\n谈到未来，教育技术人员经常从科幻小说中获得灵感\n\ndrawn inspiration for their innovations from science fiction.\n谈到未来，教育技术人员经常从科幻小说中获得灵感\n\nIn particular, many researchers were inspired by the future envisioned in the book\n具体来说，Neal Stephenson 的\"钻石时代\"这本书\\N 激励了很多研究人员\n\n\"The Diamond Age\" by Neal Stephenson.\n具体来说，Neal Stephenson 的\"钻石时代\"这本书\\N 激励了很多研究人员\n\nIt describes a young girl who learns from a book\n里面说一个年轻女孩从书中学习\n\nthat has a set of virtual agents who interact with her\n书中有一些虚拟助手会和她互动，教她知识\n\nin natural language acting as coaches, teachers,\n书中有一些虚拟助手会和她互动，教她知识\n\nand mentors who grow and change with her as she grows up.\n这些助手和她一起成长\n\nThey can detect what she knows and how’s she’s feeling,\n直到她学会了什么，以及感觉如何，\n\nand give just the right feedback and support to help her learn.\n给她正确的反馈和支持，帮助她学习\n\nToday, there are non-science-fiction researchers, such as Justine Cassell,\n如今 有非科幻小说研究者，比如 贾斯汀卡塞尔，\n\ncrafting pedagogical virtual agents\n在制作虚拟教学助手\n\nthat can \"exhibit the verbal and bodily behaviors found in\n助手可以\"像人类一样沟通 有人类一样的行为\n\nconversation among humans, and in doing so, build trust,\n在陪伴过程中和学习者建立信任，\n\nrapport and even friendship with their human students.\"\n相处融洽，甚至和人类学生成为朋友\"\n\nMaybe Crash Course in 2040 will have a little John Green A.I. that lives on your iPhone 30.\n2040年的\"速成课\" \\N 可能会有一个 John Green AI，活在你的 iPhone 30 上\n\nEducational technology and devices are now moving off of laptop and desktop computers,\n教育科技和设备 \\N如今在逐渐扩展到笔记本和台式电脑之外\n\nonto huge tabletop surfaces, where students can collaborate in groups,\n比如巨大桌面设备，让学生可以团队合作\n\nand also tiny mobile devices, where students can learn on the go.\n以及小型移动设备，让学生路上也能学习\n\nVirtual reality and augmented reality are also getting people excited\n\"虚拟现实\"和\"增强现实\"也让人们兴奋不已\n\nand enabling new educational experiences for learners –\n它们可以为学习者提供全新的体验 -\n\ndiving deep under the oceans, exploring outer space,\n深潜海洋，探索太空，\n\ntraveling through the human body, or interacting with cultures\n漫游人体，或是和现实中难以遇见的生物互动\n\nthey might never encounter in their real lives.\n漫游人体，或是和现实中难以遇见的生物互动\n\nIf we look far into the future, educational interfaces might disappear entirely,\n如果猜想遥远的未来，教育可能会完全消失，\n\nand instead happen through direct brain learning,\n直接在大脑层面进行\n\nwhere people can be uploaded with new skills, directly into their brains.\n把新技能直接下载到大脑\n\nThis might seem really far fetched,\n这看起来可能很遥远，\n\nbut scientists are making inroads already - such as detecting\n但科学家们已经在摸索 - 比如\n\nwhether someone knows something just from their brain signals.\n仅仅通过检测大脑信号，得知某人是否知道什么\n\nThat leads to an interesting question:\n这带来了一个有趣的问题：\n\nif we can download things INTO our brains,\n如果我们可以把东西下载到大脑里\n\ncould we also upload the contents of our brains?\n我们能不能上传大脑里的东西？\n\nWe’ll explore that in our series finale next week about the far future of computing.\n下周的最后一集，我们会讨论计算的未来\n\nI'll see you then.\n到时见\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本/40. 奇点,天网,计算机的未来-The Singularity, Skynet, and the Future of Computing.ass.txt",
    "content": "Hi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nWe’re here: the final episode!\n我们到了 最后一集！\n\nIf you’ve watched the whole series,\n如果你看了整个系列，\n\nhopefully you’ve developed a newfound appreciation\n希望你对计算机影响的深度和广度 \\N 有全新的认知和欣赏\n\nfor the incredible breadth of computing applications and topics.\n希望你对计算机影响的深度和广度 \\N 有全新的认知和欣赏\n\nIt’s hard to believe we’ve worked up from mere transistors and logic gates,\n难以相信 我们从简单的晶体管和逻辑门开始\n\nall the way to computer vision, machine learning, robotics and beyond.\n一直到计算机视觉，机器学习，机器人以及更多\n\nWe’ve stood on the shoulders of giants\n我们站在巨人的肩膀上\n\nlike Babbage and Lovelace, Hollerith and Turing,\nCharles Babbage \\N Ada Lovelac \\N Herman Hollerith \\N Alan Turing\n\nEckert and Hopper, Sutherland and Engelbart,\nJ. Presper Eckert \\N Grace Hopper \\N  Ivan Sutherland \\N Douglas Engelbart\n\nBush and Berners Lee, Gates and the Woz,\nVannevar Bush (Memex) \\N  Berners-Lee  (万维网) \\N Bill Gates (微软)\\N Steve Wozniak (苹果)\n\nand many other computing pioneers.\n和许多其他先驱\n\nMy biggest hope is that these episodes have inspired you to\n我最大的希望是 这些视频能激励你 \\N 去了解这些东西如何影响你的人生\n\nlearn more about how these subjects affect your life.\n我最大的希望是 这些视频能激励你 \\N 去了解这些东西如何影响你的人生\n\nMaybe you’ll even pick up programming or choose a career in computing.\n甚至开始学编程，或找一份计算机职业\n\nIt’s awesome!\n这很棒！\n\nIt’s also a skill of the future.\n这是未来的技能\n\nI said in the very first episode that computer science isn’t magic, but it sort of is!\n我在第一集说过，计算机科学不是魔法\\N 但它有点像魔法\n\nKnowing how to use and program computers is sorcery of the 21st century.\n学习使用电脑和编程，是21世纪的巫术\n\nInstead of incantations and spells, it’s scripts and code.\n只不过用的不是咒语 而是代码\n\nThose who know how to wield that tremendous power will be able to craft great things,\n懂得运用的人，能创造出伟大的东西\n\nnot just to improve their own lives, but also their communities and humanity at large.\n不仅改善自己的生活，还有当地社区乃至整体人类\n\nComputing is also going to be literally everywhere –\n计算机会随处可见 -\n\nnot just the computers we see today, sitting on desks and countertops,\n不仅是放在桌上 带在包里\n\nand carried in pockets and bags – but inside every object imaginable.\n而是在所有可想象的东西里\n\nInside all your kitchen appliances, embedded in your walls, nanotagged in your food,\n厨房用具里，墙里，食物里\n\nwoven into your clothes, and floating around inside your body.\n编织进衣服里，在你的血液里\n\nThis is the vision of the field of Ubiquitous Computing.\n这是\"普适计算\"的愿景\n\nIn some ways, it’s already here, and in other ways, we’ve got many decades to go.\n从某种角度来讲 它已经来临了\\N 而换一个角度  还要几十年\n\nSome might view this eventuality as dystopian,\n有些人把这种未来看成 反乌托邦\n\nwith computers everywhere surveilling us and competing for our attention.\n到处都有监视器，有无数东西想吸引我们的注意力\n\nBut the late Mark Weiser, who articulated this idea in the 1990s,\n但 1990 年代提出这个想法的 马克·维泽尔\n\nsaw the potential very differently:\n看到了非常不同的潜力：\n\n\"For [fifty] years, most interface design, and most computer design,\n\"[五十]年来，大多数界面和计算机设计，\n\nhas been headed down the path of the \"dramatic\" machine.\n都是朝\"戏剧性\"方向前进\n\nIts highest idea is to make a computer so exciting, so wonderful,\n想把计算机做得超好，让人一刻也不想离开\n\nso interesting, that we never want to be without it.\n想把计算机做得超好，让人一刻也不想离开\n\nA less-traveled path I call the \"invisible\";\n另一条少有人走的路 是\"无形\"的\n\nits highest idea is to make a computer so imbedded, so fitting,\n把计算机整合到所有东西里 \\N 用的时候很自然 完全注意不到\n\nso natural, that we use it without even thinking about it …\n把计算机整合到所有东西里 \\N 用的时候很自然 完全注意不到\n\nThe most profound technologies are those that disappear.\n最厉害的科技是看不见的科技\n\nThey weave themselves into the fabric of everyday life\n它们融入到日常生活的每一部分 直到无法区分\"\n\nuntil they are indistinguishable from it.\"\n它们融入到日常生活的每一部分 直到无法区分\"\n\nThat doesn’t describe computing of today\n如今我们还没达到这样\n\n– where people sit for hours upon end in front of computer monitors,\n- 人们在电脑前连续坐好几小时\n\nand social media notifications interrupt us at dinner.\n吃晚餐被手机推送通知打扰\n\nBut, it could describe computing of the future, our final topic.\n但它可以描述计算的未来 \\N  本系列最后一个主题\n\nWhen people think of computing in the future,\n人们思考计算机的未来时 经常会直接想到人工智能\n\nthey often jump right to Artificial Intelligence.\n人们思考计算机的未来时 经常会直接想到人工智能\n\nNo doubt there will be tremendous strides made in AI in the coming years,\n毫无疑问，接下来几十年人工智能会有巨大进步\n\nbut not everything will be, or need to be, AI-powered.\n但不是所有东西都要做成 AI ，或需要 AI\n\nYour car might have an AI to self-drive, but the door locks\n车有自动驾驶AI，但门锁依然会很简单\n\nmight continue to be powered by what are essentially if-statements.\n车有自动驾驶AI，但门锁依然会很简单\n\nAI technology is just as likely to enhance existing devices,\n人工智能可能只是增强现有设备\n\nlike cars, as it is to open up entirely new product categories.\n比如汽车，AI 带来了一个全新的产品种类\n\nThe exact same thing happened with the advent of electrical power – lightbulbs replaced candles.\n刚出现电力时也是这样，灯泡取代了蜡烛.\n\nBut electrification also led to the creation of hundreds of new electrically-powered gadgets.\n但电气化也导致上百种新的电动小工具诞生\n\nAnd of course, we still have candles today.\n当然 我们如今仍然有蜡烛\n\nIt’s most likely that AI will be yet another tool\n最可能的情况是 AI 变成 \\N 计算机科学家手中的另一门新工具\n\nthat computer scientists can draw upon to tackle problems.\n最可能的情况是 AI 变成 \\N 计算机科学家手中的另一门新工具\n\nWhat really gets people thinking, and sometimes sweating,\n但真正让人深思和担忧的是\n\nis whether Artificial Intelligence will surpass human intelligence.\n人工智能是否会超越人类智能？\n\nThis is a really tricky question for a multitude of reasons,\n这个问题很难 有多方面原因\n\nincluding most immediately: \"what is intelligence?\"\n比如 \"智能的准确定义是什么？\"\n\nOn one hand, we have computers that can drive cars,\n一方面，有会开车的计算机\n\nrecognize songs with only a few seconds of audio,\n几秒就能识别歌的 App\n\ntranslate dozens of languages, and totally dominate at games like chess, Jeopardy, and Go.\n翻译几十种语言，\\N 还称霸了一些游戏，比如象棋，知识竞答和围棋\n\nThat sounds pretty smart!\n听起来很聪明！\n\nBut on the other hand, computers fail at some basic tasks,\n但另一方面，计算机连一些简单事情都做不了\n\nlike walking up steps, folding laundry,\n比如走楼梯，叠衣服，\n\nunderstanding speech at a cocktail party, and feeding themselves.\n在鸡尾酒派对和人聊天，喂饱自己\n\nWe’re a long way from Artificial Intelligence that’s as general purpose and capable as a human.\n人工智能成长到和人类一样通用，还有很长的路\n\nWith intelligence being somewhat hard to quantify,\n因为\"智能\"是难以量化的指标\n\npeople prefer to characterize computers and creatures\n人们更喜欢用处理能力来区分\n\nby their processing power instead,\n人们更喜欢用处理能力来区分\n\nbut that’s a pretty computing-centric view of intelligence.\n但这种衡量智能的方法比较\"以计算为中心\"\n\nNonetheless, if we do this exercise,\n但如果把视频中出现过的电脑和处理器 画张图\n\nplotting computers and processors we’ve talked about in this series,\n但如果把视频中出现过的电脑和处理器 画张图\n\nwe find that computing today has very roughly equivalence in calculating\n可以看到 如今的计算能力粗略等同于一只老鼠\n\npower to that of a mouse...\n可以看到 如今的计算能力粗略等同于一只老鼠\n\nwhich, to be fair, also can’t fold laundry, although that would be super cute!\n公平点说，老鼠也不会叠衣服\\N 但如果真的会叠 就太可爱了\n\nHuman calculating power is up here, another 10 to the 5,\n人类的计算能力在这儿，多10的5次方\n\nor 100,000 times more powerful than computers today.\n也就是比如今电脑强10万倍\n\nThat sounds like a big gap, but with the rate of change in computing technologies,\n听起来差距很大，但按如今的发展速度，\n\nwe might meet that point in as early as a decade,\n也许十几年就可以赶上了\n\neven though processor speeds are no longer following Moore’s Law,\n虽然现在处理器的速度 不再按摩尔定律增长了\n\nlike we discussed in Episode 17.\n我们在第17集讨论过\n\nIf this trend continues, computers would have more processing power/intelligence,\n假设趋势继续保持下去，在本世纪结束前\n\nthan the sum total of all human brains combined before the end of this century.\n计算机的处理能力/智能 会比全人类加起来还多\n\nAnd this could snowball as such systems need less human input,\n然后人的参与会越来越少，人工超级智能会开始改造自己\n\nwith an artificial superintelligence designing and training new versions of itself.\n然后人的参与会越来越少，人工超级智能会开始改造自己\n\nThis runaway technological growth, especially with respect to an intelligence explosion,\n智能科技的失控性发展叫 \"奇点\"\n\nis called the singularity.\n智能科技的失控性发展叫 \"奇点\"\n\nThe term was first used by our old friend from Episode 10,\n第10集 约翰·冯·诺伊曼 最早用这个词\n\nJohn von Neumann, who said:\n他说：\n\n\"The accelerating progress of technology and changes in the mode of human life,\n\"越来越快的技术发展速度和人类生活方式的改变，\n\ngive the appearance of approaching some essential singularity\n看起来会接近人类历史中某些重要的奇点\n\nin the history of the race beyond which human affairs,\n看起来会接近人类历史中某些重要的奇点\n\nas we know them, could not continue.\"\n这个势头不会永远继续下去\"\n\nAnd Von Neumann suggested this back in the 1950s,\n冯诺依曼在 1950 年代说的这话.\n\nwhen computers were trillions of times slower than they are today.\n那时计算机比现在慢得多\n\nSixty years later, though, the singularity is\n六十年后的今天，奇点仍然在遥远的地平线上\n\nstill just a possibility on the horizon.\n六十年后的今天，奇点仍然在遥远的地平线上\n\nSome experts believe this progress is going to level off,\n一些专家认为 发展趋势会更平缓一些\n\nand be more of an S curve than an exponential one,\n更像是S型，而不是指数型\n\nwhere as complexity increases, it becomes more difficult to make additional progress.\n而随着复杂度增加，进步会越来越难\n\nMicrosoft co-founder Paul Allen calls it a \"complexity brake\".\n微软联合创始人 保罗·艾伦 叫这个\"复杂度刹车\"\n\nBut, as a thought experiment,\n但当作思维练习\n\nlet’s just say that superintelligent computers will emerge.\n我们假设 超智能计算机会出现。\n\nWhat that would mean for humanity is a hotly debated topic.\n这对人类意味着什么，是个讨论激烈的话题\n\nThere are people who eagerly await it,\n有些人迫不及待\n\nand those who are already working to stop it from happening.\n有些人则努力阻止它\n\nProbably the most immediate effect would be technological unemployment,\n最直接的影响可能是\"技术性失业\"\n\nwhere workers in many job sectors are rendered obsolete\n很多工作被计算机，比如AI和机器人，给代替掉了\n\nby computers – like AIs and Robots –\n很多工作被计算机，比如AI和机器人，给代替掉了\n\nthat can do their work better and for less pay.\n它们的效率更高，成本更低\n\nAlthough computers are new, this effect is not.\n虽然计算机出现没多久，但\"技术性失业\"不是新事\n\nRemember Jacquard's Loom from Episode 10?\n还记得第10集里 雅卡尔的织布机 吗？\n\nThat automated the task of skilled textile workers back in the 1800s, which led to riots.\n它让1800年代的纺织工人失业，导致了骚乱\n\nAlso, back then, most of the population of the US and Europe were farmers.\n当时美国和欧洲 大部分人都是农民\n\nThat’s dropped to under 5% today,\n如今农民占人口比例<5％\n\ndue to advances like synthetic fertilizers and tractors.\n因为有合成肥料和拖拉机等等技术\n\nMore modern examples include telephone switchboard operators\n时间更近一些的例子是\"电话接线员\"\n\nbeing replaced with automatic switchboards in 1960,\n在1960年被自动接线板代替了\n\nand robotic arms replacing human painters in car factories in the 1980s.\n还有1980年代的\"机器喷漆臂\"替代了人工喷漆\n\nAnd the list goes on and on.\n这样的例子还有很多.\n\nOn one hand, these were jobs lost to automation.\n一方面，因为自动化失去了工作\n\nAnd on the other hand, clothes, food, bicycles, toys,\n另一方面，我们有大量产品，\\N 衣服，食物，自行车，玩具等\n\nand a myriad of other products are all plentiful today\n另一方面，我们有大量产品，\\N 衣服，食物，自行车，玩具等\n\nbecause they can be cheaply produced thanks to computing.\n因为可以廉价生产\n\nBut, experts argue that AI, robots and computing technologies in general,\n但专家认为人工智能，机器人 以及更广义的计算\n\nare going to be even more disruptive than these historical examples.\n比之前更有破坏性\n\nJobs, at a very high level, can be summarized along two dimensions.\n工作可以用两个维度概括\n\nFirst, jobs can be either more manual – like assembling toys\n首先，手工型工作，比如组装玩具\n\n– or more cognitive – like picking stocks.\n- 或思维型工作 - 比如选股票\n\nThese jobs can also be routine – the same tasks over and over again\n还有重复性工作，一遍遍做相同的事\n\nor non-routine, where tasks vary and workers need to problem solve and be creative.\n或非重复性，需要创造性的解决问题\n\nWe already know that routine-manual jobs can be automated by machines.\n我们知道 重复性手工工作，可以让机器自动化\n\nIt has already happened for some jobs and is happening right now for others.\n现在有些已经替代了，剩下的在逐渐替代\n\nWhat’s getting people worried is that non-routine manual jobs,\n让人担心的是\"非重复性手工型工作\"\n\nlike cooks, waiters and security guards, may get automated too.\n比如厨师，服务员，保安。\n\nAnd the same goes for routine cognitive work,\n思维型工作也一样\n\nlike customer service agents, cashiers, bank tellers, and office assistants.\n比如客服，收银员，银行柜员和办公室助理\n\nThat leaves us with just one quadrant that might be safe,\n剩下一个暂时比较安全的象限\n\nat least for a little while:\n剩下一个暂时比较安全的象限\n\nnon-routine cognitive work,\n非重复性思维型工作\n\nwhich includes professions like teachers and artists,\n包括教师和艺术家，\n\nnovelists and lawyers, and doctors and scientists.\n小说家和律师，医生和科学家\n\nThese types of jobs encompass roughly 40% of the US workforce.\n这类工作占美国劳动力大概40％\n\nThat leaves 60% of jobs vulnerable to automation.\n意味着剩下60％工作容易受自动化影响\n\nPeople argue that technological unemployment at this scale\n有人认为这种规模的技术失业\n\nwould be unprecedented and catastrophic,\n是前所未有的，会导致灾难性的后果，\n\nwith most people losing their jobs.\n大部分人会失业\n\nOthers argue that this will be great,\n其他人则认为很好，\n\nfreeing people from less interesting jobs to pursue better ones,\n让人们从无聊工作解脱，去做更好的工作，\n\nall while enjoying a higher standard of living with the bounty of food and products\n同时享受更高生活水平，有更多食物和物品\n\nthat will result from computers and robots doing most of the hard work.\n都是计算机和机器人生产的.\n\nNo one really knows how this is going to shake out,\n没人知道未来到底会怎样\n\nbut if history is any guide, it’ll probably be ok in the long run.\n但如果历史有指导意义，长远看 一切会归于平静\n\nAfterall, no one is advocating that 90% of people\n毕竟，现在没人嚷嚷着让90％的人 回归耕田和纺织\n\ngo back to farming and weaving textiles by hand.\n毕竟，现在没人嚷嚷着让90％的人 回归耕田和纺织\n\nThe tough question, which politicians are now discussing,\n政界在讨论的棘手问题是\n\nis how to handle hopefully-short-term economic disruption,\n怎么处理数百万人突然失业 \\N 造成的短期经济混乱\n\nfor millions of people that might be suddenly out of a job.\n怎么处理数百万人突然失业 \\N 造成的短期经济混乱\n\nBeyond the workplace, computers are also very likely to change our bodies.\n除了工作，计算机很可能会改变我们的身体\n\nFor example, futurist Ray Kurzweil believes that\n举个例子, 未来学家 Ray Kurzweil 认为\n\n\"The Singularity will allow us to transcend\n\"奇点会让我们超越 肉体和大脑的局限性\n\n[the] limitations of our biological bodies and brains.\n\"奇点会让我们超越 肉体和大脑的局限性\n\nWe will gain power over our fates.\n我们能掌控自己的命运\n\n... We will be able to live as long as we want.\n可以想活多久活多久  我们能完全理解并扩展大脑思维\n\nWe will fully understand human thinking and will vastly extend and expand its reach.\"\n可以想活多久活多久  我们能完全理解并扩展大脑思维\n\nTranshumanists see this happening in the form of cyborgs,\n超人类主义者认为会出现\"改造人\"\n\nwhere humans and technology merge, enhancing our intellect and physiology.\n人类和科技融合在一起，增强智力和身体\n\nThere are already brain computer interfaces in use today.\n如今已经有脑电接口了\n\nAnd wearable computers, like Google Glass and Microsoft Hololens,\n而 Google Glass 和 微软 Hololens \\N 这样的穿戴式计算机 也在模糊这条界线\n\nare starting to blur the line too.\n而 Google Glass 和 微软 Hololens \\N 这样的穿戴式计算机 也在模糊这条界线\n\nThere are also people who foresee \"Digital Ascension\",\n也有人预见到\"数字永生\"\n\nwhich, in the words of Jaron Lanier,\nJaron Lanier 的说法是\n\n\"would involve people dying in the flesh and being uploaded into a computer and remaining conscious\".\n\"人类的肉体死去，意识上传到计算机\"\n\nThis transition from biological to digital beings\n从生物体变成数字体 可能是下一次进化跨越\n\nmight end up being our next evolutionary step...\n从生物体变成数字体 可能是下一次进化跨越\n\nand a new level of abstraction.\n一层新的抽象\n\nOthers predict humans staying largely human,\n其他人则预测  人类大体会保持原样\n\nbut with superintelligent computers as a benevolent force,\n但超智能电脑会照顾我们，帮我们管农场\n\nemerging as a caretaker for humanity – running all the farms,\n但超智能电脑会照顾我们，帮我们管农场\n\ncuring diseases, directing robots to pick-up trash,\n治病，指挥机器人收垃圾，\n\nbuilding new homes and many other functions.\n建房子 以及很多其他事情\n\nThis would allow us to simply enjoy our time on this lovely pale blue dot.\n让我们在这个可爱蓝点上(地球) 好好享受\n\nStill others view AI with more suspicion –\n另一些人对 AI 持怀疑态度 -\n\nwhy would a superintelligent AI waste its time taking care of us?\n为什么超级人工智能 会费时间照顾我们？\n\nIt’s not like we’ve taken on the role of being the benevolent caretaker of ants.\n人类不也没照顾蚂蚁吗？\n\nSo maybe this play out like so many Sci-Fi movies\n也许会像许多科幻电影一样，和计算机开战\n\nwhere we’re at war with computers, our own creation having turned on us.\n也许会像许多科幻电影一样，和计算机开战\n\nIt’s impossible to know what the future holds,\n我们无法知道未来到底会怎样\n\nbut it’s great that this discussion and debate is already happening,\n但现在已经有相关讨论了，这非常好\n\nso as these technologies emerge, we can plan and react intelligently.\n所以等这些技术出现后，我们可以更好地计划\n\nWhat’s much more likely, regardless of whether you see computers as future friend or foe,\n不论你把计算机视为未来的朋友或敌人\n\nis that they will outlive humanity.\n更有可能的是，它们的存在时间会超过人类\n\nMany futurists and science fiction writers have speculated\n许多未来学家和科幻作家猜测\n\nthat computers will head out into space and colonize the galaxy,\n机器人会去太空殖民\n\nambivalent to time scales, radiation,\n无视时间，辐射 \\N 以及一些其他让人类难以长时间太空旅行的因素.\n\nand all that other stuff that makes\n无视时间，辐射 \\N 以及一些其他让人类难以长时间太空旅行的因素.\n\nlong-distance space travel difficult for us humans.\n无视时间，辐射 \\N 以及一些其他让人类难以长时间太空旅行的因素.\n\nAnd when the sun is burned up and the Earth is space dust,\n亿万年后太阳燃尽 地球成为星尘 \\N 也许我们的机器人孩子 会继续努力探索宇宙每一个角落\n\nmaybe our technological children will be hard at work\n亿万年后太阳燃尽 地球成为星尘 \\N 也许我们的机器人孩子 会继续努力探索宇宙每一个角落\n\nexploring every nook and cranny of the universe,\n亿万年后太阳燃尽 地球成为星尘 \\N 也许我们的机器人孩子 会继续努力探索宇宙每一个角落\n\nhopefully in honor of their parents’ tradition to build knowledge,\n以纪念它们的父母，同时让宇宙变得更好，\n\nimprove the state of the universe,\n以纪念它们的父母，同时让宇宙变得更好，\n\nand to boldly go where no one has gone before!\n大胆探索无人深空\n\nIn the meantime, computers have a long way to go,\n与此同时，计算机还有很长的路要走\n\nand computer scientists are hard at work advancing\n计算机科学家们在努力推进  过去40集谈到的话题\n\nall of the topics we talked about over the past forty episodes.\n计算机科学家们在努力推进  过去40集谈到的话题\n\nIn the next decade or so,\n在接下来的十几年\n\nwe’ll likely see technologies like virtual and augmented reality,\nVR 和 AR，无人驾驶车，无人机，可穿戴计算机，\n\nself-driving vehicles, drones, wearable computers,\nVR 和 AR，无人驾驶车，无人机，可穿戴计算机，\n\nand service robots go mainstream.\n和服务型机器人 会变得主流\n\nThe internet will continue to evolve new services,\n互联网会继续诞生新服务\n\nstream new media, and connect people in different ways.\n在线看新媒体. 用新方式连接人们\n\nNew programming languages and paradigms will be developed\n会出现新的编程语言和范例，帮助创造令人惊叹的新软件\n\nto facilitate the creation of new and amazing software.\n会出现新的编程语言和范例，帮助创造令人惊叹的新软件\n\nAnd new hardware will make complex operations blazingly fast,\n而新硬件能让复杂运算快如闪电 \\N 比如神经网络和3D图形\n\nlike neural networks and 3D graphics.\n而新硬件能让复杂运算快如闪电 \\N 比如神经网络和3D图形\n\nPersonal computers are also ripe for innovation,\n个人电脑也会创新\n\nperhaps shedding their forty-year old desktop metaphor\n不像过去40年着重宣传 \"桌面\" 电脑\n\nand being reborn as omnipresent and lifelong virtual assistants.\n而是变成无处不在的虚拟助手\n\nAnd there’s so much we didn’t get to talk about in this series,\n这个系列 我们还有很多话题没谈\n\nlike cryptocurrencies, wireless communication,\n比如加密货币，无线通讯，3D打印，生物信息学和量子计算\n\n3D printing, bioinformatics, and quantum computing.\n比如加密货币，无线通讯，3D打印，生物信息学和量子计算\n\nWe’re in a golden age of computing\n我们正处于计算机的黄金时代\n\nand there’s so much going on, it’s impossible to summarize.\n有很多事情在发生，全部总结是不可能的\n\nBut most importantly, you can be a part of this amazing transformation and challenge,\n但最重要的是 你可以学习计算机 \\N 成为这个惊人转型的一部分\n\nby learning about computing, and taking what’s arguably humanity’s greatest invention,\n但最重要的是 你可以学习计算机 \\N 成为这个惊人转型的一部分\n\nto make the world a better place.\n把世界变得更好\n\nThanks for watching.\n感谢收看\n\n"
  },
  {
    "path": "(字幕)全40集中英字幕文本.txt",
    "content": "Hello world, I'm Carrie Anne, and welcome to Crash Course Computer Science!\nHello world！我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the course of this series, we're going to go from bits, bytes, transistors and logic gates,\n在这个系列中，我们会学习 Bits(位)，Bytes(字节)，晶体管, 逻辑门，\n\nall the way to Operating Systems, Virtual Reality and Robots!\n一直到操作系统，虚拟现实和机器人!\n\nWe're going to cover a lot, but just to clear things up\n我们要学很多东西，但预先说明\n\nwe ARE NOT going to teach you how to program.\n我们 *不会* 教你怎么编程\n\nInstead, we're going to explore a range of computing topics as a discipline and a technology.\n我们会从高层次上纵览一系列计算机话题\n\nComputers are the lifeblood of today's world.\n计算机是当今世界的命脉\n\nIf they were to suddenly turn off, all at once,\n如果突然关掉所有的计算机\n\nthe power grid would shut down, cars would crash, planes would fall,\n电网会关闭，车辆会相撞，飞机会坠毁\n\nwater treatment plants would stop, stock markets would freeze,\n净水厂会关闭，证券市场会停止运作\n\ntrucks with food wouldn't know where to deliver, and employees wouldn't get paid.\n装满食物的卡车不知运往何方，员工得不到薪水\n\nEven many non-computer objects -like DFTBA shirts and the chair I'm sitting on-\n甚至很多和计算机无关的东西，例如 DFTBA 的 T 恤和我现在坐的椅子\n\nare made in factories run by computers.\n也都是在计算机管理的工厂中制造的\n\nComputing really has transformed nearly every aspect of our lives.\n计算机改变了我们生活中几乎所有方面\n\nAnd this isn't the first time we've seen this sort of technology-driven global change.\n我们也不是第一次遇到推动全球发展的科技了\n\nAdvances in manufacturing during the Industrial Revolution\n工业革命中生产能力的提高\n\nbrought a new scale to human civilization - in agriculture, industry and domestic life.\n大幅提升了农业，工业，畜牧业的规模\n\nMechanization meant superior harvests and more food, mass produced goods,\n机械化导致更好的收成，更多的食物，商品可以大批量生产\n\ncheaper and faster travel and communication, and usually a better quality of life.\n旅行和通讯变得更便宜更快，生活质量变得更好.\n\nAnd computing technology is doing the same right now\n计算机和工业革命有一样的影响\n\n- from automated farming and medical equipment,\n从自动化农业和医疗设备\n\nto global telecommunications and educational opportunities,\n到全球通信和教育机会\n\nand new frontiers like Virtual Reality and Self Driving Cars.\n还有 虚拟现实 和 无人驾驶汽车 等新领域\n\nWe are living in a time likely to be remembered as the Electronic Age.\n现在这个时代很可能会被后人总结成 \"信息时代\"\n\nAnd with billions of transistors in just your smartphones, computers can seem pretty complicated,\n你的智能手机中有数十亿个晶体管，看起来好像很复杂\n\nbut really, they're just simple machines\n但实际上它是很简单的机器\n\nthat perform complex actions through many layers of abstraction.\n通过一层层的抽象  来做出复杂操作\n\nSo in this series, we're going break down those layers,\n在这个系列中，我们会一层层讲解，\n\nand build up from simple 1's and 0's, to logic units, CPUs,\n从最底层的1和0，到逻辑门，CPU\n\noperating systems, the entire internet and beyond.\n操作系统，整个互联网，以及更多~~\n\nAnd don't worry, in the same way someone buying t-shirts on a webpage\n不用担心，正如在网上买T恤的人 不用知道网站代码是怎么写的\n\ndoesn't need to know how that webpage was programmed,\n不用担心，正如在网上买T恤的人 不用知道网站代码是怎么写的\n\nor the web designer doesn't need to know how all the packets are routed,\n设计师不用知道数据包是怎么传输的\n\nor router engineers don't need to know about transistor logic,\n设计路由器的工程师不用理解晶体管的逻辑\n\nthis series will build on previous episodes but not be dependent on them.\n本系列中每个视频会接着上集继续讲，但并不依赖前面的视频\n\nBy the end of this series,\n等这个系列结束后\n\nI hope that you can better contextualize computing's role both in your own life and society,\n希望你能了解计算机在你的人生 以及社会中扮演什么角色\n\nand how humanity's (arguably) greatest invention is just in its infancy,\n以及这个人类史上最伟大的发明（可以这样说啦）是怎么开始的，\n\nwith its biggest impacts yet to come.\n它对未来还会有更大的影响\n\nBut before we get into all that, we should start at computing's origins,\n但深入之前，我们应该从计算的起源讲起,\n\nbecause although electronic computers are relatively new, the need for computation is not.\n虽然电子计算机才出现不久，但人类对计算的需求早就有了\n\nThe earliest recognized device for computing was the abacus,\n公认最早的计算设备是 算盘\n\ninvented in Mesopotamia around 2500 BCE.\n发明于\"美索不达米亚\"，大约公元前 2500 年\n\nIt's essentially a hand operated calculator,\n它是手动计算器，用来帮助加减数字\n\nthat helps add and subtract many numbers.\n它是手动计算器，用来帮助加减数字\n\nIt also stores the current state of the computation, much like your hard drive does today.\n它存储着当前的计算状态，类似于如今的硬盘\n\nThe abacus was created because,\n人们制造算盘是因为\n\nthe scale of society had become greater than\n社会的规模已经超出个人心算的能力\n\nwhat a single person could keep and manipulate in their mind.\n社会的规模已经超出个人心算的能力\n\nThere might be thousands of people in a village or tens of thousands of cattle.\n一个村庄可能有上千个人和上万头牛\n\nThere are many variants of the abacus,\n算盘有很多变种\n\nbut let's look at a really basic version with each row representing a different power of ten.\n但我们来看一个基础版，每行代表 10 的不同次方\n\nSo each bead on the bottom row represents a single unit,\n最底下那行，一个珠子代表 10 的 0 次方，也就是 1，\n\nin the next row they represent 10, the row above 100, and so on.\n再上面一行是 10 的 1 次方（也就是 10） \\N 再上面一行是 10 的 2 次方 （以此类推）\n\nLet's say we have 3 heads of cattle represented by 3 beads on the bottom row on the right side.\n假设最底部的 3 颗珠子，代表 3 头牛\n\nIf we were to buy 4 more cattle we would just slide 4 more beads to the right for a total of 7.\n假设再买 4 头牛，只需要向右移动 4 颗珠子，共 7 个珠子\n\nBut if we were to add 5 more after the first 3 we would run out of beads,\n但如果再买 5 头，珠子就不够用了\n\nso we would slide everything back to the left,\n所以把所有珠子移回左边\n\nslide one bead on the second row to the right, representing ten,\n在第二排把 1 颗珠子向右移动，代表 10\n\nand then add the final 2 beads on the bottom row for a total of 12.\n然后最底下那行，向右移动 2 颗珠子，代表 12\n\nThis is particularly useful with large numbers.\n这种方法处理大数字很有效\n\nSo if we were to add 1,251\n假设要表示 1251\n\nwe would just add 1 to the bottom row, 5 to the second row, 2 to the third row, and 1 to the fourth row\n从下往上：\\N第一行移 1 个，第二行移 5 个\\N第三行移 2 个，第四行移 1 个\n\n- we don't have to add in our head and the abacus stores the total for us.\n我们不用记在脑子里，算盘会记住.\n\nOver the next 4000 years, humans developed all sorts of clever computing devices,\n在接下来 4000 年，人类发明了各种巧妙的计算设备\n\nlike the astrolabe, which enabled ships to calculate their latitude at sea.\n比如星盘，让船只可以在海上计算纬度\n\nOr the slide rule, for assisting with multiplication and division.\n或计算尺，帮助计算乘法和除法\n\nAnd there are literally hundred of types of clocks created\n人们还创造了上百种时钟\n\nthat could be used to calculate sunrise, tides, positions of celestial bodies, and even just the time.\n算日出，潮汐，天体的位置，或纯粹拿来计时\n\nEach one of these devices made something that was previously laborious to calculate much faster,\n这些设备让原先很费力的事变得更快，更简单，更精确\n\neasier, and often more accurate\n这些设备让原先很费力的事变得更快，更简单，更精确\n\n- it lowered the barrier to entry,\n降低了门槛\n\nand at the same time, amplified our mental abilities -\n加强了我们的能力\n\ntake note, this is a theme we're going to touch on a lot in this series.\n记笔记!（敲黑板）这个系列会多次提到这一点\n\nAs early computer pioneer Charles Babbage said:\n计算机先驱 Charles Babbage 说过：\n\n\"At each increase of knowledge, as well as on the contrivance of every new tool,\n\"随着知识的增长和新工具的诞生，人工劳力会越来越少\"\n\nhuman labour becomes abridged.\"\n\"随着知识的增长和新工具的诞生，人工劳力会越来越少\"\n\nHowever, none of these devices were called \"computers\".\n然而，这些设备那时都不叫 \"计算机\"\n\nThe earliest documented use of the word \"computer\" is from 1613, in a book by Richard Braithwait.\n最早使用 \"计算机\" 一词的文献 \\N 来自 1613 年的一本书，作者 Richard Braithwait\n\nAnd it wasn't a machine at all - it was a job title.\n然而指的不是机器，而是一种职业\n\nBraithwait said,\nBraithwait 说：\n\n\"I have read the truest computer of times,\n\"我听说过的计算者里最厉害的，能把好几天的工作量大大缩减\"\n\nand the best arithmetician that ever breathed, and he reduceth thy dayes into a short number\".\n\"我听说过的计算者里最厉害的，能把好几天的工作量大大缩减\"\n\nIn those days, computer was a person who did calculations,\n那时, \"Computer\" 指负责计算的人\n\nsometimes with the help of machines, but often not.\n\"Computer\" 偶尔会用机器帮忙，但大部分时候靠自己\n\nThis job title persisted until the late 1800s,\n这个职位一直到 1800 年代还存在\n\nwhen the meaning of computer started shifting to refer to devices.\n之后 \"Computer\" 逐渐开始代表机器\n\nNotable among these devices was the Step Reckoner,\n其中\"步进计算器\"最有名\n\nbuilt by German polymath Gottfried Leibniz in 1694.\n由德国博学家 戈特弗里德·莱布尼茨 建造于 1694 年\n\nLeibniz said \"... it is beneath the dignity of excellent men to waste their time in calculation\n莱布尼茨说过 \"... 让优秀的人浪费时间算数简直侮辱尊严\n\nwhen any peasant could do the work just as accurately with the aid of a machine.\"\n农民用机器能算得一样准\"\n\nIt worked kind of like the odometer in your car,\n\"步进计算器\"有点像汽车里的里程表，不断累加里程数\n\nwhich is really just a machine for adding up the number of miles your car has driven.\n\"步进计算器\"有点像汽车里的里程表，不断累加里程数\n\nThe device had a series of gears that turned;\n它有一连串可以转动的齿轮\n\neach gear had ten teeth, to represent the digits from 0 to 9.\n每个齿轮有十个齿，代表数字0到9\n\nWhenever a gear bypassed nine, it rotated back to 0 and advanced the adjacent gear by one tooth.\n每当一个齿轮转过 9，它会转回 0，同时让旁边的齿轮前进 1 个齿\n\nKind of like when hitting 10 on that basic abacus.\n就像算盘超过 10 一样.\n\nThis worked in reverse when doing subtraction, too.\n做减法时，机器会反向运作.\n\nWith some clever mechanical tricks,\n利用一些巧妙的机械结构\n\nthe Step Reckoner was also able to multiply and divide numbers.\n步进计算器也能做乘法和除法\n\nMultiplications and divisions are really just many additions and subtractions.\n乘法和除法 实际上只是多个加法和减法\n\nFor example, if we want to divide 17 by 5, we just subtract 5, then 5, then 5 again,\n举例，17除以5，我们只要减5，减5，再减5\n\nand then we can't subtract any more 5's… so we know 5 goes into 17 three times, with 2 left over.\n直到不能再减 5，就知道了 17=5x3+2\n\nThe Step Reckoner was able to do this in an automated way,\n步进计算器 可以自动完成这种操作\n\nand was the first machine that could do all four of these operations.\n它是第一台能做\"加减乘除\"全部四种运算的机器\n\nAnd this design was so successful it was used for the next three centuries of calculator design.\n它的设计非常成功，以至于沿用了 3 个世纪.\n\nUnfortunately, even with mechanical calculators,\n不幸的是，即使有机械计算器\n\nmost real world problems required many steps of computation before an answer was determined.\n许多现实问题 依然需要很多步\n\nIt could take hours or days to generate a single result.\n算一个结果可能要几小时甚至几天\n\nAlso, these hand-crafted machines were expensive, and not accessible to most of the population.\n而且这些手工制作的机器非常昂贵，大部分人买不起\n\nSo, before 20th century,\n所以在 20 世纪以前\n\nmost people experienced computing through pre-computed tables\n大部分人会用预先算好的计算表\n\nassembled by those amazing \"human computers\" we talked about.\n这些计算表由之前说的 \"人力计算器\" 编撰\n\nSo if you needed to know the square root of 8 million 6 hundred and 75 thousand 3 hundred and 9,\n如果你想知道 867,5309 的平方根\n\ninstead of spending all day hand-cranking your step reckoner,\n与其花一整天来手摇 \"步进计算器\"\n\nyou could look it up in a huge book full of square root tables in a minute or so.\n你可以花一分钟在表里找答案\n\nSpeed and accuracy is particularly important on the battlefield,\n速度和准确性在战场上尤为重要\n\nand so militaries were among the first to apply computing to complex problems.\n因此军队很早就开始用计算解决复杂问题\n\nA particularly difficult problem is accurately firing artillery shells,\n如何精确瞄准炮弹是一个很难的问题\n\nwhich by the 1800s could travel well over a kilometer (or a bit more than half a mile).\n19世纪，这些炮弹的射程可以达到 1 公里以上（比半英里多一点）\n\nAdd to this varying wind conditions, temperature, and atmospheric pressure,\n因为风力，温度，大气压力会不断变化\n\nand even hitting something as large as a ship was difficult.\n想打中船一样大的物体也非常困难\n\nRange Tables were created that allowed gunners to look up environmental conditions\n于是出现了射程表，炮手可以查环境条件和射击距离\n\nand the distance they wanted to fire,\n于是出现了射程表，炮手可以查环境条件和射击距离\n\nand the table would tell them the angle to set the canon.\n然后这张表会告诉他们，角度要设成多少\n\nThese Range Tables worked so well, they were used well into World War Two.\n这些射程表很管用，二战中被广泛应用\n\nThe problem was, if you changed the design of the cannon or of the shell,\n问题是如果改了大炮或炮弹的设计，就要算一张新表\n\na whole new table had to be computed,\n问题是如果改了大炮或炮弹的设计，就要算一张新表\n\nwhich was massively time consuming and inevitably led to errors.\n这样很耗时而且会出错\n\nCharles Babbage acknowledged this problem in 1822\nCharles Babbage 在 1822 年写了一篇论文\n\nin a paper to the Royal Astronomical Society entitled:\n向皇家天文学会指出了这个问题\n\n\"Note on the application of machinery to the computation of astronomical and mathematical tables\".\n标题叫： \"机械在天文与计算表中的应用\"\n\nLet's go to the thought bubble.\n让我们进入思想泡泡\n\nCharles Babbage proposed a new mechanical device called the Difference Engine,\nCharles Babbage 提出了一种新型机械装置叫 \"差分机\"\n\na much more complex machine that could approximate polynomials.\n一个更复杂的机器，能近似多项式.\n\nPolynomials describe the relationship between several variables\n多项式描述了几个变量之间的关系\n\n- like range and air pressure, or amount of pizza Carrie Anne eats and happiness.\n比如射程和大气压力，或者 Carrie Anne 要吃多少披萨才开心\n\nPolynomials could also be used to approximate logarithmic and trigonometric functions,\n多项式也可以用于近似对数和三角函数\n\nwhich are a real hassle to calculate by hand.\n这些函数手算相当麻烦\n\nBabbage started construction in 1823,\nCharles Babbage 在 1823 年开始建造差分机\n\nand over the next two decades, tried to fabricate and assemble the 25,000 components,\n并在接下来二十年，试图制造和组装 25,000 个零件\n\ncollectively weighing around 15 tons.\n总重接近 15 吨\n\nUnfortunately, the project was ultimately abandoned.\n不幸的是，该项目最终放弃了\n\nBut, in 1991,\n但在 1991 年\n\nhistorians finished constructing a Difference Engine based on Babbage's drawings and writings\n历史学家根据 Charles Babbage 的草稿做了一个差分机\n\n- and it worked!\n而且它还管用！\n\nBut more importantly, during construction of the Difference Engine,\n但更重要的是，在差分机的建造期间\n\nBabbage imagined an even more complex machine - the Analytical Engine.\nCharles Babbage 构想了一个更复杂的机器 - 分析机\n\nUnlike the Difference Engine,\n不像差分机，步进计算器 和以前的其他计算设备\n\nStep Reckoner and all other computational devices before it\n不像差分机，步进计算器 和以前的其他计算设备\n\n- the Analytical Engine was a \"general purpose computer\".\n分析机是 \"通用计算机\"\n\nIt could be used for many things, not just one particular computation;\n它可以做很多事情，不只是一种特定运算\n\nit could be given data and run operations in sequence;\n甚至可以给它数据，然后按顺序执行一系列操作\n\nit had memory and even a primitive printer.\n它有内存 甚至一个很原始的打印机\n\nLike the Difference Engine, it was ahead of its time, and was never fully constructed.\n就像差分机，这台机器太超前了，所以没有建成\n\nHowever, the idea of an \"automatic computer\"\n然而，这种 \"自动计算机\" 的概念\n\n- one that could guide itself through a series of operations automatically,\n-计算机可以自动完成一系列操作\n\nwas a huge deal, and would foreshadow computer programs.\n是个跨时代的概念，预示着计算机程序的诞生\n\nEnglish mathematician Ada Lovelace wrote hypothetical programs for the Analytical Engine, saying,\n英国数学家 Ada Lovelace 给分析机写了假想的程序，她说：\n\n\"A new, a vast, and a powerful language is developed for the future use of analysis.\"\n\"未来会诞生一门全新的，强大的，专为分析所用的语言\"\n\nFor her work, Ada is often considered the world's first programmer.\n因此 Ada 被认为是世上第一位程序员.\n\nThe Analytical Engine would inspire, arguably, the first generation of computer scientists,\n分析机激励了（可以这么讲）第一代计算机科学家\n\nwho incorporated many of Babbage's ideas in their machines.\n这些计算机科学家 \\N 把很多 Charles Babbage 的点子融入到他们的机器\n\nThis is why Babbage is often considered the \"father of computing\".\n所以 Charles Babbage 经常被认为是 \"计算之父\"\n\nThanks! Thought Bubble\n谢啦！思想泡泡\n\nSo by the end of the 19th century,\n到了 19 世纪末\n\ncomputing devices were used for special purpose tasks in the sciences and engineering,\n科学和工程领域中的特定任务 会用上计算设备\n\nbut rarely seen in business, government or domestic life.\n但公司，政府，家庭中很少见到计算设备\n\nHowever, the US government faced a serious problem for its 1890 census\n然而，美国政府在 1890 年的人口普查中面临着严重的问题\n\nthat demanded the kind of efficiency that only computers could provide.\n只有计算机能提供所需的效率\n\nThe US Constitution requires that a census be conducted every ten years,\n美国宪法要求 10 年进行一次人口普查\n\nfor the purposes of distributing federal funds, representation in congress, and good stuff like that.\n目的是分配联邦资金，国会代表，等等\n\nAnd by 1880s, the US population was booming, mostly due to immigration.\n到 1880 年代，美国人口迅速增长，大部分因为移民\n\nThat census took seven years to manually compile\n人口普查要七年时间来手工编制，等做完都过时了\n\nand by the time it was completed, it was already out of date\n人口普查要七年时间来手工编制，等做完都过时了\n\n- and it was predicted that the 1890 census would take 13 years to compute.\n而且 1890 年的人口普查，预计要 13 年完成\n\nThat's a little problematic when it's required every decade!\n但人口普查可是 10 年一次啊！\n\nThe Census bureau turned to Herman Hollerith, who had built a tabulating machine.\n人口普查局找了 Herman Hollerith，他发明了打孔卡片制表机\n\nHis machine was \"electro-mechanical\"\n他的机器是 \"电动机械的\"\n\n- it used traditional mechanical systems for keeping count,\n- 用传统机械来计数\n\nlike Leibniz's Step Reckoner - but coupled them with electrically-powered components.\n结构类似莱布尼茨的乘法器，但用电动结构连接其他组件\n\nHollerith's machine used punch cards\nHollerith 的机器用打孔卡\n\nwhich were paper cards with a grid of locations that can be punched out to represent data.\n一种纸卡，上面有网格，用打孔来表示数据.\n\nFor example, there was a series of holes for marital status.\n举个例子，有一连串孔代表婚姻状况\n\nIf you were married, you would punch out the married spot,\n如果你结婚了，就在 \"结婚\" 的位置打孔\n\nthen when the card was inserted into Hollerith's machine, little metal pins would come down over the card\n当卡插入 Hollerith 的机器时，小金属针会到卡片上\n\n- if a spot was punched out, the pin would pass through the hole in the paper\n-如果有个地方打孔了，针会穿过孔\n\nand into a little vial of mercury, which completed the circuit.\n泡入一小瓶汞，联通电路\n\nThis now completed circuit powered an electric motor,\n电路会驱动电机\n\nwhich turned a gear to add one, in this case, to the \"married\" total.\n然后给 \"已婚\" 的齿轮 + 1\n\nHollerith's machine was roughly 10x faster than manual tabulations,\nHollerith 的机器速度是手动的 10 倍左右\n\nand the Census was completed in just two and a half years\n使人口普查在短短两年半内完成\n\n- saving the census office millions of dollars.\n给人口普查办公室省了上百万美元\n\nBusinesses began recognizing the value of computing,\n企业开始意识到计算机的价值\n\nand saw its potential to boost profits by improving labor- and data-intensive tasks,\n可以提升劳动力以及数据密集型任务 来提升利润\n\nlike accounting, insurance appraisals, and inventory management.\n比如会计，保险评估和库存管理等行业\n\nTo meet this demand, Hollerith founded The Tabulating Machine Company,\n为了满足这一需求，Hollerith 成立了制表机器公司\n\nwhich later merged with other machine makers in 1924\n这家公司后来在 1924 年与其它机械制造商合并\n\nto become The International Business Machines Corporation or IBM\n成为了 \"国际商业机器公司\"，简称 IBM\n\n- which you've probably heard of.\n-你可能听过 IBM\n\nThese electro-mechanical \"business machines\" were a huge success, transforming commerce and government,\n这些电子机械的 \"商业机器\" 取得了巨大成功，改变了商业和政府.\n\nand by the mid-1900s, the explosion in world population and the rise of globalized trade\n到了 1900 年代中叶，世界人口的爆炸和全球贸易的兴起\n\ndemanded even faster and more flexible tools for processing data,\n要求更快，更灵活的工具来处理数据\n\nsetting the stage for digital computers,\n为电子计算机的发展奠定了基础\n\nwhich we'll talk about next week.\n我们下周讨论\n\nOur last episode brought us to the start of the 20th century,\n上集讲到 20 世纪初\n\nwhere early, special purpose computing devices, like tabulating machines,\n当时的早期计算设备都针对特定用途  比如 制表机\n\nwere a huge boon to governments and business\n大大推进了政府和企业\n\n- aiding, and sometimes replacing, rote manual tasks.\n它们帮助, 甚至代替了人工\n\nBut the scale of human systems continued to increase at an unprecedented rate.\n然而人类社会的规模  在以前所未有的速度增长\n\nThe first half of the 20th century saw the world's population almost double.\n20世纪上半叶，世界人口几乎翻倍\n\nWorld War 1 mobilized 70 million people, and World War 2 involved more than 100 million.\n一战动员7千万人，二战1亿多人\n\nGlobal trade and transit networks became interconnected like never before,\n全球贸易和运输更加紧密\n\nand the sophistication of our engineering and scientific endeavors reached new heights\n工程和科学的复杂度也达到新高\n\n- we even started to seriously consider visiting other planets.\n- 我们甚至开始考虑造访其他行星\n\nAnd it was this explosion of complexity, bureaucracy, and ultimately data,\n复杂度的增高导致数据量暴增\n\nthat drove an increasing need for automation and computation.\n人们需要更多自动化 更强的计算能力\n\nSoon those cabinet-sized electro-mechanical computers grew into room-sized behemoths\n很快，柜子大小的计算机变成房间大小\n\nthat were expensive to maintain and prone to errors.\n维护费用高 而且容易出错\n\nAnd it was these machines that would set the stage for future innovation.\n而正是这些机器 为未来的创新打下基础\n\nOne of the largest electro-mechanical computers built was the Harvard Mark I,\n最大的机电计算机之一是 哈佛马克一号\n\ncompleted in 1944 by IBM for the Allies during World War 2.\nIBM 在 1944 完成建造，给二战同盟国建造的.\n\nIt contained 765,000 components, three million connections, and five hundred miles of wire.\n它有76万5千个组件，300万个连接点和500英里长的导线\n\nTo keep its internal mechanics synchronized,\n为了保持内部机械装置同步\n\nit used a 50-foot shaft running right through the machine driven by a five horsepower motor.\n它有一个50英尺的传动轴，由一个 5 马力的电机驱动\n\nOne of the earliest uses for this technology was running simulations for the Manhattan Project.\n这台机器最早的用途之一 是给\"曼哈顿计划\"跑模拟\n\nThe brains of these huge electro-mechanical beasts were relays:\n这台机器的大脑是\"继电器\"\n\nelectrically-controlled mechanical switches.\n继电器是：用电控制的机械开关\n\nIn a relay, there is a control wire that determines whether a circuit is opened or closed.\n继电器里，有根\"控制线路\"，控制电路是开还是关\n\nThe control wire connects to a coil of wire inside the relay.\n\"控制线路\" 连着一个线圈\n\nWhen current flows through the coil, an electromagnetic field is created,\n当电流流过线圈，线圈产生电磁场\n\nwhich in turn, attracts a metal arm inside the relay, snapping it shut and completing the circuit.\n吸引金属臂，从而闭合电路\n\nYou can think of a relay like a water faucet.\n你可以把继电器 想成水龙头\n\nThe control wire is like the faucet handle.\n把控制线路 想成水龙头把\n\nOpen the faucet, and water flows through the pipe.\n打开水龙头，水会流出来\n\nClose the faucet, and the flow of water stops.\n关闭水龙头，水就没有了\n\nRelays are doing the same thing, just with electrons instead of water.\n继电器是一样的，只不过控制的是电子  而不是水\n\nThe controlled circuit can then connect to other circuits, or to something like a motor,\n这个控制电路可以连到其他电路，比如马达\n\nwhich might increment a count on a gear,\n马达让计数齿轮 +1\n\nlike in Hollerith's tabulating machine we talked about last episode.\n就像上集中 Hollerith 的制表机一样\n\nUnfortunately, the mechanical arm inside of a relay *has mass*,\n不幸的是，继电器内的机械臂 *有质量*\n\nand therefore can't move instantly between opened and closed states.\n因此无法快速开关\n\nA good relay in the 1940's might be able to flick back and forth fifty times in a second.\n1940 年代一个好的继电器 1 秒能翻转 50 次\n\nThat might seem pretty fast, but it's not fast enough to be useful at solving large, complex problems.\n看起来好像很快，但还不够快，不足以解决复杂的大问题\n\nThe Harvard Mark I could do 3 additions or subtractions per second;\n哈佛马克一号，1 秒能做 3 次加法或减法运算\n\nmultiplications took 6 seconds, and divisions took 15.\n一次乘法要花 6 秒，除法要花 15 秒\n\nAnd more complex operations, like a trigonometric function, could take over a minute.\n更复杂的操作 比如三角函数，可能要一分钟以上\n\nIn addition to slow switching speed, another limitation was wear and tear.\n除了速度慢，另一个限制是齿轮磨损\n\nAnything mechanical that moves will wear over time.\n任何会动的机械都会随时间磨损\n\nSome things break entirely, and other things start getting sticky, slow, and just plain unreliable.\n有些部件会完全损坏，有些则是变黏，变慢，变得不可靠\n\nAnd as the number of relays increases, the probability of a failure increases too.\n并且随着继电器数量增加，故障概率也会增加\n\nThe Harvard Mark I had roughly 3500 relays.\n哈佛马克一号 有大约 3500 个继电器\n\nEven if you assume a relay has an operational life of 10 years,\n哪怕假设继电器的使用寿命是 10 年\n\nthis would mean you'd have to replace, on average, one faulty relay every day!\n也意味着平均每天得换一个故障继电器！\n\nThat's a big problem when you are in the middle of running some important, multi-day calculation.\n这个问题很严重，因为有些重要运算要运行好几天\n\nAnd that's not all engineers had to contend with.\n而且还有更多其他问题要考虑\n\nThese huge, dark, and warm machines also attracted insects.\n这些巨大，黑色，温暖的机器也会吸引昆虫\n\nIn September 1947, operators on the Harvard Mark II pulled a dead moth from a malfunctioning relay.\n1947年9月，哈佛马克2型的操作员从故障继电器中，拔出一只死虫\n\nGrace Hopper who we'll talk more about in a later episode noted,\nGrace Hopper（这位我们以后还会提到）曾说\n\n\"From then on, when anything went wrong with a computer,\n\"从那时起，每当电脑出了问题，\n\nwe said it had bugs in it.\"\n我们就说它出了 bug（虫子）\"\n\nAnd that's where we get the term computer bug.\n这就是术语 \"bug\" 的来源\n\nIt was clear that a faster, more reliable alternative to electro-mechanical relays was needed\n显然，如果想进一步提高计算能力\n\nif computing was going to advance further,\n我们需要更快更可靠的东西，来替代继电器\n\nand fortunately that alternative already existed!\n幸运的是，替代品已经存在了！\n\nIn 1904, English physicist John Ambrose Fleming\n在 1904 年，英国物理学家 \"约翰·安布罗斯·弗莱明\"\n\ndeveloped a new electrical component called a thermionic valve,\n开发了一种新的电子组件，叫\"热电子管\"\n\nwhich housed two electrodes inside an airtight glass bulb\n把两个电极装在一个气密的玻璃灯泡里\n\n- this was the first vacuum tube.\n-这是世上第一个真空管\n\nOne of the electrodes could be heated, which would cause it to emit electrons\n其中一个电极可以加热，从而发射电子\n\n– a process called thermionic emission.\n-这叫 \"热电子发射\"\n\nThe other electrode could then attract these electrons to create the flow of our electric faucet,\n另一个电极会吸引电子，形成\"电龙头\"的电流\n\nbut only if it was positively charged\n但只有带正电才行\n\n- if it had a negative or neutral charge, the electrons would no longer be attracted across the vacuum\n- 如果带负电荷或中性电荷，电子就没办法被吸引，越过真空区域\n\nso no current would flow.\n因此没有电流\n\nAn electronic component that permits the one-way flow of current is called a diode,\n电流只能单向流动的电子部件叫 \"二极管\"\n\nbut what was really needed was a switch to help turn this flow on and off.\n但我们需要的是，一个能开关电流的东西\n\nLuckily, shortly after, in 1906, American inventor Lee de Forest\n幸运的是，不久之后在 1906 年，美国发明家 \"李·德富雷斯特\"\n\nadded a third \"control\" electrode that sits between the two electrodes in Fleming's design.\n他在\"弗莱明\"设计的两个电极之间，加入了第三个 \"控制\" 电极\n\nBy applying a positive charge to the control electrode, it would permit the flow of electrons as before.\n向\"控制\"电极施加正电荷，它会允许电子流动\n\nBut if the control electrode was given a negative charge,\n但如果施加负电荷\n\nit would prevent the flow of electrons.\n它会阻止电子流动\n\nSo by manipulating the control wire, one could open or close the circuit.\n因此通过控制线路，可以断开或闭合电路\n\nIt's pretty much the same thing as a relay\n和继电器的功能一样\n\n- but importantly, vacuum tubes have no moving parts.\n- 但重要的是，真空管内没有会动的组件\n\nThis meant there was less wear,\n这意味着更少的磨损\n\nand more importantly, they could switch thousands of times per second.\n更重要的是，每秒可以开闭数千次\n\nThese triode vacuum tubes would become the basis of radio, long distance telephone,\n因此这些\"三极真空管\"成为了无线电，长途电话\n\nand many other electronic devices for nearly a half century.\n以及其他电子设备的基础，持续了接近半个世纪\n\nI should note here that vacuum tubes weren't perfect\n我应该提到，真空管不是完美的\n\n- they're kind of fragile, and can burn out like light bulbs,\n-它们有点脆弱，并且像灯泡一样会烧坏\n\nthey were a big improvement over mechanical relays.\n但比起机械继电器是一次巨大进步\n\nAlso, initially vacuum tubes were expensive\n起初，真空管非常昂贵\n\n– a radio set often used just one,\n收音机一般只用一个\n\nbut a computer might require hundreds or thousands of electrical switches.\n但计算机可能要上百甚至上千个电气开关\n\nBut by the 1940s,\n但到了 1940 年代\n\ntheir cost and reliability had improved to the point where they became feasible for use in computers….\n它的成本和可靠性得到改进，可以用在计算机里\n\nat least by people with deep pockets, like governments.\n至少有钱人负担得起，比如政府\n\nThis marked the shift from electro-mechanical computing to electronic computing.\n这标志着计算机 从机电转向电子\n\nLet's go to the Thought Bubble.\n我们来进入思想泡泡\n\nThe first large-scale use of vacuum tubes for computing was the Colossus MK 1,\n第一个大规模使用真空管的计算机是 \"巨人1号\"\n\ndesigned by engineer Tommy Flowers and completed in December of 1943.\n由工程师 Tommy Flowers 设计，完工于1943年12月\n\nThe Colossus was installed at Bletchley Park, in the UK,\n巨人1号 在英国的\"布莱切利园\", 用于破解纳粹通信\n\nand helped to decrypt Nazi communications.\n巨人1号 在英国的\"布莱切利园\", 用于破解纳粹通信\n\nThis may sound familiar because two years prior Alan Turing,\n听起来可能有点熟，因为 2 年前 阿兰·图灵\n\noften called the father of computer science,\n他经常被称为\"计算机科学之父\"\n\nhad created an electromechanical device, also at Bletchley Park, called the Bombe.\n图灵也在\"布莱切利园\"做了台机电装置，叫 \"Bombe\"\n\nIt was an electromechanical machine designed to break Nazi Enigma codes,\n这台机器的设计目的是  破解纳粹\"英格码\"通讯加密设备\n\nbut the Bombe wasn't technically a computer,\n但 Bombe 严格来说不算计算机\n\nand we'll get to Alan Turing's contributions later.\n我们之后会讨论\"阿兰·图灵\"的贡献\n\nAnyway, the first version of Colossus contained 1,600 vacuum tubes,\n总之，巨人1号有 1600 个真空管\n\nand in total, ten Colossi were built to help with code-breaking.\n总共造了 10 台巨人计算机，来帮助破解密码\n\nColossus is regarded as the first programmable, electronic computer.\n巨人 被认为是第一个可编程的电子计算机\n\nProgramming was done by plugging hundreds of wires into plugboards,\n编程的方法是把几百根电线插入插板\n\nsort of like old school telephone switchboards,\n有点像老电话交换机\n\nin order to set up the computer to perform the right operations.\n这是为了让计算机执行正确操作\n\nSo while \"programmable\", it still had to be configured to perform a specific computation.\n虽然\"可编程\" ，但还是要配置它\n\nEnter the The Electronic Numerical Integrator and Calculator - or ENIAC -\n电子数值积分计算机 \"ENIAC\"\n\ncompleted a few years later in 1946 at the University of Pennsylvania.\n几年后在 1946 年，在\"宾夕法尼亚大学\"完成建造\n\nDesigned by John Mauchly and J. Presper Eckert,\n设计者是 John Mauchly 和 J. Presper Eckert\n\nthis was the world's first truly general purpose, programmable, electronic computer.\n这是世上第一个真正的通用，可编程，电子计算机\n\nENIAC could perform 5000 ten-digit additions or subtractions per second,\nENIAC 每秒可执行 5000 次十位数加减法\n\nmany, many times faster than any machine that came before it.\n比前辈快了很多倍\n\nIt was operational for ten years,\n它运作了十年\n\nand is estimated to have done more arithmetic than the entire human race up to that point.\n据估计，它完成的运算，比全人类加起来还多\n\nBut with that many vacuum tubes failures were common,\n因为真空管很多，所以故障很常见\n\nand ENIAC was generally only operational for about half a day at a time before breaking down.\nENIAC 运行半天左右就会出一次故障\n\nThanks Thought Bubble.\n谢了 思想泡泡\n\nBy the 1950's, even vacuum-tube-based computing was reaching its limits.\n到 1950 年代，真空管计算机都达到了极限\n\nThe US Air Force's AN/FSQ-7 computer, which was completed in 1955,\n美国空军的 AN/FSQ-7 计算机于 1955 年完成\n\nwas part of the \"SAGE\" air defense computer system,\n是 \"SAGE\" 防空计算机系统的一部分\n\nwhich we'll talk more about in a later episode.\n之后的视频还会提到.\n\nTo reduce cost and size, as well as improve reliability and speed,\n为了降低成本和大小，同时提高可靠性和速度\n\na radical new electronic switch would be needed.\n我们需要一种新的电子开关\n\nIn 1947, Bell Laboratory scientists John Bardeen, Walter Brattain, and William Shockley\n1947 年，贝尔实验室科学家 \\N John Bardeen，Walter Brattain，William Shockley\n\ninvented the transistor,\n发明了晶体管\n\nand with it, a whole new era of computing was born!\n一个全新的计算机时代诞生了！\n\nThe physics behind transistors is pretty complex, relying on quantum mechanics,\n晶体管的物理学相当复杂，牵扯到量子力学\n\nso we're going to stick to the basics.\n所以我们只讲基础\n\nA transistor is just like a relay or vacuum tube\n晶体管 就像之前提过的\"继电器\"或\"真空管\"\n\n- it's a switch that can be opened or closed by applying electrical power via a control wire.\n-它是一个开关，可以用控制线路来控制开或关\n\nTypically, transistors have two electrodes separated by a material that sometimes can conduct electricity,\n晶体管有两个电极，\\N 电极之间有一种材料隔开它们，这种材料有时候导电\n\nand other times resist it\n有时候不导电\n\n- a semiconductor.\n- 这叫\"半导体\"\n\nIn this case, the control wire attaches to a \"gate\" electrode.\n控制线连到一个 \"门\" 电极\n\nBy changing the electrical charge of the gate,\n通过改变 \"门\" 的电荷\n\nthe conductivity of the semiconducting material can be manipulated,\n我们可以控制半导体材料的导电性\n\nallowing current to flow or be stopped\n来允许或不允许 电流流动\n\n- like the water faucet analogy we discussed earlier.\n- 就像之前的水龙头比喻\n\nEven the very first transistor at Bell Labs showed tremendous promise\n贝尔实验室的第一个晶体管就展示了巨大的潜力\n\n- it could switch between on and off states 10,000 times per second.\n每秒可以开关 10,000 次\n\nFurther, unlike vacuum tubes made of glass and with carefully suspended, fragile components,\n而且，比起玻璃制成，小心易碎的真空管\n\ntransistors were solid material known as a solid state component.\n晶体管是固态的\n\nAlmost immediately, transistors could be made smaller than the smallest possible relays or vacuum tubes.\n晶体管可以远远小于继电器或真空管\n\nThis led to dramatically smaller and cheaper computers, like the IBM 608, released in 1957\n导致更小更便宜的计算机，比如1957年发布的IBM 608\n\n– the first fully transistor-powered, commercially-available computer.\n- 第一个完全用晶体管，而且消费者也可以买到的计算机\n\nIt contained 3000 transistors and could perform 4,500 additions,\n它有 3000 个晶体管，每秒执行 4500 次加法\n\nor roughly 80 multiplications or divisions, every second.\n每秒能执行 80 次左右的乘除法\n\nIBM soon transitioned all of its computing products to transistors,\nIBM 很快把所有产品都转向了晶体管\n\nbringing transistor-based computers into offices, and eventually, homes.\n把晶体管计算机带入办公室，最终引入家庭\n\nToday, computers use transistors that are smaller than 50 nanometers in size\n如今，计算机里的晶体管小于 50 纳米\n\n- for reference, a sheet of paper is roughly 100,000 nanometers thick.\n- 而一张纸的厚度大概是 10 万纳米\n\nAnd they're not only incredibly small, they're super fast\n晶体管不仅小，还超级快\n\n- they can switch states millions of times per second, and can run for decades.\n- 每秒可以切换上百万次，并且能工作几十年\n\nA lot of this transistor and semiconductor development happened\n很多晶体管和半导体的开发在\"圣克拉拉谷\"\n\nin the Santa Clara Valley, between San Francisco and San Jose, California.\n这个地方在加州，位于\"旧金山\"和\"圣荷西\"之间\n\nAs the most common material used to create semiconductors is silicon,\n而生产半导体最常见的材料是 \"硅\"\n\nthis region soon became known as Silicon Valley.\n所以这个地区被称为 \"硅谷\"\n\nEven William Shockley moved there, founding Shockley Semiconductor,\n甚至 William Shockley 都搬了过去，创立了\"肖克利半导体\"\n\nwhose employees later founded Fairchild Semiconductors,\n里面的员工后来成立了\"仙童半导体\"\n\nwhose employees later founded Intel - the world's largest computer chip maker today.\n这里面的员工后来创立了英特尔 - 当今世界上最大的计算机芯片制造商\n\nOk, so we've gone from relays to vacuum tubes to transistors.\n好了，我们从\"继电器\"到\"真空管\"到\"晶体管\"\n\nWe can turn electricity on and off really, really, really fast.\n我们可以让电路开闭得非常非常快\n\nBut how do we get from transistors to actually computing something,\n但我们是如何用晶体管做计算的？\n\nespecially if we don't have motors and gears?\n我们没有马达和齿轮啊？\n\nThat's what we're going to cover over the next few episodes.\n我们接下来几集会讲\n\nThanks for watching. See you next week.\n感谢观看 下周见\n\nHi, I'm Carrie Anne and welcome to Crash Course Computer Science!\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nToday we start our journey up the ladder of abstraction,\n今天我们开始\"抽象\"的旅程\n\nwhere we leave behind the simplicity of being able to see every switch and gear,\n不用管底层细节，把精力用来构建更复杂的系统\n\nbut gain the ability to assemble increasingly complex systems.\n不用管底层细节，把精力用来构建更复杂的系统\n\nLast episode, we talked about how computers evolved from electromechanical devices,\n上集，我们谈了计算机最早是机电设备\n\nthat often had decimal representations of numbers\n一般用十进制计数\n\n- like those represented by teeth on a gear\n- 比如用齿轮数来代表十进制\n\n- to electronic computers with transistors that can turn the flow of electricity on or off.\n- 再到晶体管计算机\n\nAnd fortunately, even with just two states of electricity,\n幸运的是，只用 开/关 两种状态也可以代表信息\n\nwe can represent important information.\n幸运的是，只用 开/关 两种状态也可以代表信息\n\nWe call this representation Binary\n这叫 二进制\n\n-- which literally means \"of two states\",\n- 意思是\"用两种状态表示\"\n\nin the same way a bicycle has two wheels or a biped has two legs.\n就像自行车有两个轮，双足动物有两条腿\n\nYou might think two states isn't a lot to work with, and you'd be right!\n你可能觉得两种状态不多，你是对的！\n\nBut, it's exactly what you need for representing the values \"true\" and \"false\".\n但如果只需要表示 true 和 false，两个值就够了\n\nIn computers, an \"on\" state, when electricity is flowing, represents true.\n电路闭合，电流流过，代表 \"真\"\n\nThe off state, no electricity flowing, represents false.\n电路断开，无电流流过，代表\"假\"\n\nWe can also write binary as 1's and 0's instead of true's and false's\n二进制也可以写成 1 和 0 而不是 true 和 false\n\n- they are just different expressions of the same signal\n- 只是不同的表达方式罢了\n\n- but we'll talk more about that in the next episode.\n- 我们下集会讲更多细节\n\nNow it is actually possible to use transistors for more than just turning electrical current on and off,\n晶体管的确可以不只是 开/关，还可以让不同大小的电流通过\n\nand to allow for different levels of current.\n晶体管的确可以不只是 开/关，还可以让不同大小的电流通过\n\nSome early electronic computers were ternary, that's three states,\n一些早期电子计算机是三进制的，有 3 种状态\n\nand even quinary, using 5 states.\n甚至五进制，5 种状态\n\nThe problem is, the more intermediate states there are,\n问题是，状态越多，越难区分信号\n\nthe harder it is to keep them all seperate\n问题是，状态越多，越难区分信号\n\n-- if your smartphone battery starts running low or there's electrical noise\n- 如果手机快没电了或者附近有电噪音\n\nbecause someone's running a microwave nearby,\n因为有人在用微波炉，\n\nthe signals can get mixed up...\n信号可能会混在一起...\n\nand this problem only gets worse with transistors changing states millions of times per second!\n而每秒百万次变化的晶体管会让这个问题变得更糟！\n\nSo, placing two signals as far apart as possible\n所以我们把两种信号尽可能分开\n\n- using just 'on and off' - gives us the most distinct signal to minimize these issues.\n- 只用\"开\"和\"关\"两种状态，可以尽可能减少这类问题\n\nAnother reason computers use binary\n计算机用二进制的另一个原因是\n\nis that an entire branch of mathematics already existed that dealt exclusively with true and false values.\n有一整个数学分支存在，专门处理\"真\"和\"假\"\n\nAnd it had figured out all of the necessary rules and operations for manipulating them.\n它已经解决了所有法则和运算\n\nIt's called Boolean Algebra!\n叫\"布尔代数\"！\n\nGeorge Boole, from which Boolean Algebra later got its name,\n乔治·布尔（George Boole）是布尔二字的由来\n\nwas a self-taught English mathematician in the 1800s.\n是一位 19 世纪自学成才的英国数学家\n\nHe was interested in representing logical statements that went \"under, over, and beyond\"\n他有兴趣用数学式子 扩展亚里士多德基于哲学的逻辑方法\n\nAristotle's approach to logic, which was, unsurprisingly, grounded in philosophy.\n他有兴趣用数学式子 扩展亚里士多德基于哲学的逻辑方法\n\nBoole's approach allowed truth to be systematically and formally proven, through logic equations\n布尔用 逻辑方程 系统而正式的证明真理(truth)\n\nwhich he introduced in his first book, \"The Mathematical Analysis of Logic\" in 1847.\n他在 1847 年的第一本书\"逻辑的数学分析\"中介绍过\n\nIn \"regular\" algebra -- the type you probably learned in high school -- the values of variables\n在\"常规\"代数里 - 你在高中学的那种 - 变量的值\n\nare numbers, and operations on those numbers are things like addition and multiplication.\n是数字，可以进行加法或乘法之类的操作\n\nBut in Boolean Algebra, the values of variables are true and false, and the operations are logical.\n但在布尔代数中，变量的值是 true 和 false，\\N 能进行逻辑操作\n\nThere are three fundamental operations in Boolean Algebra: a NOT, an AND, and an OR operation.\n布尔代数中有三个基本操作：NOT, AND 和 OR\n\nAnd these operations turn out to be really useful so we're going to look at them individually.\n这些操作非常有用，我们一个个来看\n\nA NOT takes a single boolean value, either true or false, and negates it.\nNOT 操作把布尔值反转，\\N把 true 进行 NOT 就会变成 false，反之亦然\n\nIt flips true to false, and false to true.\nNOT 操作把布尔值反转，\\N把 true 进行 NOT 就会变成 false，反之亦然\n\nWe can write out a little logic table that shows the original value under Input,\n我们可以根据 NOT 操作的输入和输出，做出这个表\n\nand the outcome after applying the operation under Output.\n我们可以根据 NOT 操作的输入和输出，做出这个表\n\nNow here's the cool part -- we can easily build boolean logic out of transistors.\n酷的地方是 - 用晶体管可以轻松实现这个逻辑\n\nAs we discussed last episode, transistors are really just little electrically controlled switches.\n上集说过，晶体管只是电控制的开关\n\nThey have three wires: two electrodes and one control wire.\n有 3 根线：2 根电极和 1 根控制线\n\nWhen you apply electricity to the control wire,\n控制线通电时\n\nit lets current flow through from one electrode, through the transistor, to the other electrode.\n电流就可以从一个电极流到另一个电极\n\nThis is a lot like a spigot on a pipe\n就像水龙头一样\n\n-- open the tap, water flows,\n- 打开水龙头，就有水流出来\n\nclose the tap, water shuts off.\n关掉水龙头，就没水了\n\nYou can think of the control wire as an input,\n可以把控制线，当做输入 ( input ) \\N 底部的电极，当做输出（output）\n\nand the wire coming from the bottom electrode as the output.\n可以把控制线，当做输入 ( input ) \\N 底部的电极，当做输出（output）\n\nSo with a single transistor, we have one input and one output.\n所以 1 个晶体管，有一个输入和一个输出\n\nIf we turn the input on, the output is also on because the current can flow through it.\n如果我们打开输入（input on) \\N 输出也会打开（output on） \\N 因为电流可以流过\n\nIf we turn the input off, the output is also off and the current can no longer pass through.\n如果关闭输入（input off） \\N 输出也会关闭（output off）\\N 因为电流无法通过\n\nOr in boolean terms, when the input is true, the output is true.\n或者用布尔术语来说\\N 输入为 真，输出为 真\n\nAnd when the input is false, the output is also false.\n输入为 假 \\N 输出为 假\n\nWhich again we can show on a logic table.\n我们也可以把这个做成\"真值表\"\n\nThis isn't a very exciting circuit though because its not doing anything\n这个电路没什么意思，因为它没做什么事\n\n-- the input and output are the same.\n- 输入和输出是一样的\n\nBut, we can modify this circuit just a little bit to create a NOT.\n但我们可以稍加修改，实现 NOT\n\nInstead of having the output wire at the end of the transistor, we can move it before.\n与其把下面那根线当做 输出，我们可以把 输出 放到上面\n\nIf we turn the input on, the transistor allows current to pass through it to the \"ground\",\n如果打开 输入，电流可以流过然后 \"接地\"\n\nand the output wire won't receive that current\n输出就没有电流，所以输出是 off\n\n- so it will be off.\n输出就没有电流，所以输出是 off\n\nIn our water metaphor grounding would be like\n如果用水来举例\n\nif all the water in your house was flowing out of a huge hose\n就像家里的水都从一个大管子流走了\n\nso there wasn't any water pressure left for your shower.\n打开淋浴头一点水也没有\n\nSo in this case if the input is on, output is off.\n如果输入是 on，输出是 off\n\nWhen we turn off the transistor, though, current is prevented from flowing down it to the ground,\n当输入是 off，电流没法接地，就流过了输出，所以输出是 on\n\nso instead, current flows through the output wire.\n当输入是 off，电流没法接地，就流过了输出，所以输出是 on\n\nSo the input will be off and the output will be on.\n如果输入是 off，输出是 on\n\nAnd this matches our logic table for NOT, so congrats, we just built a circuit that computes NOT!\n和 NOT 操作表一样！太棒了！我们做了个有点用的电路！\n\nWe call them NOT gates - we call them gates because they're controlling the path of our current.\n我们叫它 \"NOT 门\" \\N 之所以叫 \"门\"，是因为它能控制电流的路径\n\nThe AND Boolean operation takes two inputs, but still has a single output.\n\"AND\"操作有 2 个输入，1 个输出\n\nIn this case the output is only true if both inputs are true.\n如果 2 个输入都是 true，输出才是 true\n\nThink about it like telling the truth.\n你可以想成是 说真话\n\nYou're only being completely honest if you don't lie even a little.\n如果完全不说谎，才是诚实\n\nFor example, let's take the statement,\n举例，看如下这个句子\n\n\"My name is Carrie Anne AND I'm wearing a blue dress\".\n我叫 Carrie Anne \"而且\"我穿着蓝色的衣服\n\nBoth of those facts are true, so the whole statement is true.\n2 个都是真的，所以整个是真的\n\nBut if I said, \"My name is Carrie Anne AND I'm wearing pants\" that would be false,\n但如果说，我叫 Carrie Anne\"而且\"我穿了裤子, 就是假的\n\nbecause I'm not wearing pants.\n因为我没穿裤子\n\nOr trousers.\n或长裤，如果你是英国人你会用这个词……（英/美单词不同梗）\n\nIf you're in England.\n或长裤，如果你是英国人你会用这个词……（英/美单词不同梗）\n\nThe Carrie Anne part is true, but a true AND a false, is still false.\n虽然前半句是真的，但是 真 \"AND\" 假，还是假\n\nIf I were to reverse that statement it would still obviously be false,\n就算把前后顺序反过来，也依然是 假\n\nand if I were to tell you two complete lies that is also false,\n如果我说 2 个假的事情，那么结果是假。\n\nand again we can write all of these combinations out in a table.\n和上次一样，可以给\"AND\"做个表\n\nTo build an AND gate, we need two transistors connected together\n为了实现 \"AND 门\"，我们需要 2 个晶体管连在一起\n\nso we have our two inputs and one output.\n这样有 2 个输入和 1 个输出\n\nIf we turn on just transistor A, current won't flow because the current is stopped by transistor B.\n如果只打开 A，不打开 B \\N 电流无法流到 output，所以输出是 false\n\nAlternatively, if transistor B is on, but the transistor A is off,\n如果只打开 B，不打开 A ，也一样，电流无法流到 output\n\nthe same thing, the current can't get through.\n如果只打开 B，不打开 A ，也一样，电流无法流到 output\n\nOnly if transistor A AND transistor B are on does the output wire have current.\n只有 A 和 B 都打开了，output 才有电流\n\nThe last boolean operation is OR\n最后一个是 OR （前面讲了 NOT 和 AND)\n\n-- where only one input has to be true for the output to be true.\n只要 2 个输入里，其中 1 个是 true，输出就是 true\n\nFor example, my name is Margaret Hamilton OR I'm wearing a blue dress.\n比如，我叫 Margaret Hamilton\"或\"我穿着蓝色衣服\n\nThis is a true statement because although I'm not Margaret Hamilton unfortunately,\n结果是 true，虽然我不是 Margaret Hamilton\n\nI am wearing a blue dress, so the overall statement is true.\n但是我穿着蓝色衣服，所以结果是 true\n\nAn OR statement is also true if both facts are true.\n对于\"OR 操作\"来说，\\N如果 2 个 输入都是 true，输出也是 true\n\nThe only time an OR statement is false is if both inputs are false.\n只有 2 个输入都是 false，OR 的结果才是 false\n\nBuilding an OR gate from transistors needs a few extra wires.\n实现 \"OR 门\" 除了晶体管还要额外的线\n\nInstead of having two transistors in series -- one after the other --\n不是串联起来。而是并联\n\nwe have them in parallel.\n不是串联起来。而是并联\n\nWe run wires from the current source to both transistors.\n然后左边这条线有电流输入\n\nWe use this little arc to note that the wires jump over one another and aren't connected,\n我们用\"小拱门\"代表 2 条线没连在一起，只是跨过而已\n\neven though they look like they cross.\n虽然看起来像连在一起\n\nIf both transistors are turned off, the current is prevented from flowing to the output,\n如果 A 和 B 都是 off，电流无法流过\n\nso the output is also off.\n所以输出是 off\n\nNow, if we turn on just Transistor A, current can flow to the output.\n如果打开 A，电流可以流过。输出是 on\n\nSame thing if transistor A is off, but Transistor B in on.\n如果只打开 B 也一样\n\nBasically if A OR B is on, the output is also on.\n只要 A OR B 是 on， 输出就是 on\n\nAlso, if both transistors are on, the output is still on.\n如果 A 和 B 都 on，结果是 on\n\nOk, now that we've got NOT, AND, and OR gates,\n好，现在 NOT 门, AND 门, OR 门 都搞定了\n\nand we can leave behind the constituent transistors and move up a layer of abstraction.\n我们可以进行一次抽象\n\nThe standard engineers use for these gates are a triangle with a dot for a NOT,\nNOT 门的画法是三角形前面一个圆点\n\na D for the AND, and a spaceship for the OR.\nAND 门用 D 表示 ，OR 门用太空船表示\n\nThose aren't the official names, but that's howI like to think of them.\n\"D 形状和太空船\"不是标准叫法, 只是我喜欢这样叫而已\n\nRepresenting them and thinking about them this way allows us to build even bigger components\n我们可以用这种方法表示它们，构建更大的组件\n\nwhile keeping the overall complexity relatively the same\n就不会变得很复杂\n\n- just remember that that mess of transistors and wires is still there.\n- 晶体管和电线依然在那里，我们只是用符号来代表而已\n\nFor example, another useful boolean operation in computation is called an Exclusive OR\n除了前面说的三个\\N 另一个有用的布尔操作叫 \"异或\"\n\n- or XOR for short.\n- 简称 XOR\n\nXOR is like a regular OR, but with one difference:\nXOR 就像普通 OR，但有一个区别：\n\nif both inputs are true, the XOR is false.\n如果 2 个输入都是 true，XOR 输出 false\n\nThe only time an XOR is true is when one input is true and the other input is false.\n想要 XOR 输出 true \\N 一个输入必须是 true，另一个必须是 false\n\nIt's like when you go out to dinner and your meal comes with a side salad OR a soup\n就像你出去吃晚饭，你点的饭要么配沙拉，要么配汤\n\n- sadly, you can't have both!\n- 你不能两个都要！\n\nAnd building this from transistors is pretty confusing,\n用晶体管实现 XOR 门有点烧脑子\n\nbut we can show how an XOR is created from our three basic boolean gates.\n但我可以展示一下\\N 怎么用前面提到的 3 种门来做 XOR 门\n\nWe know we have two inputs again -- A and B -- and one output.\n我们有 2 个输入，A 和 B ，还有 1 个输出.\n\nLet's start with an OR gate, since the logic table looks almost identical to an OR.\n我们先放一个 OR 门. 因为 OR 和 XOR 的逻辑表很像\n\nThere's only one problem - when A and B are true, the logic is different from OR,\n只有 1 个问题 - 当 A 和 B 都是 true 时 \\N OR 的输出和想要的 XOR 输出不一样\n\nand we need to output \"false\".\n我们想要 false\n\nAnd XOR turns out to be a very useful component,\nXOR 超有用的\n\nand we'll get to it in another episode,\n我们下次再说它\n\nso useful in fact engineers gave it its own symbol too -- an OR gate with a smile :)\n因为超有用，\\N 工程师给了它一个符号，一个 OR 门 + 一个笑脸\n\nBut most importantly, we can now put XOR into our metaphorical toolbox\n重要的是，现在可以把 XOR 放入\"工具箱\"了\n\nand not have to worry about the individual logic gates that make it up,\n不用担心 XOR 具体用了几个门\n\nor the transistors that make up those gates,\n这几个门又是怎么用晶体管拼的\n\nor how electrons are flowing through a semiconductor.\n或电子是怎么流过半导体的\n\nMoving up another layer of abstraction.\n再次向上抽象\n\nWhen computer engineers are designing processors, they rarely work at the transistor level,\n工程师设计处理器时，很少在晶体管的层面上思考，\n\nand instead work with much larger blocks, like logic gates, and even larger components\n而是用更大的组件，比如逻辑门，或者由逻辑门组成的更大组件，\n\nmade up of logic gates, which we'll discuss in future episodes.\n我们以后会讲\n\nAnd even if you are a professional computer programmer,\n就算是专业程序员\n\nit's not often that you think about\n也不用考虑逻辑是怎样在物理层面实现的\n\nhow the logic that you are programming is actually implemented\n也不用考虑逻辑是怎样在物理层面实现的\n\nin the physical world by these teeny tiny components.\n也不用考虑逻辑是怎样在物理层面实现的\n\nWe've also moved from thinking about raw electrical signals to our first representation of data\n我们从电信号开始，到现在第一次表示数据\n\n- true and false - and we've even gotten a little taste of computation.\n- 真和假 - 开始有点\"计算\"的感觉了\n\nWith just the logic gates in this episode,\n仅用这集讲的 逻辑门\n\nwe could build a machine that evaluates complex logic statements,\n我们可以判断复杂的语句 比如：\n\nlike if \"Name is John Green AND after 5pm OR is Weekend AND near Pizza Hut\",\n[如果是 John Green] AND [下午 5 点后] \\N OR [周末] AND [在比萨店附近]\n\nthen \"John will want pizza\" equals true.\n那么 \"John 想要比萨\" = 真\n\nAnd with that, I'm starving, I'll see you next week.\n我都说饿了，下周见\n\nHi I'm Carrie Anne, this is Crash Course Computer Science\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nand today we're going to talk about how computers store and represent numerical data.\n今天，我们讲计算机如何存储和表示数字\n\nWhich means we've got to talk about Math!\n所以会有一些数学\n\nBut don't worry.\n不过别担心\n\nEvery single one of you already knows exactly what you need to know to follow along.\n你们的数学水平绝对够用了\n\nSo, last episode we talked about how transistors can be used to build logic gates,\n上集我们讲了，怎么用晶体管做逻辑门\n\nwhich can evaluate boolean statements.\n逻辑门可以判断布尔语句\n\nAnd in boolean algebra, there are only two, binary values: true and false.\n布尔代数只有两个值：True 和 False\n\nBut if we only have two values,\n但如果只有两个值，我们怎么表达更多东西？\n\nhow in the world do we represent information beyond just these two values?\n但如果只有两个值，我们怎么表达更多东西？\n\nThat's where the Math comes in.\n这就需要数学了\n\nSo, as we mentioned last episode, a single binary value can be used to represent a number.\n上集提到，1 个二进制值可以代表 1 个数\n\nInstead of true and false, we can call these two states 1 and 0 which is actually incredibly useful.\n我们可以把真和假 ，当做 1 和 0\n\nAnd if we want to represent larger things we just need to add more binary digits.\n如果想表示更多东西，加位数就行了\n\nThis works exactly the same way as the decimal numbers that we're all familiar with.\n和我们熟悉的十进制一样\n\nWith decimal numbers there are \"only\" 10 possible values a single digit can be; 0 through 9,\n十进制只有 10 个数（0到9）\n\nand to get numbers larger than 9 we just start adding more digits to the front.\n要表示大于 9 的数，加位数就行了\n\nWe can do the same with binary.\n二进制也可以这样玩\n\nFor example, let's take the number two hundred and sixty three.\n拿 263 举例\n\nWhat does this number actually represent?\n这个数字 \"实际\" 代表什么？\n\nWell, it means we've got 2 one-hundreds, 6 tens, and 3 ones.\n2 个 100 \\N6 个 10 \\N 3 个 1\n\nIf you add those all together, we've got 263.\n加在一起，就是 263\n\nNotice how each column has a different multiplier.\n注意每列有不同的乘数\n\nIn this case, it's 100, 10, and 1.\n100, 10, 1\n\nEach multiplier is ten times larger than the one to the right.\n每个乘数都比右边大十倍\n\nThat's because each column has ten possible digits to work with, 0 through 9,\n因为每列有 10 个可能的数字（0到9）\n\nafter which you have to carry one to the next column.\n如果超过 9，要在下一列进 1.\n\nFor this reason, it's called base-ten notation, also called decimal since deci means ten.\n因此叫 \"基于十的表示法\"  或十进制\n\nAND Binary works exactly the same way, it's just base-two.\n二进制也一样，只不过是基于 2 而已\n\nThat's because there are only two possible digits in binary - 1 and 0.\n因为二进制只有两个可能的数， 1 和 0\n\nThis means that each multiplier has to be two times larger than the column to its right.\n意味着每个乘数必须是右侧乘数的两倍\n\nInstead of hundreds, tens, and ones, we now have fours, twos and ones.\n就不是之前的 100, 10, 1 \\N 而是 4, 2, 1\n\nTake for example the binary number: 101.\n拿二进制数 101 举例\n\nThis means we have 1 four, 0 twos, and 1 one.\n意味着有\\N 1个 \"4\"  \\N 0个 \"2\"  \\N 1个 \"1\"\n\nAdd those all together and we've got the number 5 in base ten.\n加在一起，得到十进制的 5\n\nBut to represent larger numbers, binary needs a lot more digits.\n为了表示更大的数字，二进制需要更多位数\n\nTake this number in binary 10110111.\n拿二进制数 10110111 举例\n\nWe can convert it to decimal in the same way.\n我们可以用相同的方法转成十进制\n\nWe have 1 x 128, 0 x 64, 1 x 32, 1 x 16, 0 x 8, 1 x 4, 1 x 2, and 1 x 1.\n1 x 128 ，0 x 64 ，1 x 32 ，1 x 16 \\N 0 x 8 ，1 x 4 ，1 x 2 ，1 x 1\n\nWhich all adds up to 183.\n加起来等于 183\n\nMath with binary numbers isn't hard either.\n二进制数的计算也不难\n\nTake for example decimal addition of 183 plus 19.\n以十进制数 183 加 19 举例\n\nFirst we add 3 + 9, that's 12, so we put 2 as the sum and carry 1 to the ten's column.\n首先 3 + 9，得到 12，然后位数记作 2，向前进 1\n\nNow we add 8 plus 1 plus the 1 we carried, thats 10, so the sum is 0 carry 1.\n现在算 8+1+1=10，所以位数记作0，再向前进 1\n\nFinally we add 1 plus the 1 we carried, which equals 2.\n最后 1+1=2，位数记作2\n\nSo the total sum is 202.\n所以和是202\n\nHere's the same sum but in binary.\n二进制也一样\n\nJust as before, we start with the ones column.\n和之前一样，从个位开始\n\nAdding 1+1 results in 2, even in binary.\n1+1=2，在二进制中也是如此\n\nBut, there is no symbol \"2\" so we use 10 and put 0 as our sum and carry the 1.\n但二进制中没有 2，所以位数记作 0 ，进 1\n\nJust like in our decimal example.\n就像十进制的例子一样\n\n1 plus 1, plus the 1 carried,\n1+1，再加上进位的1\n\nequals 3 or 11 in binary,\n等于 3，用二进制表示是 11\n\nso we put the sum as 1 and we carry 1 again, and so on.\n所以位数记作 1，再进 1，以此类推\n\nWe end up with this number, which is the same as the number 202 in base ten.\n最后得到这个数字，跟十进制 202 是一样的\n\nEach of these binary digits, 1 or 0, is called a \"bit\".\n二进制中，一个 1 或 0  叫一\"位\"\n\nSo in these last few examples, we were using 8-bit numbers with their lowest value of zero\n上个例子我们用了 8 位 , 8 位能表示的最小数是 0,  8位都是0\n\nand highest value is 255, which requires all 8 bits to be set to 1.\n最大数是 255，8 位都是 1\n\nThats 256 different values, or 2 to the 8th power.\n能表示 256 个不同的值，2 的 8 次方\n\nYou might have heard of 8-bit computers, or 8-bit graphics or audio.\n你可能听过 8 位机，8 位图像，8 位音乐\n\nThese were computers that did most of their operations in chunks of 8 bits.\n意思是计算机里\\N 大部分操作都是 8 位 8 位这样处理的\n\nBut 256 different values isn't a lot to work with, so it meant things like 8-bit games\n但 256 个值不算多，意味着 8位游戏只能用 256 种颜色\n\nwere limited to 256 different colors for their graphics.\n但 256 个值不算多，意味着 8位游戏只能用 256 种颜色\n\nAnd 8-bits is such a common size in computing, it has a special word: a byte.\n8 位是如此常见，以至于有专门的名字：字节\n\nA byte is 8 bits.\n1 字节 = 8 位 \\N 1 bytes = 8 bits\n\nIf you've got 10 bytes, it means you've really got 80 bits.\n如果有 10 个字节，意味着有 80 位\n\nYou've heard of kilobytes, megabytes, gigabytes and so on.\n你听过 千字节（KB）兆字节（MB）千兆字节（GB）等等\n\nThese prefixes denote different scales of data.\n不同前缀代表不同数量级\n\nJust like one kilogram is a thousand grams,\n就像 1 千克 = 1000 克，1 千字节 = 1000 字节\n\n1 kilobyte is a thousand bytes.\n就像 1 千克 = 1000 克，1 千字节 = 1000 字节\n\nor really 8000 bits.\n或 8000 位\n\nMega is a million bytes (MB), and giga is a billion bytes (GB).\nMega 是百万字节（MB）, Giga 是十亿字节（GB）\n\nToday you might even have a hard drive that has 1 terabyte (TB) of storage.\n如今你可能有 1 TB 的硬盘\n\nThat's 8 trillion ones and zeros.\n8 万亿个1和0\n\nBut hold on!\n等等，我们有另一种计算方法\n\nThat's not always true.\n等等，我们有另一种计算方法\n\nIn binary, a kilobyte has two to the power of 10 bytes, or 1024.\n二进制里，1 千字节 = 2的10次方 = 1024 字节\n\n1000 is also right when talking about kilobytes,\n1000 也是千字节（KB）的正确单位\n\nbut we should acknowledge it isn't the only correct definition.\n1000 和 1024 都对\n\nYou've probably also heard the term 32-bit or 64-bit computers\n你可能听过 32 位 或 64 位计算机\n\nyou're almost certainly using one right now.\n你现在用的电脑几乎肯定是其中一种\n\nWhat this means is that they operate in chunks of 32 or 64 bits.\n意思是一块块处理数据，每块是 32 位或 64 位\n\nThat's a lot of bits!\n这可是很多位\n\nThe largest number you can represent with 32 bits is just under 4.3 billion.\n32 位能表示的最大数，是 43 亿左右\n\nWhich is thirty-two 1's in binary.\n也就是 32 个 1\n\nThis is why our Instagram photos are so smooth and pretty\n所以 Instagram 照片很清晰\n\n- they are composed of millions of colors,\n- 它们有上百万种颜色\n\nbecause computers today use 32-bit color graphics\n因为如今都用 32 位颜色\n\nOf course, not everything is a positive number\n当然，不是所有数都是正数\n\n- like my bank account in college.\n比如我上大学时的银行账户 T_T\n\nSo we need a way to represent positive and negative numbers.\n我们需要有方法表示正数和负数\n\nMost computers use the first bit for the sign:\n大部分计算机用第一位表示正负：\n\n1 for negative, 0 for positive numbers,\n1 是负，0 是正\n\nand then use the remaining 31 bits for the number itself.\n用剩下 31 位来表示符号外的数值\n\nThat gives us a range of roughly plus or minus two billion.\n能表示的数的范围大约是正 20 亿到负 20 亿\n\nWhile this is a pretty big range of numbers, it's not enough for many tasks.\n虽然是很大的数，但许多情况下还不够用\n\nThere are 7 billion people on the earth, and the US national debt is almost 20 trillion dollars after all.\n全球有 70 亿人口，美国国债近 20 万亿美元\n\nThis is why 64-bit numbers are useful.\n所以 64 位数很有用\n\nThe largest value a 64-bit number can represent is around 9.2 quintillion!\n64 位能表达最大数大约是 9.2×10 ^ 18\n\nThat's a lot of possible numbers and will hopefully stay above the US national debt for a while!\n希望美国国债在一段时间内不会超过这个数！\n\nMost importantly, as we'll discuss in a later episode,\n重要的是（我们之后的视频会深入讲）\n\ncomputers must label locations in their memory,\n计算机必须给内存中每一个位置，做一个 \"标记\"\n\nknown as addresses, in order to store and retrieve values.\n这个标记叫 \"地址\", 目的是为了方便存取数据\n\nAs computer memory has grown to gigabytes and terabytes - that's trillions of bytes\n如今硬盘已经增长到 GB 和 TB，上万亿个字节！\n\nit was necessary to have 64-bit memory addresses as well.\n内存地址也应该有 64 位\n\nIn addition to negative and positive numbers,\n除了负数和正数，计算机也要处理非整数\n\ncomputers must deal with numbers that are not whole numbers,\n除了负数和正数，计算机也要处理非整数\n\nlike 12.7 and 3.14, or maybe even stardate: 43989.1.\n比如 12.7 和 3.14，或\"星历 43989.1\"\n\nThese are called \"floating point\" numbers,\n这叫 浮点数\n\nbecause the decimal point can float around in the middle of number.\n因为小数点可以在数字间浮动\n\nSeveral methods have been developed to represent floating point numbers.\n有好几种方法 表示浮点数\n\nThe most common of which is the IEEE 754 standard.\n最常见的是 IEEE 754 标准\n\nAnd you thought historians were the only people bad at naming things!\n你以为只有历史学家取名很烂吗？\n\nIn essence, this standard stores decimal values sort of like scientific notation.\n它用类似科学计数法的方法，来存十进制值\n\nFor example, 625.9 can be written as 0.6259 x 10^3.\n例如，625.9 可以写成 0.6259×10 ^ 3\n\nThere are two important numbers here: the .6259 is called the significand.\n这里有两个重要的数：.6259 叫 \"有效位数\" , 3 是指数\n\nAnd 3 is the exponent.\n这里有两个重要的数：.6259 叫 \"有效位数\" , 3 是指数\n\nIn a 32-bit floating point number,\n在 32 位浮点数中\n\nthe first bit is used for the sign of the number -- positive or negative.\n第 1 位表示数的符号——正或负\n\nThe next 8 bits are used to store the exponent\n接下来 8 位存指数\n\nand the remaining 23 bits are used to store the significand.\n剩下 23 位存有效位数\n\nOk, we've talked a lot about numbers, but your name is probably composed of letters,\n好了，聊够数了，但你的名字是字母组成的\n\nso it's really useful for computers to also have a way to represent text.\n所以我们也要表示文字\n\nHowever, rather than have a special form of storage for letters,\n与其用特殊方式来表示字母 \\N 计算机可以用数表示字母\n\ncomputers simply use numbers to represent letters.\n与其用特殊方式来表示字母 \\N 计算机可以用数表示字母\n\nThe most straightforward approach might be to simply number the letters of the alphabet:\n最直接的方法是给字母编号：\n\nA being 1, B being 2, C 3, and so on.\nA是1，B是2，C是3，以此类推\n\nIn fact, Francis Bacon, the famous English writer,\n著名英国作家 弗朗西斯·培根（Francis Bacon）\n\nused five-bit sequences to encode all 26 letters of the English alphabet\n曾用 5位序列 来编码英文的 26 个字母\n\nto send secret messages back in the 1600s.\n在十六世纪传递机密信件\n\nAnd five bits can store 32 possible values - so that's enough for the 26 letters,\n五位（bit）可以存 32 个可能值（2^5） - 这对26个字母够了\n\nbut not enough for punctuation, digits, and upper and lower case letters.\n但不能表示 标点符号，数字和大小写字母\n\nEnter ASCII, the American Standard Code for Information Interchange.\nASCII，美国信息交换标准代码\n\nInvented in 1963, ASCII was a 7-bit code, enough to store 128 different values.\n发明于 1963 年，ASCII 是 7 位代码，足够存 128 个不同值\n\nWith this expanded range, it could encode capital letters, lowercase letters,\n范围扩大之后，可以表示大写字母，小写字母,\n\ndigits 0 through 9, and symbols like the @ sign and punctuation marks.\n数字 0 到 9, @ 这样的符号, 以及标点符号\n\nFor example, a lowercase 'a' is represented by the number 97, while a capital 'A' is 65.\n举例，小写字母 a 用数字 97 表示，大写字母 A 是 65\n\nA colon is 58 and a closed parenthesis is 41.\n: 是58  \\n ) 是41\n\nASCII even had a selection of special command codes,\nASCII 甚至有特殊命令符号\n\nsuch as a newline character to tell the computer where to wrap a line to the next row.\n比如换行符，用来告诉计算机换行\n\nIn older computer systems,\n在老计算机系统中\n\nthe line of text would literally continue off the edge of the screen if you didn't include a new line character!\n如果没换行符，文字会超出屏幕\n\nBecause ASCII was such an early standard,\n因为 ASCII 是个很早的标准\n\nit became widely used,\n所以它被广泛使用\n\nand critically, allowed different computers built by different companies to exchange data.\n让不同公司制作的计算机，能互相交换数据\n\nThis ability to universally exchange information is called \"interoperability\".\n这种通用交换信息的能力叫 \"互操作性\"\n\nHowever, it did have a major limitation: it was really only designed for English.\n但有个限制：它是为英语设计的\n\nFortunately, there are 8 bits in a byte, not 7,\n幸运的是，一个字节有8位，而不是7位\n\nand it soon became popular to use codes 128 through 255,\n128 到 255 的字符渐渐变得常用\n\npreviously unused, for \"national\" characters.\n这些字符以前是空的，是给各个国家自己  \"保留使用的\"\n\nIn the US, those extra numbers were largely used to encode additional symbols,\n在美国，这些额外的数字主要用于编码附加符号\n\nlike mathematical notation, graphical elements, and common accented characters.\n比如数学符号，图形元素和常用的重音字符\n\nOn the other hand, while the Latin characters were used universally,\n另一方面，虽然拉丁字符被普遍使用\n\nRussian computers used the extra codes to encode Cyrillic characters,\n在俄罗斯，他们用这些额外的字符表示西里尔字符\n\nand Greek computers, Greek letters, and so on.\n而希腊电脑用希腊字母，等等\n\nAnd national character codes worked pretty well for most countries.\n这些保留下来给每个国家自己安排的空位，\\N 对大部分国家都够用\n\nThe problem was,\n问题是\n\nif you opened an email written in Latvian on a Turkish computer,\n如果在 土耳其 电脑上打开 拉脱维亚语 写的电子邮件\n\nthe result was completely incomprehensible.\n会显示乱码\n\nAnd things totally broke with the rise of computing in Asia,\n随着计算机在亚洲兴起，这种做法彻底失效了\n\nas languages like Chinese and Japanese have thousands of characters.\n中文和日文这样的语言有数千个字符\n\nThere was no way to encode all those characters in 8-bits!\n根本没办法用 8 位来表示所有字符！\n\nIn response, each country invented multi-byte encoding schemes,\n为了解决这个问题，每个国家都发明了多字节编码方案\n\nall of which were mutually incompatible.\n但相互不兼容\n\nThe Japanese were so familiar with this encoding problem that they had a special name for it:\n日本人总是碰到编码问题，以至于专门有词来称呼：\n\n\"mojibake\", which means \"scrambled text\".\n\"mojibake\" 意思是 乱码\n\nAnd so it was born - Unicode - one format to rule them all.\n所以 Unicode 诞生了 - 统一所有编码的标准\n\nDevised in 1992 to finally do away with all of the different international schemes\n设计于 1992 年，解决了不同国家不同标准的问题\n\nit replaced them with one universal encoding scheme.\nUnicode 用一个统一编码方案\n\nThe most common version of Unicode uses 16 bits with space for over a million codes -\n最常见的 Unicode 是 16 位的，有超过一百万个位置 -\n\nenough for every single character from every language ever used\n对所有语言的每个字符都够了\n\nmore than 120,000 of them in over 100 types of script\n100 多种字母表加起来占了 12 万个位置。\n\nplus space for mathematical symbols and even graphical characters like Emoji.\n还有位置放数学符号，甚至 Emoji\n\nAnd in the same way that ASCII defines a scheme for encoding letters as binary numbers,\n就像 ASCII 用二进制来表示字母一样\n\nother file formats - like MP3s or GIFs -\n其他格式 - 比如 MP3 或 GIF  -\n\nuse binary numbers to encode sounds or colors of a pixel in our photos, movies, and music.\n用二进制编码声音/颜色，表示照片,电影,音乐\n\nMost importantly, under the hood it all comes down to long sequences of bits.\n重要的是，这些标准归根到底是一长串位\n\nText messages, this YouTube video, every webpage on the internet,\n短信，这个 YouTube 视频，互联网上的每个网页\n\nand even your computer's operating system, are nothing but long sequences of 1s and 0s.\n甚至操作系统，只不过是一长串 1 和 0\n\nSo next week,\n下周\n\nwe'll start talking about how your computer starts manipulating those binary sequences,\n我们会聊计算机怎么操作二进制\n\nfor our first true taste of computation.\n初尝\"计算\"的滋味\n\nThanks for watching. See you next week.\n感谢观看，下周见\n\nHi, I'm Carrie Ann and this is Crash Course Computer Science.\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课\n\nSo last episode, we talked about how numbers can be represented in binary.\n上集，我们谈了如何用二进制表示数字\n\nRepresenting Like, 00101010 is 42 in decimal.\n比如二进制 00101010 是十进制的 42\n\nRepresenting and storing numbers is an important function of a computer,\n表示和存储数字是计算机的重要功能\n\nbut the real goal is computation, or manipulating numbers in a structured and purposeful way,\n但真正的目标是计算，有意义的处理数字\n\nlike adding two numbers together.\n比如把两个数字相加\n\nThese operations are handled by a computer's Arithmetic and Logic Unit,\n这些操作由计算机的 \"算术逻辑单元 \"处理\n\nbut most people call it by its street name:\n但大家会简称：ALU\n\nthe ALU.\n但大家会简称：ALU\n\nThe ALU is the mathematical brain of a computer.\nALU 是计算机的数学大脑\n\nWhen you understand an ALU's design and function,\n等你理解了 ALU 的设计和功能之后\n\nyou'll understand a fundamental part of modern computers.\n你就理解了现代计算机的基石\n\nIt is THE thing that does all of the computation in a computer,\nALU *就是* 计算机里负责运算的组件\\N 基本其他所有部件都用到了它\n\nso basically everything uses it.\nALU *就是* 计算机里负责运算的组件\\N 基本其他所有部件都用到了它\n\nFirst though, look at this beauty.\n先来看看这个美人\n\nThis is perhaps the most famous ALU ever, the Intel 74181.\n这可能是最著名的 ALU，英特尔 74181\n\nWhen it was released in 1970,\n1970 年发布时，它是第一个封装在单个芯片内的完整 ALU\n\nit was It was the first complete ALU that fit entirely inside of a single chip -\n1970 年发布时，它是第一个封装在单个芯片内的完整 ALU\n\nWhich was a huge engineering feat at the time.\n这在当时是惊人的工程壮举\n\nSo today we're going to take those Boolean logic gates we learned about last week\n今天我们用上周学的布尔逻辑门\n\nto build a simple ALU circuit with much of the same functionality as the 74181.\n做一个简单的 ALU 电路，功能和 74181 一样\n\nAnd over the next few episodes we'll use this to construct a computer from scratch.\n然后接下来几集，用它从头做出一台电脑\n\nSo it's going to get a little bit complicated,\n所以会有点复杂\n\nbut I think you guys can handle it.\n但我觉得你们搞的定\n\nAn ALU is really two units in one\nALU 有 2 个单元，1 个算术单元和 1 个逻辑单元\n\n-- there's an arithmetic unit and a logic unit.\nALU 有 2 个单元，1 个算术单元和 1 个逻辑单元\n\nLet's start with the arithmetic unit,\n我们先讲\"算术单元\"，它负责计算机里的所有数字操作\n\nwhich is responsible for handling all numerical operations in a computer,\n我们先讲\"算术单元\"，它负责计算机里的所有数字操作\n\nlike addition and subtraction.\n比如加减法\n\nIt also does a bunch of other simple things like add one to a number,\n它还做很多其他事情，比如给某个数字+1\n\nwhich is called an increment operation, but we'll talk about those later.\n这叫增量运算，我们之后会说\n\nToday, we're going to focus on the piece of rsistance, the crme de la crme of operations\n今天的重点是一切的根本 - \"把两个数字相加\"\n\nthat underlies almost everything else a computer does - adding two numbers together.\n今天的重点是一切的根本 - \"把两个数字相加\"\n\nWe could build this circuit entirely out of individual transistors,\n我们可以用单个晶体管一个个拼，把这个电路做出来，\\N 但很快就会复杂的难以理解\n\nbut that would get confusing really fast.\n我们可以用单个晶体管一个个拼，把这个电路做出来，\\N 但很快就会复杂的难以理解\n\nSo instead as we talked about in Episode 3\n所以与其用晶体管，我们会像第 3 集\n\n- we can use a high-level of abstraction and build our components out of logic gates,\n- 用更高层的抽象，用逻辑门来做\n\nin this case: AND, OR, NOT and XOR gates.\n我们会用到 AND，OR，NOT 和 XOR 逻辑门\n\nThe simplest adding circuit that we can build takes two binary digits, and adds them together.\n最简单的加法电路， \\N 是拿 2 个 bit 加在一起（bit 是 0 或 1）\n\nSo we have two inputs, A and B, and one output, which is the sum of those two digits.\n有 2 个输入：A 和 B， 1 个输出：就是两个数字的和\n\nJust to clarify: A, B and the output are all single bits.\n需要注意的是：A, B, 输出，这3个都是单个 Bit （ 0 或 1 ）\n\nThere are only four possible input combinations.\n输入只有四种可能\n\nThe first three are: 0+0 = 0\n前三个是\\N 0 + 0 = 0 \\N 1 + 0 = 1 \\N 0 + 1 = 1\n\n1+0 = 1 0+1 = 1\n前三个是\\N 0 + 0 = 0 \\N 1 + 0 = 1 \\N 0 + 1 = 1\n\nRemember that in binary, 1 is the same as true, and 0 is the same as false.\n记住二进制里，1 与 true 相同，0 与 false 相同\n\nSo this set of inputs exactly matches the boolean logic of an XOR gate,\n这组输入和输出，和 XOR 门的逻辑完全一样\n\nand we can use it as our 1-bit adder.\n所以我们可以把 XOR 用作 1 位加法器（adder）\n\nBut the fourth input combination, 1 + 1, is a special case. 1 + 1 is 2 (obviously)\n但第四个输入组合，1+1，是个特例 \\N 1+1=2（显然）\n\nbut there's no 2 digit in binary,\n但二进制里没有 2\n\nso as we talked about last episode, the result is 0 and the 1 is carried to the next column.\n上集说过，二进制 1+1 的结果是0，1进到下一位\n\nSo the sum is really 10 in binary.\n和是 10 (二进制)\n\nNow, the output of our XOR gate is partially correct - 1 plus 1, outputs 0.\nXOR 门的输出，只对了一部分， 1+1 输出 0\n\nBut, we need an extra output wire for that carry bit.\n但我们需要一根额外的线代表 \"进位\"\n\nThe carry bit is only \"true\" when the inputs are 1 AND 1,\n只有输入是 1 和 1 时，进位才是 \"true\"\n\nbecause that's the only time when the result (two) is bigger than 1 bit can store\n因为算出来的结果用 1 个 bit 存不下\n\nand conveniently we have a gate for that!\n方便的是，我们刚好有个逻辑门能做这个事！\n\nIt's not that complicated - just two logic gates -\n没那么复杂 - 就两个逻辑门而已\n\nbut let's abstract away even this level of detail\n让我们抽象化\n\nand encapsulate our newly minted half adder as its own component,\n把 \"半加器\" 封装成一个单独组件\n\nwith two inputs - bits A and B - and two outputs, the sum and the carry bits.\n两个输入   A 和 B 都是 1 位 \\N 两个输出  \"总和\" 与 \"进位\"\n\nThis takes us to another level of abstraction\n这进入了另一层抽象\n\nheh I feel like I say that a lot.\n我好像说了很多次，说不定会变成一个梗\n\nI wonder if this is going to become a thing.\n我好像说了很多次，说不定会变成一个梗\n\nAnyway, If you want to add more than 1 + 1\n如果想处理超过 1+1 的运算，我们需要\"全加器\"\n\nwe're going to need a \"Full Adder.\"\n如果想处理超过 1+1 的运算，我们需要\"全加器\"\n\nThat half-adder left us with a carry bit as output.\n半加器 输出了进位\n\nThat means that when we move on to the next column in a multi-column addition,\n意味着，我们算下一列的时候\n\nand every column after that, we are going to have to add three bits together, no two.\n还有之后的每一列，我们得加 3 个位在一起，并不是 2 个\n\nA full adder is a bit more complicated\n全加器复杂了一点点\n\n全加器表格\n\n- it takes three bits as inputs: A, B and C.\n有 3 个输入：A, B, C （都是 1 个 bit)\n\nSo the maximum possible input is 1 + 1 + 1,\n所以最大的可能是 1 + 1 + 1\n\nwhich equals 1 carry out 1, so we still only need two output wires: sum and carry.\n\"总和\"1 \"进位\"1 \\N 所以要两条输出线： \"总和\"和\"进位\"\n\nWe can build a full adder using half adders.\n我们可以用 半加器 做 全加器\n\nTo do this, we use a half adder to add A plus B\n我们先用半加器将 A 和 B 相加\n\njust like before - but then feed that result and input C into a second half adder.\n然后把 C 输入到第二个半加器\n\nLastly, we need a OR gate to check if either one of the carry bits was true.\n最后用一个 OR 门检查进位是不是 true\n\nThat's it, we just made a full adder!\n这样就做出了一个全加器！\n\nAgain,we can go up a level of abstraction and wrap up this full adder as its own component.\n我们可以再提升一层抽象，把全加器作为独立组件\n\nIt takes three inputs, adds them, and outputs the sum and the carry, if there is one.\n全加器会把 A，B，C 三个输入加起来 \\N 输出 \"总和\" 和 \"进位\"\n\nArmed with our new components, we can now build a circuit that takes two, 8-bit numbers\n现在有了新组件，我们可以相加两个 8 位数字\n\nLet's call them A and B  and adds them together.\n叫两个数字叫 A 和 B 好了\n\nLet's start with the very first bit of A and B,\n我们从 A  和 B 的第一位开始\n\nwhich we'll call A0 and B0.\n叫 A0 和 B0 好了\n\nAt this point, there is no carry bit to deal with,\n现在不用处理任何进位，因为是第一次加法\n\nbecause this is our first addition.\n现在不用处理任何进位，因为是第一次加法\n\nSo we can use our half adder to add these two bits together.\n所以我们可以用半加器，来加这2个数字\n\nThe output is sum0.\n输出叫 sum0\n\nNow we want to add A1 and B1 together.\n现在加 A1 和 B1\n\nIt's possible there was a carry from the previous addition of A0 and B0,\n因为 A0 和 B0 的结果有可能进位\n\nso this time we need to use a full adder that also inputs the carry bit.\n所以这次要用全加器，除了 A1 和 B1，还要连上进位\n\nWe output this result as sum1.\n输出叫 sum1\n\nThen, we take any carry from this full adder,\n然后，把这个全加器的进位 \\N 连到下个全加器的输入，处理 A2 和 B2\n\nand run it into the next full adder that handles A2 and B2.\n然后，把这个全加器的进位 \\N 连到下个全加器的输入，处理 A2 和 B2\n\nAnd we just keep doing this in a big chain until all 8 bits have been added.\n以此类推，把 8 个 bit 都搞定\n\nNotice how the carry bits ripple forward to each subsequent adder.\n注意每个进位是怎么连到下一个全加器的\n\nFor this reason, this is called an 8-bit ripple carry adder.\n所以叫 \"8位行波进位加法器\"\n\nNotice how our last full adder has a carry out.\n注意最后一个全加器有 \"进位\" 的输出\n\nIf there is a carry into the 9th bit, it means the sum of the two numbers is too large to fit into 8-bits.\n如果第 9 位有进位，代表着 2 个数字的和太大了，超过了 8 位\n\nThis is called an overflow.\n这叫 \"溢出\" (overflow)\n\nIn general, an overflow occurs when the result of an addition is too large\n一般来说 \"溢出\" 的意思是, 两个数字的和太大了\n\nto be represented by the number of bits you are using.\n超过了用来表示的位数\n\nThis can usually cause errors and unexpected behavior.\n这会导致错误和不可预期的结果\n\nFamously, the original PacMan arcade game used 8 bits to keep track of what level you were on.\n著名的例子是，吃豆人用 8 位存当前关卡数\n\nThis meant that if you made it past level 255 - the largest number storablein 8 bits - to level 256,\n如果你玩到了第 256 关（ 8 位 bit 最大表示 255）\n\nthe ALU overflowed.\nALU 会溢出\n\nThis caused a bunch of errors and glitches making the level unbeatable.\n造成一连串错误和乱码，使得该关卡无法进行\n\nThe bug became a rite of passage for the greatest PacMan players.\n这个 bug 成了厉害吃豆人玩家的代表\n\nSo if we want to avoid overflows,\n如果想避免溢出\n\nwe can extend our circuit with more full adders, allowing us to add 16 or 32 bit numbers.\n我们可以加更多全加器，可以操作 16 或 32 位数字\n\nThis makes overflows less likely to happen, but at the expense of more gates.\n让溢出更难发生，但代价是更多逻辑门\n\nAn additional downside is that it takes a little bit of time for each of the carries to ripple forward.\n另外一个缺点是，每次进位都要一点时间\n\nAdmittedly, not very much time, electrons move pretty fast,\n当然时间不久，因为电子移动的很快\n\nso we're talking about billionths of a second,\n但如今的量级是每秒几十亿次运算，所以会造成影响\n\nbut that's enough to make a difference in today's fast computers.\n但如今的量级是每秒几十亿次运算，所以会造成影响\n\nFor this reason, modern computers use a slightly different adding circuit\n所以，现代计算机用的加法电路有点不同\n\ncalled a 'carry-look-ahead' adder\n叫 \"超前进位加法器\"\n\nwhich is faster, but ultimately does exactly the same thing\n它更快，做的事情是一样的 - 把二进制数相加\n\n-- adds binary numbers.\n它更快，做的事情是一样的 - 把二进制数相加\n\nThe ALU's arithmetic unit also has circuits for other math operations\nALU 的算术单元，也能做一些其他数学运算\n\nand in general these 8 operations are always supported.\n一般支持这 8 个操作\n\nAnd like our adder, these other operations are built from individual logic gates.\n就像加法器一样，这些操作也是由逻辑门构成的\n\nInterestingly, you may have noticed that there are no multiply and divide operations.\n有趣的是，你可能注意到没有乘法和除法\n\nThat's because simple ALUs don't have a circuit for this,\n因为简单的 ALU 没有专门的电路来处理\n\nand instead just perform a series of additions.\n而是把乘法用多次加法来实现\n\nLet's say you want to multiply 12 by 5.\n假设想算 12x5\n\nThat's the same thing as adding 12 to itself 5 times.\n这和把 \"12\" 加 5 次是一样的\n\nSo it would take 5 passes through the ALU to do this one multiplication.\n所以要 5 次 ALU 操作来实现这个乘法\n\nAnd this is how many simple processors,\n很多简单处理器都是这样做的\n\nlike those in your thermostat, TV remote, and microwave, do multiplication.\n比如恒温器，电视遥控器和微波炉\n\nIt's slow, but it gets the job done.\n慢是慢，但是搞的定\n\nHowever, fancier processors, like those in your laptop or smartphone,\n然而笔记本和手机有更好的处理器\n\nhave arithmetic units with dedicated circuits for multiplication.\n有专门做乘法的算术单元\n\nAnd as you might expect, the circuit is more complicated than addition\n你可能猜到了，乘法电路比加法复杂\n\n-- there's no magic, it just takes a lot more logic gates\n- 没什么魔法，只是更多逻辑门\n\nwhich is why less expensive processors don't have this feature.\n所以便宜的处理器没有.\n\nOk, let's move on to the other half of the ALU:\n好了，我们现在讲 ALU 的另一半：逻辑单元\n\nthe Logic Unit.\n好了，我们现在讲 ALU 的另一半：逻辑单元\n\nInstead of arithmetic operations, the Logic Unit performs well...\n逻辑单元执行逻辑操作\n\nlogical operations, like AND, OR and NOT, which we've talked about previously.\n比如之前讨论过的 AND，OR 和 NOT 操作\n\nIt also performs simple numerical tests,\n它也能做简单的数值测试\n\nlike checking if a number is negative.\n比如一个数字是不是负数\n\nFor example, here's a circuit that tests if the output of the ALU is zero.\n例如，这是检查 ALU 输出是否为 0 的电路\n\nIt does this using a bunch of OR gates to see if any of the bits are 1.\n它用一堆 OR 门检查其中一位是否为 1\n\nEven if one single bit is 1,\n哪怕只有一个 Bit (位) 是1，\n\nwe know the number can't be zero and then we use a final NOT gate to flip this input\n我们就知道那个数字肯定不是 0，然后用一个 NOT 门取反\n\nso the output is 1 only if the input number is 0.\n所以只有输入的数字是 0，输出才为 1\n\nSo that's a high level overview of what makes up an ALU.\n以上就是 ALU 的一个高层次概括\n\nWe even built several of the main components from scratch, like our ripple adder.\n我们甚至从零做了几个主要组件，比如行波进位加法器\n\nAs you saw, it's just a big bunch of logic gates connected in clever ways.\n它们只是一大堆逻辑门巧妙的连在一起而已.\n\nWhich brings us back to that ALU you admired so much at the beginning of the episode.\n让我们回到视频开始时的 ALU，英特尔 74181\n\nThe Intel 74181.\n让我们回到视频开始时的 ALU，英特尔 74181\n\nUnlike the 8-bit ALU we made today, the 74181 could only handle 4-bit inputs,\n和我们刚刚做的 8 位 ALU 不同，74181 只能处理 4 位输入\n\nwhich means\n也就是说\n\nYOU BUILT AN ALU THAT'S LIKE TWICE AS GOOD AS THAT SUPER FAMOUS ONE. WITH YOUR MIND!\n你刚做了一个比英特尔 74181 还好的 ALU ！\n\nWell.. sort of.\n其实 差不多啦..\n\nWe didn't build the whole thing\n我们虽然没有全部造出来\n\nbut you get the idea.\n但你理解了整体概念\n\nThe 74181 used about 70 logic gates, and it couldn't multiply or divide.\n74181 用了大概 70 个逻辑门，但不能执行乘除.\n\nBut it was a huge step forward in miniaturization,\n但它向小型化迈出了一大步\n\nopening the doors to more capable and less expensive computers.\n让计算机可以更强大更便宜\n\nThis 4-bit ALU circuit is already a lot to take in,\n4 位 ALU 已经要很多逻辑门了\n\nbut our 8-bit ALU would require hundreds of logic gates to fully build\n但我们的 8 位 ALU 会需要数百个逻辑门\n\nand engineers don't want to see all that complexity when using an ALU,\n工程师不想在用 ALU 时去想那些事情,\n\nso they came up with a special symbol to wrap it all up, which looks like a big V'.\n所以想了一个特殊符号来代表它，看起来像一个大 \"V\"\n\nJust another level of abstraction!\n又一层抽象！\n\nOur 8-bit ALU has two inputs, A and B, each with 8 bits.\n我们的 8 位  ALU 有两个输入，A和B，都是 8 位 (bits)\n\nWe also need a way to specify what operation the ALU should perform,\n我们还需要告诉 ALU 执行什么操作\n\nfor example, addition or subtraction.\n例如加法或减法\n\nFor that, we use a 4-bit operation code.\n所以我们用 4 位的操作代码\n\nWe'll talk about this more in a later episode,\n我们之后的视频会再细说\n\nbut in brief, 1000 might be the command to add, while 1100 is the command for subtract.\n简言之,\"1000\"可能代表加法命令 \\N \"1100\"代表减法命令\n\nBasically, the operation code tells the ALU what operation to perform.\n操作代码告诉 ALU 执行什么操作\n\nAnd the result of that operation on inputs A and B is an 8-bit output.\n输出结果是 8 位的\n\nALUs also output a series of Flags,\nALU 还会输出一堆标志（Flag）\n\nwhich are 1-bit outputs for particular states and statuses.\n\"标志\"是1位的，代表特定状态.\n\nFor example, if we subtract two numbers, and the result is 0,\n比如相减两个数字，结果为 0\n\nour zero-testing circuit, the one we made earlier, sets the Zero Flag to True (1).\n我们的零测试电路（前面做的）\\N 会将零标志设为 True（1）\n\nThis is useful if we are trying to determine if two numbers are are equal.\n如果想知道两个数字是否相等，这个非常有用\n\nIf we wanted to test if A was less than B,\n如果想知道： A 是否小于 B\n\nwe can use the ALU to calculate A subtract B and look to see if the Negative Flag was set to true.\n可以用 ALU 来算 A 减 B，看负标志是否为 true\n\nIf it was, we know that A was smaller than B.\n如果是 true，我们就知道 A 小于 B\n\nAnd finally, there's also a wire attached to the carry out on the adder we built,\n最后，还有一条线连到加法器的进位\n\nso if there is an overflow, we'll know about it.\n如果有溢出，我们就知道\n\nThis is called the Overflow Flag.\n这叫溢出标志\n\nFancier ALUs will have more flags,\n高级 ALU 有更多标志\n\nbut these three flags are universal and frequently used.\n但这 3 个标志是 ALU 普遍用的\n\nIn fact, we'll be using them soon in a future episode.\n其实，我们之后的视频会用到它们\n\nSo now you know how your computer does all its basic mathematical operations digitally\n现在你知道了\\N 计算机是怎样在没有齿轮或杠杆的情况下 进行运算\n\nwith no gears or levers required.\n现在你知道了\\N 计算机是怎样在没有齿轮或杠杆的情况下 进行运算\n\nWe're going to use this ALU when we construct our CPU two episodes from now.\n接下来两集  我们会用 ALU 做 CPU\n\nBut before that, our computer is going to need some memory!\n但在此之前，计算机需要一些 \"记忆\" ！\n\nWe'll talk about that next week.\n我们下周会讲\n\nHi, I'm Carrie Anne and welcome to Crash Course Computer Science.\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课\n\nSo last episode, using just logic gates, we built a simple ALU,\n上集，我们用逻辑门做了个简单 ALU\n\nwhich performs arithmetic and logic operations, hence the 'A' and the 'L'.\n它能执行算术(Arithmetic)和逻辑(Logic)运算 \\N ALU 里的 A 和 L 因此得名\n\nBut of course, there's not much point in calculating a result only to throw it away\n当然，算出来之后如果扔掉就没什么意义了\n\n- it would be useful to store that value somehow,\n得找个方法存起来\n\nand maybe even run several operations in a row.\n可能还要进行多个连续操作\n\nThat's where computer memory comes in!\n这就用到计算机内存了\n\nIf you've ever been in the middle of a long RPG campaign on your console,\n如果你在主机上打过一场长时间的对局\n\nor slogging through a difficult level on Minesweeper on your desktop,\n或玩困难模式的 \"扫雷\"\n\nand your dog came by, tripped and pulled the power cord out of the wall,\n然后狗跑过来，被电源线绊倒，把插头拔了出来\n\nyou know the agony of losing all your progress.\n你知道失去进度的痛苦\n\nCondolences.\n真同情你 :(\n\nBut the reason for your loss is that your console, your laptop and your computers\n你损失数据的原因是 \\N 电脑用的是\"随机存取存储器\"，简称\"RAM\"\n\nmake use of Random Access Memory, or RAM,\n你损失数据的原因是 \\N 电脑用的是\"随机存取存储器\"，简称\"RAM\"\n\nwhich stores things like game state - as long as the power stays on.\n它只能在有电的情况下存储东西，比如游戏状态\n\nAnother type of memory, called persistent memory, can survive without power,\n另一种存储 (memory) 叫持久存储，电源关闭时数据也不会丢失\n\nand it's used for different things;\n它用来存其他东西.\n\nWe'll talk about the persistence of memory in a later episode.\n我们之后会讨论存储 (memory) 的持久性问题\n\nToday, we're going to start small\n今天我们从简单开始\n\n- literally by building a circuit that can store one.. single.. bit of information.\n- 做只能存储 1 位的电路\n\nAfter that, we'll scale up, and build our very own memory module,\n之后再扩大，做出我们的内存模块\n\nand we'll combine it with our ALU next time, when we finally build our very own CPU!\n下次和 ALU 结合起来，做出 CPU！\n\nAll of the logic circuits we've discussed so far go in one direction\n我们至今说过的电路都是单向的\n\n- always flowing forward.\n- 总是向前流动\n\nlike our 8-bit ripple adder from last episode.\n比如上集的 8 位 \"脉动进位加法器\"\n\nBut we can also create circuits that loop back on themselves.\n但也可以做回向电路，把输出连回输入\n\nLet's try taking an ordinary OR gate, and feed the output back into one of its inputs\n我们拿一个 OR 门试试，把输出连回输入\n\nand see what happens.\n看看会发生什么\n\nFirst, let's set both inputs to 0.\n首先，两个输入都设为 0\n\nSo 0 OR 0 is 0, and so this circuit always outputs 0.\n\"0 OR 0\" 是 0，所以电路输出0\n\nIf we were to flip input A to 1.\n如果将 A 变成1\n\n1 OR 0 is 1, so now the output of the OR gate is 1.\n\"1 OR 0\" 为 1，所以输出 1\n\nA fraction of a second later, that loops back around into input B,\n一转眼的功夫，输出回到 B\n\nso the OR gate sees that both of its inputs are now 1.\nOR 门看到两个输入都是 1\n\n1 OR 1 is still 1, so there is no change in output.\n\"1 OR 1\" 仍然为1，所以输出不变\n\nIf we flip input A back to 0, the OR gate still outputs 1.\n如果将 A 变成 0，OR 门依然输出 1\n\nSo now we've got a circuit that records a \"1\" for us.\n现在我们有个电路能记录 \"1\"\n\nExcept, we've got a teensy tiny problem - this change is permanent!\n然而有个小问题：这是永久的！\n\nNo matter how hard we try, there's no way to get this circuit to flip back from a 1 to a 0.\n无论怎么试，都没法从 1 变回 0\n\nNow let's look at this same circuit, but with an AND gate instead.\n我们换成 AND 门看看会怎样\n\nWe'll start inputs A and B both at 1.\n开始时，A 和 B 都设 1\n\n1 AND 1 outputs 1 forever.\n\"1 AND 1\" 永远输出 1\n\nBut, if we then flip input A to 0, because it's an AND gate, the output will go to 0.\n如果之后 A 设为 0，由于是 AND 门，输出会变成 0\n\nSo this circuit records a 0, the opposite of our other circuit.\n这个电路能记录 0，和之前那个相反\n\nLike before, no matter what input we apply to input A afterwards, the circuit will always output 0.\n就像之前，无论 A 设什么值，电路始终输出 0\n\nNow we've got circuits that can record both 0s and 1s.\n现在有了能存 0 和 1 的电路\n\nThe key to making this a useful piece of memory is to combine our two circuits into what is\n为了做出有用的存储 (memory) \\N 我们把两个电路结合起来\n\ncalled the AND-OR Latch.\n这叫 \"AND-OR 锁存器\"\n\nIt has two inputs, a \"set\" input, which sets the output to a 1,\\Ncalled the AND-OR Latch.\nIt has two inputs, a \"set\" input, which sets the output to a 1,\n它有两个输入\\N  \"设置\"输入, 把输出变成 1\\N \"复位\"输入, 把输出变成 0\n\nand a \"reset\" input, which resets the output to a 0.\n它有两个输入\\N  \"设置\"输入, 把输出变成 1\\N \"复位\"输入, 把输出变成 0\n\nIf set and reset are both 0, the circuit just outputs whatever was last put in it.\n如果\"设置\"和\"复位\"都是 0，电路会输出最后放入的内容\n\nIn other words, it remembers a single bit of information!\n也就是说，它存住了 1 位的信息！\n\nMemory!\n存储！\n\nThis is called a \"latch\" because it \"latches onto\" a particular value and stays that way.\n这叫\"锁存\", 因为它\"锁定\"了一个值\n\nThe action of putting data into memory is called writing, whereas getting the data out is called reading.\n放入数据的动作叫 \"写入\"  ，拿出数据的动作叫 \"读取\"\n\nOk, so we've got a way to store a single bit of information!\n现在我们终于有办法存一个位了！\n\nGreat!\n超棒！\n\nUnfortunately, having two different wires for input - set and reset - is a bit confusing.\n麻烦的是, 用两条线 \"设置\"和\"复位\" 来输入, 有点难理解\n\nTo make this a little easier to use, we really want a single wire to input data,\n为了更容易用，我们希望只有一条输入线\n\nthat we can set to either 0 or 1 to store the value.\n将它设为 0 或 1 来存储值\n\nAdditionally, we are going to need a wire that enables the memory\n还需要一根线来\"启用\"内存\n\nto be either available for writing or \"locked\" down\n启用时允许写入，没启用时就 \"锁定\"\n\n- which is called the write enable line.\n- 这条线叫 \"允许写入线\"\n\nBy adding a few extra logic gates, we can build this circuit,\n加一些额外逻辑门，可以做出这个电路\n\nwhich is called a Gated Latch since the \"gate\" can be opened or closed.\n这叫\"门锁\"，因为门可以打开和关上\n\nNow this circuit is starting to get a little complicated.\n现在有点复杂了\n\nWe don't want to have to deal with all the individual logic gates...\n我们不想关心单独的逻辑门\n\nso as before, we're going to bump up a level of abstraction,\n所以我们提升一层抽象\n\nand put our whole Gated Latch circuit in a box -- a box that stores one bit.\n把 \"门锁\" 放到盒子里 - 这个盒子能存一个 bit\n\nLet's test out our new component!\n我们来测一下新组件！\n\nLet's start everything at 0.\n一切从 0 开始\n\nIf we toggle the Data wire from 0 to 1 or 1 to 0,\n数据输入从0换到1, 从1换到0\n\nnothing happens - the output stays at 0.\n什么也不会发生 - 输出依然是 0\n\nThat's because the write enable wire is off, which prevents any change to the memory.\n因为 \"允许写入线\" 是关闭的，所以内容不会变化\n\nSo we need to \"open\" the \"gate\" by turning the write enable wire to 1.\n所以要给 \"允许写入线\" 输入 1, \"打开\" 门\n\nNow we can put a 1 on the data line to save the value 1 to our latch.\n现在往 \"数据线\" 放 1，1 就能存起来了\n\nNotice how the output is now 1.\\NNow we can put a 1 on the data line to save the value 1 to our latch.\nNotice how the output is now 1.\n注意输出现在是 1 了\n\nSuccess!\n成功！\n\nWe can turn off the enable line and the output stays as 1.\n现在可以关掉  \"允许写入线\" ，输出会保持 1\n\nOnce again, we can toggle the value on the data line all we want,\n现在不管给 \"数据线\" 什么值\n\nbut the output will stay the same.\n输出都不会变\n\nThe value is saved in memory.\n值存起来了\n\nNow let's turn the enable line on again use our data line to set the latch to 0.\n现在又打开 \"允许写入线\"  \\N  \"数据线\" 设为0\n\nDone.\n完成\n\nEnable line off, and the output is 0.\n\"允许写入线\" 关闭，输出 0\n\nAnd it works!\n成功了！\n\nNow, of course, computer memory that only stores one bit of information isn't very useful\n当然，只能存 1 bit 没什么大用\n\n-- definitely not enough to run Frogger.\n- 肯定玩不了游戏\n\nOr anything, really.\n或做其它事情\n\nBut we're not limited to using only one latch.\n但我们没限制只能用一个锁存器\n\nIf we put 8 latches side-by-side, we can store 8 bits of information like an 8-bit number.\n如果我们并排放 8 个锁存器，\\N 可以存 8 位信息，比如一个 8 bit 数字\n\nA group of latches operating like this is called a register,\n一组这样的锁存器叫 \"寄存器\"\n\nwhich holds a single number, and the number of bits in a register is called its width.\n寄存器能存一个数字，这个数字有多少位，叫\"位宽\"\n\nEarly computers had 8-bit registers, then 16, 32,\n早期电脑用 8 位寄存器，然后是 16 位，32 位\n\nand today, many computers have registers that are 64-bits wide.\n如今许多计算机都有 64 位宽的寄存器\n\nTo write to our register, we first have to enable all of the latches.\n写入寄存器前，要先启用里面所有锁存器\n\nWe can do this with a single wire that connects to all of their enable inputs, which we set to 1.\n我们可以用一根线连接所有 \"允许输入线\", 把它设为 1\n\nWe then send our data in using the 8 data wires, and then set enable back to 0,\n然后用 8 条数据线发数据，然后将 \"允许写入线\" 设回 0\n\nand the 8 bit value is now saved in memory.\n现在 8 位的值就存起来了\n\nPutting latches side-by-side works ok for a small-ish number of bits.\n如果只有很少的位(bits)，把锁存器并排放置，也勉强够用了.\n\nA 64-bit register would need 64 wires running to the data pins, and 64 wires running to the outputs.\n64 位寄存器要 64 根数据线，64 根连到输出端\n\nLuckily we only need 1 wire to enable all the latches, but that's still 129 wires.\n幸运的是，我们只要 1 根线启用所有锁存器 \\N 但加起来也有 129 条线了\n\nFor 256 bits, we end up with 513 wires!\n如果存 256 位要 513 条线！\n\nThe solution is a matrix!\n解决方法是矩阵！\n\nIn this matrix, we don't arrange our latches in a row,\n在矩阵中，我们不并列排放锁存器\n\nwe put them in a grid.\n而是做成网格\n\nFor 256 bits, we need a 16 by 16 grid of latches with 16 rows and columns of wires.\n存 256 位，我们用 16x16 网格的锁存器，有 16 行 16 列\n\nTo activate any one latch, we must turn on the corresponding row AND column wire.\n要启用某个锁存器，就打开相应的 行线 和 列线\n\nLet's zoom in and see how this works.\n放大看看怎么做的\n\nWe only want the latch at the intersection of the two active wires to be enabled,\n我们只想打开交叉处  锁存器的 \"允许写入线\"\n\nbut all of the other latches should stay disabled.\n所有其他锁存器，保持关闭\n\nFor this, we can use our trusty AND gate!\n我们可以用 AND 门！\n\nThe AND gate will output a 1 only if the row and the column wires are both 1.\n只有 行线和列线 均为 1 ，AND 门才输出 1\n\nSo we can use this signal to uniquely select a single latch.\n所以可以用选择单个锁存器\n\nThis row/column setup connects all our latches with a single, shared, write enable wire.\n这种行/列排列法，用一根 \"允许写入线\" 连所有锁存器\n\nIn order for a latch to become write enabled,\n为了让锁存器变成 \"允许写入\"\n\nthe row wire, the column wire, and the write enable wire must all be 1.\n行线，列线和 \"允许写入线\" 都必须是 1\n\nThat should only ever be true for one single latch at any given time.\n每次只有 1 个锁存器会这样\n\nThis means we can use a single, shared wire for data.\n代表我们可以只用一根 \"数据线\"  \\N 连所有锁存器来传数据\n\nBecause only one latch will ever be write enabled, only one will ever save the data\n因为只有一个锁存器会启用，只有那个会存数据\n\n-- the rest of the latches will simply ignore values on the data wire because they are not write enabled.\n其他锁存器会忽略数据线上的值，因为没有 \"允许写入\"\n\nWe can use the same trick with a read enable wire to read the data later,\n我们可以用类似的技巧, 做\"允许读取线\"来读数据\n\nto get the data out of one specific latch.\n从一个指定的锁存器，读取数据\n\nThis means in total, for 256 bits of memory,\n所以对于 256 位的存储\n\nwe only need 35 wires - 1 data wire, 1 write enable wire, 1 read enable wire,\n只要 35 条线 \\N1条\"数据线\", 1条\"允许写入线\", 1条\"允许读取线\"\n\nand 16 rows and columns for the selection.\n还有16行16列的线用于选择锁存器 \\N （16+16=32, 32+3=35）\n\nThat's significant wire savings!\n这省了好多线！\n\nBut we need a way to uniquely specify each intersection.\n但我们需要某种方法来 唯一指定 交叉路口\n\nWe can think of this like a city,\n我们可以想成城市\n\nwhere you might want to meet someone at 12th avenue and 8th street\n你可能想和别人  在第 12 大道和第 8 街的交界碰面\n\n-- that's an address that defines an intersection.\n- 这是一个交叉点的地址\n\nThe latch we just saved our one bit into has an address of row 12 and column 8.\n我们刚刚存了一位的地址是 \"12行 8列\"\n\nSince there is a maximum of 16 rows, we store the row address in a 4 bit number.\n由于最多 16 行, 用 4 位就够了\n\n12 is 1100 in binary.\n12 用二进制表示为 1100\n\nWe can do the same for the column address: 8 is 1000 in binary.\n列地址也可以这样： 8 用二进制表示为 1000\n\nSo the address for the particular latch we just used can be written as 11001000.\n刚才说的\"12行 8列\"可以写成 11001000\n\nTo convert from an address into something that selects the right row or column,\n为了将地址转成  行和列\n\nwe need a special component called a multiplexer\n我们需要 \"多路复用器\"\n\n-- which is the computer component with a pretty cool name at least compared to the ALU.\n- 这个名字起码比 ALU 酷一点\n\nMultiplexers come in all different sizes,\n多路复用器有不同大小\n\nbut because we have 16 rows, we need a 1 to 16 multiplexer.\n因为有 16 行，我们需要 1 到 16 多路复用器\n\nIt works like this.\n工作方式是\n\nYou feed it a 4 bit number, and it connects the input line to a corresponding output line.\n输入一个 4 位数字，它会把那根线，连到相应的输出线\n\nSo if we pass in 0000, it will select the very first column for us.\n如果输入 0000，它会选择第一列\n\nIf we pass in 0001, the next column is selected, and so on.\n如果输入 0001，会选择下一列，依此类推\n\nWe need one multiplexer to handle our rows and another multiplexer to handle the columns.\n一个多路复用器处理行(row) \\N 另一个多路复用器处理列(column)\n\nOk, it's starting to get complicated again,\n好吧，开始有点复杂了\n\nso let's make our 256-bit memory its own component.\n那么把 256 位内存当成一个整体好了\n\nOnce again a new level of abstraction!\n又提升了一层抽象！\n\nIt takes an 8-bit address for input - the 4 bits for the column and 4 for the row.\n它输入一个 8 位地址：4 位代表列，4 位代表行\n\nWe also need write and read enable wires.\n我们还需要 \"允许写入线\" 和 \"允许读取线\"\n\nAnd finally, we need just one data wire, which can be used to read or write data.\n最后，还需要一条数据线，用于读/写数据\n\nUnfortunately, even 256-bits of memory isn't enough to run much of anything,\n不幸的是， 256 位的内存也没法做什么事\n\nso we need to scale up even more!\n所以还要扩大规模\n\nWe're going to put them in a row.\n把它们并排放置\n\nJust like with the registers.\n就像寄存器一样\n\nWe'll make a row of 8 of them, so we can store an 8 bit number - also known as a byte.\n一行8个，可以存一个 8 位数字 \\N 8 位也叫一个字节（byte）\n\nTo do this, we feed the exact same address into all 8 of our 256-bit memory components at the same time,\n为了存一个 8 位数字，我们同时给 8 个 256 位内存一样的地址\n\nand each one saves one bit of the number.\n每个地址存 1 位\n\nThat means the component we just made can store 256 bytes at 256 different addresses.\n意味着这里总共能存 256 个字节 （byte）\n\nAgain, to keep things simple, we want to leave behind this inner complexity.\n再次，为了简单，我们不管内部\n\nInstead of thinking of this as a series of individual memory modules and circuits,\n不看作是一堆独立的存储模块和电路\n\nwe'll think of it as a uniform bank of addressable memory.\n而是看成一个整体的可寻址内存\n\nWe have 256 addresses,\n我们有 256 个地址\n\nand at each address, we can read or write an 8-bit value.\n每个地址能读或写一个 8 位值\n\nWe're going to use this memory component next episode when we build our CPU.\n我们下集做 CPU 时会用到这个内存\n\nThe way that modern computers scale to megabytes and gigabytes of memory\n现代计算机的内存 \\N 扩展到上兆字节（MB）和千兆字节（GB）的方式\n\nis by doing the same thing we've been doing here\n和我们这里做的一样\n\n-- keep packaging up little bundles of memory into larger, and larger, and larger arrangements.\n不断把内存打包到更大规模\n\nAs the number of memory locations grow, our addresses have to grow as well.\n随着内存地址增多，内存地址也必须增长\n\n8 bits hold enough numbers to provide addresses for 256 bytes of our memory,\n8 位最多能代表 256 个内存地址 \\N（1111 1111 是255，0~255 一共 256 个数字）\n\nbut that's all.\n只有这么多\n\nTo address a gigabyte - or a billion bytes of memory - we need 32-bit addresses.\n要给千兆或十亿字节的内存寻址，需要 32 位的地址\n\nAn important property of this memory is that we can access any memory location, at any time, and in a random order.\n内存的一个重要特性是：可以随时访问任何位置\n\nFor this reason, it's called Random-Access Memory or RAM.\n因此叫 \"随机存取存储器\" ，简称 RAM\n\nWhen you hear people talking about how much RAM a computer has\n当你听到有人说 RAM 有多大\n\n- that's the computer's memory.\n他的意思是内存有多大\n\nRAM is like a human's short term or working memory,\nRAM 就像人类的短期记忆\n\nwhere you keep track of things going on right now\n记录当前在做什么事\n\n- like whether or not you had lunch or paid your phone bill.\n比如吃了午饭没，或有没有交电话费\n\nHere's an actual stick of RAM - with 8 memory modules soldered onto the board.\n这是一条真的内存，上面焊了 8 个内存模块\n\nIf we carefully opened up one of these modules and zoomed in,\n如果打开其中一个，然后放大\n\nThe first thing you would see are 32 squares of memory.\n会看到 32 个内存方块\n\nZoom into one of those squares, and we can see each one is comprised of 4 smaller blocks.\n放大其中一个方块，可以看到有 4 个小块\n\nIf we zoom in again, we get down to the matrix of individual bits.\n如果再放大，可以看到存一个\"位\"的矩阵\n\nThis is a matrix of 128 by 64 bits.\n这个矩阵是 128 位 x 64 位\n\nThat's 8192 bits in total.\n总共 8192 位\n\nEach of our 32 squares has 4 matrices, so that's 32 thousand, 7 hundred and 68 bits.\n每个方格 4 个矩阵 \\N 所以一个方格有 32768 个位 （8192 x 4 = 32768）\n\nAnd there are 32 squares in total.\n而一共 32 个方格\n\nSo all in all, that's roughly 1 million bits of memory in each chip.\n总而言之，1 个芯片大约存 100 万位\n\nOur RAM stick has 8 of these chips, so in total, this RAM can store 8 millions bits,\nRAM 有 8 个芯片，所以总共 800 万位\n\notherwise known as 1 megabyte.\n也就是 1 兆字节（1 MB）\n\nThat's not a lot of memory these days -- this is a RAM module from the 1980's.\n1 MB 如今不算大 - 这是 1980 年代的 RAM\n\nToday you can buy RAM that has a gigabyte or more of memory\n如今你可以买到千兆字节（GB）的 RAM\n\n- that's billions of bytes of memory.\n那可是数十亿字节的内存\n\nSo, today, we built a piece of SRAM - Static Random-Access Memory - which uses latches.\n今天，我们用锁存器做了一块 SRAM（静态随机存取存储器）\n\nThere are other types of RAM, such as DRAM, Flash memory, and NVRAM.\n还有其他类型的 RAM，如 DRAM，闪存和 NVRAM\n\nThese are very similar in function to SRAM,\n它们在功能上与 SRAM 相似\n\nbut use different circuits to store the individual bits\n但用不同的电路存单个位\n\n- for example, using different logic gates, capacitors, charge traps, or memristors.\n- 比如用不同的逻辑门，电容器，电荷捕获或忆阻器\n\nBut fundamentally, all of these technologies store bits of information\n但根本上  这些技术都是矩阵层层嵌套，来存储大量信息\n\nin massively nested matrices of memory cells.\n但根本上  这些技术都是矩阵层层嵌套，来存储大量信息\n\nLike many things in computing, the fundamental operation is relatively simple.\n就像计算机中的很多事情，底层其实都很简单\n\nit's the layers and layers of abstraction that's mind blowing\n让人难以理解的，是一层层精妙的抽象\n\n-- like a russian doll that keeps getting smaller and smaller and smaller.\n像一个越来越小的俄罗斯套娃\n\nI'll see you next week.\n下周见\n\nHi, I'm Carrie Anne, this is Crash Course Computer Science\n嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nand today, we're talking about processors.\n今天我们讲 处理器\n\nJust a warning though - this is probably the most complicated episode in the series.\n提示下 - 这集可能是最难的一集\n\nSo once you get this, you're golden.\n所以一旦你理解了，就会变得超厉害der~\n\nWe've already made a Arithmetic and Logic Unit,\n我们已经做了一个算术逻辑单元（ALU）\n\nwhich takes in binary numbers and performs calculations,\n输入二进制，它会执行计算\n\nand we've made two types of computer memory:\n我们还做了两种内存：\n\nRegisters -- small, linear chunks of memory, useful for storing a single value\n寄存器 - 很小的一块内存，能存一个值\n\nand then we scaled up, and made some RAM,\n之后我们增大做出了 RAM\n\na larger bank of memory that can store a lot of numbers located at different addresses.\nRAM 是一大块内存，能在不同地址存大量数字\n\nNow it's time to put it all together and build ourselves the heart of any computer,\n现在是时候把这些放在一起，组建计算机的 \"心脏\" 了\n\nbut without any of the emotional baggage that comes with human hearts.\n但这个 \"心脏\" 不会有任何包袱，比如人类情感.\n\nFor computers, this is the Central Processing Unit, most commonly called the CPU.\n计算机的心脏是\"中央处理单元\"，简称 \"CPU\"\n\nA CPU's job is to execute programs.\nCPU 负责执行程序\n\nPrograms, like Microsoft Office, Safari, or your beloved copy of Half Life: 2,\n比如 Office，Safari 浏览器，你最爱的 《半条命2》\n\nare made up of a series of individual operations,\n程序由一个个操作组成\n\ncalled instructions, because they \"instruct\" the computer what to do.\n这些操作叫\"指令\"(Instruction) \\N 因为它们\"指示\"计算机要做什么\n\nIf these are mathematical instructions, like add or subtract,\n如果是数学指令，比如加/减\n\nthe CPU will configure its ALU to do the mathematical operation.\nCPU 会让 ALU 进行数学运算\n\nOr it might be a memory instruction,\n也可能是内存指令，CPU 会和内存通信，然后读/写值\n\nin which case the CPU will talk with memory to read and write values.\n也可能是内存指令，CPU 会和内存通信，然后读/写值\n\nThere are a lot of parts in a CPU,\nCPU 里有很多组件.\n\nso we're going to lay it out piece by piece, building up as we go.\n所以我们一边说一边建\n\nWe'll focus on functional blocks, rather than showing every single wire.\n我们把重点放在功能，而不是一根根线具体怎么连\n\nWhen we do connect two components with a line,\n当我们用一条线连接两个组件时\n\nthis is an abstraction for all of the necessary wires.\n这条线只是所有必须线路的一个抽象\n\nThis high level view is called the microarchitecture.\n这种高层次视角叫  \"微体系架构\"\n\nOK, first, we're going to need some memory.\n好，我们首先要一些内存，把上集做的 RAM 拿来就行\n\nLets drop in the RAM module we created last episode.\n好，我们首先要一些内存，把上集做的 RAM 拿来就行\n\nTo keep things simple, we'll assume it only has 16 memory locations, each containing 8 bits.\n为了保持简单，假设它只有 16 个位置，每个位置存 8 位\n\nLet's also give our processor four, 8-bit memory registers, labeled A, B, C and D\n再来四个 8 位寄存器，叫 A，B，C，D\n\nwhich will be used to temporarily store and manipulate values.\n寄存器用来 临时存数据 和 操作数据\n\nWe already know that data can be stored in memory as binary values\n我们已经知道数据  是以二进制值存在内存里\n\nand programs can be stored in memory too.\n程序也可以存在内存里\n\nWe can assign an ID to each instruction supported by our CPU.\n我们可以给 CPU 支持的所有指令，分配一个 ID\n\n指令表\n\n指令\n\n描述\n\n4位操作码\n\n地址或寄存器\n\nIn our hypothetical example, we use the first four bits to store the \"operation code\",\n在这个假设的例子 \\N 我们用前四位存 \"操作代码\" （operation code）\n\nor opcode for short.\n简称 \"操作码\" （opcode）\n\nThe final four bits specify where the data for that operation should come from -\n后四位代表数据来自哪里\n\nthis could be registers or an address in memory.\n- 可以是寄存器或内存地址\n\nWe also need two more registers to complete our CPU.\n我们还需要两个寄存器，来完成 CPU.\n\nFirst, we need a register to keep track of where we are in a program.\n1. 一个寄存器追踪程序运行到哪里了，我们叫它  \"指令地址寄存器\"\n\nFor this, we use an instruction address register,\n1. 一个寄存器追踪程序运行到哪里了，我们叫它  \"指令地址寄存器\"\n\nwhich as the name suggests, stores the memory address of the current instruction.\n顾名思义，存当前指令的内存地址\n\nAnd then we need the other register to store the current instruction,\n2. 另一个寄存器存当前指令，叫  \"指令寄存器\"\n\nwhich we'll call the instruction register.\n2. 另一个寄存器存当前指令，叫  \"指令寄存器\"\n\nWhen we first boot up our computer, all of our registers start at 0.\n当启动计算机时，所有寄存器从 0 开始\n\nAs an example, we've initialized our RAM with a simple computer program that we'll to through today.\n为了举例，我们在 RAM 里放了一个程序，我们今天会过一遍\n\nThe first phase of a CPU's operation is called the fetch phase.\nCPU 的第一个阶段叫 \"取指令阶段\"\n\nThis is where we retrieve our first instruction.\n负责拿到指令\n\nFirst, we wire our Instruction Address Register to our RAM module.\n首先，将 \"指令地址寄存器\" 连到 RAM\n\nThe register's value is 0, so the RAM returns whatever value is stored in address 0.\n寄存器的值为 0，因此 RAM 返回地址 0 的值\n\nIn this case, 0010 1110.\n0010 1110 会复制到 \"指令寄存器\" 里\n\nThen this value is copied into our instruction register.\n0010 1110 会复制到 \"指令寄存器\" 里\n\nNow that we've fetched an instruction from memory,\n现在指令拿到了\n\nwe need to figure out what that instruction is\n要弄清是什么指令，才能执行（execute）\n\nso we can execute it.\n要弄清是什么指令，才能执行（execute）\n\nThat is run it.\n而不是杀死（kill）它\n\nNot kill it.\n而不是杀死（kill）它\n\nThis is called the decode phase.\n这是 \"解码阶段\"\n\n指令表\n\n指令\n\n描述\n\n4位操作码\n\n地址或寄存器\n\nIn this case the opcode, which is the first four bits, is: 0010.\n前 4 位 0010 是 LOAD A 指令\n\nThis opcode corresponds to the \"LOAD A\" instruction,\n前 4 位 0010 是 LOAD A 指令\n\nwhich loads a value from RAM into Register A.\n意思是，把 RAM 的值放入寄存器 A\n\nThe RAM address is the last four bits of our instruction which are 1110, or 14 in decimal.\n后 4 位 1110 是 RAM 的地址, 转成十进制是 14\n\nNext, instructions are decoded and interpreted by a Control Unit.\n接下来，指令由 \"控制单元\" 进行解码\n\nLike everything else we've built, it too is made out of logic gates.\n就像之前的所有东西 \\N  \"控制单元\" 也是逻辑门组成的\n\nFor example, to recognize a LOAD A instruction,\n比如，为了识别 \"LOAD A\" 指令\n\nwe need a circuit that checks if the opcode matches 0010\n需要一个电路，检查操作码是不是 0010\n\nwhich we can do with a handful of logic gates.\n我们可以用很少的逻辑门来实现.\n\nNow that we know what instruction we're dealing with,\n现在知道了是什么指令\n\nwe can go ahead and perform that instruction which is the beginning of the execute phase!\n就可以开始执行了，开始 \"执行阶段\"\n\nUsing the output of our LOAD_A checking circuit,\n用 \"检查是否 LOAD_A 指令的电路\"\n\nwe can turn on the RAM's read enable line and send in address 14.\n可以打开 RAM 的 \"允许读取线\", 把地址 14 传过去\n\nThe RAM retrieves the value at that address, which is 00000011, or 3 in decimal.\nRAM 拿到值，0000 0011，十进制的 3\n\nNow, because this is a LOAD_A instruction,\n因为是 LOAD_A 指令 \\N 我们想把这个值只放到寄存器 A，其他寄存器不受影响\n\nwe want that value to only be saved into Register A and not any of the other registers.\n因为是 LOAD_A 指令 \\N 我们想把这个值只放到寄存器 A，其他寄存器不受影响\n\nSo if we connect the RAM's data wires to our four data registers,\n所以需要一根线，把 RAM 连到 4 个寄存器\n\nwe can use our LOAD_A check circuit to enable the write enable only for Register A.\n用 \"检查是否 LOAD_A 指令的电路\" \\N 启用寄存器 A 的 \"允许写入线\"\n\nAnd there you have it\n这就成功了\n\n-- we've successfully loaded the value at RAM address 14 into Register A.\n- 把 RAM 地址 14 的值，放到了寄存器 A.\n\nWe've completed the instruction, so we can turn all of our wires off,\n既然指令完成了，我们可以关掉所有线路\n\nand we are ready to fetch the next instruction in memory.\n去拿下一条指令\n\nTo do this, we increment the Instruction Address Register by 1 which completes the execute phase.\n我们把 \"指令地址寄存器\"+1，\"执行阶段\"就此结束.\n\nLOAD_A is just one of several possible instructions that our CPU can execute.\nLOAD_A 只是 CPU 可以执行的各种指令之一\n\nDifferent instructions are decoded by different logic circuits,\n不同指令由不同逻辑电路解码\n\nwhich configure the CPU's components to perform that action.\n这些逻辑电路会配置 CPU 内的组件来执行对应操作\n\nLooking at all those individual decode circuits is too much detail,\n具体分析这些解码电路太繁琐了\n\nso since we looked at one example,\n既然已经看了 1 个例子，\n\nwe're going to go head and package them all up as a single Control Unit to keep things simple.\n干脆把 \"控制单元 \"包成一个整体，简洁一些.\n\nThat's right a new level of abstraction.\n没错，一层新抽象\n\nThe Control Unit is comparable to the conductor of an orchestra,\n控制单元就像管弦乐队的指挥\n\ndirecting all of the different parts of the CPU.\n\"指挥\" CPU 的所有组件\n\nHaving completed one full fetch/decode/execute cycle,\n\"取指令→解码→执行\" 完成后\n\nwe're ready to start all over again, beginning with the fetch phase.\n现在可以再来一次，从 \"取指令\" 开始\n\nThe Instruction Address Register now has the value 1 in it,\n\"指令地址寄存器\" 现在的值是 1\n\nso the RAM gives us the value stored at address 1, which is 0001 1111.\n所以 RAM 返回地址 1 里的值：0001 1111\n\nOn to the decode phase!\n到 \"解码\" 阶段！\n\n0001 is the \"LOAD B\" instruction, which moves a value from RAM into Register B.\n0001 是 LOAD B 指令 \\N 从 RAM 里把一个值复制到寄存器 B\n\nThe memory location this time is 1111, which is 15 in decimal.\n这次内存地址是 1111，十进制的 15\n\nNow to the execute phase!\n现在到 \"执行阶段\"！\n\nThe Control Unit configures the RAM to read address 15 and configures Register B to receive the data.\n\"控制单元\" 叫 RAM 读地址 15，并配置寄存器 B 接收数据\n\nBingo, we just saved the value 00001110, or the number 14 in decimal, into Register B.\n成功，我们把值 0000 1110 \\N 也就是十进制的 14 存到了寄存器 B\n\nLast thing to do is increment our instruction address register by 1,\n最后一件事是 \"指令地址寄存器\" +1\n\nand we're done with another cycle.\n我们又完成了一个循环\n\nOur next instruction is a bit different.\n下一条指令有点不同\n\nLet's fetch it.\n来取它吧\n\n1000 0100.\n1000 0100\n\nThat opcode 1000 is an ADD instruction.\n1000 是 ADD 指令\n\nInstead of an 4-bit RAM address, this instruction uses two sets of 2 bits.\n这次后面的 4 位不是 RAM 地址，\\N 而是 2 位 2 位分别代表 2 个寄存器\n\nRemember that 2 bits can encode 4 values,\n2 位可以表示 4 个值\n\nso 2 bits is enough to select any one of our 4 registers.\n所以足够表示 4 个寄存器\n\nThe first set of 2 bits is 01, which in this case corresponds to Register B,\n第一个地址是 01, 代表寄存器B\n\nand 00, which is Register A.\n第二个地址是 00, 代表寄存器A\n\nSo \"1000 01 00\" is the instruction for adding the value in Register B into the value in register A.\n因此，1000 0100，代表把寄存器 B 的值，加到寄存器 A 里\n\nSo to execute this instruction, we need to integrate the ALU we made in Episode 5 into our CPU.\n为了执行这个指令，我们要整合第 5 集的 ALU\n\nThe Control Unit is responsible for selecting the right registers to pass in as inputs,\n\"控制单元\" 负责选择正确的寄存器作为输入\n\nand configuring the ALU to perform the right operation.\n并配置 ALU 执行正确的操作\n\nFor this ADD instruction, the Control Unit enables Register B\n对于 \"ADD\" 指令， \"控制单元\" 会\n\nand feeds its value into the first input of the ALU.\n启用寄存器 B，作为 ALU 的第一个输入\n\nIt also enables Register A and feeds it into the second ALU input.\n还启用寄存器 A，作为 ALU 的第二个输入\n\nAs we already discussed, the ALU itself can perform several different operations,\n之前说过，ALU 可以执行不同操作\n\nso the Control Unit must configure it to perform an ADD operation by passing in the ADD opcode.\n所以控制单元必须传递 ADD 操作码告诉它要做什么\n\nFinally, the output should be saved into Register A.\n最后，结果应该存到寄存器 A\n\nBut it can't be written directly\n但不能直接写入寄存器 A\n\nbecause the new value would ripple back into the ALU and then keep adding to itself.\n这样新值会进入 ALU ，不断和自己相加\n\nSo the Control Unit uses an internal register to temporarily save the output,\n因此，控制单元用一个自己的寄存器暂时保存结果\n\nturn off the ALU, and then write the value into the proper destination register.\n关闭 ALU，然后把值写入正确的寄存器\n\nIn this case, our inputs were 3 and 14, and so the sum is 17, or 00010001 in binary,\n这里 3+14=17，二进制是 0001 0001\n\nwhich is now sitting in Register A.\n现在存到了寄存器 A\n\nAs before, the last thing to do is increment our instruction address by 1,\n和之前一样，最后一件事是把指令地址 + 1\n\nand another cycle is complete.\n这个循环就完成了\n\nOkay, so let's fetch one last instruction: 0100 1101.\n好，来看最后一个指令：0100 1101\n\nWhen we decode it we see that 0100 is a STORE_A instruction, with a RAM address of 13.\n解码得知是 STORE A 指令（把寄存器 A 的值放入内存） \\N RAM 地址 13\n\nAs usual, we pass the address to the RAM module,\n接下来，把地址传给 RAM\n\nbut instead of read-enabling the memory, we write-enable it.\n但这次不是 \"允许读取\" ，而是 \"允许写入\"\n\nAt the same time, we read-enable Register A.\n同时，打开寄存器 A 的 \"允许读取\"\n\nThis allows us to use the data line to pass in the value stored in register A.\n这样就可以把寄存器 A 里的值，传给 RAM\n\nCongrats, we just ran our first computer program!\n恭喜，我们刚运行了第一个电脑程序！\n\nIt loaded two values from memory, added them together,\n它从内存中加载两个值，相加，然后把结果放回内存\n\nand then saved that sum back into memory.\n它从内存中加载两个值，相加，然后把结果放回内存\n\nOf course, by me talking you through the individual steps,\n刚刚是我一步步来讲的,\n\nI was manually transitioning the CPU through its fetch, decode and execute phases.\n我们人工切换 CPU 的状态 \"取指令→解码→执行\"\n\nBut there isn't a mini Carrie Anne inside of every computer.\n但不是每台电脑里都有一个迷你 Carrie Anne\n\nSo the responsibility of keeping the CPU ticking along falls to a component called the clock.\n其实是 \"时钟\" 来负责管理 CPU 的节奏\n\nAs it's name suggests, the clock triggers an electrical signal at a precise and regular interval.\n时钟以精确的间隔  触发电信号\n\nIts signal is used by the Control Unit to advance the internal operation of the CPU,\n控制单元会用这个信号，推进 CPU 的内部操作\n\nkeeping everything in lock-step\n确保一切按步骤进行\n\n- like the dude on a Roman galley drumming rhythmically at the front,\n- 就像罗马帆船的船头，有一个人负责按节奏的击鼓,\n\nkeeping all the rowers synchronized... or a metronome.\n让所有划船的人同步... 就像节拍器一样\n\nOf course you can't go too fast,\n节奏不能太快\n\nbecause even electricity takes some time to travel down wires and for the signal to settle.\n因为就算是电也要一定时间来传输\n\nThe speed at which a CPU can carry out each step of the fetch-decode-execute cycle\nCPU \"取指令→解码→执行\" 的速度叫 \"时钟速度\"\n\nis called its Clock Speed.\nCPU \"取指令→解码→执行\" 的速度叫 \"时钟速度\"\n\nThis speed is measured in Hertz - a unit of frequency.\n单位是赫兹 - 赫兹是用来表示频率的单位\n\nOne Hertz means one cycle per second.\n1 赫兹代表一秒 1 个周期\n\nGiven that it took me about 6 minutes to talk you through 4 instructions\n因为我花了大概 6 分钟，给你讲了 4 条指令\n\nLOAD, LOAD, ADD and STORE\n读取→读取→相加→存储\n\nthat means I have an effective clock speed of roughly .03 Hertz.\n所以我的时钟速度大概是 0.03 赫兹\n\nAdmittedly, I'm not a great computer\n我承认我算数不快\n\nbut even someone handy with math might only be able to do one calculation in their head every second or 1 Hertz.\n但哪怕有人算数很快，最多也就是一秒一次，或 1 赫兹\n\nThe very first, single-chip CPU was the Intel 4004, a 4-bit CPU released in 1971.\n第一个单芯片 CPU 是 \"英特尔 4004\" \\N 1971 年发布的 4 位CPU\n\nIt's microarchitecture is actually pretty similar to our example CPU.\n它的微架构 很像我们之前说的 CPU\n\nDespite being the first processor of its kind,\n虽然是第一个单芯片的处理器\n\nit had a mind-blowing clock speed of 740 Kilohertz\n但它的时钟速度达到了 740 千赫兹 - 每秒 74 万次\n\n-- that's 740 thousand cycles per second.\n但它的时钟速度达到了 740 千赫兹 - 每秒 74 万次\n\nYou might think that's fast,\n你可能觉得很快\n\nbut it's nothing compared to the processors that we use today.\n但和如今的处理器相比不值一提\n\nOne megahertz is one million clock cycles per second,\n一兆赫兹是 1 秒 1 百万个时钟周期\n\nand the computer or even phone that you are watching this video on right now is no doubt a few gigahertz\n你现在看视频的电脑或手机，肯定有几千兆赫兹\n\n-- that's BILLIONs of CPU cycles every single... second.\n- 1 秒 10 亿次时钟周期\n\nAlso, you may have heard of people overclocking their computers.\n你可能听过有人会把计算机超频\n\nThis is when you modify the clock to speed up the tempo of the CPU\n意思是修改时钟速度，加快 CPU 的速度\n\n-- like when the drummer speeds up when the Roman Galley needs to ram another ship.\n- 就像罗马帆船要撞另一艘船时，鼓手会加快敲鼓速度\n\nChip makers often design CPUs with enough tolerance to handle a little bit of overclocking,\n芯片制造商经常给 CPU 留一点余地，可以接受一点超频\n\nbut too much can either overheat the CPU,\n但超频太多会让 CPU 过热\n\nor produce gobbledygook as the signals fall behind the clock.\n或产生乱码，因为信号跟不上时钟\n\nAnd although you don't hear very much about underclocking,\n你可能很少听说降频\n\nit's actually super useful.\n但降频其实很有用\n\nSometimes it's not necessary to run the processor at full speed...\n有时没必要让处理器全速运行\n\nmaybe the user has stepped away, or just not running a particularly demanding program.\n可能用户走开了，或者在跑一个性能要求较低的程序\n\nBy slowing the CPU down, you can save a lot of power,\n把 CPU 的速度降下来，可以省很多电\n\nwhich is important for computers that run on batteries, like laptops and smartphones.\n省电对用电池的设备很重要，比如笔记本和手机\n\nTo meet these needs,\n为了尽可能省电\n\nmany modern processors can increase or decrease their clock speed based on demand,\n很多现代处理器可以按需求  加快或减慢时钟速度\n\nwhich is called dynamic frequency scaling.\n这叫 \"动态调整频率\"\n\nSo, with the addition of a clock, our CPU is complete.\n加上时钟后，CPU 才是完整的.\n\nWe can now put a box around it, and make it its own component.\n现在可以放到盒子里，变成一个独立组件\n\nYup.\n对\n\nA new level of abstraction!\n一层新的抽象！\n\nRAM, as I showed you last episode,\nRAM，上集说过，是在 CPU 外面的独立组件\n\nlies outside the CPU as its own component,\nRAM，上集说过，是在 CPU 外面的独立组件\n\nand they communicate with each other using address, data and enable wires.\nCPU 和 RAM 之间 \\N 用 \"地址线\"  \"数据线\" 和 \"允许读/写线\" 进行通信\n\nAlthough the CPU we designed today is a simplified example,\n虽然今天我们设计的 CPU 是简化版的,\n\nmany of the basic mechanics we discussed are still found in modern processors.\n但我们提到的很多机制，依然存在于现代处理器里\n\nNext episode, we're going to beef up our CPU,\n下一集，我们要加强 CPU，给它扩展更多指令.\n\nextending it with more instructions as we take our first baby steps into software.\n同时开始讲软件.\n\nI'll see you next week.\n下周见\n\nHi, I’m Carrie Anne and this is Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode, we combined an ALU, control unit, some memory, and a clock together to\n上集我们把 ALU, 控制单元, RAM, 时钟 结合在一起\n\nmake a basic, but functional Central Processing Unit – or CPU\n做了个基本，但可用的\"中央处理单元\", 简称 CPU\n\n– the beating, ticking heart of a computer.\n它是计算机的核心\n\nWe’ve done all the hard work of building many of these components from the electronic\n我们已经用电路做了很多组件.\n\ncircuits up, and now it’s time to give our CPU some actual instructions to process!\n这次我们给 CPU 一些指令来运行!\n\nThe thing that makes a CPU powerful is the fact that it is programmable –\nCPU 之所以强大，是因为它是可编程的 -\n\nif you write a different sequence of instructions, then the CPU will perform a different task.\n如果写入不同指令，就会执行不同任务\n\nSo the CPU is a piece of hardware which is controlled by easy-to-modify software!\nCPU 是一块硬件，可以被软件控制!\n\nLet’s quickly revisit the simple program that we stepped through last episode.\n我们重新看一下上集的简单程序\n\nThe computer memory looked like this.\n内存里有这些值\n\nEach address contained 8 bits of data.\n每个地址可以存 8 位数据\n\nFor our hypothetical CPU, the first four bits specified the operation code, or opcode, and\n因为我们的 CPU 是假设的，这里前4位是\"操作码\"\n\nthe second set of four bits specified an address or registers.\n后4位指定一个内存地址，或寄存器.\n\nIn memory address zero we have 0010 1110.\n内存地址 0 是 0010 1110\n\nAgain, those first four bits are our opcode which corresponds to a \"LOAD_A\" instruction.\n前 4 位代表 LOAD_A 指令\n\nThis instruction reads data from a location of memory specified in those last four bits\n意思是：把后 4 位指定的内存地址的值，放入寄存器 A\n\nof the instruction and saves it into Register A. In this case, 1110, or 14 in decimal.\n后 4 位是 1110，十进制的 14\n\nSo let’s not think of this of memory address 0 as \"0010 1110\", but rather as the instruction\n我们来把 0010 1110 看成 \"LOAD_A 14\" 指令\n\n\"LOAD_A 14\".\n我们来把 0010 1110 看成 \"LOAD_A 14\" 指令\n\nThat’s much easier to read and understand!\n这样更好理解！\n\nAnd for me to say!\n也更方便说清楚\n\nAnd we can do the same thing for the rest of the data in memory.\n可以对内存里剩下的数也这样转换.\n\nIn this case, our program is just four instructions long,\n这里，我们的程序只有4个指令\n\nand we’ve put some numbers into memory too, 3 and 14.\n还有数字 3 和 14\n\nSo now let’s step through this program:\n现在一步步看\n\nFirst is LOAD_A 14, which takes the value in address 14, which is the number 3,\n\"LOAD_A 14\" 是从地址 14 中拿到数字3，放入寄存器A\n\nand stores it into Register A.\n\"LOAD_A 14\" 是从地址 14 中拿到数字3，放入寄存器A\n\nThen we have a \"LOAD_B 15\" instruction, which takes the value in memory location 15,\n\"LOAD_B 15\" 是从地址 15 中拿到数字14，放入寄存器B\n\nwhich is the number 14, and saves it into Register B.\n\"LOAD_B 15\" 是从地址 15 中拿到数字14，放入寄存器B\n\nOkay.\n好.\n\nEasy enough.\n挺简单的！\n\nBut now we have an \"ADD\" instruction.\n下一个是 ADD 指令\n\nThis tells the processor to use the ALU to add two registers together,\n\"ADD B A\" 告诉 ALU \\N 把寄存器 B 和寄存器 A 里的数字加起来\n\nin this case, B and A are specified.\n\"ADD B A\" 告诉 ALU \\N 把寄存器 B 和寄存器 A 里的数字加起来\n\nThe ordering is important, because the resulting sum is saved into the second register that’s specified.\n（B和A的）顺序很重要，因为结果会存在第二个寄存器\n\nSo in this case, the resulting sum is saved into Register A.\n也就是寄存器 A\n\nAnd finally, our last instruction is \"STORE_A 13\", which instructs the CPU to write whatever\n最后一条指令是 \"STORE_A 13\" \\N 把寄存器 A 的值存入内存地址 13\n\nvalue is in Register A into memory location 13.\n最后一条指令是 \"STORE_A 13\" \\N 把寄存器 A 的值存入内存地址 13\n\nYesss!\n好棒！\n\nOur program adds two numbers together.\n我们把 2 个数加在了一起!\n\nThat’s about as exciting as it gets when we only have four instructions to play with.\n毕竟只有4个指令，也只能做这个了.\n\nSo let’s add some more!\n加多一些指令吧!\n\nNow we’ve got a subtract function, which like ADD, specifies two registers to operate on.\nSUB 是减法，和 ADD 一样也要 2 个寄存器来操作.\n\nWe’ve also got a fancy new instruction called JUMP.\n还有 JUMP（跳转）\n\nAs the name implies, this causes the program to \"jump\" to a new location.\n让程序跳转到新位置\n\nThis is useful if we want to change the order of instructions, or choose to skip some instructions.\n如果想改变指令顺序，或跳过一些指令，这个很实用\n\nFor example, a JUMP 0, would cause the program to go back to the beginning.\n举例, JUMP 0 可以跳回开头\n\nAt a low level, this is done by writing the value specified in the last four bits into\nJUMP 在底层的实现方式是 \\N 把指令后 4 位代表的内存地址的值\n\nthe instruction address register, overwriting the current value.\n覆盖掉 \"指令地址寄存器\" 里的值\n\nWe’ve also added a special version of JUMP called JUMP_NEGATIVE.\n还有一个特别版的 JUMP 叫 JUMP_NEGATIVE\n\n\"This only jumps the program if the ALU’s negative flag is set to true.\n它只在 ALU 的 \"负数标志\" 为真时，进行 JUMP\n\nAs we talked about in Episode 5, the negative flag is only set\n第5集讲过，算术结果为负，\"负数标志\"才是真\n\nwhen the result of an arithmetic operation is negative.\n第5集讲过，算术结果为负，\"负数标志\"才是真\n\nIf the result of the arithmetic was zero or positive, the negative flag would not be set.\n结果不是负数时, \"负数标志\"为假\n\nSo the JUMP NEGATIVE won’t jump anywhere, and the CPU will just continue on to the next instruction.\n如果是假，JUMP_NEGATIVE 就不会执行 \\N 程序照常进行\n\nOur previous program really should have looked like this to be correct,\n我们之前的例子程序，其实应该是这样，才能正确工作.\n\notherwise the CPU would have just continued on after the STORE instruction, processing all those 0’s.\n否则跑完  STORE_A 13 之后，\\N CPU 会不停运行下去，处理后面的 0\n\nBut there is no instruction with an opcode of 0, and so the computer would have crashed!\n因为 0 不是操作码，所以电脑会崩掉!\n\nIt’s important to point out here that we’re storing\n我还想指出一点，指令和数据都是存在同一个内存里的.\n\nboth instructions and data in the same memory.\n我还想指出一点，指令和数据都是存在同一个内存里的.\n\nThere is no difference fundamentally -- it’s all just binary numbers.\n它们在根本层面上毫无区别 - 都是二进制数\n\nSo the HALT instruction is really important because it allows us to separate the two.\nHALT 很重要，能区分指令和数据\n\nOkay, so let’s make our program a bit more interesting, by adding a JUMP.\n好，现在用 JUMP 让程序更有趣一些.\n\nWe’ll also modify our two starting values in memory to 1 and 1.\n我们还把内存中 3 和 14 两个数字，改成 1 和 1\n\nLets step through this program just as our CPU would.\n现在来从 CPU 的视角走一遍程序\n\nFirst, LOAD_A 14 loads the value 1 into Register A.\n首先 LOAD_A 14，把 1 存入寄存器A \\N（因为地址 14 里的值是 1）\n\nNext, LOAD_B 15 loads the value 1 into Register B.\n然后 LOAD_B 15，把 1 存入寄存器B\\N（因为地址 15 里的值也是 1）\n\nAs before, we ADD registers B and A together, with the sum going into Register A. 1+1 = 2,\n然后 ADD B A 把寄存器 B 和 A 相加 \\N 结果放到寄存器 A 里\n\nso now Register A has the value 2 in it (stored in binary of course)\n现在寄存器 A 的值是 2 \\N (当然是以二进制存的）\n\nThen the STORE instruction saves that into memory location 13.\n然后 STORE_A 13 指令，把寄存器 A 的值存入内存地址 13\n\nNow we hit a \"JUMP 2\" instruction.\n现在遇到 JUMP 2 指令\n\nThis causes the processor to overwrite the value in the instruction address register,\nCPU 会把\"指令地址寄存器\"的值，现在是 4，改成 2\n\nwhich is currently 4, with the new value, 2.\nCPU 会把\"指令地址寄存器\"的值，现在是 4，改成 2\n\nNow, on the processor’s next fetch cycle, we don’t fetch HALT,\n因此下一步不再是 HALT\n\ninstead we fetch the instruction at memory location 2, which is ADD B A.\n而是读内存地址 2 里的指令，也就是 ADD B A\n\nWe’ve jumped!\n我们跳转了!\n\nRegister A contains the value 2, and register B contains the value 1.\n寄存器 A 里是 2，寄存器 B 里是 1\n\nSo 1+2 = 3, so now Register A has the value 3.\n1+2=3，寄存器 A 变成 3\n\nWe store that into memory.\n存入内存\n\nAnd we’ve hit the JUMP again, back to ADD B A.\n又碰到 JUMP 2，又回到 ADD B A.\n\n1+3=4\n1+3=4\n\nSo now register A has the value 4.\n现在寄存器 A 是 4\n\nSee what's happening here?\n发现了吗？\n\nEvery loop, we’re adding one.\n每次循环都+1\n\nIts counting up!\n不断增多\n\nCooooool.\n酷\n\nBut notice there’s no way to ever escape.\n但没法结束啊\n\nWe’re never.. ever.. going to get to that halt instruction,\n永远不会碰到 HALT\n\nbecause we’re always going to hit that JUMP.\n总是会碰到 JUMP\n\nThis is called an infinite loop – a program that runs forever… ever… ever… ever…\n这叫无限循环 - 这个程序会永远跑下去.. 下去.. 下去.. 下去\n\never\n下去\n\nTo break the loop, we need a conditional jump.\n为了停下来，我们需要有条件的 JUMP\n\nA jump that only happens if a certain condition is met.\n只有特定条件满足了，才执行 JUMP.\n\nOur JUMP_NEGATIVE is one example of a conditional jump,\n比如 JUMP NEGATIVE 就是条件跳转的一个例子\n\nbut computers have other types too - like JUMP IF EQUAL and JUMP IF GREATER.\n还有其他类型的条件跳转，比如\\N  JUMP IF EQUAL（如果相等）\\N JUMP IF GREATER（如果更大）\n\nSo let’s make our code a little fancier and step through it.\n现在把代码弄花哨一点，再过一遍代码\n\nLike before, the program starts by loading values from memory into registers A and B.\n就像之前，程序先把内存值放入寄存器 A 和 B.\n\nIn this example, the number 11 gets loaded into Register A, and 5 gets loaded into Register B.\n寄存器 A 是 11，寄存器 B 是 5\n\nNow we subtract register B from register A. That’s 11 minus 5, which is 6,\nSUB B A，用 A 减 B，11-5=6\n\nand so 6 gets saved into Register A.\n6 存入寄存器 A\n\nNow we hit our JUMP NEGATIVE.\nJUMP NEGATIVE 出场\n\nThe last ALU result was 6.\n上一次 ALU 运算的结果是 6\n\nThat’s a positive number, so the the negative flag is false.\n是正数，所以 \"负数标志\" 是假\n\nThat means the processor does not jump.\n因此处理器不会执行 JUMP\n\nSo we continue on to the next instruction...\n继续下一条指令\n\n...which is a JUMP 2.\nJUMP 2\n\nNo conditional on this one, so we jump to instruction 2 no matter what.\nJUMP 2 没有条件，直接执行！\n\nOk, so we’re back at our SUBTRACT Register B from Register A. 6 minus 5 equals 1.\n又回到寄存器 A-B，6-5=1\n\nSo 1 gets saved into register A.\nA 变成 1\n\nNext instruction.\n下一条指令\n\nWe’re back again at our JUMP NEGATIVE.\n又是 JUMP NEGATIVE\n\n1 is also a positive number, so the CPU continues on to the JUMP 2, looping back around again\n因为 1 还是正数，因此 JUMP NEGATIVE 不会执行 \\N 来到下一条指令，JUMP 2\n\nto the SUBTRACT instruction.\n又来减一次\n\nThis time is different though.\n这次就不一样了\n\n1 minus 5 is negative 4.\n1-5=-4\n\nAnd so the ALU sets its negative flag to true for the first time.\n这次ALU的 \"负数标志\" 是真\n\nNow, when we advance to the next instruction,\n现在下一条指令\n\nJUMP_NEGATIVE 5, the CPU executes the jump to memory location 5.\nJUMP NEGATIVE 5, CPU 的执行跳到内存地址 5\n\nWe’re out of the infinite loop!\n跳出了无限循环！\n\nNow we have a ADD B to A. Negative 4 plus 5, is positive 1, and we save that into Register A.\n现在的指令是 ADD B A，-4+5=1，1 存入寄存器 A\n\nNext we have a STORE instruction that saves Register A into memory address 13.\n下一条指令  STORE_A 13，把 A 的值存入内存地址 13\n\nLastly, we hit our HALT instruction and the computer rests.\n最后碰到 HALT 指令，停下来.\n\nSo even though this program is only 7 instructions long, the CPU ended up executing 13 instructions,\n虽然程序只有 7 个指令，但 CPU 执行了 13 个指令,\n\nand that's because it looped twice internally.\n因为在内部循环了 2 次.\n\nThis code calculated the remainder if we divide 5 into 11, which is one.\n这些代码其实是算余数的，11除5余1\n\nWith a few extra lines of code, we could also keep track of how many loops we did, the count\n如果加多几行指令，我们还可以跟踪循环了多少次\n\nof which would be how many times 5 went into 11… we did two loops, so that means 5 goes\n11除5，循环2次\n\ninto 11 two times... with a remainder of 1.\n余1\n\nAnd of course this code could work for any two numbers, which we can just change in memory\n当然，我们可以用任意2个数，7和81，18和54，什么都行\n\nto whatever we want: 7 and 81, 18 and 54, it doesn’t matter\n当然，我们可以用任意2个数，7和81，18和54，什么都行\n\n-- that’s the power of software!\n这就是软件的强大之处\n\nSoftware also allowed us to do something our hardware could not.\n软件还让我们做到硬件做不到的事\n\nRemember, our ALU didn’t have the functionality to divide two numbers,\nALU 可没有除法功能\n\ninstead it’s the program we made that gave us that functionality.\n是程序给了我们这个功能.\n\nAnd then other programs can use our divide program to do even fancier things.\n别的程序也可以用我们的除法程序，来做其他事情\n\nAnd you know what that means.\n这意味着  一层新抽象！\n\nNew levels of abstraction!\n这意味着  一层新抽象！\n\nSo, our hypothetical CPU is very basic – all of its instructions are 8 bits long,\n我们这里假设的 CPU 很基础，所有指令都是 8 位,\n\nwith the opcode occupying only the first four bits.\n操作码只占了前面 4 位\n\nSo even if we used every combination of 4 bits, our CPU would only be able to support\n即便用尽 4 位，也只能代表 16 个指令\n\na maximum of 16 different instructions.\n即便用尽 4 位，也只能代表 16 个指令\n\nOn top of that, several of our instructions used the last 4 bits to specify a memory location.\n而且我们有几条指令，是用后 4 位来指定内存地址\n\nBut again, 4 bits can only encode 16 different values,\n因为 4 位最多只能表示 16 个值，\n\nmeaning we can address a maximum of 16 memory locations - that’s not a lot to work with.\n所以我们只能操作 16 个地址，这可不多.\n\nFor example, we couldn’t even JUMP to location 17,\n我们甚至不能 JUMP 17\n\nbecause we literally can’t fit the number 17 into 4 bits.\n因为 4 位二进制无法表示数字 17\n\nFor this reason, real, modern CPUs use two strategies.\n因此，真正的现代 CPU 用两种策略\n\nThe most straightforward approach is just to have bigger instructions, with more bits,\n最直接的方法是用更多位来代表指令，比如 32 位或 64 位\n\nlike 32 or 64 bits.\n最直接的方法是用更多位来代表指令，比如 32 位或 64 位\n\nThis is called the instruction length.\n这叫 指令长度\n\nUnsurprisingly.\n毫不意外\n\nThe second approach is to use variable length instructions.\n第二个策略是 \"可变指令长度\"\n\nFor example, imagine a CPU that uses 8 bit opcodes.\n举个例子，比如某个 CPU 用 8 位长度的操作码\n\nWhen the CPU sees an instruction that needs no extra values, like the HALT instruction,\n如果看到 HALT 指令，HALT 不需要额外数据\n\nit can just execute it immediately.\n那么会马上执行.\n\nHowever, if it sees something like a JUMP instruction, it knows it must also fetch\n如果看到 JUMP，它得知道位置值\n\nthe address to jump to, which is saved immediately behind the JUMP instruction in memory.\n这个值在 JUMP 的后面\n\nThis is called, logically enough, an Immediate Value.\n这叫 \"立即值\"\n\nIn such processor designs, instructions can be any number of bytes long,\n这样设计，指令可以是任意长度\n\nwhich makes the fetch cycle of the CPU a tad more complicated.\n但会让读取阶段复杂一点点\n\nNow, our example CPU and instruction set is hypothetical,\n要说明的是，我们拿来举例的 CPU 和指令集都是假设的,\n\ndesigned to illustrate key working principles.\n是为了展示核心原理\n\nSo I want to leave you with a real CPU example.\n所以我们来看个真的 CPU 例子.\n\nIn 1971, Intel released the 4004 processor.\n1971年，英特尔发布了 4004 处理器.\n\nIt was the first CPU put all into a single chip\n这是第一次把 CPU 做成一个芯片  \\N 给后来的英特尔处理器打下了基础\n\nand paved the path to the intel processors we know and love today.\n这是第一次把 CPU 做成一个芯片  \\N 给后来的英特尔处理器打下了基础\n\nIt supported 46 instructions, shown here.\n它支持 46 个指令\n\nWhich was enough to build an entire working computer.\n足够做一台能用的电脑\n\nAnd it used many of the instructions we’ve talked about like JUMP ADD SUBTRACT and LOAD.\n它用了很多我们说过的指令，比如 JUMP ADD SUB LOAD\n\nIt also uses 8-bit immediate values, like we just talked about, for things like JUMPs,\n它也用 8 位的\"立即值\"来执行 JUMP, 以表示更多内存地址.\n\nin order to address more memory.\n它也用 8 位的\"立即值\"来执行 JUMP, 以表示更多内存地址.\n\nAnd processors have come a long way since 1971.\n处理器从 1971 年到现在发展巨大.\n\nA modern computer processor, like an Intel Core i7, has thousands of different instructions\n现代 CPU, 比如英特尔酷睿 i7, 有上千个指令和指令变种\n\nand instruction variants, ranging from one to fifteen bytes long.\n长度从1到15个字节.\n\nFor example, there’s over a dozens different opcodes just for variants of ADD!\n举例，光 ADD 指令就有很多变种!\n\nAnd this huge growth in instruction set size is due in large part to extra bells and whistles\n指令越来越多，是因为给 CPU 设计了越来越多功能\n\nthat have been added to processor designs overtime, which we’ll talk about next episode.\n下集我们会讲\n\nSee you next week!\n下周见\n\nHi, I’m Carrie Anne and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nAs we’ve discussed throughout the series, computers have come a long way from mechanical devices\n随着本系列进展，我们知道计算机进步巨大\n\ncapable of maybe one calculation per second,\n从 1 秒 1 次运算，到现在有千赫甚至兆赫的CPU\n\nto CPUs running at kilohertz and megahertz speeds.\n从 1 秒 1 次运算，到现在有千赫甚至兆赫的CPU\n\nThe device you’re watching this video on right now is almost certainly running at Gigahertz speeds\n你现在看视频的设备八成也有 GHz 速度\n\n- that’s billions of instructions executed every second.\n1 秒十亿条指令\n\nWhich, trust me, is a lot of computation!\n这是很大的计算量！\n\nIn the early days of electronic computing, processors were typically made faster by\n早期计算机的提速方式是  减少晶体管的切换时间.\n\nimproving the switching time of the transistors inside the chip\n早期计算机的提速方式是  减少晶体管的切换时间.\n\n- the ones that make up all the logic gates, ALUs\n晶体管组成了逻辑门，ALU 以及前几集的其他组件\n\nand other stuff we’ve talked about over the past few episodes.\n晶体管组成了逻辑门，ALU 以及前几集的其他组件\n\nBut just making transistors faster and more efficient only went so far, so processor designers\n但这种提速方法最终会碰到瓶颈，所以处理器厂商\n\nhave developed various techniques to boost performance allowing not only simple instructions\n发明各种新技术来提升性能，不但让简单指令运行更快\n\nto run fast, but also performing much more sophisticated operations.\n也让它能进行更复杂的运算\n\nLast episode, we created a small program for our CPU that allowed us to divide two numbers.\n上集我们写了个做除法的程序，给 CPU 执行\n\nWe did this by doing many subtractions in a row... so, for example, 16 divided by 4\n方法是做一连串减法，比如16除4 会变成\n\ncould be broken down into the smaller problem of 16 minus 4, minus 4, minus 4, minus 4.\n16-4 -4 -4 -4\n\nWhen we hit zero, or a negative number, we knew that we we’re done.\n碰到 0 或负数才停下.\n\nBut this approach gobbles up a lot of clock cycles, and isn’t particularly efficient.\n但这种方法要多个时钟周期，很低效\n\nSo most computer processors today have divide as one of the instructions\n所以现代 CPU 直接在硬件层面设计了除法 \\N 可以直接给 ALU 除法指令\n\nthat the ALU can perform in hardware.\n所以现代 CPU 直接在硬件层面设计了除法 \\N 可以直接给 ALU 除法指令\n\nOf course, this extra circuitry makes the ALU bigger and more complicated to design,\n这让 ALU 更大也更复杂一些\n\nbut also more capable - a complexity-for-speed tradeoff that\n但也更厉害 - \\N  复杂度 vs 速度 的平衡在计算机发展史上经常出现\n\nhas been made many times in computing history.\n但也更厉害 - \\N  复杂度 vs 速度 的平衡在计算机发展史上经常出现\n\nFor instance, modern computer processors now have special circuits for things like\n举例，现代处理器有专门电路来处理 \\N 图形操作, 解码压缩视频, 加密文档 等等\n\ngraphics operations, decoding compressed video, and encrypting files\n举例，现代处理器有专门电路来处理 \\N 图形操作, 解码压缩视频, 加密文档 等等\n\nall of which are operations that would take many many many clock cycles to perform with standard operations.\n如果用标准操作来实现，要很多个时钟周期.\n\nYou may have even heard of processors with MMX, 3DNow!, or SSE.\n你可能听过某些处理器有 MMX, 3DNOW, SEE\n\nThese are processors with additional, fancy circuits that allow them to\n它们有额外电路做更复杂的操作\n\nexecute additional fancy instructions - for things like gaming and encryption.\n用于游戏和加密等场景\n\nThese extensions to the instruction set have grown, and grown over time, and once people\n指令不断增加，人们一旦习惯了它的便利就很难删掉\n\nhave written programs to take advantage of them, it’s hard to remove them.\n指令不断增加，人们一旦习惯了它的便利就很难删掉\n\nSo instruction sets tend to keep getting larger and larger keeping all the old opcodes around for backwards compatibility.\n所以为了兼容旧指令集，指令数量越来越多\n\nThe Intel 4004, the first truly integrated CPU, had 46 instructions\n英特尔 4004，第一个集成CPU，有 46 条指令\n\n- which was enough to build a fully functional computer.\n足够做一台能用的计算机\n\nBut a modern computer processor has thousands of different instructions,\n但现代处理器有上千条指令，有各种巧妙复杂的电路\n\nwhich utilize all sorts of clever and complex internal circuitry.\n但现代处理器有上千条指令，有各种巧妙复杂的电路\n\nNow, high clock speeds and fancy instruction sets lead to another problem\n超高的时钟速度带来另一个问题\n\n- getting data in and out of the CPU quickly enough.\n- 如何快速传递数据给 CPU\n\nIt’s like having a powerful steam locomotive, but no way to shovel in coal fast enough.\n就像有强大的蒸汽机  但无法快速加煤\n\nIn this case, the bottleneck is RAM.\nRAM 成了瓶颈\n\nRAM is typically a memory module that lies outside the CPU.\nRAM 是 CPU 之外的独立组件\n\nThis means that data has to be transmitted to and from RAM along sets of data wires,\n意味着数据要用线来传递，叫\"总线\"\n\ncalled a bus.\n意味着数据要用线来传递，叫\"总线\"\n\nThis bus might only be a few centimeters long,\n总线可能只有几厘米\n\nand remember those electrical signals are traveling near the speed of light,\n别忘了电信号的传输接近光速\n\nbut when you are operating at gigahertz speeds\n但 CPU 每秒可以处理上亿条指令\n\n– that’s billionths of a second – even this small delay starts to become problematic.\n很小的延迟也会造成问题\n\nIt also takes time for RAM itself to lookup the address, retrieve the data\nRAM 还需要时间找地址 \\N 取数据，配置，输出数据\n\nand configure itself for output.\nRAM 还需要时间找地址 \\N 取数据，配置，输出数据\n\nSo a “load from RAM” instruction might take dozens of clock cycles to complete, and during\n一条\"从内存读数据\"的指令可能要多个时钟周期\n\nthis time the processor is just sitting there idly waiting for the data.\nCPU 空等数据\n\nOne solution is to put a little piece of RAM right on the CPU -- called a cache.\n解决延迟的方法之一是 \\N 给 CPU 加一点 RAM - 叫\"缓存\"\n\nThere isn’t a lot of space on a processor’s chip,\n因为处理器里空间不大，所以缓存一般只有 KB 或 MB\n\nso most caches are just kilobytes or maybe megabytes in size,\n因为处理器里空间不大，所以缓存一般只有 KB 或 MB\n\nwhere RAM is usually gigabytes.\n而 RAM 都是 GB 起步\n\nHaving a cache speeds things up in a clever way.\n缓存提高了速度\n\nWhen the CPU requests a memory location from RAM, the RAM can transmit\nCPU 从 RAM 拿数据时 \\N RAM 不用传一个，可以传一批\n\nnot just one single value, but a whole block of data.\nCPU 从 RAM 拿数据时 \\N RAM 不用传一个，可以传一批\n\nThis takes only a little bit more time,\n虽然花的时间久一点，但数据可以存在缓存\n\nbut it allows this data block to be saved into the cache.\n虽然花的时间久一点，但数据可以存在缓存\n\nThis tends to be really useful because computer data is often arranged and processed sequentially.\n这很实用，因为数据常常是一个个按顺序处理\n\nFor example, let say the processor is totalling up daily sales for a restaurant.\n举个例子，算餐厅的当日收入\n\nIt starts by fetching the first transaction from RAM at memory location 100.\n先取 RAM 地址 100 的交易额\n\nThe RAM, instead of sending back just that one value, sends a block of data, from memory\nRAM 与其只给1个值，直接给一批值\n\nlocation 100 through 200, which are then all copied into the cache.\n把地址100到200都复制到缓存\n\nNow, when the processor requests the next transaction to add to its running total, the\n当处理器要下一个交易额时\n\nvalue at address 101, the cache will say “Oh, I’ve already got that value right here,\n地址 101，缓存会说：\"我已经有了，现在就给你\"\n\nso I can give it to you right away!”\n地址 101，缓存会说：\"我已经有了，现在就给你\"\n\nAnd there’s no need to go all the way to RAM.\n不用去 RAM 取数据\n\nBecause the cache is so close to the processor,\n因为缓存离 CPU 近, 一个时钟周期就能给数据 - CPU 不用空等！\n\nit can typically provide the data in a single clock cycle -- no waiting required.\n因为缓存离 CPU 近, 一个时钟周期就能给数据 - CPU 不用空等！\n\nThis speeds things up tremendously over having to go back and forth to RAM every single time.\n比反复去 RAM 拿数据快得多\n\nWhen data requested in RAM is already stored in the cache like this it’s called a\n如果想要的数据已经在缓存，叫 缓存命中\n\ncache hit,\n如果想要的数据已经在缓存，叫 缓存命中\n\nand if the data requested isn’t in the cache, so you have to go to RAM, it’s a called\n如果想要的数据不在缓存，叫 缓存未命中\n\na cache miss.\n如果想要的数据不在缓存，叫 缓存未命中\n\nThe cache can also be used like a scratch space,\n缓存也可以当临时空间，存一些中间值，适合长/复杂的运算\n\nstoring intermediate values when performing a longer, or more complicated calculation.\n缓存也可以当临时空间，存一些中间值，适合长/复杂的运算\n\nContinuing our restaurant example, let’s say the processor has finished totalling up\n继续餐馆的例子，假设 CPU 算完了一天的销售额\n\nall of the sales for the day, and wants to store the result in memory address 150.\n想把结果存到地址 150\n\nLike before, instead of going back all the way to RAM to save that value,\n就像之前，数据不是直接存到 RAM\n\nit can be stored in cached copy, which is faster to save to,\n而是存在缓存，这样不但存起来快一些\n\nand also faster to access later if more calculations are needed.\n如果还要接着算，取值也快一些\n\nBut this introduces an interesting problem -\n但这样带来了一个有趣的问题\n\n- the cache’s copy of the data is now different to the real version stored in RAM.\n缓存和 RAM 不一致了.\n\nThis mismatch has to be recorded, so that at some point everything can get synced up.\n这种不一致必须记录下来，之后要同步\n\nFor this purpose, the cache has a special flag for each block of memory it stores, called\n因此缓存里每块空间  有一个特殊标记\n\nthe dirty bit\n叫 \"脏位\"\n\n-- which might just be the best term computer scientists have ever invented.\n- 这可能是计算机科学家取的最贴切的名字\n\nMost often this synchronization happens when the cache is full,\n同步一般发生在 当缓存满了而 CPU 又要缓存时\n\nbut a new block of memory is being requested by the processor.\n同步一般发生在 当缓存满了而 CPU 又要缓存时\n\nBefore the cache erases the old block to free up space, it checks its dirty bit,\n在清理缓存腾出空间之前，会先检查 \"脏位\"\n\nand if it’s dirty, the old block of data is written back to RAM before loading in the new block.\n如果是\"脏\"的, 在加载新内容之前, 会把数据写回 RAM\n\nAnother trick to boost cpu performance is called instruction pipelining.\n另一种提升性能的方法叫 \"指令流水线\"\n\nImagine you have to wash an entire hotel’s worth of sheets,\n想象下你要洗一整个酒店的床单\n\nbut you’ve only got one washing machine and one dryer.\n但只有 1 个洗衣机, 1 个干燥机\n\nOne option is to do it all sequentially: put a batch of sheets in the washer\n选择1：按顺序来，放洗衣机等 30 分钟洗完\n\nand wait 30 minutes for it to finish.\n选择1：按顺序来，放洗衣机等 30 分钟洗完\n\nThen take the wet sheets out and put them in the dryer and wait another 30 minutes for that to finish.\n然后拿出湿床单，放进干燥机等 30 分钟烘干\n\nThis allows you to do one batch of sheets every hour.\n这样1小时洗一批\n\nSide note: if you have a dryer that can dry a load of laundry in 30 minutes,\n另外一说：如果你有 30 分钟就能烘干的干燥机\n\nPlease tell me the brand and model in the comments, because I’m living with 90 minute dry times, minimum.\n请留言告诉我是什么牌子，我的至少要 90 分钟.\n\nBut, even with this magic clothes dryer,\n即使有这样的神奇干燥机,  \\N 我们可以用\"并行处理\"进一步提高效率\n\nyou can speed things up even more if you parallelize your operation.\n即使有这样的神奇干燥机,  \\N 我们可以用\"并行处理\"进一步提高效率\n\nAs before, you start off putting one batch of sheets in the washer.\n就像之前，先放一批床单到洗衣机\n\nYou wait 30 minutes for it to finish.\n等 30 分钟洗完\n\nThen you take the wet sheets out and put them in the dryer.\n然后把湿床单放进干燥机\n\nBut this time, instead of just waiting 30 minutes for the dryer to finish,\n但这次，与其干等 30 分钟烘干，\\N 可以放另一批进洗衣机\n\nyou simultaneously start another load in the washing machine.\n但这次，与其干等 30 分钟烘干，\\N 可以放另一批进洗衣机\n\nNow you’ve got both machines going at once.\n让两台机器同时工作\n\nWait 30 minutes, and one batch is now done, one batch is half done,\n30 分钟后，一批床单完成, 另一批完成一半\n\nand another is ready to go in.\n另一批准备开始\n\nThis effectively doubles your throughput.\n效率x2！\n\nProcessor designs can apply the same idea.\n处理器也可以这样设计\n\nIn episode 7, our example processor performed the fetch-decode-execute cycle sequentially\n第7集，我们演示了 CPU 按序处理\n\nand in a continuous loop: Fetch-decode-execute, fetch-decode-execute, fetch-decode-execute, and so on\n取指 → 解码 → 执行, 不断重复\n\nThis meant our design required three clock cycles to execute one instruction.\n这种设计，三个时钟周期执行 1 条指令\n\nBut each of these stages uses a different part of the CPU,\n但因为每个阶段用的是 CPU 的不同部分\n\nmeaning there is an opportunity to parallelize!\n意味着可以并行处理！\n\nWhile one instruction is getting executed, the next instruction could be getting decoded,\n\"执行\"一个指令时，同时\"解码\"下一个指令\n\nand the instruction beyond that fetched from memory.\n\"读取\"下下个指令\n\nAll of these separate processes can overlap\n不同任务重叠进行，同时用上 CPU 里所有部分.\n\nso that all parts of the CPU are active at any given time.\n不同任务重叠进行，同时用上 CPU 里所有部分.\n\nIn this pipelined design, an instruction is executed every single clock cycle\n这样的流水线  每个时钟周期执行1个指令\n\nwhich triples the throughput.\n吞吐量 x 3\n\nBut just like with caching this can lead to some tricky problems.\n和缓存一样，这也会带来一些问题\n\nA big hazard is a dependency in the instructions.\n第一个问题是 指令之间的依赖关系\n\nFor example, you might fetch something that the currently executing instruction is just about to modify,\n举个例子，你在读某个数据 \\N 而正在执行的指令会改这个数据\n\nwhich means you’ll end up with the old value in the pipeline.\n也就是说拿的是旧数据\n\nTo compensate for this, pipelined processors have to look ahead for data dependencies,\n因此流水线处理器  要先弄清数据依赖性\n\nand if necessary, stall their pipelines to avoid problems.\n必要时停止流水线，避免出问题\n\nHigh end processors, like those found in laptops and smartphones,\n高端 CPU，比如笔记本和手机里那种\n\ngo one step further and can dynamically reorder instructions with dependencies\n会更进一步，动态排序 有依赖关系的指令\n\nin order to minimize stalls and keep the pipeline moving,\n最小化流水线的停工时间\n\nwhich is called out-of-order execution.\n这叫 \"乱序执行\"\n\nAs you might imagine, the circuits that figure this all out are incredibly complicated.\n和你猜的一样，这种电路非常复杂\n\nNonetheless, pipelining is tremendously effective and almost all processors implement it today.\n但因为非常高效，几乎所有现代处理器都有流水线\n\nAnother big hazard are conditional jump instructions -- we talked about one example, a JUMP NEGATIVE,last episode.\n第二个问题是 \"条件跳转\"，比如上集的 JUMP NEGATIVE\n\nThese instructions can change the execution flow of a program depending on a value.\n这些指令会改变程序的执行流\n\nA simple pipelined processor will perform a long stall when it sees a jump instruction,\n简单的流水线处理器，看到 JUMP 指令会停一会儿 \\N 等待条件值确定下来\n\nwaiting for the value to be finalized.\n简单的流水线处理器，看到 JUMP 指令会停一会儿 \\N 等待条件值确定下来\n\nOnly once the jump outcome is known, does the processor start refilling its pipeline.\n一旦 JUMP 的结果出了，处理器就继续流水线\n\nBut, this can produce long delays, so high-end processors have some tricks to deal with this problem too.\n因为空等会造成延迟，所以高端处理器会用一些技巧\n\nImagine an upcoming jump instruction as a fork in a road - a branch.\n可以把 JUMP 想成是 \"岔路口\"\n\nAdvanced CPUs guess which way they are going to go, and start filling their pipeline with\n高端 CPU 会猜哪条路的可能性大一些\n\ninstructions based off that guess – a technique called speculative execution.\n然后提前把指令放进流水线，这叫 \"推测执行\"\n\nWhen the jump instruction is finally resolved, if the CPU guessed correctly,\n当 JUMP 的结果出了，如果 CPU 猜对了\n\nthen the pipeline is already full of the correct instructions and it can motor along without delay.\n流水线已经塞满正确指令，可以马上运行\n\nHowever, if the CPU guessed wrong, it has to discard all its speculative results and\n如果 CPU 猜错了，就要清空流水线\n\nperform a pipeline flush - sort of like when you miss a turn and have to do a u-turn to\n就像走错路掉头\n\nget back on route, and stop your GPS’s insistent shouting.\n让 GPS 不要再！叫！了！\n\nTo minimize the effects of these flushes, CPU manufacturers have developed sophisticated\n为了尽可能减少清空流水线的次数，CPU 厂商开发了复杂的方法\n\nways to guess which way branches will go, called branch prediction.\n来猜测哪条分支更有可能，叫\"分支预测\"\n\nInstead of being a 50/50 guess, today’s processors can often guess with over 90% accuracy!\n现代 CPU 的正确率超过 90%\n\nIn an ideal case, pipelining lets you complete one instruction every single clock cycle,\n理想情况下，流水线一个时钟周期完成 1 个指令\n\nbut then superscalar processors came along\n然后\"超标量处理器\"出现了，一个时钟周期完成多个指令\n\nwhich can execute more than one instruction per clock cycle.\n然后\"超标量处理器\"出现了，一个时钟周期完成多个指令\n\nDuring the execute phase even in a pipelined design,\n即便有流水线设计，在指令执行阶段\n\nwhole areas of the processor might be totally idle.\n处理器里有些区域还是可能会空闲\n\nFor example, while executing an instruction that fetches a value from memory,\n比如，执行一个 \"从内存取值\" 指令期间\n\nthe ALU is just going to be sitting there, not doing a thing.\nALU 会闲置\n\nSo why not fetch-and-decode several instructions at once, and whenever possible, execute instructions\n所以一次性处理多条指令（取指令+解码） 会更好.\n\nthat require different parts of the CPU all at the same time\n如果多条指令要 ALU 的不同部分，就多条同时执行\n\nBut we can take this one step further and add duplicate circuitry\n我们可以再进一步，加多几个相同的电路 \\N 执行出现频次很高的指令\n\nfor popular instructions.\n我们可以再进一步，加多几个相同的电路 \\N 执行出现频次很高的指令\n\nFor example, many processors will have four, eight or more identical ALUs,\n举例，很多 CPU 有四个, 八个甚至更多 完全相同的ALU\n\nso they can execute many mathematical instructions all in parallel!\n可以同时执行多个数学运算\n\nOk, the techniques we’ve discussed so far primarily optimize the execution throughput\n好了，目前说过的方法，都是优化 1 个指令流的吞吐量\n\nof a single stream of instructions,\n好了，目前说过的方法，都是优化 1 个指令流的吞吐量\n\nbut another way to increase performance is to run several streams of instructions at once\n另一个提升性能的方法是 同时运行多个指令流\n\nwith multi-core processors.\n用多核处理器\n\nYou might have heard of dual core or quad core processors.\n你应该听过双核或四核处理器\n\nThis means there are multiple independent processing units inside of a single CPU chip.\n意思是一个 CPU 芯片里，有多个独立处理单元\n\nIn many ways, this is very much like having multiple separate CPUs,\n很像是有多个独立 CPU\n\nbut because they’re tightly integrated, they can share some resources,\n但因为它们整合紧密，可以共享一些资源\n\nlike cache, allowing the cores to work together on shared computations.\n比如缓存，使得多核可以合作运算\n\nBut, when more cores just isn’t enough, you can build computers with multiple independent CPUs!\n但多核不够时，可以用多个 CPU\n\nHigh end computers, like the servers streaming this video from YouTube’s datacenter, often\n高端计算机，比如现在给你传视频的 Youtube 服务器\n\nneed the extra horsepower to keep it silky smooth for the hundreds of people watching simultaneously.\n需要更多马力，让上百人能同时流畅观看\n\nTwo- and four-processor configuration are the most common right now,\n2个或4个CPU是最常见的\n\nbut every now and again even that much processing power isn’t enough.\n但有时人们有更高的性能要求\n\nSo we humans get extra ambitious and build ourselves a supercomputer!\n所以造了超级计算机！\n\nIf you’re looking to do some really monster calculations\n如果要做怪兽级运算\n\n– like simulating the formation of the universe - you’ll need some pretty serious compute power.\n比如模拟宇宙形成，你需要强大的计算能力\n\nA few extra processors in a desktop computer just isn’t going to cut it.\n给普通台式机加几个 CPU 没什么用\n\nYou’re going to need a lot of processors.\n你需要很多处理器！\n\nNo.. no... even more than that.\n不…不…还要更多\n\nA lot more!\n更多\n\nWhen this video was made, the world’s fastest computer was located in\n截止至视频发布，世上最快的计算机在\n\nThe National Supercomputing Center in Wuxi, China.\n中国无锡的国家超算中心\n\nThe Sunway TaihuLight contains a brain-melting 40,960 CPUs, each with 256 cores!\n神威·太湖之光有 40960 个CPU，每个 CPU 有 256 个核心\n\nThats over ten million cores in total... and each one of those cores runs at 1.45 gigahertz.\n总共超过1千万个核心，每个核心的频率是 1.45GHz\n\nIn total, this machine can process 93 Quadrillion -- that’s 93 million-billions\n每秒可以进行 9.3 亿亿次浮点数运算\n\nfloating point math operations per second, knows as FLOPS.\n也叫 每秒浮点运算次数 (FLOPS)\n\nAnd trust me, that’s a lot of FLOPS!!\n相信我  这个速度很可怕\n\nNo word on whether it can run Crysis at max settings, but I suspect it might.\n没人试过跑最高画质的《孤岛危机》但我估计没问题\n\nSo long story short, not only have computer processors gotten a lot faster over the years,\n长话短说，这些年处理器不但大大提高了速度\n\nbut also a lot more sophisticated, employing all sorts of clever tricks to squeeze out\n而且也变得更复杂，用各种技巧\n\nmore and more computation per clock cycle.\n榨干每个时钟周期 做尽可能多运算\n\nOur job is to wield that incredible processing power to do cool and useful things.\n我们的任务是利用这些运算能力，做又酷又实用的事\n\nThat’s the essence of programming, which we’ll start discussing next episode.\n编程就是为了这个，我们下集说\n\nSee you next week.\n下周见\n\nHi, I'm Carrie Anne and welcome to Crash Course Computer Science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the last few episodes,\n前几集我们把重点放在计算机的原理\n\nWe've talked a lot about the mechanics of how computers work.\n前几集我们把重点放在计算机的原理\n\nHow they use complex circuits to save and retrieve values from memory,\n怎么从内存读写数据，执行操作\n\nand perform operations on those values\n怎么从内存读写数据，执行操作\n\nlike adding two numbers together.\n比如把两个数字加在一起\n\nWe've even briefly talked about sequences of operations,\n还简单讲了下指令的执行，也就是计算机程序\n\nwhich is a computer program\n还简单讲了下指令的执行，也就是计算机程序\n\nWhat we haven't talked about is how a program gets into a computer?\n但我们还没讲的是：程序如何\"进入\"计算机\n\nYou might remember in episode 7 and 8 ,\n你应该记得在第 7, 8 集，我们一步步讲了例子程序\n\nwe step through some simple example programs for the CPU that we had created\n你应该记得在第 7, 8 集，我们一步步讲了例子程序\n\nFor simplicity, we just waved our hands and said that the program was already magically in memory\n当时为了简单，我们假设程序已经魔法般在内存里了\n\nBut in reality, programs have to be loaded into a computer's memory.\n但事实是，程序需要加载进内存\n\nIt's not magic. It's computer science\n这不是魔法，是计算机科学！\n\nThe need to program machines existed way before the development of computers.\n给机器编程这个需求，早在计算机出现之前就有了\n\nThe most famous example of this was in textile manufacturing\n最著名的例子来自纺织业\n\nIf you just wanted to weave a big red tablecloth\n如果你只想织一块红色大桌布\n\nYou could simply feed red thread into a loom and let it run\n可以直接放红线进织布机\n\nWhat about if you wanted the cloth to have a pattern like stripes or plaid?\n但如果想要图案怎么办? 比如条纹或者方格\n\nWorkers would have to periodically reconfigure the loom as dictated by the pattern,\n工人要每隔一会儿 调整一次织布机\n\nbut this was labor intensive which made patterned fabrics expensive.\n因为非常消耗劳动力，所以图案纺织品很贵\n\nThe presence or absence of a hole in the card determined if a specific thread was held high or low in the loom\n特定位置有没有穿孔，决定了线是高是低\n\nSuch as the cross thread, called the weft,  passed above or below the thread\n横线是从上/从下穿过\n\nTo vary the pattern across rows these punch cards were arranged in long chains\n为了让每行图案不同，纸卡连成长条\n\nForming a sequence of commands for the loom.\n形成连续指令\n\nSound familiar?\n听起来很熟？\n\nMany consider Jacquard loom to be one of the earliest forms of programming.\n很多人认为雅卡尔织布机是最早的编程\n\nPunched cards, turned out to be a cheap, reliable, fairly human-readable way to store data.\n事实证明 穿孔纸卡便宜、可靠、也易懂\n\nNearly a century later,\n近一个世纪后\n\npunch cards were used to help tabulate the 1890 US census\n穿孔纸卡用于 1890 年美国人口普查\n\nwhich we talked about in episode 1\n我们在第一集提过\n\nEach card held an individual person's data.\n一张卡存一个人的信息\n\nthings like race\n比如种族\n\nmarital status\n婚姻状况\n\nnumber of children\n子女数量\n\ncountry of birth and so on\n出生国家 等等\n\nfor each demographic question\n针对每个问题，人口普查工作者会在对应位置打孔\n\na census worker would punch out a hole of the appropriate position\n针对每个问题，人口普查工作者会在对应位置打孔\n\nwhen a card was fed into the tabulating machine\n当卡片插入汇总机\n\na hole would cause the running total for that specific answer to be increased by one\n孔会让对应总和值+1\n\nin this way you could afeed the entire counties worth of people\n可以插入整个国家人口的卡片\n\nand at the end you'd have running totals for all of the questions that you ask\n在结束后得到各个总值\n\nIt is important to note here that early tabulating machines were not truly computers\n值得注意的是，早期汇总机不算计算机\n\nas they can only do one thing-tabulate\n因为它们只做一件事 - 汇总数据\n\ntheir operation was fixed and not programmable\n操作是固定的，不能编程\n\npunched cards stored data, but not a program\n穿孔纸卡存的是数据，不是程序.\n\nover the next 60 years, these business machines grew in capability\n之后60年，这些机器被加强，可以做减、乘、除\n\nAdding features to subtract multiply divide\n之后60年，这些机器被加强，可以做减、乘、除\n\nand even make simple decisions about when to perform certain operations.\n甚至可以做一些小决定，决定何时执行某指令\n\nTo trigger these functions appropriately\n为了正确执行不同计算，程序员需要某种控制面板\n\nso that different calculations could be performed, a programmer accessed a control panel\n为了正确执行不同计算，程序员需要某种控制面板\n\nthis panel was full of little sockets into which a programmer would plug cables\n面板有很多小插孔，程序员可以插电线\n\nto pass values and signals between different parts of the machine\n让机器的不同部分  互相传数据和信号\n\nfor this reason they were also called plug boards\n因此也叫 \"插线板\"\n\nUnfortunately this meant having to rewire the machine each time a different program needed to be run\n不幸的是, 这意味着 运行不同程序要重新接线\n\nAnd so by the 1920s these plug boards were made swappable\n所以到 1920 年代，控制面板变成了可拔插\n\nThis not only made programming a lot more comfortable\n让编程更方便\n\nbut also allowed for different programs be plugged into a machine\n可以给机器插入不同程序\n\nFor example one board might be wired to calculate sales tax\n比如，一个插线板算销售税，另一个算工资单\n\nWhile another helps with payroll\n比如，一个插线板算销售税，另一个算工资单\n\nBut plug boards were fiendishly complicated to program\n但给插线板编程很复杂\n\nThis tangle of wires is a program for calculating a profit loss summary using an IBM 402 accounting machine\n图中乱成一团的线  负责算盈亏总额 \\N 用于 IBM 402 核算机\n\nwhich were popular in the 1940s\n在 1940 年代这样做很流行\n\nAnd this style of plug board programming wasn't unique through electromechanical computers\n用插线板编程  不只在机电计算机流行\n\nThe world's first general-purpose electronic computer, the ENIAC, completed in 1946\n世上第一台通用电子计算机，ENIAC，完成于 1946 年\n\nused a ton of them\n用了一大堆插线板\n\nEven after a program had been completely figured out on paper\n程序在纸上设计好之后\n\nPhysically wiring up the ENIAC and getting the program to run could take upwards of three weeks\n给 ENIAC 连线，最多可能花三个星期\n\nGiven the enormous cost of these early computers, weeks of downtime simply to switch programs was unacceptable\n因为早期计算机非常昂贵 \\N 停机几个星期只为换程序  完全无法接受\n\nand the new faster more flexible way to program machines was badly needed\n人们急需更快、更灵活的新方式来编程\n\nFortunately by the late 1940s and into the 50s\n幸运的是，到 1940 年代晚期 1950 年代初\n\nelectronic memory was becoming feasible\n内存变得可行\n\nAs costs fell, memory size grew, instead of storing a program as a physical plug board of wires\n价格下降, 容量上升.  与其把程序存在插线板\n\nit became possible to store a program entirely in a computer's memory\n存在内存变得可行\n\nwhere it could be easily changed by programmers and quickly accessed by the CPU\n这样程序易于修改、方便 CPU 快速读取\n\nthese machines were called Stored-program Computers\n这类机器叫 \"存储程序计算机\"\n\nWith enough computer memory you could store not only the program you wanted to run\n如果内存足够，不仅可以存要运行的程序\n\nbut also any data your program would need\n还可以存程序需要的数据\n\nincluding new values it created along the way\n包括程序运行时产生的新数据\n\nUnifying the program and data into a single shared memory is called the Von Neumann Architecture\n程序和数据都存在一个地方，叫 \"冯诺依曼结构\"\n\nnamed after John Von Neumann\n命名自 约翰·冯·诺依曼\n\na prominent mathematician and physicist who worked on the Manhattan project and several early electronic computers\n杰出的数学家和物理学家 \\N 参与了曼哈顿计划和早期电子计算机项目\n\nand once said I am thinking about something much more important than Bombs\n他曾说：我在思考比炸弹重要得多的东西\n\nI'm thinking about computers\n计算机\n\nThe hallmarks of a Von Neumann computer are a processing unit containing an arithmetic logic unit\n冯诺依曼计算机的标志是，一个处理器(有算术逻辑单元)+\n\ndata registers and instruction register and instruction address register\n数据寄存器+指令寄存器+指令地址寄存器\n\nAnd finally a memory to store both data and instructions\n+内存（负责存数据和指令)\n\nHopefully this sounds familiar\n希望这听起来很耳熟\n\nBecause we actually built a Von Neumann computer in episode 7\n因为第7集我们造了一个冯诺依曼计算机\n\nThe very first Von Neumann Architecture Stored-program computer\n第一台冯诺依曼架构的\"储存程序计算机\"\n\nwas constructed in 1948 by the University of Manchester, nicknamed Baby.\n由曼彻斯特大学于 1948 年建造完成，绰号\"宝宝\"\n\nand even the computer you are watching this video right now\n甚至你现在看视频的计算机，也在用一样的架构\n\nuses the same architecture\n甚至你现在看视频的计算机，也在用一样的架构\n\nNow electronic computer memory is great and all\n虽然有内存很棒\n\nbut you still have to load the program and data into the computer before it can run\n但程序和数据  依然需要某种方式输入计算机\n\nand for this reason punch cards were used\n所以用穿孔纸卡\n\nLet's get to the Thought bubbles\n让我们进入  思维泡泡\n\nWell into the 1980s almost all computers have a punch card reader\n到1980年代，几乎所有的计算机都有穿孔纸卡读取器\n\nwhich could suck in a single punch card at a time\n可以吸入一张卡片，把卡片内容写进内存\n\nand write the contents of the card into the computer's memory\n可以吸入一张卡片，把卡片内容写进内存\n\nIf you load it in a stack of punch cards,\n如果放了一叠卡片，读取器会一个个写进内存\n\nthe reader would load them all into memory sequentially as a big block\n如果放了一叠卡片，读取器会一个个写进内存\n\nonce the program and data were in memory, the computer would be told to execute it\n一旦程序和数据写入完毕，电脑会开始执行\n\nOf course even simple computer programs might have hundreds of instructions\n即便简单程序也有几百条指令，要用一叠纸卡来存\n\nwhich meant that programs were stored as stacks of punch cards\n即便简单程序也有几百条指令，要用一叠纸卡来存\n\nSo if you ever have the misfortune of accidentally dropping your program on the floor\n如果不小心摔倒弄撒了\n\nit could take you hours days or even weeks to put the code back in the right order\n要花上几小时、几天、甚至几周来整理\n\nA common trick was to draw a diagonal line on the side of the card stack called striping,\n有个小技巧是  在卡片侧面画对角线\n\nso you'd have at least some clue how to get it back into the right order\n如果弄散了，整理起来会方便很多\n\nThe largest program ever punched into punch cards was the US Air Force's SAGE air defense system, completed in 1955.\n用纸卡的最大型程序 \\N 是美国空军的 SAGE 防空系统，于 1955 年完成\n\nand its peak, the project is said to have employed 20% of the world's programmers\n据称顶峰时期 雇佣了世上 20% 程序员\n\nIts main control program was stored on a whopping 62,500 punch cards\n主控制程序用了 62500 张穿孔纸卡\n\nwhich is equivalent to roughly 5 megabytes of data\n等同于大约 5MB 的数据\n\nPretty underwhelming by today's standards\n以如今的标准，不值一提\n\nAnd punch cards weren't only useful for getting data into computers\n穿孔纸卡不仅可以往计算机放数据\n\nbut also getting data out of them\n还可以取出数据\n\nAt the end of a program results could be written out of computer memory and onto punch cards by, well, punching cards\n程序运行到最后，结果可以输到纸卡上，方式嘛，当然是打孔\n\nthen this data could be analyzed by humans or loaded into a second program for additional computation\n然后人可以分析结果，或者再次放进计算机，做进一步计算\n\nThanks, thought-bubble\n谢了 思维泡泡\n\nA close cousin to punch cards was punched paper tape\n穿孔纸卡 的亲戚是纸带\n\nWhich is basically the same idea, but continuous instead of being on individual cards\n基本是一回事，只不过更连续，不是一张张卡.\n\nAnd of course we haven't talked about Hard Drives, CD-ROMs, DVDs, USB-Thumb drives and other similar goodies\n当然我们还没提硬盘, 只读光盘, DVD, U盘等等\n\nWe'll get to those more advanced types of data storage in a future episode\n以后我们会讲这些更先进的存储方法\n\nFinally in addition to plug boards and punch paper\n最后，除了插线板和穿孔纸卡\n\nthere was another common way to program and control computers in pre-1980\n在 1980 年代前，还有一种常见编程方式\n\nPanel programming\n面板编程\n\nRather than having to physically plug in cables to activate certain functions\n与其插一堆线到插线板\n\nthis could also be done with huge panels full of switches and buttons\n可以用一大堆开关和按钮，做到一样的效果\n\nAnd there were indicator lights to display the status of various functions and values in memory\n面板上有指示灯，代表各种函数的状态和内存中的值\n\nComputers of the 50s and 60s often featured huge control consoles that look like this\n50和60年代的计算机，一般都有这样巨大的控制台\n\nAlthough it was rare to input a whole program using just switches,it was possible\n很少有人只用开关来输入一整个程序，但技术上是可行的\n\nAnd early home computers made for the hobbyist market use switches extensively\n早期针对计算机爱好者的家用计算机，大量使用了开关\n\nbecause most home users couldn't afford expensive peripherals like punch card readers\n因为大多数家庭用户负担不起昂贵的外围设备 \\N 比如穿孔纸卡读取器\n\nThe first commercially successful home computer was the Altair 8800\n第一款取得商业成功的家用计算机是 Altair 8800\n\nwhich sold in two versions: Pre-assembled and the Kit\n有两种版本可以买: \\N 1. 预先装好的整机  \\N 2. 需要组装的组件\n\nthe Kit which was popular with amateur computing enthusiasts,\n计算机爱好者 喜欢买组件版\n\nsold for the then unprecedented low price are around $400 in 1975\n售价极低，在 1975 年卖 400 美元左右\n\nOr about $2,000 in 2017\n相当于 2017 年的 2000 美元\n\nTo program the 8800, you'd literally toggle the switches on the front panel\n为了给 8800 编程，你要拨动面板上的开关\n\nto enter the binary op-codes for the instruction you wanted\n输入二进制操作码\n\nThen you press the deposit button to write that value into memory\n然后按 \"存储键\" 把值存入内存\n\nThen in the next location in memory you toggle the switches again\n然后会到下一个内存位置 \\N 你可以再次拨开关，写下一个指令\n\nfor your next instruction deposit it and so on\n重复这样做\n\nWhen you finally entered your whole program into memory\n把整个程序都写入内存之后\n\nyou would toggle the switches moves back to memory address 0\n可以推动开关，回到内存地址0\n\npress the run button and watch the little lights blink\n然后按运行按钮，灯会闪烁\n\nThat was home computing in 1975, Wow.\n这就是 1975 年的家用计算机, 哇.\n\nWhether it was plug board, switches or punched paper\n不管是插线板、开关或穿孔纸卡\n\nProgramming these early computers was the realm of experts\n早期编程都是专家活\n\neither professionals who did this for living or technology enthusiasts\n不管是全职还是技术控，都要非常了解底层硬件\n\nyou needed intimate knowledge of the underlying hardware,\n不管是全职还是技术控，都要非常了解底层硬件\n\nso things like processor op-codes and register wits, to write programs\n比如 操作码, 寄存器等, 才能写程序\n\nThis meant programming was hard and tedious and even professional engineers\n所以编程很难，很烦\n\nand scientists struggled to take full advantage of what computing could offer\n哪怕工程师和科学家都无法 完全发挥计算机的能力\n\nWhat was needed was a simpler way to tell computers what to do,\n我们需要一种更简单方式  告诉计算机要做什么\n\na simpler way to write programs\n一种更简单的编程方式\n\nAnd that brings us to programming languages, which we'll talk about next episode\n这带领我们到下一个话题 - 编程语言, 我们下集会讲\n\nSee you next week\n下周见\n\nThis episode is brought to you by CuriosityStream.\n本集由 CuriosityStream 赞助播出\n\nHi, I'm Carrie Anne and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nSo far, for most of this series, we've focused on hardware\n之前我们把重点放在硬件 - 组成计算机的物理组件\n\n-- the physical components of computing --\n之前我们把重点放在硬件 - 组成计算机的物理组件\n\nthings like: electricity and circuits, registers and RAM, ALUs and CPUs.\n比如电，电路，寄存器，RAM，ALU，CPU\n\nBut programming at the hardware level is cumbersome and inflexible,\n但在硬件层面编程非常麻烦\n\nso programmers wanted a more versatile way to program computers\n所以程序员想要一种更通用的方法编程\n\n- what you might call a \"softer\" medium.\n- 一种\"更软的\"媒介\n\nThat's right, we're going to talk about Software!\n没错，我们要讲软件！\n\nIn episode 8, we walked through a simple program for the CPU we designed.\n第 8 集我们一步步讲了一个简单程序\n\nThe very first instruction to be executed, the one at memory address 0, was 0010 1110.\n第一条指令在内存地址 0：0010 1110\n\nAs we discussed, the first four bits of an instruction is the operation code,\n之前说过，前 4 位是操作码\n\nor OPCODE for short.\n简称 OPCODE\n\nOn our hypothetical CPU, 0010 indicated a LOAD_A instruction\n对于这个假设 CPU，0010 代表 LOAD_A 指令\n\n-- which moves a value from memory into Register A.\n- 把值从内存复制到寄存器 A\n\nThe second set of four bits defines the memory location,\n后 4 位是内存地址，1110 是十进制的 14\n\nin this case, 1110, which is 14 in decimal.\n后 4 位是内存地址，1110 是十进制的 14\n\nSo what these eight numbers really mean is \"LOAD Address 14 into Register A\".\n所以这 8 位表达的意思是 \\N  \"读内存地址 14，放入寄存器 A\"\n\nWe're just using two different languages.\n只是用了两种不同语言\n\nYou can think of it like English and Morse Code.\n可以想成是英语和摩尔斯码的区别\n\n\"Hello\" and \".... . .-.. .-.. ---\" mean the same thing -- hello! --\n\"你好\" 和 \".... . .-.. .-.. ---\" 是一个意思：你好\n\nthey're just encoded differently.\n只是编码方式不同\n\nEnglish and Morse Code also have different levels of complexity.\n英语和摩尔斯码的复杂度也不同\n\nEnglish has 26 different letters in its alphabet and way more possible sounds.\n英文有 26 个字母以及各种发音\n\nMorse only has dots and dashes.\n摩尔斯码只有\"点\"和\"线\"\n\nBut, they can convey the same information, and computer languages are similar.\n但它们可以传达相同的信息，计算机语言也类似.\n\nAs we've seen, computer hardware can only handle raw, binary instructions.\n计算机能处理二进制，二进制是处理器的\"母语\"\n\nThis is the \"language\" computer processors natively speak.\n计算机能处理二进制，二进制是处理器的\"母语\"\n\nIn fact, it's the only language they're able to speak.\n事实上，它们*只能*理解二进制\n\nIt's called Machine Language or Machine Code.\n这叫\"机器语言\"或\"机器码\"\n\nIn the early days of computing, people had to write entire programs in machine code.\n在计算机早期阶段，必须用机器码写程序\n\nMore specifically, they'd first write a high-level version of a program on paper, in English,\n具体来讲，会先在纸上用英语写一个\"高层次版\"\n\nFor example \"retrieve the next sale from memory,\n举例：\"从内存取下一个销售额，\n\nthen add this to the running total for the day, week and year,\n然后加到天、周、年的总和\n\nthen calculate any tax to be added\"\n然后算税\"\n\n...and so on.\n等等...\n\nAn informal, high-level description of a program like this is called Pseudo-Code.\n这种对程序的高层次描述，叫 \"伪代码\"\n\nThen, when the program was all figured out on paper,\n在纸上写好后\n\nthey'd painstakingly expand and translate it into binary machine code by hand,\n用\"操作码表\"把伪代码转成二进制机器码\n\nusing things like opcode tables.\n用\"操作码表\"把伪代码转成二进制机器码\n\nAfter the translation was complete, the program could be fed into the computer and run.\n翻译完成后，程序可以喂入计算机并运行\n\nAs you might imagine, people quickly got fed up with this process.\n你可能猜到了，很快人们就厌烦了\n\nSo, by the late 1940s and into the 50s,\n所以在 1940~1950 年代\n\nprogrammers had developed slightly higher-level languages that were more human-readable.\n程序员开发出一种新语言， 更可读 更高层次\n\nOpcodes were given simple names, called mnemonics,\n每个操作码分配一个简单名字，叫\"助记符\"\n\nwhich were followed by operands, to form instructions.\n\"助记符\"后面紧跟数据，形成完整指令\n\nSo instead of having to write instructions as a bunch of 1's and 0's,\n与其用 1 和 0 写代码，程序员可以写\"LOAD_A 14\"\n\nprogrammers could write something like \"LOAD_A 14\".\n与其用 1 和 0 写代码，程序员可以写\"LOAD_A 14\"\n\nWe used this mnemonic in Episode 8 because it's so much easier to understand!\n我们在第 8 集用过这个助记符，因为容易理解得多！\n\nOf course, a CPU has no idea what \"LOAD_A 14\" is.\n当然，CPU 不知道 LOAD_A 14 是什么\n\nIt doesn't understand text-based language, only binary.\n它不能理解文字，只能理解二进制\n\nAnd so programmers came up with a clever trick.\n所以程序员想了一个技巧，写二进制程序来帮忙\n\nThey created reusable helper programs, in binary,\n所以程序员想了一个技巧，写二进制程序来帮忙\n\nthat read in text-based instructions,\n它可以读懂文字指令，自动转成二进制指令\n\nand assemble them into the corresponding binary instructions automatically.\n它可以读懂文字指令，自动转成二进制指令\n\nThis program is called\n这种程序叫\n\n-- you guessed it --\n你可能猜到了\n\nan Assembler.\n汇编器\n\nIt reads in a program written in an Assembly Language\n汇编器读取用\"汇编语言\"写的程序，然后转成\"机器码\"\n\nand converts it to native machine code.\n汇编器读取用\"汇编语言\"写的程序，然后转成\"机器码\"\n\n\"LOAD_A 14\" is one example of an assembly instruction.\n\"LOAD_A 14\" 是一个汇编指令的例子\n\nOver time, Assemblers gained new features that made programming even easier.\n随着时间推移，汇编器有越来越多功能，让编程更容易\n\nOne nifty feature is automatically figuring out JUMP addresses.\n其中一个功能是自动分析 JUMP 地址\n\nThis was an example program I used in episode 8:\n这里有一个第8集用过的例子：\n\nNotice how our JUMP NEGATIVE instruction jumps to address 5,\n注意, JUMP NEGATIVE 指令跳到地址 5\n\nand our regular JUMP goes to address 2.\nJUMP 指令跳到地址 2\n\nThe problem is, if we add more code to the beginning of this program,\n问题是，如果在程序开头多加一些代码\n\nall of the addresses would change.\n所有地址都会变\n\nThat's a huge pain if you ever want to update your program!\n更新程序会很痛苦！\n\nAnd so an assembler does away with raw jump addresses,\n所以汇编器不用固定跳转地址\n\nand lets you insert little labels that can be jumped to.\n而是让你插入可跳转的标签\n\nWhen this program is passed into the assembler,\n当程序被传入汇编器，汇编器会自己搞定跳转地址\n\nit does the work of figuring out all of the jump addresses.\n当程序被传入汇编器，汇编器会自己搞定跳转地址\n\nNow the programmer can focus more on programming\n程序员可以专心编程，不用管底层细节\n\nand less on the underlying mechanics under the hood\n程序员可以专心编程，不用管底层细节\n\nenabling more sophisticated things to be built by hiding unnecessary complexity.\n隐藏不必要细节来做更复杂的工作\n\nAs we've done many times in this series,\n我们又提升了一层抽象\n\nwe're once again moving up another level of abstraction.\n我们又提升了一层抽象\n\nHowever, even with nifty assembler features like auto-linking JUMPs to labels,\n然而，即使汇编器有这些厉害功能，比如自动跳转\n\nAssembly Languages are still a thin veneer over machine code.\n汇编只是修饰了一下机器码\n\nIn general, each assembly language instruction converts directly\n一般来说，一条汇编指令对应一条机器指令\n\nto a corresponding machine instruction - a one-to-one mapping -\n一般来说，一条汇编指令对应一条机器指令\n\nso it's inherently tied to the underlying hardware.\n所以汇编码和底层硬件的连接很紧密\n\nAnd the assembler still forces programmers to think about\n汇编器仍然强迫程序员思考  用什么寄存器和内存地址\n\nwhich registers and memory locations they will use.\n汇编器仍然强迫程序员思考  用什么寄存器和内存地址\n\nIf you suddenly needed an extra value,\n如果你突然要一个额外的数，可能要改很多代码\n\nyou might have to change a lot of code to fit it in.\n如果你突然要一个额外的数，可能要改很多代码\n\nLet's go to the Thought Bubble.\n让我们进入思考泡泡\n\nThis problem did not escape Dr. Grace Hopper.\n葛丽丝·霍普博士 也遇到了这个问题\n\nAs a US naval officer, she was one of the first programmers on the Harvard Mark 1 computer,\n作为美国海军军官，她是哈佛1号计算机的首批程序员之一\n\nwhich we talked about in Episode 2.\n这台机器我们在第 2 集提过\n\nThis was a colossal, electro-mechanical beast\n这台巨大机电野兽在 1944 年战时建造完成，帮助盟军作战\n\ncompleted in 1944 as part of the allied war effort.\n这台巨大机电野兽在 1944 年战时建造完成，帮助盟军作战\n\nPrograms were stored and fed into the computer on punched paper tape.\n程序写在打孔纸带上，放进计算机执行\n\nBy the way, as you can see,\n顺便一说，如果程序里有漏洞\n\nthey \"patched\" some bugs in this program\n顺便一说，如果程序里有漏洞\n\nby literally putting patches of paper over the holes on the punch tape.\n真的就 直接用胶带来补\"漏洞\"\n\nThe Mark 1's instruction set was so primitive,\nMark 1 的指令集非常原始，甚至没有 JUMP 指令\n\nthere weren't even JUMP instructions.\nMark 1 的指令集非常原始，甚至没有 JUMP 指令\n\nTo create code that repeated the same operation multiple times,\n如果代码要跑不止一次\n\nyou'd tape the two ends of the punched tape together, creating a physical loop.\n得把带子的两端连起来  做成循环\n\nIn other words, programming the Mark 1 was kind of a nightmare!\n换句话说，给 Mark 1 编程简直是噩梦！\n\nAfter the war, Hopper continued to work at the forefront of computing.\n战后，霍普继续在计算机前沿工作\n\nTo unleash the potential of computers,\n为了释放电脑的潜力\n\nshe designed a high-level programming language called \"Arithmetic Language Version 0\",\n她设计了一个高级编程语言，叫\"算术语言版本 0\"\n\nor A-0 for short.\n简称\"A-0\"\n\nAssembly languages have direct, one-to-one mapping to machine instructions.\n汇编与机器指令是一一对应的\n\nBut, a single line of a high-level programming language\n但一行高级编程语言  可能会转成几十条二进制指令\n\nmight result in dozens of instructions being executed by the CPU.\n但一行高级编程语言  可能会转成几十条二进制指令\n\nTo perform this complex translation, Hopper built the first compiler in 1952.\n为了做到这种复杂转换 \\N Hopper 在 1952 年创造了第一个编译器\n\nThis is a specialized program\n编译器专门把高级语言 转成低级语言\n\nthat transforms \"source\" code written in a programming language into a low-level language,\n编译器专门把高级语言 转成低级语言\n\nlike assembly or the binary \"machine code\" that the CPU can directly process.\n比如汇编或机器码（CPU 可以直接执行机器码）\n\nThanks, Thought Bubble.\n谢了 思想泡泡\n\nSo, despite the promise of easier programming,\n尽管\"使编程更简单\"很诱人\n\nmany people were skeptical of Hopper's idea.\n但很多人对霍普的点子持怀疑态度\n\nShe once said, \"I had a running compiler and nobody would touch it.\n她曾说\"我有能用的编译器，但没人愿意用\n\nthey carefully told me, computers could only do arithmetic;\n他们告诉我计算机只能做算术,不能运行程序\"\n\nthey could not do programs.\"\n他们告诉我计算机只能做算术,不能运行程序\"\n\nBut the idea was a good one,\n但这个点子是好的\n\nand soon many efforts were underway to craft new programming languages\n不久，很多人尝试创造新编程语言\n\n-- today there are hundreds!\n- 如今有上百种语言！\n\nSadly, there are no surviving examples of A-0 code,\n可惜的是，没有任何 A-0 的代码遗留下来\n\nso we'll use Python, a modern programming language, as an example.\n所以我们用 Python 举例（一门现代编程语言）\n\nLet's say we want to add two numbers and save that value.\n假设我们想相加两个数字，保存结果\n\nRemember, in assembly code,\n记住，如果用汇编代码\n\nwe had to fetch values from memory, deal with registers, and other low-level details.\n我们得从内存取值，和寄存器打交道，以及其他底层细节\n\nBut this same program can be written in python like so:\n但同样的程序可以用 Python 这样写：\n\nNotice how there are no registers or memory locations to deal with\n不用管寄存器或内存位置\n\n-- the compiler takes care of that stuff, abstracting away a lot of low-level and unnecessary complexity.\n- 编译器会搞定这些细节，不用管底层细节\n\nThe programmer just creates abstractions for needed memory locations, known as variables,\n程序员只需要创建 代表内存地址的抽象，叫\"变量\"\n\nand gives them names.\n给变量取名字\n\nSo now we can just take our two numbers, store them in variables we give names to\n现在可以把两个数 存在变量里\n\n-- in this case, I picked a and b but those variables could be anything -\n这里取名 A 和 B, 实际编程时你可以随便取名\n\nand then add those together, saving the result in c, another variable I created.\n然后相加两个数，把结果存在变量 C\n\nIt might be that the compiler assigns Register A under the hood to store the value in a,\n底层操作时，编译器可能把变量 A 存在寄存器 A\n\nbut I don't need to know about it!\n但我不需要知道这些！\n\nOut of sight, out of mind!\n眼不见心不烦\n\nIt was an important historical milestone,\n这是个重要历史里程碑\n\nbut A-0 and its later variants weren't widely used.\n但 A-0 和之后的版本没有广泛使用\n\nFORTRAN, derived from \"Formula Translation\",\nFORTRAN，名字来自 \"公式翻译\"\n\nwas released by IBM a few years later, in 1957,\n这门语言数年后由 IBM 在 1957 年发布\n\nand came to dominate early computer programming.\n主宰了早期计算机编程\n\nJohn Backus, the FORTRAN project director,\nFORTRAN 项目总监 John Backus 说过\n\nsaid: \"Much of my work has come from being lazy.\n\"我做的大部分工作都是因为懒\n\nI didn't like writing programs,\n我不喜欢写程序\n\nand so ... I started work on a programming system to make it easier to write programs.\"\n所以我写这门语言，让编程更容易\"\n\nYou know, typical lazy person.\n你懂的，典型的\"懒人\"\n\nThey're always creating their own programming systems.\n（白眼）创造自己的编程语言\n\nAnyway, on average, programs written in FORTRAN\n平均来说，FORTRAN 写的程序\n\nwere 20 times shorter than equivalent handwritten assembly code.\n比等同的手写汇编代码短 20 倍\n\nThen the FORTRAN Compiler would translate and expand that into native machine code.\n然后 FORTRAN 编译器会把代码转成机器码\n\nThe community was skeptical that the performance would be as good as hand written code,\n人们怀疑性能是否比得上手写代码\n\nbut the fact that programmers could write more code more quickly,\n但因为能让程序员写程序更快，所以成了一个更经济的选择\n\nmade it an easy choice economically:\n但因为能让程序员写程序更快，所以成了一个更经济的选择\n\ntrading a small increase in computation time for a significant decrease in programmer time.\n运行速度慢一点点，编程速度大大加快\n\nOf course, IBM was in the business of selling computers,\n当时 IBM 在卖计算机\n\nand so initially, FORTRAN code could only be compiled and run on IBM computers.\n因此最初 FORTRAN 代码只能跑在 IBM 计算机上\n\nAnd most programing languages and compilers of the 1950s\n1950 年代大多数编程语言和编译器\n\ncould only run on a single type of computer.\n只能运行在一种计算机上\n\nSo, if you upgraded your computer,\n如果升级电脑\n\nyou'd often have to re-write all the code too!\n可能要重写所有代码！\n\nIn response, computer experts from industry,\n因此工业界，学术界，政府的计算机专家 \\N 在 1959 年组建了一个联盟\n\nacademia and government formed a consortium in 1959\n因此工业界，学术界，政府的计算机专家 \\N 在 1959 年组建了一个联盟\n\n-- the Committee on Data Systems Languages, advised by our friend Grace Hopper --\n- 数据系统语言委员会，Grace Hopper 担任顾问\n\nto guide the development of a common programming language\n开发一种通用编程语言，可以在不同机器上通用\n\nthat could be used across different machines.\n开发一种通用编程语言，可以在不同机器上通用\n\nThe result was the high-level, easy to use,\n最后诞生了一门高级，易于使用，\n\nCommon Business-Oriented Language, or COBOL for short.\n\"普通面向商业语言\"，简称 COBOL\n\nTo deal with different underlying hardware,\n为了兼容不同底层硬件\n\neach computing architecture needed its own COBOL compiler.\n每个计算架构需要一个 COBOL 编译器\n\nBut critically, these compilers could all accept the same COBOL source code,\n最重​​要的是，这些编译器都可以接收相同 COBOL 代码\n\nno matter what computer it was run on.\n不管是什么电脑\n\nThis notion is called write once, run anywhere.\n这叫\"一次编写，到处运行\"\n\nIt's true of most programming languages today,\n如今大多数编程语言都是这样\n\na benefit of moving away from assembly and machine code,\n不必接触 CPU 特有的汇编码和机器码\n\nwhich is still CPU specific.\n不必接触 CPU 特有的汇编码和机器码\n\nThe biggest impact of all this was reducing computing's barrier to entry.\n减小了使用门槛\n\nBefore high level programming languages existed,\n在高级编程语言出现之前\n\nit was a realm exclusive to computer experts and enthusiasts.\n编程只是计算机专家和爱好者才会做的事\n\nAnd it was often their full time profession.\n而且通常是主职\n\nBut now, scientists, engineers, doctors, economists, teachers,\n但现在，科学家，工程师，医生，经济学家，教师\n\nand many others could incorporate computation into their work .\n等等，都可以把计算机用于工作\n\nThanks to these languages,\n感谢这些语言\n\ncomputing went from a cumbersome and esoteric discipline\n计算机科学从深奥学科 变成了大众化工具\n\nto a general purpose and accessible tool.\n计算机科学从深奥学科 变成了大众化工具\n\nAt the same time, abstraction in programming allowed those computer experts\n同时，编程的抽象也让计算机专家\n\n- now \"professional programmers\" -\n现在叫\"专业程序员\"\n\nto create increasingly sophisticated programs,\n制作更复杂的程序\n\nwhich would have taken millions, tens of millions, or even more lines of assembly code.\n如果用汇编写可能要上百万行\n\nNow, this history didn't end in 1959.\n当然，计算机的历史没有在 1959 年结束\n\nIn fact, a golden era in programming language design jump started,\n编程语言设计的黄金时代才刚刚开始\n\nevolving in lockstep with dramatic advances in computer hardware.\n和硬件一起飞速发展\n\nIn the 1960s, we had languages like ALGOL, LISP and BASIC.\n在 1960 年代，有 ALGOL, LISP 和 BASIC 等语言\n\nIn the 70's: Pascal, C and Smalltalk were released.\n70年代有：Pascal，C 和 Smalltalk\n\nThe 80s gave us C++, Objective-C, and Perl.\n80年代有：C++，Objective-C 和 Perl\n\nAnd the 90's: python, ruby, and Java.\n90年代有：Python，Ruby 和 Java\n\nAnd the new millennium has seen the rise of Swift, C#, and Go\n新千年 Swift, C#, Go 在崛起\n\n- not to be confused with Let it Go and Pokemon Go.\n不要把 Go 和\\N 《冰雪奇缘》的 Let it Go 和游戏 Pokemon Go 弄混\n\nAnyway, some of these might sound familiar\n有些语言你可能听起来耳熟 - 很多现在还存在\n\n-- many are still around today.\n有些语言你可能听起来耳熟 - 很多现在还存在\n\nIt's extremely likely that the web browser you're using right now\n你现在用的浏览器很可能是 C++ 或 Objective-C 写的\n\nwas written in C++ or Objective-C.\n你现在用的浏览器很可能是 C++ 或 Objective-C 写的\n\nThat list I just gave is the tip of the iceberg.\n我刚才说的编程语言名字 只是冰山一角\n\nAnd languages with fancy, new features are proposed all the time.\n新的编程语言在不断诞生\n\nEach new language attempts to leverage new and clever abstractions\n新语言想用更聪明的抽象\n\nto make some aspect of programming easier or more powerful,\n让某些方面更容易或更强大\n\nor take advantage of emerging technologies and platforms,\n或利用新技术和新平台带来的优势\n\nso that more people can do more amazing things, more quickly.\n让更多人能快速做出美妙的事情\n\nMany consider the holy grail of programming to be the use of \"plain ol' English\",\n许多人认为编程的\"圣杯\"是直接用英文\n\nwhere you can literally just speak what you want the computer to do,\n直接对计算机说话，然后它会理解并执行\n\nit figures it out, and executes it.\n直接对计算机说话，然后它会理解并执行\n\nThis kind of intelligent system is science fiction for now.\n这种智能系统目前只存在于科幻小说\n\nAnd fans of 2001: A Space Odyssey may be okay with that.\n\"2001：太空漫游\" 的粉丝可能没什么意见\n\nNow that you know all about programming languages,\n现在你理解了编程语言,\n\nwe're going to deep dive for the next couple of episodes,\n接下来几集 我们会深入了解\n\nand we'll continue to build your understanding\n接下来几集 我们会深入了解\n\nof how programming languages, and the software they create,\n编程语言和用语言写的软件\n\nare used to do cool and unbelievable things.\n是怎么做到那些酷事\n\nSee you next week.\n下周见\n\n（给 Curiosity Stream 打广告）\n\nHi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode we discussed how writing programs in native machine code,\n上集讲到用机器码写程序,\n\nand having to contend with so many low level details, was a huge impediment to writing complex programs.\n还要处理那么多底层细节  对写大型程序是个巨大障碍\n\nTo abstract away many of these low-level details, Programming Languages were developed that\n为了脱离底层细节，开发了编程语言\n\nlet programmers concentrate on solving a problem with computation, and less on nitty gritty hardware details.\n让程序员专心解决问题，不用管硬件细节\n\nSo today, we’re going to continue that discussion, and introduce some fundamental building blocks\n今天我们讨论  大多数编程语言都有的基本元素\n\nthat almost all programming languages provide.\n今天我们讨论  大多数编程语言都有的基本元素\n\nJust like spoken languages, programming languages have statements.\n就像口语一样，编程语言有\"语句\"\n\nThese are individual complete thoughts, like \"I want tea\" or \"it is raining\".\n语句表达单个完整思想，比如\"我想要茶\"或者\"在下雨\"\n\nBy using different words, we can change the meaning;\n用不同词汇可以代表不同含义 \\N 比如\"我想要茶\"变成\"我想要独角兽\"\n\nfor example, \"I want tea\" to \"I want unicorns\".\n用不同词汇可以代表不同含义 \\N 比如\"我想要茶\"变成\"我想要独角兽\"\n\nBut we can’t change \"I want tea\" to \"I want raining\" - that doesn’t make grammatical sense.\n但没法把\"我想要茶\"改成\"我想要雨\"- 语法毫无意义\n\nThe set of rules that govern the structure and composition of statements in a language\n规定句子结构的一系列规则 叫语法\n\nis called syntax.\n规定句子结构的一系列规则 叫语法\n\nThe English language has syntax, and so do all programming languages.\n英语有语法，所有编程语言也都有语法\n\n\"a = 5\" is a programming language statement.\na=5 是一个编程语言语句\n\nIn this case, the statement says a variable named A has the number 5 stored in it.\n意思是创建一个叫 a 的变量，把数字 5 放里面.\n\nThis is called an assignment statement because we're assigning a value to a variable.\n这叫\"赋值语句\"，把一个值赋给一个变量\n\nTo express more complex things, we need a series of statements,\n为了表达更复杂的含义，需要更多语句\n\nlike \"A is 5, B is 10, C equals A plus B\"\n比如 \\Na=5 \\N b=10 \\Nc=a+b\n\nThis program tells the computer to set variable ‘A’ equal to 5, variable ‘B’ to 10,\n意思是，变量 a 设为5，变量 b 设为10\n\nand finally to add ‘A’ and ‘B’ together, and put that result, which is 15, into -- you guessed it -- variable C.\n把 a 和 b 加起来，把结果 15 放进变量 c\n\nNote that we can call variables whatever we want.\n注意，变量名可以随意取\n\nInstead of A, B and C, it could be apples, pears, and fruits.\n除了 a b c，也可以叫苹果、梨、水果\n\nThe computer doesn’t care, as long as variables are uniquely named.\n计算机不在乎你取什么名，只要不重名就行\n\nBut it’s probably best practice to name them things that make sense\n当然取名最好还是有点意义，方便别人读懂\n\nin case someone else is trying to understand your code.\n当然取名最好还是有点意义，方便别人读懂\n\nA program, which is a list of instructions, is a bit like a recipe:\n程序由一个个指令组成，有点像菜谱：\n\nboil water, add noodles, wait 10 minutes, drain and enjoy.\n烧水、加面，等10分钟，捞出来就可以吃了\n\nIn the same way, the program starts at the first statement\n程序也是这样，从第一条语句开始\n\nand runs down one at a time until it hits the end.\n一句一句运行到结尾\n\nSo far, we’ve added two numbers together.\n刚才我们只是把两个数字加在一起\n\nBoring.\n无聊\n\nLet’s make a video game instead!\n我们来做一款游戏吧\n\nOf course, it’s way too early to think about coding an entire game,\n当然，现在这个学习阶段 \\N来编写一整个游戏还太早了\n\nso instead, we’ll use our example to write little snippets of code\n所以我们只写一小段一小段的代码\n\nthat cover some programming fundamentals.\n来讲解一些基础知识\n\nImagine we’re building an old-school arcade game where Grace Hopper has to capture bugs\n假设我们在写一款老派街机游戏：Grace Hopper 拍虫子\n\nbefore they get into the Harvard Mark 1 and crash the computer!\n阻止虫子飞进计算机造成故障\n\nOn every level, the number of bugs increases.\n关卡越高，虫子越多\n\nGrace has to catch them before they wear out any relays in the machine.\nGrace 要在虫子损坏继电器之前  抓住虫子\n\nFortunately, she has a few extra relays for repairs.\n好消息是  她有几个备用继电器\n\nTo get started, we’ll need to keep track of a bunch of values that are important for gameplay\n开始编写时，我们需要一些值 来保存游戏数据\n\nlike what level the player is on, the score, the number of bugs remaining,\n比如当前关卡数、分数、剩余虫子数、\n\nas well as the number of spare relays in Grace’s inventory.\nGrace 还剩几个备用继电器\n\nSo, we must \"initialize\" our variables, that is, set their initial value:\n所以我们要\"初始化\"变量 \\N \"初始化\"的意思是设置最开始的值.\n\n\"level equals 1, score equals 0, bugs equals 5, spare relays equals 4, and player name equals \"Andre\".\n关卡=1  分数=0  虫子数=5 \\N 备用继电器=4   玩家名=Andre\n\nTo create an interactive game, we need to control the flow of the program\n为了做成交互式游戏，程序的执行顺序要更灵活\n\nbeyond just running from top to bottom.\n不只是从上到下执行\n\nTo do this, we use Control Flow Statements.\n因此用 \"控制流语句\"\n\nThere are several types, but If Statements are the most common.\n控制流语句有好几种，最常见的是 if 语句\n\nYou can think of them as \"If X is true, then do Y\".\n可以想成是 \"如果 X 为真，那么执行 Y\"\n\nAn English language example is: \"If I am tired, then get tea\"\n用英语举例就是 \"如果累了, 就去喝茶\"\n\nSo if \"I am tired\" is a true statement, then I will go get tea\n如果 \"累了\" 为真，就去喝茶\n\nIf \"I am tired\" is false, then I will not go get tea.\n如果 \"累了\" 为假，就不喝茶\n\nAn IF statement is like a fork in the road.\nif 语句就像岔路口\n\nWhich path you take is conditional on whether the expression is true or false\n走哪条路  取决于 \"表达式\" 的真假，\n\nso these expressions are called Conditional Statements.\n因此这些表达式又叫 \"条件语句\"\n\nIn most programming languages, an if statement looks something like\n在大多数编程语言中，if 语句看起来像这样：\n\n\"If, expression, then, some code, then end the if statement\".\nif [条件], then [一些代码]，结束 if 语句.\n\nFor example, if \"level\" is 1, then we set the score to zero, because the player is just starting.\n比如，if [第一关]，then [分数设为0] \\N 因为玩家才刚开始游戏\n\nWe also set the number of bugs to 1, to keep it easy for now.\n同时把虫子数设为 1，让游戏简单些\n\nNotice the lines of code that are conditional on the if-statement are nested between the\n注意, 依赖于 if 条件的代码，要放在 IF 和 END IF 之间\n\nIF and END IF.\n注意, 依赖于 if 条件的代码，要放在 IF 和 END IF 之间\n\nOf course, we can change the conditional expression to whatever we want to test, like\n当然，条件表达式 可以改成别的，比如：\n\n\"is score greater than 10\"  or \"is bugs less than 1\".\n\"分数 >10\" 或者 \"虫子数 <1\"\n\nAnd If-Statements can be combined with an ELSE statement, which acts as a catch-all if the expression is false.\nif 还可以和 else 结合使用 \\N 条件为假会执行 else 里的代码\n\nIf the level is not 1, the code inside the ELSE block will be executed instead, and the\n如果不是第1关，else 里的指令就会被执行\n\nnumber of bugs that Grace has to battle is set to 3 times the level number.\nGrace 要抓的虫子数，是当前关卡数 * 3\n\nSo on level 2, it would be six bugs, and on level 3 there’s 9, and so on.\n所以第 2 关有 6 个虫子，第 3 关有 9 个虫子，以此类推\n\nScore isn’t modified in the ELSE block, so Grace gets to keep any points earned.\nelse 中没有改分数，所以 Grace 的分数不会变\n\nHere are some examples of if-then-else statements from some popular programming languages\n这里列了一些热门编程语言  if-then-else 的具体语法\n\n-- you can see the syntax varies a little, but the underlying structure is roughly the same.\n具体语法略有不同，但主体结构一样\n\nIf-statements are executed once, a conditional path is chosen, and the program moves on.\nif 语句 根据条件执行一次\n\nTo repeat some statements many times, we need to create a conditional loop.\n如果希望根据条件执行多次，需要\"条件循环\"\n\nOne way is a while statement, also called a while loop.\n比如 while 语句，也叫 \"while 循环\"\n\nAs you might have guessed, this loops a piece of code \"while\" a condition is true.\n当 while 条件为真，代码会重复执行\n\nRegardless of the programming language, they look something like this:\n不管是哪种编程语言，结构都是这样\n\nIn our game, let’s say at certain points, a friendly colleague restocks Grace with relays!\n假设到达一定分数会冒出一个同事，给 Grace 补充继电器\n\nHooray!\n棒极了！\n\nTo animate him replenishing our stock back up to a maximum of 4, we can use a while loop.\n把继电器补满到最大数 4 个 \\N 我们可以用 while 语句来做\n\nLet’s walk through this code.\n来过一遍代码\n\nFirst we’ll assume that Grace only has 1 tube left when her colleague enters.\n假设同事入场时， Grace 只剩一个继电器\n\nWhen we enter the while loop, the first thing the computer does is test its conditional…\n当执行 while 循环，第一件事是检查条件\n\nis relays less than 4?\n继电器数量<4?\n\nWell, relays is currently 1, so yes.\n继电器数量现在是1，所以是真\n\nNow we enter the loop!\n进入循环！\n\nThen, we hit the line of code: \"relays equals relays plus 1\".\n碰到这一行：继电器数量=继电器数量+1\n\nThis is a bit confusing because the variable is using itself in an assignment statement,\n看起来有点怪，变量的赋值用到了自己\n\nso let's unpack it.\n我们讲下这个\n\nYou always start by figuring out the right side of the equals sign first,\n总是从等号右边开始，\n\nso what does \"relays plus 1\" come out to be?\n\"继电器数量+1\" 是多少？\n\nWell, relays is currently the value 1, so 1 plus 1 equals 2.\n当前值是1，所以 1+1=2\n\nThen, this result gets saved back into the variable relays, writing over the old value,\n结果存到\"继电器数量\"，覆盖旧的值\n\nso now relays stores the value 2.\n所以现在继电器数量是 2\n\nWe’ve hit the end of the while loop, which jumps the program back up.\n现在到了结尾，跳回开始点\n\nJust as before, we test the conditional to see if we’re going to enter the loop.\n和之前一样，先判断条件，看要不要进入循环\n\nIs relays less than 4?\n继电器数量<4？\n\nWell, yes, relays now equals 2, so we enter the loop again!\n是，继电器数量是2，所以再次进入循环!\n\n2 plus 1 equals 3.\n2+1=3\n\nso 3 is saved into relays.\n3 存入\"继电器数量\"\n\nLoop again.\n回到开头\n\nIs 3 less than 4?\n3<4？\n\nYes it is!\n是!\n\nInto the loop again.\n进入循环\n\n3 plus 1 equals 4.\n3+1=4\n\nSo we save 4 into relays.\n4 存入\"继电器数量\"\n\nLoop again.\n回到开头\n\nIs 4 less than 4?....\n4<4?\n\nNo!\n不！\n\nSo the condition is now false, and thus we exit the loop and move on to any remaining code\n现在条件为假，退出循环，执行后面的代码\n\nThat’s how a while loop works!\nwhile 循环就是这样运作的!\n\nThere’s also the common For Loop.\n另一种常见的叫 \"for 循环\"\n\nInstead of being a condition-controlled loop that can repeat forever until the condition is false\n不判断条件，判断次数，会循环特定次数\n\na FOR loop is count-controlled; it repeats a specific number of times.\n不判断条件，判断次数，会循环特定次数\n\nThey look something like this:\n看起来像上图\n\nNow, let’s put in some real values.\n现在放些真正的值进去\n\nThis example loops 10 times, because we’ve specified that variable ‘i’\n上图例子会循环10次，因为设了变量 i\n\nstarts at the value 1 and goes up to 10.\n从 1 开始，一直到 10\n\nThe unique thing about a FOR loop is that each time it hits NEXT, it adds one to ‘i’.\nfor 的特点是，每次结束， i 会 +1\n\nWhen ‘i’ equals 10, the computer knows it’s been looped 10 times, and the loop exits\n当 i 等于10，就知道循环了10次，然后退出.\n\nWe can set the number to whatever we want -- 10, 42, or a billion -- it’s up to us.\n我们可以用任何数字，10, 42, 10 亿\n\nLet’s say we want to give the player a bonus at the end of each level\n假设每关结束后  给玩家一些奖励分\n\nfor the number of vacuum relays they have left over.\n奖励分多少取决于 继电器剩余数量\n\nAs the game gets harder, it takes more skill to have unused relays,\n随着难度增加，剩下继电器会越来越难\n\nso we want the bonus to go up exponentially based on the level.\n因此奖励分会根据当前关卡数，指数级增长\n\nWe need to write a piece of code that calculates exponents -\n我们要写一小段代码来算指数\n\nthat is, multiplying a number by itself a specific number of times.\n指数是一个数乘自己，乘特定次数\n\nA loop is perfect for this!\n用循环来实现简直完美!\n\nFirst lets initialize a new variable called \"bonus\" and set it to 1.\n首先，创建一个叫\"奖励分\"的新变量，设为 1 （看上图）\n\nThen, we create a FOR loop starting at 1, and looping up to the level number.\n然后 for 循环，从 1 到 [当前关卡数]\n\nInside that loop, we multiply bonus times the number of relays,\n[奖励分] x [继电器剩余数]，结果存入 [奖励分]\n\nand save that new value back into bonus.\n[奖励分] x [继电器剩余数]，结果存入 [奖励分]\n\nFor example, let’s say relays equals 2, and level equals 3.\n比如继电器数是2，关卡数是3\n\nSo the FOR loop will loop three times, which means bonus is going to get multiplied by\nfor 会循环3次，奖励分会乘\n\nrelays... by relays... by relays.\n继电器数量 x 继电器数量 x 继电器数量\n\nOr in this case, times 2, times 2, times 2, which is a bonus of 8!\n也就是1×2×2×2，奖励分是8，2的3次方\n\nThat’s 2 to the 3rd power!\n也就是1×2×2×2，奖励分是8，2的3次方\n\nThis exponent code is useful, and we might want to use it in other parts of our code.\n这个指数代码很实用，其他地方可能会用到\n\nIt’d be annoying to copy and paste this everywhere, and have to update the variable names each time.\n如果每次想用就复制粘贴，会很麻烦，每次都要改变量名\n\nAlso, if we found a bug, we’d have to hunt around and update every place we used it.\n如果代码发现问题，要补漏洞时 \\N 要把每一个复制黏贴过的地方都找出来改\n\nIt also makes code more confusing to look at.\n而且会让代码更难懂\n\nLess is more!\n少即是多！\n\nWhat we want is a way to package up our exponent code so we can use it, get the result, and\n我们想要某种方法，把代码\"打包\" \\N 可以直接使用，得出结果，\n\nnot have to see all the internal complexity.\n不用管内部复杂度.\n\nWe’re once again moving up a new level of abstraction!\n这又提升了一层抽象！\n\nTo compartmentalize and hide complexity,\n为了隐藏复杂度\n\nprogramming languages can package pieces of code into named functions,\n可以把代码打包成 \"函数\"\n\nalso called methods or subroutines in different programming languages.\n也叫 \"方法\" 或 \"子程序\"\\N（有些编程语言这么叫）\n\nThese functions can then be used by any other part of that program just by calling its name.\n其他地方想用这个函数，直接写函数名就可以了\n\nLet’s turn our exponent code into a function! First, we should name it.\n现在我们把指数代码变成函数.  第一步，取名.\n\nWe can call it anything we want, like HappyUnicorn,\n叫什么都行，比如\"快乐独角兽\"\n\nbut since our code calculates exponents, let’s call it exponent.\n但因为是算指数,  直接叫\"指数\"合适一些\n\nAlso, instead of using specific variable names, like \"relays\" and \"levels\",\n还有，与其用特定变量名，比如 \"继电器\" 和 \"关卡数\"\n\nwe specify generic variable names, like Base and Exp,\n用更通用的名字，比如 底数(Base) 和 指数(Exp)\n\nwhose initial values are going to be \"passed\" into our function from some other part of the program.\nBase 和 Exp 的初始值需要外部传入\n\nThe rest of our code is the same as before\n剩余代码和之前一样\n\nNow tucked into our function and with new variable names.\n现在完成了，有函数名和新变量名.\n\nFinally, we need to send the result of our exponent code back to the part of the program that requested it.\n最后, 我们还需要把结果 交给使用这个函数的代码\n\nFor this, we use a RETURN statement, and specify that the value in ‘result’ be returned.\n所以用 RETURN 语句，指明返回什么.\n\nSo our full function code looks like this:\n完整版代码是这样\n\nNow we can use this function anywhere in our program,\n现在可以随意用这个函数\n\nsimply by calling its name and passing in two numbers.\n只需要写出名字 然后传入2个数字  就可以了\n\nFor example, if we want to calculate 2 to the 44th power, we can just call \"exponent 2 comma 44.\"\n如果要算 2 的 44 次方，写 exponent(2,44)\n\nand like 18 trillion comes back.\n结果是 18 万亿左右\n\nBehind the scenes, 2 and 44 get saved into variables Base and Exp inside the function,\n幕后原理是，2 和 44 存进 Base 和 Exp\n\nit does all its loops as necessary, and then the function returns with the result.\n跑循环，然后返回结果\n\nLet’s use our newly minted function to calculate a score bonus.\n我们来用这个新函数 算奖励分\n\nFirst, we initialize bonus to 0.\n首先，奖励分初始化为 0\n\nThen we check if the player has any remaining relays with an if-statement.\n然后用 if 语句，看剩不剩继电器（看上图的 > 0）\n\nIf they do, we call our exponent function, passing in relays and level,\n如果还剩，用指数函数，传入 [继电器数] 和 [关卡数]\n\nwhich calculates relays to the power of level, and returns the result, which we save into bonus.\n它会算 [继电器数]的[关卡数]次方,  存入奖励分\n\nThis bonus calculating code might be useful later, so let’s wrap it up as a function too!\n这段算奖励分的代码，之后可能还会用，也打包成一个函数\n\nYes, a function that calls a function!\n没错，这个函数 (CalcBonus) \\N 会调用另一个函数 (Exponent)\n\nAnd then, wait for it…. we can use this function in an even more complex function.\n还有！这个 CalcBonus 函数，可以用在其他更复杂的函数\n\nLet’s write one that gets called everytime the player finishes a level.\n我们来写一个函数, 每一关结束后都会调用\n\nWe’ll call it \"LevelFinished\"\n叫 LevelFinished (关卡结束)\n\n- it needs to know the number of relays left, what level it was, and the current score;\n需要传入 [剩余继电器数]  [关卡数] [当前分]\n\nthose values have to get passed in.\n这些数据必须传入.\n\nInside our function, we’ll calculate the bonus, using our CalcBonus function,\n里面用 CalcBonus 算奖励分，并加进总分\n\nand add that to the running score.\n里面用 CalcBonus 算奖励分，并加进总分\n\nAlso, if the current score is higher than the game’s high score,\n还有，如果当前分 > 游戏最高分\n\nwe save the new high score and the players name.\n把新高分和玩家名 存起来\n\nNow we’re getting pretty fancy.\n现在代码变得蛮\"花哨\"了\n\nFunctions are calling functions are calling functions!\n函数调函数调函数\n\nWhen we call a single line of code, like this the complexity is hidden.\n我们写这样一行代码时，复杂度都隐藏起来了\n\nWe don’t see all the internal loops and variables,\n不需要知道内部的循环和变量\n\nwe just see the result come back as if by magic…. a total score of 53.\n只知道结果会像魔术一样返回，总分 53\n\nBut it’s not magic, it’s the power of abstraction!\n但是这不是魔术，是抽象的力量\n\nIf you understand this example, then you understand the power of functions,\n如果你理解了这个例子，就明白了函数的强大之处\n\nand the entire essence of modern programming.\n和现代编程的核心\n\nIt’s not feasible to write, for example, a web browser as one gigantically long list of statements.\n比如浏览器这样的复杂程序，用一长串语句来写是不可能的\n\nIt would be millions of lines long and impossible to comprehend!\n会有几百万行代码，没人能理解\n\nSo instead, software consists of thousands of smaller functions,\n所以现代软件由上千个函数组成\n\neach responsible for different features.\n每个负责不同的事\n\nIn modern programming, it’s uncommon to see functions longer than around 100 lines of code\n如今超过100行代码的函数很少见\n\nbecause by then, there’s probably something that\n如果多于 100 行，应该有东西可以拆出来做成一个函数\n\nshould be pulled out and made into its own function.\n如果多于 100 行，应该有东西可以拆出来做成一个函数\n\nModularizing programs into functions not only allows a single programmer to write an entire app\n模块化编程  不仅可以让单个程序员独立制作 App\n\nbut also allows teams of people to work efficiently on even bigger programs.\n也让团队协作可以写更大型的程序\n\nDifferent programmers can work on different functions,\n不同程序员写不同函数\n\nand if everyone makes sure their code works correctly,\n只需要确保自己的代码工作正常\n\nthen when everything is put together, the whole program should work too!\n把所有人的拼起来，整个程序也应该能正常运作！\n\nAnd in the real world, programmers aren’t wasting time writing things like exponents.\n现实中，程序员不会浪费时间写指数函数这种东西\n\nModern programming languages come with huge bundles of pre-written functions, called Libraries.\n现代编程语言 有很多预先写好的函数集合，叫 \"库\"\n\nThese are written by expert coders, made efficient and rigorously tested, and then given to everyone.\n由专业人员编写，不仅效率高，而且经过了仔细检查\n\nThere are libraries for almost everything, including networking, graphics, and sound\n几乎做所有事情都有库，网络、图像、声音\n\n-- topics we’ll discuss in future episodes.\n我们之后会讲这些主题.\n\nBut before we get to those, we need to talk about Algorithms.\n但在此之前，我们先讲算法\n\nIntrigued?\n好奇吗？\n\nYou should be.\n你应该才是！\n\nI’ll see you next week.\n下周见\n\nHi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the past two episodes, we got our first taste of programming in a high-level language,\n前两集，我们\"初尝\"了高级编程语言\\N （比如 Python 和 Java）\n\nlike Python or Java.\n前两集，我们\"初尝\"了高级编程语言\\N （比如 Python 和 Java）\n\nWe talked about different types of programming language statements\n我们讨论了几种语句 - 赋值语句，if 语句，循环语句\n\n- like assignments, ifs, and loops -\n我们讨论了几种语句 - 赋值语句，if 语句，循环语句\n\nas well as putting statements into functions that perform a computation,\n以及把代码打包成 \"函数\"\n\nlike calculating an exponent.\n比如算指数\n\nImportantly, the function we wrote to calculate exponents is only one possible solution.\n重要的是，之前写的指数函数 \\N 只是无数解决方案的一种\n\nThere are other ways to write this function\n还有其它方案\n\n- using different statements in different orders -\n- 用不同顺序写不同语句 也能得到一样结果\n\nthat achieve exactly the same numerical result.\n- 用不同顺序写不同语句 也能得到一样结果\n\nThe difference between them is the algorithm,\n不同的是 \"算法\"，意思是：解决问题的具体步骤\n\nthat is the specific steps used to complete the computation.\n不同的是 \"算法\"，意思是：解决问题的具体步骤\n\nSome algorithms are better than others even if they produce equal results.\n即使结果一致，有些算法会更好\n\nGenerally, the fewer steps it takes to compute, the better it is,\n一般来说，所需步骤越少越好\n\nthough sometimes we care about other factors, like how much memory it uses.\n不过有时我们也会关心其他因素，比如占多少内存\n\nThe term algorithm comes from Persian polymath Muhammad ibn Musa al-Khwarizmi\n\"算法\" 一词来自 波斯博识者 阿尔·花拉子密\n\nwho was one of the fathers of algebra more than a millennium ago.\n1000 多年前的代数之父之一\n\nThe crafting of efficient algorithms\n如何想出高效算法 - 是早在计算机出现前就有的问题\n\n- a problem that existed long before modern computers -\n如何想出高效算法 - 是早在计算机出现前就有的问题\n\nled to a whole science surrounding computation,\n诞生了专门研究计算的领域，然后发展成一门现代学科\n\nwhich evolved into the modern discipline of...\n诞生了专门研究计算的领域，然后发展成一门现代学科\n\nyou guessed it!\n你猜对了！\n\nComputer Science!\n计算机科学！\n\nOne of the most storied algorithmic problems in all of computer science is sorting\n记载最多的算法之一是\"排序\"\n\nas in sorting names or sorting numbers.\n比如给名字、数字排序\n\nComputers sort all the time.\n排序到处都是\n\nLooking for the cheapest airfare,\n找最便宜的机票\n\narranging your email by most recently sent,\n按最新时间排邮件\n\nor scrolling your contacts by last name\n按姓氏排联系人\n\n-- those all require sorting.\n-这些都要排序\n\nYou might think\n你可能想\"排序看起来不怎么难… 能有几种算法呢?\"\n\n\"sorting isn't so tough how many algorithms can there possibly be?\"\n你可能想\"排序看起来不怎么难… 能有几种算法呢?\"\n\nThe answer is: a lot.\n答案是超多\n\nComputer Scientists have spent decades inventing algorithms for sorting,\n计算机科学家花了数十年发明各种排序算法\n\nwith cool names like Bubble Sort and Spaghetti Sort.\n还起了酷酷的名字，\"冒泡排序\"\"意面排序\"\n\nLet's try sorting!\n我们来试试排序！\n\nImagine we have a set of airfare prices to Indianapolis.\n试想有一堆机票价格，都飞往  印第安纳波利斯 (美国地名)\n\nWe'll talk about how data like this is represented in memory next week,\n数据具体怎么在内存中表示  下周再说\n\nbut for now, a series of items like this is called an array.\n上图的这样一组数据  叫\"数组\"（Array）\n\nLet's take a look at these numbers to help see how we might sort this programmatically.\n来看看怎么排序\n\nWe'll start with a simple algorithm.\n先从一种简单算法开始\n\nFirst, let's scan down the array to find the smallest number.\n先找到最小数，从最上面的 307 开始\n\nStarting at the top with 307.\n先找到最小数，从最上面的 307 开始\n\nIt's the only number we've seen, so it's also the smallest.\n因为现在只看了这一个，所以它是最小数\n\nThe next is 239, that's smaller than 307,\n下一个是 239，比 307 小\n\nso it becomes our new smallest number.\n所以新的最小数变成 239\n\nNext is 214, our new smallest number.\n下一个是 214 ，新的最小数\n\n250 is not, neither is 384, 299, 223 or 312.\n250 不是，384, 299, 223, 312 都不是\n\nSo we've finished scanning all numbers,\n现在扫完了所有数字\n\nand 214 is the smallest.\n214 是最小的\n\nTo put this into ascending order,\n为了升序排列（从小到大排序）\n\nwe swap 214 with the number in the top location.\n把 214 和最上面的数字，交换位置\n\nGreat! We sorted one number!\n好棒! 刚排序了一个数字！\n\nNow we repeat the same procedure,\n现在重复同样的过程\n\nbut instead of starting at the top, we can start one spot below.\n这次不从最上面开始，从第 2 个数开始\n\nFirst we see 239, which we save as our new smallest number.\n先看到 239，我们当作是 \"最小数\"\n\nScanning the rest of the array, we find 223 is the next smallest,\n扫描剩下的部分，发现 223 最小\n\nso we swap this with the number in the second spot.\n所以把它和第 2 位交换\n\nNow we repeat again, starting from the third number down.\n重复这个过程，从第 3 位数字开始\n\nThis time, we swap 239 with 307.\n让 239 和 307 互换位置\n\nThis process continues until we get to the very last number,\n重复直到最后一个数字\n\nand voila, the array is sorted and you're ready to book that flight to Indianapolis!\n瞧，数字排好了，可以买机票了！\n\nThe process we just walked through is one way\n刚刚这种方法，或者说算法，\n\n- or one algorithm - for sorting an array.\n刚刚这种方法，或者说算法，\n\nIt's called Selection sort - and it's pretty basic.\n叫 选择排序 - 非常基础的一种算法\n\nHere's the pseudo-code.\n以下是\"伪代码\"\n\nThis function can be used to sort 8, 80, or 80 million numbers\n这个函数可以排序8个, 80个或8千万个数字\n\n- and once you've written the function, you can use it over and over again.\n函数写好了就可以重复使用\n\nWith this sort algorithm, we loop through each position in the array, from top to bottom,\n这里用循环 遍历数组\n\nand then for each of those positions,\n每个数组位置都跑一遍循环，找最小数然后互换位置\n\nwe have to loop through the array to find the smallest number to swap.\n每个数组位置都跑一遍循环，找最小数然后互换位置\n\nYou can see this in the code, where one FOR loop is nested inside of another FOR loop.\n可以在代码中看到这一点 \\N （一个 for 循环套另一个 for 循环）\n\nThis means, very roughly, that if we want to sort N items, we have to loop N times,\n这意味着，大致来说，如果要排 N 个东西，要循环 N 次，\n\ninside of which, we loop N times, for a grand total of roughly N times N loops, or N squared.\n每次循环中再循环 N 次，共 N*N,  或 N\n\nThis relationship of input size to the number of steps the algorithm takes to run\n算法的 输入大小 和 运行步骤 之间的关系\n\ncharacterizes the complexity of the Selection Sort algorithm.\n叫算法的 复杂度\n\nIt gives you an approximation of how fast, or slow, an algorithm is going to be.\n表示运行速度的量级\n\nComputer Scientists write this order of growth in something known as - no joke -\n计算机科学家们把算法复杂度叫 - 没开玩笑\n\n\"big O notation\".\n大 O 表示法\n\nN squared is not particularly efficient.\n算法复杂度 O(N  ) 效率不高\n\nOur example array had n = 8 items, and 8 squared is 64.\n前面的例子有 8 个元素（n=8）, 8  = 64\n\nIf we increase the size of our array from 8 items to 80,\n如果 8 个变 80 个\n\nthe running time is now 80 squared, which is 6,400.\n运行时间变成 80  = 6400\n\nSo although our array only grew by 10 times - from 8 to 80 -\n虽然大小只增长了 10 倍（8 到 80）\n\nthe running time increased by 100 times - from 64 to 6,400!\n但运行时间增加了 100 倍！（64 到 6400 ）\n\nThis effect magnifies as the array gets larger.\n随着数组增大，对效率的影响会越来越大\n\nThat's a big problem for a company like Google,\n这对大公司来说是个问题，比如 谷歌\n\nwhich has to sort arrays with millions or billions of entries.\n要对几十亿条信息排序\n\nSo, you might ask,\n作为未来的计算机科学家你可能会问：有没有更高效的排序算法？\n\nas a burgeoning computer scientist, is there a more efficient sorting algorithm?\n作为未来的计算机科学家你可能会问：有没有更高效的排序算法？\n\nLet's go back to our old, unsorted array\n回到未排序的数组\n\nand try a different algorithm, merge sort.\n试另一个算法 \"归并排序\"\n\nThe first thing merge sort does is check if the size of the array is greater than 1.\n第一件事是检查数组大小是否 > 1\n\nIf it is, it splits the array into two halves.\n如果是，就把数组分成两半\n\nSince our array is size 8, it gets split into two arrays of size 4.\n因为数组大小是 8，所以分成两个数组，大小是 4\n\nThese are still bigger than size 1, so they get split again, into arrays of size 2,\n但依然大于 1，所以再分成大小是 2 的数组\n\nand finally they split into 8 arrays with 1 item in each.\n最后变成 8 个数组，每个大小为 1\n\nNow we are ready to merge, which is how \"merge sort\" gets its name.\n现在可以\"归并\"了，\"归并排序\"因此得名\n\nStarting with the first two arrays, we read the first - and only - value in them,\n从前两个数组开始，读第一个（也是唯一一个）值\n\nin this case, 307 and 239.\n307 和 239\n\n239 is smaller, so we take that value first.\n239 更小，所以放前面\n\nThe only number left is 307, so we put that value second.\n剩下的唯一数字是 307 ，所以放第二位\n\nWe've successfully merged two arrays.\n成功合并了两个数组\n\nWe now repeat this process for the remaining pairs, putting them each in sorted order.\n重复这个过程，按序排列\n\nThen the merge process repeats.\n然后再归并一次\n\nAgain, we take the first two arrays, and we compare the first numbers in them.\n同样，取前两个数组，比较第一个数\n\nThis time its 239 and 214.\n239 和 214\n\n214 is lowest, so we take that number first.\n214 更小，放前面\n\nNow we look again at the first two numbers in both arrays: 239 and 250.\n再看两个数组里的第一个数：239 和 250\n\n239 is lower, so we take that number next.\n239 更小，所以放下一位\n\nNow we look at the next two numbers: 307 and 250.\n看剩下两个数：307 和 250\n\n250 is lower, so we take that.\n250 更小，所以放下一位\n\nFinally, we're left with just 307, so that gets added last.\n最后剩下 307 ，所以放最后\n\nIn every case, we start with two arrays,\n每次都以 2 个数组开始\n\neach individually sorted, and merge them into a larger sorted array.\n然后合并成更大的有序数组\n\nWe repeat the exact same merging process for the two remaining arrays of size two.\n我们把刚隐藏起来的，下面的数组也这样做\n\nNow we have two sorted arrays of size 4.\n现在有两个大小是 4 的有序数组\n\nJust as before, we merge,\n就像之前，比较两个数组的第一个数，取最小数\n\ncomparing the first two numbers in each array, and taking the lowest.\n就像之前，比较两个数组的第一个数，取最小数\n\nWe repeat this until all the numbers are merged,\n重复这个过程，直到完成\n\nand then our array is fully sorted again!\n就排好了！\n\nThe bad news is: no matter how many times we sort these,\n但坏消息是：无论排多少次\n\nyou're still going to have to pay $214 to get to Indianapolis.\n你还是得付 214 美元到 印第安纳波利斯\n\nAnyway, the \"Big O\" computational complexity of merge sort is N times the Log of N.\n总之，\"归并排序\"的算法复杂度是 O(n * log n)\n\nThe N comes from the number of times we need to compare and merge items,\nn 是需要 比较+合并 的次数\n\nwhich is directly proportional to the number of items in the array.\n和数组大小成正比\n\nThe Log N comes from the number of merge steps.\nlog N 是合并步骤的次数\n\nIn our example, we broke our array of 8 items into 4,\n例子中把大小是 8 的数组，分成四个数组\n\nthen 2, and finally 1.\n然后分成 2 个，最后分成 1 个\n\nThat's 3 splits.\n分了 3 次\n\nSplitting in half repeatedly like this has a logarithmic relationship with the number of items\n重复切成两半，和数量成对数关系\n\n- trust me!\n相信我！\n\nLog base 2 of 8 equals 3 splits.\nLog   8=3\n\nIf we double the size of our array to 16 - that's twice as many items to sort -\n如果数组大小变成 16 - 之前的两倍\n\nit only increases the number of split steps by 1\n也只要多分割 1 次\n\nsince log base 2 of 16 equals 4.\n因为 Log   16=4\n\nEven if we increase the size of the array more than a thousand times,\n即使扩大一千倍\n\nfrom 8 items to 8000 items, the number of split steps stays pretty low.\n从8到8000，分割次数也不会增大多少\n\nLog base 2 of 8000 is roughly 13.\nlog   8000≈13\n\nThat's more, but not much more than 3 -- about four times larger --\n13 比 3 只是4倍多一点\n\nand yet we're sorting a lot more numbers.\n然而排序的元素多得多\n\nFor this reason, merge sort is much more efficient than selection sort.\n因此\"归并排序\"比\"选择排序\"更有效率\n\nAnd now I can put my ceramic cat collection in name order MUCH faster!\n这下我收藏的陶瓷猫  可以更快排序了！\n\nThere are literally dozens of sorting algorithms we could review,\n有好几十种排序算法，但没时间讲\n\nbut instead, I want to move on to my other favorite category of classic algorithmic problems:\n所以我们来谈一个经典算法问题：\n\ngraph search!\n图搜索\n\nA graph is a network of nodes connected by lines.\n\"图\" 是用线连起来的一堆 \"节点\"\n\nYou can think of it like a map, with cities and roads connecting them.\n可以想成地图，每个节点是一个城市，线是公路\n\nRoutes between these cities take different amounts of time.\n一个城市到另一个城市，花的时间不同\n\nWe can label each line with what is called a cost or weight.\n可以用 成本(cost) 或 权重(weight) 来代称\n\nIn this case, it's weeks of travel.\n代表要几个星期\n\nNow let's say we want to find the fastest route\n假设想找\"高庭\"到\"凛冬城\"的最快路线\n\nfor an army at Highgarden to reach the castle at Winterfell.\n假设想找\"高庭\"到\"凛冬城\"的最快路线\n\nThe simplest approach would just be to try every single path exhaustively\n最简单的方法是尝试每一条路\n\nand calculate the total cost of each.\n计算总成本\n\nThat's a brute force approach.\n这是蛮力方法\n\nWe could have used a brute force approach in sorting,\n假设用蛮力方法 来排序数组\n\nby systematically trying every permutation of the array to check if it's sorted.\n尝试每一种组合，看是否排好序\n\nThis would have an N factorial complexity\n这样的时间复杂度是 O(n!)\n\n- that is the number of nodes, times one less, times one less than that, and so on until 1.\nn 是节点数，n! 是 n 乘 n-1 乘 n-2... 一直到 1\n\nWhich is way worse than even N squared.\n比 O(n  ) 还糟糕\n\nBut, we can be way more clever!\n我们可以更聪明些！\n\nThe classic algorithmic solution to this graph problem was invented by\n图搜索问题的经典算法  发明者是\n\none of the greatest minds in computer science practice and theory, Edsger Dijkstra\n理论计算机科学的伟人 Edsger Dijkstra\n\nso it's appropriately named Dijkstra's algorithm.\n所以叫 \"Dijkstra 算法\"\n\nWe start in Highgarden with a cost of 0, which we mark inside the node.\n从\"高庭\"开始，此时成本为0，把0标在节点里\n\nFor now, we mark all other cities with question marks\n其他城市标成问号，因为不知道成本多少\n\n- we don't know the cost of getting to them yet.\n其他城市标成问号，因为不知道成本多少\n\nDijkstra's algorithm always starts with the node with lowest cost.\nDijkstra 算法总是从成本最低的节点开始\n\nIn this case, it only knows about one node, Highgarden, so it starts there.\n目前只知道一个节点 \"高庭\", 所以从这里开始\n\nIt follows all paths from that node to all connecting nodes that are one step away,\n跑到所有相邻节点，记录成本\n\nand records the cost to get to each of them.\n跑到所有相邻节点，记录成本\n\nThat completes one round of the algorithm.\n完成了一轮算法\n\nWe haven't encountered Winterfell yet,\n但还没到\"凛冬城\"\n\nso we loop and run Dijkstra's algorithm again.\n所以再跑一次 Dijkstra 算法\n\nWith Highgarden already checked,\n\"高庭\" 已经知道了\n\nthe next lowest cost node is King's Landing.\n下一个成本最低的节点，是 \"君临城\"\n\nJust as before, we follow every unvisited line to any connecting cities.\n就像之前，记录所有相邻节点的成本\n\nThe line to The Trident has a cost of 5.\n到\"三叉戟河\"的成本是 5\n\nHowever, we want to keep a running cost from Highgarden,\n然而我们想记录的是，从\"高庭\"到这里的成本\n\nso the total cost of getting to The Trident is 8 plus 5, which is 13 weeks.\n所以\"三叉戟河\"的总成本是 8+5=13周\n\nNow we follow the offroad path to Riverrun,\n现在走另一条路到\"奔流城\"\n\nwhich has a high cost of 25, for a total of 33.\n成本高达 25 ，总成本 33\n\nBut we can see inside of Riverrun that we've already found a path with a lower cost of just 10.\n但 \"奔流城\" 中最低成本是 10\n\nSo we disregard our new path, and stick with the previous, better path.\n所以无视新数字，保留之前的成本 10\n\nWe've now explored every line from King's Landing and didn't find Winterfell, so we move on.\n现在看了\"君临城\"的每一条路，还没到\"凛冬城\" 所以继续.\n\nThe next lowest cost node is Riverrun, at 10 weeks.\n下一个成本最低的节点，是\"奔流城\"，要 10 周\n\nFirst we check the path to The Trident, which has a total cost of 10 plus 2, or 12.\n先看 \"三叉戟河\" 成本： 10+2=12\n\nThat's slightly better than the previous path we found, which had a cost of 13,\n比之前的 13 好一点\n\nso we update the path and cost to The Trident.\n所以更新 \"三叉戟河\" 为 12\n\nThere is also a line from Riverrun to Pyke with a cost of 3.\n\"奔流城\"到\"派克城\"成本是 3\n\n10 plus 3 is 13, which beats the previous cost of 14,\n10+3=13，之前是14\n\nand so we update Pyke's path and cost as well.\n所以更新 \"派克城\" 为 13\n\nThat's all paths from Riverrun checked. so you guessed it, Dijkstra's algorithm loops again.\n\"奔流城\"出发的所有路径都走遍了， \\N 你猜对了，再跑一次 Dijkstra 算法\n\nThe node with the next lowest cost is The Trident\n下一个成本最低的节点，是\"三叉戟河\"\n\nand the only line from The Trident that we haven't checked is a path to Winterfell!\n从\"三叉戟河\"出发，唯一没看过的路，通往\"凛冬城\"！\n\nIt has a cost of 10,\n成本是 10\n\nplus we need to add in the cost of 12 it takes to get to The Trident,\n加\"三叉戟河\"的成本 12\n\nfor a grand total cost of 22.\n总成本 22\n\nWe check our last path, from Pyke to Winterfell, which sums to 31.\n再看最后一条路，\"派克城\"到\"凛冬城\"，成本 31\n\nNow we know the lowest total cost, and also the fastest route for the army to get there,\n现在知道了最低成本路线，让军队最快到达,\n\nwhich avoids King's Landing!\n还绕过了\"君临城\"！\n\nDijkstra's original algorithm, conceived in 1956,\nDijkstra 算法的原始版本，构思于 1956 年\n\nhad a complexity of the number of nodes in the graph squared.\n算法复杂度是 O(n  )\n\nAnd squared, as we already discussed, is never great,\n前面说过这个效率不够好\n\nbecause it means the algorithm can't scale to big problems\n意味着输入不能很大\n\n- like the entire road map of the United States.\n比如美国的完整路线图\n\nFortunately, Dijkstra's algorithm was improved a few years later\n幸运的是，Dijkstra 算法几年后得到改进\n\nto take the number of nodes in the graph,\n变成 O(n log n + l)\n\ntimes the log of the number of nodes, PLUS the number of lines.\nn 是节点数，l 是多少条线\n\nAlthough this looks more complicated,\n虽然看起来更复杂\n\nit's actually quite a bit faster.\n但实际更快一些\n\nPlugging in our example graph, with 6 cities and 9 lines, proves it.\n用之前的例子，可以证明更快 \\N （6 个节点 9 条线）\n\nOur algorithm drops from 36 loops to around 14.\n从 36 减少到 14 左右\n\nAs with sorting,\n就像排序，图搜索算法也有很多，有不同优缺点\n\nthere are innumerable graph search algorithms, with different pros and cons.\n就像排序，图搜索算法也有很多，有不同优缺点\n\nEvery time you use a service like Google Maps to find directions,\n每次用谷歌地图时\n\nan algorithm much like Dijkstra's is running on servers to figure out the best route for you.\n类似 Dijkstra 的算法就在服务器上运行，找最佳路线\n\nAlgorithms are everywhere\n算法无处不在\n\nand the modern world would not be possible without them.\n现代世界离不开它们\n\nWe touched only the very tip of the algorithmic iceberg in this episode,\n这集只触及了算法的冰山一角\n\nbut a central part of being a computer scientist\n但成为计算机科学家的核心\n\nis leveraging existing algorithms and writing new ones when needed,\n是根据情况合理决定 用现有算法 还是自己写新算法\n\nand I hope this little taste has intrigued you to SEARCH further.\n希望这集的小例子能让你体会到这点\n\nI'll see you next week.\n下周见\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode, we discussed a few example classic algorithms,\n上集讲了一些经典算法\n\nlike sorting a list of numbers and finding the shortest path in a graph.\n比如给数组排序，找图的最短路径\n\nWhat we didn't talk much about,\n而上集没讲的是\n\nis how the data the algorithms ran on was stored in computer memory.\n算法处理的数据  存在内存里的格式是什么\n\nYou don't want your data to be like John Green's college dorm room,\n你肯定不想数据像 John Green 的大学宿舍一样乱 \\N 到处都是食物，衣服和纸\n\nwith food, clothing and papers strewn everywhere.\n你肯定不想数据像 John Green 的大学宿舍一样乱 \\N 到处都是食物，衣服和纸\n\nInstead, we want our data to be structured,\n我们希望数据是结构化的，方便读取\n\nso that it's organized, allowing things to be easily retrieved and read.\n我们希望数据是结构化的，方便读取\n\nFor this, computer scientists use Data Structures!\n因此计算机科学家发明了 \"数据结构\"！\n\nWe already introduced one basic data structure last episode,\n上集已经介绍了一种基本数据结构：\n\nArrays, also called lists or Vectors in some languages.\n数组（Array）\\N 也叫列表（list）或向量（Vector）（在其它编程语言里）\n\nThese are a series of values stored in memory.\n数组的值一个个连续存在内存里\n\nSo instead of just a single value being saved into a variable, like 'j equals 5',\n所以不像之前，一个变量里只存一个值（比如 j = 5）\n\nwe can define a whole series of numbers, and save that into an array variable.\n我们可以把多个值存在数组变量里\n\nTo be able to find a particular value in this array, we have to specify an index.\n为了拿出数组中某个值，我们要指定一个下标（index）\n\nAlmost all programing languages start arrays at index 0,\n大多数编程语言里，数组下标都从 0 开始\n\nand use a square bracket syntax to denote array access.\n用方括号 [ ] 代表访问数组\n\nSo, for example, if we want to add the values in the first and third spots of our array 'j',\n如果想相加数组 J 的第一个和第三个元素\n\nand save that into a variable 'a', we would write a line of code like this.\n把结果存在变量 a，可以写上图这样一行代码\n\nHow an array is stored in memory is pretty straightforward.\n数组存在内存里的方式  十分易懂\n\nFor simplicity, let's say that the compiler chose to store ours at memory location 1,000.\n为了简单，假设编译器从内存地址 1000 开始存数组\n\nThe array contains 7 numbers, and these are stored one after another in memory, as seen here.\n数组有7个数字，像上图一样按顺序存.\n\nSo when we write \"j index of 0\", the computer goes to memory location 1,000,\n写 j[0]，会去内存地址 1000\n\nwith an offset of 0, and we get the value 5.\n加 0 个偏移，得到地址 1000，拿值：5\n\nIf we wanted to retrieve \"j index of 5\", our program goes to memory location 1000,\n如果写 j[5]，会去内存地址 1000\n\nplus an offset of 5, which in this case, holds a value of 4.\n加 5 个偏移，得到地址 1005，拿值： 4\n\nIt's easy to confuse the fifth number in the array with the number at index 5.\n很容易混淆 \"数组中第 5 个数\" 和 \"数组下标为 5 的数\"\n\nThey are not the same.\n它们不是一回事\n\nRemember, the number at index 5 is the 6th number in the array\n记住，下标 5 其实是数组中第 6 个数\n\nbecause the first number is at index 0.\n因为下标是从 0 开始算的\n\nArrays are extremely versatile data structures, used all the time,\n数组的用途广泛\n\nand so there are many functions that can handle them to do useful things.\n所以几乎所有编程语言  都自带了很多函数来处理数组\n\nFor example, pretty much every programming language comes with a built-in sort function,\n举例，数组排序函数很常见\n\nwhere you just pass in your array, and it comes back sorted.\n只需要传入数组，就会返回排序后的数组\n\nSo there's no need to write that algorithm from scratch.\n不需要写排序算法\n\nVery closely related are Strings, which are just arrays of characters,\n数组的亲戚是 字符串 (string)\n\nlike letters, numbers, punctuation and other written symbols.\n其实就是字母,数字,标点符号等  组成的数组\n\nWe talked about how computers store characters way back in Episode 4.\n第 4 集讨论过计算机怎么存储字符\n\nMost often, to save a string into memory, you just put it in quotes, like so.\n写代码时 用引号括起来就行了  \\N j = \"STAN ROCKS\"\n\nAlthough it doesn't look like an array, it is.\n虽然长的不像数组，但的确是数组\n\nBehind the scenes, the memory looks like this.\n幕后看起来像这样\n\nNote that the string ends with a zero in memory.\n注意，字符串在内存里以 0 结尾\n\nIt's not the character zero, but the binary value 0.\n不是\"字符0\"，是\"二进制值0\" \\N 这叫字符\"null\"，表示字符串结尾\n\nThis is called the null character, and denotes the end of the string in memory.\n不是\"字符0\"，是\"二进制值0\" \\N 这叫字符\"null\"，表示字符串结尾\n\nThis is important because if I call a function like \"print quote\",\n这个字符非常重要，如果调用 print 函数\n\nwhich writes the string to the screen,\nprint 在屏幕上输出字符串\n\nit prints out each character in turn starting at the first memory location,\n会从开始位置，逐个显示到屏幕\n\nbut it needs to know when to stop!\n但得知道什么时候停下来！\n\nOtherwise, it would print out every single thing in memory as text.\n否则会把内存里所有东西 都显示出来\n\nThe zero tells string functions when to stop.\n0 告诉函数何时停下\n\nBecause computers work with text so often,\n因为计算机经常处理字符串，所以有很多函数专门处理字符串\n\nthere are many functions that specifically handle strings.\n因为计算机经常处理字符串，所以有很多函数专门处理字符串\n\nFor example, many programming languages have a string concatenation function, or \"strcat\",\n比如连接字符串的 strcat\n\nwhich takes in two strings, and copies the second one to the end of the first.\nstrcat 接收两个字符串，把第二个放到第一个结尾.\n\nWe can use arrays for making one dimensional lists,\n我们可以用数组做一维列表\n\nbut sometimes you want to manipulate data that is two dimensional,\n但有时想操作二维数据\n\nlike a grid of numbers in a spreadsheet, or the pixels on your computer screen.\n比如电子表格，或屏幕上的像素\n\nFor this, we need a Matrix.\n那么需要 矩阵（Matrix）\n\nYou can think of a Matrix as an array of arrays!\n可以把矩阵看成  数组的数组！\n\nSo a 3 by 3 matrix is really  an array of size 3, with each index storing an array of size 3.\n一个 3x3 矩阵就是一个长度为3的数组 \\N 数组里每个元素都是一个长度为3的数组\n\nWe can initialize a matrix like so.\n可以这样初始化.\n\nIn memory, this is packed together in order like this.\n内存里是这样排列的\n\nTo access a value, you need to specify two indexes, like \"J index of 2, then index of 1\" -\n为了拿一个值，需要两个下标，比如 j[2][1]\n\nthis tells the computer you're looking for the item in subarray 2 at position 1.\n告诉计算机在找数组 2 里，位置是 1 的元素\n\nAnd this would give us the value 12.\n得到数字 12\n\nThe cool thing about matrices is we're not limited to 3 by 3\n矩阵酷的地方是，不止能做 3x3 的矩阵\n\n-- we can make them any size we want\n任何维度都行\n\n-- and we can also make them any number of dimensions we want.\n任何维度都行\n\nFor example, we can create a five dimensional matrix and access it like this.\n可以做一个5维矩阵，然后这样访问 \\N a = j[2][0][18][18][3]\n\nThat's right, you now know how to access a five dimensional matrix\n现在你知道了  怎么读一个 5 维矩阵\n\n-- tell your friends!\n快去告诉你的朋友！\n\nSo far, we've been storing individual numbers or letters into our arrays or matrices.\n目前我们只存过单个数字/字符，存进数组或矩阵\n\nBut often it's useful to store a block of related variables together.\n但有时, 把几个有关系的变量存在一起, 会很有用\n\nLike, you might want to store a bank account number along with its balance.\n比如银行账户号和余额\n\nGroups of variables like these can be bundled together into a Struct.\n多个变量打包在一起叫  结构体 (Struct)\n\nNow we can create variables that aren't just single numbers,\n现在多个不同类型数据，可以放在一起\n\nbut are compound data structures, able to store several pieces of data at once.\n现在多个不同类型数据，可以放在一起\n\nWe can even make arrays of structs that we define,\n甚至可以做一个数组，里面放很多结构体\n\nwhich are automatically bundled together in memory.\n这些数据在内存里  会自动打包在一起\n\nIf we access, for example, J index of 0, we get back the whole struct stored there,\n如果写 j[0]，能拿到  j[0] 里的结构体\n\nand we can pull the specific account number and balance data we want.\n然后拿银行账户和余额\n\nThis array of structs, like any other array,\n存结构体的数组，和其它数组一样\n\ngets created at a fixed size that can't be enlarged to add more items.\n创建时就有固定大小，不能动态增加大小\n\nAlso, arrays must be stored in order in memory,\n还有，数组在内存中 按顺序存储\n\nmaking it hard to add a new item to the middle.\n在中间插入一个值很困难\n\nBut, the struct data structure can be used for\n但结构体可以创造更复杂的数据结构，消除这些限制\n\nbuilding more complicated data structures that avoid these restrictions.\n但结构体可以创造更复杂的数据结构，消除这些限制\n\nLet's take a look at this struct that's called a \"node\".\n我们来看一个结构体，叫 节点(node)\n\nIt stores a variable, like a number, and also a pointer.\n它存一个变量 \\N 一个指针（pointer）\n\nA pointer is a special variable that points, hence the name, to a location in memory.\n\"指针\" 是一种特殊变量，指向一个内存地址，因此得名.\n\nUsing this struct, we can create a linked list,\n用 节点 可以做 链表（linked list）\n\nwhich is a flexible data structure that can store many nodes.\n链表是一种灵活数据结构，能存很多个 节点 (node)\n\nIt does this by having each node point to the next node in the list.\n灵活性是通过每个节点 指向 下一个节点实现的\n\nLet's imagine we have three node structs saved in memory, at locations 1000, 1002 and 1008.\n假设有三个节点，在内存地址 1000，1002, 1008\n\nThey might be spaced apart because they were created at different times,\n隔开的原因 可能是创建时间不同\n\nand other data can sit between them.\n它们之间有其他数据\n\nSo, you see that the first node contains the value 7, and the location 1008 in its \"next\" pointer.\n可以看到第一个节点，值是 7，指向地址 1008\n\nThis means that the next node in the linked list is located at memory location 1008.\n代表下一个节点，位于内存地址 1008\n\nLooking down the linked list, to the next node,\n现在来到下一个节点\n\nwe see it stores the value 112 and points to another node at location 1002.\n值是 112，指向地址 1002\n\nIf we follow that, we find a node that contains the value 14\n如果跟着它，会看到一个值为 14 的节点\n\nand points back to the first node at location 1000.\n这个节点  指回地址 1000，也就是第一个节点\n\nSo this linked list happened to be circular,\n这叫 循环链表\n\nbut it could also have been terminated by using a next pointer value of 0\n但链表也可以是非循环的，最后一个指针是 0\n\n-- the null value -- which would indicate we've reached the end of the list.\n\"null\"，代表链表尽头\n\nWhen programmers use linked lists,\n当程序员用链表时\n\nthey rarely look at the memory values stored in the next pointers.\n很少看指针具体指向哪里\n\nInstead, they can use an abstraction of a linked list, that looks like this,\n而是用链表的抽象模型，就像上图\n\nwhich is much easier to conceptualize.\n更容易看懂\n\nUnlike an array, whose size has to be pre-defined,\n数组大小需要预先定好\n\nlinked lists can be dynamically extended or shortened.\n链表大小可以动态增减\n\nFor example, we can allocate a new node in memory,\n可以创建一个新节点，通过改变指针值，把新节点插入链表\n\nand insert it into this list, just by changing the next pointers.\n可以创建一个新节点，通过改变指针值，把新节点插入链表\n\nLinked Lists can also easily be re-ordered, trimmed, split, reversed, and so on.\n链表也很容易重新排序，两端缩减，分割，倒序等\n\nWhich is pretty nifty!\n超方便！\n\nAnd pretty useful for algorithms like sorting, which we talked about last week.\n链表也适合上集的排序算法\n\nOwing to this flexibility, many more-complex data structures are built on top of linked lists\n因为灵活，很多复杂数据结构 都用链表\n\nThe most famous and universal are queues and stacks.\n最出名的是 队列（queue）和 栈（stack）\n\nA queue - like the line at your post office - goes in order of arrival.\n\"队列\" 就像邮局排队，谁先来就排前面\n\nThe person who has been waiting the longest, gets served first.\n\"队列\" 就像邮局排队，谁先来就排前面\n\nNo matter how frustrating it is that all you want to do is buy stamps\n虽然你可能只想买邮票，而前面的人要寄 23 个包裹\n\nand the person in front of you seems to be mailing 23 packages.\n虽然你可能只想买邮票，而前面的人要寄 23 个包裹\n\nBut, regardless, this behavior is called First-In First-Out, or FIFO.\n这叫 先进先出（FIFO）\n\nThat's the first part.\n我指队列，不是指那 23 个包裹\n\nNot the 23 packages thing.\n我指队列，不是指那 23 个包裹\n\nImagine we have a pointer, named \"post office queue\", that points to the first node in our linked list.\n想象有个指针叫\"邮局队列\"，指向链表第一个节点\n\nOnce we're done serving Hank, we can read Hank's next pointer,\n第一个节点是 Hank，服务完 Hank 之后 \\N 读取 Hank 的指针\n\nand update our \"post office queue\" pointer to the next person in the line.\n把\"邮局队列\"指向下一个人\n\nWe've successfully dequeued Hank -- he's gone, done, finished.\n这样就把 Hank \"出队\"（dequeue）了\n\nIf we want to enqueue someone, that is, add them to the line,\n如果我们想把某人\"入队\"（enqueue） \\N 意思是加到队列里\n\nwe have to traverse down the linked list until we hit the end,\n要遍历整个链表到结尾\n\nand then change that next pointer to point to the new person.\n然后把结尾的指针，指向新人（Nick）\n\nWith just a small change, we can use linked lists as stacks, which are LIFO…\n只要稍作修改，就能用链表做 栈，\\N 栈是后进先出(LIFO)\n\nLast-In First-Out.\n只要稍作修改，就能用链表做 栈，\\N 栈是后进先出(LIFO)\n\nYou can think of this like a stack of pancakes...\n可以把\"栈\"想成一堆松饼\n\nas you make them, you add them to the top of stack.\n做好一个新松饼，就堆在之前上面\n\nAnd when you want to eat one, you take them from the top of the stack.\n吃的时候，是从最上面开始\n\nDelicious!\n美味！\n\nInstead of enqueueing and dequeuing,\n栈就不叫\"入队\"\"出队\"了\n\ndata is pushed onto the stack and popped from the stacks.\n叫\"入栈\"（push） \"出栈\"（pop）\n\nYep, those are the official terms!\n对，这些是正确术语！\n\nIf we update our node struct to contain not just one, but two pointers,\n如果节点改一下，改成 2 个指针\n\nwe can build trees,\n就能做 树（tree）\n\nanother data structure that's used in many algorithms.\n很多算法用了 \"树\" 这种数据结构\n\nAgain, programmers rarely look at the values of these pointers,\n同样，程序员很少看指针的具体值\n\nand instead conceptualize trees like this: The top most node is called the root.\n而是把\"树\"抽象成这样：最高的节点叫\"根节点\"（root）\n\nAnd any nodes that hang from other nodes are called children nodes.\n\"根节点\"下的所有节点   都叫\"子节点\"（children）\n\nAs you might expect, nodes above children are called parent nodes.\n任何子节点的直属上层节点，叫\"母节点\"（parent node）\n\nDoes this example imply that Thomas Jefferson is the parent of Aaron Burr?\n这个例子能说明 托马斯·杰斐逊 是 阿龙·伯尔 的父亲吗？\n\nI'll leave that to your fanfiction to decide.\n我让你们的同人文来决定\n\nAnd finally, any nodes that have no children\n没有任何\"子节点\"的节点\n\n-- where the tree ends -- are called Leaf Nodes.\n也就是\"树\"结束的地方，叫\"叶节点\"（leaf）\n\nIn our example, nodes can have up to two children,\n在这里的例子中，节点最多只可以有 2 个子节点\n\nand for that reason, this particular data structure is called a binary tree.\n因此叫 二叉树（binary tree）\n\nBut you could just as easily have trees with three, four or any number of children\n但你可以随便改，弄成 3个，4个，或更多\n\nby modifying the data structure accordingly.\n但你可以随便改，弄成 3个，4个，或更多\n\nYou can even have tree nodes that use linked lists to store all the nodes they point to.\n甚至节点 可以用链表存所有子节点\n\nAn important property of trees - both in real life and in data structures - is that\n\"树\"的一个重要性质是（不管现实中还是数据结构中）\n\nthere's a one-way path from roots to leaves.\n\"根\"到\"叶\"是 单向 的\n\nIt'd be weird if roots connected to leaves, that connected to roots.\n如果根连到叶，叶连到根  就很奇怪\n\nFor data that links arbitrarily, that include things like loops,\n如果数据随意连接，包括循环\n\nwe can use a graph data structure instead.\n可以用\"图\"表示\n\nRemember our graph from last episode of cities connected by roads?\n还记得上集用路连接城市的\"图\"吗？\n\nThis can be stored as nodes with many pointers, very much like a tree,\n这种结构  可以用有多个指针的节点表示\n\nbut there is no notion of roots and leaves, and children and parents…\n因此没有 根 叶 子节点 父节点 这些概念\n\nAnything can point to anything!\n可以随意指向！\n\nSo that's a whirlwind overview\n以上概述了计算机科学中，最主要的一些数据结构\n\nof pretty much all of the fundamental data structures used in computer science.\n以上概述了计算机科学中，最主要的一些数据结构\n\nOn top of these basic building blocks,\n这些基本结构之上，程序员做了各种新变体，有不同性质.\n\nprogrammers have built all sorts of clever variants, with slightly different properties\n这些基本结构之上，程序员做了各种新变体，有不同性质.\n\n-- data structures like red-black trees and heaps, which we don't have time to cover.\n比如\"红黑树\"和\"堆\"，我们没时间讲\n\nThese different data structures have properties that are useful for particular computations.\n不同数据结构适用于不同场景\n\nThe right choice of data structure can make your job a lot easier,\n选择正确数据结构会让工作更简单\n\nso it pays off to think about how you want to structure your data before you jump in.\n所以花时间考虑用什么数据结构是值得的\n\nFortunately, most programming languages come with\n幸运的是，大多数编程语言自带了预先做好的数据结构\n\nlibraries packed full of ready-made data structures.\n幸运的是，大多数编程语言自带了预先做好的数据结构\n\nFor example, C++ has its Standard Template Library, and Java has the Java Class Library.\n比如，C++有\"标准模板库\"，Java有\"Java 类库\"\n\nThese mean programmers don't have to waste time implementing things from scratch,\n程序员不用浪费时间从零写\n\nand can instead wield the power of data structures to do more interesting things,\n时间可以花在更有趣的事情\n\nonce again allowing us to operate at a new level of abstraction!\n又提升了一层抽象！\n\nI'll see you next week.\n下周见！\n\nHi, I'm Carrie Anne and welcome to Crash Course computer science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the past a few episodes,\n前几集我们聊了基础，比如函数，算法和数据结构\n\nwe've been building up our understanding of computer science fundamentals,\n前几集我们聊了基础，比如函数，算法和数据结构\n\nsuch as functions, algorithms and data structures.\n前几集我们聊了基础，比如函数，算法和数据结构\n\nToday, we're going to take a step back and look at the person\n今天，我们来看一位对计算机理论 贡献巨大的人\n\nwho formulated many of the theoretical concepts that underline modern computation.\n今天，我们来看一位对计算机理论 贡献巨大的人\n\nThe father of computer science\n计算机科学之父\n\nand not quite Benedict Cumberbatch lookalike, Alan Turing.\n长得不怎么像 本尼 的 阿兰·图灵\n\nAlan Mathison Turing was born in London in 1912\n阿兰·马蒂森·图灵 于 1921 年出生在伦敦，\\N 从小就表现出惊人数学和科学能力\n\nand showed an incredible aptitude for maths and science throughout his early education.\n阿兰·马蒂森·图灵 于 1921 年出生在伦敦，\\N 从小就表现出惊人数学和科学能力\n\nHis first brush of what we now call computer science came in 1935\n他对计算机科学的建树始于 1935 年\n\nwhile he was a master student at King's College in Cambridge.\n当时他是剑桥国王学院的硕士生\n\nHe set out to solve a problem posed by German Mathematician David Hilbert\n他开始解决德国数学家 大卫·希尔伯特 提出的问题\n\nknown as the Entscheidungsproblem\n叫 Entscheidungsproblem （德语）\n\nor decision problem,\n即\"可判定性问题\":\n\nwhich asked the following:\n即\"可判定性问题\":\n\nis there an algorithm that takes, as input, a statement written in formal logic,\n是否存在一种算法，输入正式逻辑语句 \\N 输出准确的\"是\"或\"否\"答案？\n\nand produces a \"yes\" or \"no\" answer that's always accurate?\n是否存在一种算法，输入正式逻辑语句 \\N 输出准确的\"是\"或\"否\"答案？\n\nIf such an algorithm existed,\n如果这样的算法存在， \\N 可以回答比如 \"是否有一个数大于所有数\"\n\nwe could use it to answer questions like, \"Is there a number bigger than all numbers?\"\n如果这样的算法存在， \\N 可以回答比如 \"是否有一个数大于所有数\"\n\nNo, there's not. We know the answer to that one,\n不, 没有.  我们知道答案\n\nbut there are many other questions in mathematics that we'd like to know the answer too.\n但有很多其他数学问题，我们想知道答案\n\nSo if this algorithm existed, we'd want to know it.\n所以如果这种算法存在,  我们想知道\n\nThe American mathematician Alonzo Church first presented a solution to this problem in 1935.\n美国数学家 阿隆佐·丘奇  \\N 于 1935年 首先提出解决方法\n\nHe developed a system of mathematical expressions called Lambda Calculus\n开发了一个叫\"Lambda 算子\"的数学表达系统\n\nand demonstrated that no such universal algorithm could exist.\n证明了这样的算法不存在\n\nAlthough Lambda Calculus was capable of representing any computation,\n虽然\"Lambda 算子\"能表示任何计算\n\nthe mathematical technique was difficult to apply and understand.\n但它使用的数学技巧 难以理解和使用\n\nAt pretty much the same time on the other side of the Atlantic,\n同时在大西洋另一边\n\nAlan Turing came up with his own approach to solve the decision problem.\n阿兰·图灵 想出了自己的办法来解决\"可判定性问题\"\n\nHe proposed a hypothetical computing machine, which we now call a Turing Machine.\n提出了一种假想的计算机，现在叫\"图灵机\"\n\nTuring Machines provided a simple, yet powerful\n图灵机提供了简单又强大的数学计算模型\n\nmathematical model of computation.\n图灵机提供了简单又强大的数学计算模型\n\nAlthough using totally different mathematics,\n虽然用的数学不一样\n\nthey were functionally equivalent to lambda calculus in terms of their computational power.\n但图灵机的计算能力和 Lambda 算子一样\n\nHowever their relative simplicity made them much more popular\n同时因为图灵机更简单，所以在新兴的计算机领域更受欢迎\n\nin the burgeoning field of computer science.\n同时因为图灵机更简单，所以在新兴的计算机领域更受欢迎\n\nIn fact, they're simple enough that I'm going to explain it right now.\n因为它如此简单，我现在就给你解释\n\nA Turing Machine is a theoretical computing device\n图灵机是一台理论计算设备\n\nThere's also a state variable in which we can hold a piece of information\n还有一个状态变量，保存当前状态\n\nabout the current state of the machine.\n还有一个状态变量，保存当前状态\n\nAnd a set of rules that describes what the machine does.\n还有一组规则，描述机器做什么\n\nGiven a state and the current symbol the head is reading,\n规则是根据 当前状态+读写头看到的符号，决定机器做什么\n\nthe rule can be to write a symbol on the tape,\n结果可能是在纸带写入一个符号\n\nchange the state of the machine, move the read/write head to the left or right by one spot\n或改变状态，或把读写头移动一格\n\nor any combination of these actions.\n或执行这些动作的组合\n\nTo make this concrete, let's work through a simple example:\n为了更好理解，讲个简单例子：\n\na Turing Machine that reads a string of ones ending in a zero\n让图灵机读一个以零结尾的字符串\n\nand computes whether there is an even number of ones.\n并计算 1 的出现次数  是不是偶数\n\nIf that's true,\n如果是, 在纸带上写一个 1\n\nthe machine will write a one to the tape\n如果是, 在纸带上写一个 1\n\nand if it's false, it'll write a zero.\n如果不是，在纸带上写一个 0\n\nFirst we need to define our Turing machine rules.\n首先要定义\"图灵机\"的规则\n\nIf the state is even and the current symbol of the tape is one,\n如果当前状态是\"偶数\",  当前符号是1\n\nthen we update the machine state to odd and move the head to the right.\n那么把状态更新为\"奇数\"，把读写头向右移动\n\nOn the other hand if the state is even and the current symbol is zero,\n如果当前状态为偶数，当前符号是 0\n\nwhich means we've reached the end of the string of ones,\n意味着到了字符串结尾\n\nthen we write one to the tape and change the state to halt,\n那么在纸带上写一个 1，并且把状态改成 停机(halt)\n\nas in we're finished and the Turing machine has completed the computation.\n状态改为\"停机\" 是因为图灵机已完成计算\n\nWe also need rules for when the Turing machine is in an odd state,\n但我们还需要 2 条规则，来处理状态为奇数的情况\n\none rule for the symbol on the tape is a zero and another for when it is one.\n一条处理 奇数 + 纸带是 0 的情况 \\N 一条处理 奇数 + 纸带是 1 的情况\n\nLastly we need to define a Starting state, which we'll set to be even.\n最后，要决定机器的初始状态，这里定成\"偶数\"\n\nNow we've defined the rules in the starting state of our Turing machine,\n定义好了 起始状态+规则\n\nwhich is comparable to a computer program, we can run it on some example input.\n就像写好了程序，现在可以输入了\n\nLet's say we store 1 1 0 onto tape.\n假设把\"1 1 0\"放在纸带上，有两个 1，是偶数\n\nThat's two ones, which means there is an even number of ones,\n假设把\"1 1 0\"放在纸带上，有两个 1，是偶数\n\nand if that's news to you,\n如果\"偶数\"对你是新知识 \\N 也许我们该开一门【十分钟速成课：数学】\n\nWe should probably get working on crash course Math.\n如果\"偶数\"对你是新知识 \\N 也许我们该开一门【十分钟速成课：数学】\n\nNotice that our rules only ever move their head to the right\n注意，规则只让 读写头 向右移动\n\nso the rest of the tape is irrelevant.\n其他部分无关紧要，为了简单所以留空\n\nWe'll leave it blank for simplicity.\n其他部分无关紧要，为了简单所以留空\n\nOur Turing machine is all ready to go so let's start it.\n\"图灵机\"准备好了，开始吧\n\nOur state is even and the first number we see is one.\n机器起始状态为\"偶数\"，看到的第一个数是 1\n\nThat matches our topmost rule and so we execute the effect,\n符合最上面那条规则，所以执行对应的步骤\n\nwhich is to update the state to odd and move the read/write head to the right by one spot.\n把状态更新到\"奇数\"， 读写头向右移动一格\n\nOkay, now we see another one on the tape, But this time our state is odd\n然后又看到 1, 但机器状态是\"奇数\"，所以执行第三条规则\n\nand so we execute our third rule\n然后又看到 1, 但机器状态是\"奇数\"，所以执行第三条规则\n\nwhich sets the state back to even and moves the head to the right.\n使机器状态变回\"偶数\"，读写头向右移动一格\n\nNow we see a 0 and our current state is even\n现在看到 0，并且机器状态是 偶数，所以执行第二条规则\n\nso we execute our second rule\n现在看到 0，并且机器状态是 偶数，所以执行第二条规则\n\nwhich is to write a 1 to the tape signifying that yes, it's true,\n在纸带上写 1，表示\"真\" 的确有偶数个 1\n\nthere is an even number of ones,\n在纸带上写 1，表示\"真\" 的确有偶数个 1\n\nand finally the machine halts.\n然后机器停机\n\nThat's how Turing machines work.\n这就是图灵机的原理，很简单对吧？\n\nPretty simple, right?\n这就是图灵机的原理，很简单对吧？\n\nso you might be wondering why there's such a big deal.\n你可能想知道 有什么大不了的\n\nWell, Turing shows that this simple hypothetical machine\n图灵证明了这个简单假想机器\n\ncan perform any computation if given enough time and memory.\n如果有足够时间和内存，可以执行任何计算\n\nIt's a general-purpose computer.\n它是一台通用计算机\n\nOur program was a simple example.\n刚才的程序就是个简单例子\n\nBut with enough rules, states and tape,\n只要有足够的规则，状态和纸带  可以创造任何东西\n\nyou could build anything\n只要有足够的规则，状态和纸带  可以创造任何东西\n\n- a web browser, world of warcraft, whatever!\n浏览器, 魔兽世界 任何东西！\n\nOf course it would be ridiculously inefficient, but it is theoretically possible.\n当然 这样做效率很低，但理论上可行.\n\nAnd that's why, as a model of computing,\n所以图灵机是很强大的计算模型\n\nit's such a powerful idea.\n所以图灵机是很强大的计算模型\n\nIn fact, in terms of what it can and cannot compute\n事实上，就可计算和不可计算而言\n\nthere's no computer more powerful than a turing machine.\n没有计算机比图灵机更强大\n\nA computer that is as powerful is called Turing complete.\n和图灵机一样强大的，叫 \"图灵完备\"\n\nEvery modern computing system, your laptop, your smartphone\n每个现代计算系统 比如笔记本电脑，智能手机\n\nand even the little computer inside your microwave and thermostat\n甚至微波炉和恒温器内部的小电脑\n\nare all Turing Complete.\n都是\"图灵完备\"的\n\nTo answer Hilbert's decision problem,\n为了回答可判定性问题\n\nTuring applied these new Turing machines to an intriguing computational puzzle:\n他把图灵机用于一个有趣计算问题：\n\nthe halting problem.\n\"停机问题\"\n\nPut simply this asks\n简单说就是\n\n\"Is there an algorithm that can determine,\n\"给定图灵机描述和输入纸带，是否有算法可以确定\n\ngiven a description of a turing machine and the input from its tape,\n\"给定图灵机描述和输入纸带，是否有算法可以确定\n\nwhether the Machine will run forever or halt?\"\n机器会永远算下去还是到某一点会停机？\n\nFor example we know our Turing machine will halt when given the input 1 1 0\n我们知道输入 1 1 0，图灵机会停机\n\nBecause we literally walk through the example until it halted,\n因为刚做过这个例子，它最后停机了\n\nbut what about a more complex problem?\n但如果是更复杂的问题呢？\n\nIs there a way to figure out if the program will halt without executing it?\n有没有办法在不执行的情况，弄清会不会停机？\n\nSome programs might take years to run\n一些程序可能要运行好几年\n\nso it would be useful to know before we run it\n所以在运行前知道 会不会出结果很有用\n\nand wait and wait and wait and then start getting worried and wonder\n否则就要一直等啊等，忧虑到底会不会出结果\n\nand then decades later when you're old and gray control-alt-delete.\n当几十年后变老了，再按强制结束\n\nSo much sadness!\n好悲伤！\n\nUnfortunately, Turing came up with a proof that shows the halting problem was in fact unsolvable,\n图灵通过一个巧妙逻辑矛盾 \\N 证明了停机问题是无法解决的\n\nthrough a clever logical contradiction.\n图灵通过一个巧妙逻辑矛盾 \\N 证明了停机问题是无法解决的\n\nLet's follow his reasoning.\n我们来看看他的推理\n\nImagine we have a hypothetical Turing machine that takes a description of a program\n想象有一个假想图灵机，\\N 输入：问题的描述 + 纸带的数据\n\nand some input for his tape\n想象有一个假想图灵机，\\N 输入：问题的描述 + 纸带的数据\n\nand always outputs either Yes, it halts, or no, it doesn't.\n输出 Yes 代表会\"停机\"，输出 No 代表不会\n\nAnd I'm going to give this machine a fun name\n我要给这台机器一个有趣的名字叫 H， \\N 来自\"停机\"的第一个字母\n\nH for Halts.\n我要给这台机器一个有趣的名字叫 H， \\N 来自\"停机\"的第一个字母\n\nDon't worry about how it works.\n不用担心它具体怎么工作\n\nLet's just assume such a machine exists.\n假设这样的机器存在就好  毕竟重点是推论\n\nWe're talking theory here.\n假设这样的机器存在就好  毕竟重点是推论\n\nTuring reasons if there existed a program whose halting behavior was not decidable by H,\n图灵推理说： 如果有个程序， H 无法判断是否会\"停机\"\n\nit would mean the halting problem is unsolvable.\n意味着\"停机问题\"无法解决\n\nTo find one, Turing designed another Turing machine that built on top of H.\n为了找到这样的程序，图灵用 H 设计了另一个图灵机\n\nIf H says the program halts,\n如果 H 说程序会\"停机\"，那么新机器会永远运行（即不会停机）\n\nthen we'll make our new machine loop forever.\n如果 H 说程序会\"停机\"，那么新机器会永远运行（即不会停机）\n\nIf the answer is no, it doesn't the halt.\n如果 H 的结果为 No，代表不会停机\n\nThat will have the new machine output no and halt.\n那么让新机器输出 No，然后\"停机\"\n\nIn essence, we're building a machine that does the opposite of what H says.\n实质上是一台和 H 输出相反的机器\n\nHalt if the program doesn't halt\n如果程序不停机，就停机\n\nand run forever if the program halts.\n如果程序停机，就永远运行下去\n\nSo this argument will also need to add a splitter to the front of our new machine.\n我们还需要在机器前面加一个分离器\n\nSo it accepts only one input and passes that as both the program and input into H.\n让机器只接收一个输入，\\N 这个输入既是程序，也是输入\n\nLet's call this new Machine Bizzaro.\n我们把这台新机器叫 异魔\n\nSo far this seems like a plausible machine right.\n目前为止，这个机器不难理解\n\nNow it's going to get pretty complicated.\n但接下来马上会变复杂，会有点难懂\n\nBut bear with me for a second.\n但接下来马上会变复杂，会有点难懂\n\nLook what happens when you pass bizzaro a description of itself as the input.\n如果把 异魔 的描述，作为本身的输入会怎样\n\nThis means We're asking h what bizzaro will do when asked to evaluate itself.\n意味着在问 H ，当异魔的输入是自己时会怎样\n\nBut if H says Bizzaro halts,\n但如果 H 说异魔会停机\n\nthen Bizzaro enters its infinite loop and thus doesn't halt.\n那么异魔会进入无限循环，因此不会停机\n\nAnd if H says the Bizzaro doesn't halt, then Bizzaro outputs no and halt.\n如果 H 说异魔不会停机，那么异魔会输出 No 然后停机\n\nSo H can't possibly decide the halting problem correctly\n所以 H 不能正确判定 停机问题\n\nbecause there is no answer.\n因为没有答案\n\nIt's a paradox.\n这是一个悖论\n\nAnd this paradox means that the halting problem cannot be solved with Turing machines.\n意味着\"停机问题\"不能用图灵机解决\n\nRemember Turing proves that Turing machines could implement any computation.\n还记得刚刚说： 图灵证明了图灵机可以实现任何计算\n\nSo this solution to the halting problem proves\n\"停机问题\"证明了，不是所有问题都能用计算解决\n\nthat not all problems can be solved by computation.\n\"停机问题\"证明了，不是所有问题都能用计算解决\n\nWow, that's some heavy stuff.\n哇，好难理解\n\nI might have to watch that again myself.\n我都可能要再看一遍\n\nLong story short, Church and Turing showed there were limits to the ability of computers.\n长话短说，丘奇和图灵证明了计算机的能力有极限\n\nNo matter how much time or memory you have,\n无论有多少时间或内存，有些问题是计算机无法解决的\n\nthere are just some problems that cannot be solved ever.\n无论有多少时间或内存，有些问题是计算机无法解决的\n\nThe concurrent efforts by Church and Turing to determine the limits of computation,\n丘奇和图灵证明了计算是有极限的，\n\nand in general, formalize computability, are now called the Church-Turing Thesis.\n起步了可计算性理论，现在叫\"丘奇-图灵论题\"\n\nAt this point in 1936, Turing was only 24 years old\n当时是1936年，图灵只有24岁\n\nand really only just beginning his career.\n他的职业生涯才刚刚开始\n\nFrom 1936 through 1938,\n从1936年到1938年 \\N 在丘奇指导下，他在普林斯顿拿到博士学位\n\nhe completed a PhD at Princeton University under the guidance of Church\n从1936年到1938年 \\N 在丘奇指导下，他在普林斯顿拿到博士学位\n\nthen after graduating he returned to Cambridge.\n毕业后回到剑桥\n\nShortly after in 1939, Britain became embroiled in World War II.\n1939年后不久，英国卷入第二次世界大战\n\nTuring's genius was quickly applied for the war effort.\n图灵的才能很快被投入战争\n\nIn fact, a year before the war started,\n事实上，在战争开始前一年\n\nhe was already working part-time at the UK's government Code and Cypher school,\n他已经在英国政府的 密码破译学校兼职\n\nwhich was the British code breaking group based out of Bletchley Park.\n位于\"布莱切利园\"的一个密码破译组织\n\nOne of his main efforts was figuring out how to decrypt German communications.\n他的工作内容之一是破解德国的通信加密\n\nEspecially those that use the Enigma Machine.\n特别是\"英格玛机\"加密的信息\n\nIn short, these machines scrambled text\n简单说，英格玛机会加密明文\n\nlike you type the letters H-E-L-L-O\n如果输入字母 H-E-L-L-O\n\nand the letters X-W-D-B-J would come out.\n机器输出 X-W-D-B-J\n\nThis process is called Encryption.\n这个过程叫\"加密\"\n\nThe scrambling wasn't random.\n文字不是随便打乱的\n\nThe behavior was defined by a series of real world rotors on the top of the enigma machine.\n加密由\"英格玛机\"顶部的齿轮组合决定\n\nEach were 26 possible rotational positions.\n每个齿轮有26个可能位置\n\nThere was also a plug board at the front of the machine that allow pairs of letters to be swapped.\n机器前面还有插板，可以将两个字母互换\n\nIn total, there were billions of possible settings.\n总共有上十亿种可能\n\nIf you had your only enigma machine and you knew the correct rotor and plug board settings,\n如果你有\"英格玛机\"，并且知道正确的齿轮和插头设置\n\nyou could type in X-W-D-B-J and \"hello\" would come out.\n输入X-W-D-B-J，机器会输出 hello\n\nIn other words, you decrypted the message.\n解密了这条消息\n\nOf course, the German military wasn't sharing their enigma settings on Social Media.\n当然，德军不会把机器设置发到微博上\n\nSo the allies had to break the code.\n盟军必须自己破译密码\n\nWith billions of Rotor and plug board combinations,\n有数十亿种组合，根本没法手工尝试所有组合\n\nthere was no way to check them all by hand.\n有数十亿种组合，根本没法手工尝试所有组合\n\nFortunately for Turing, Enigma Machines and the people who operated them were not perfect.\n幸运的是，英格玛机和操作员不是完美的\n\nLike one key flaw was that a letter would never be encoded as itself,\n一个大缺陷是：字母加密后绝不会是自己\n\nas in an H was never encrypted as an H.\nH 加密后绝对不是 H\n\nTuring building on earlier work by Polish code breakers\n图灵接着之前波兰破译专家的成果继续工作\n\ndesigned a special-purpose electro-mechanical computer called the bombe\n设计了一个机电计算机，叫 Bombe\n\nthat took advantages of this flaw.\n利用了这个缺陷，它对加密消息尝试多种组合\n\nIt tried lots and lots of combinations of enigma settings for a given encrypted message.\n利用了这个缺陷，它对加密消息尝试多种组合\n\nIf the bombe found a setting that led to a letter being encoded as itself\n如果发现字母解密后和原先一样\n\nwhich we know no enigma machines could do.\n我们知道英格玛机决不会这么做\n\nThat combination was discarded then the machine moved on to try another combination.\n这个组合会被跳过，接着试另一个组合\n\nSo bombe was used to greatly narrow the number of Possible enigma settings.\nBombe 大幅减少了搜索量\n\nThis allowed human code breakers to hone their efforts on the most probable solutions,\n让破译人员把精力花在更有可能的组合\n\nlooking for things like common german words in fragments of decoded text.\n比如在解码文本中找常见的德语单词\n\nPeriodically, the Germans would suspect someone was decoding their communications\n德国人时不时会怀疑有人在破解，然后升级英格玛机\n\nand upgrade the enigma machine,\n德国人时不时会怀疑有人在破解，然后升级英格玛机\n\nlike they'd add another rotor creating many more combinations.\n比如加一个齿轮，创造更多可能组合\n\nThey even built entirely new encryption machines.\n他们甚至还做了全新的加密机\n\nThroughout the war, Turing and his colleagues at Bletchley Park\n整个战争期间，图灵和同事在布莱切利园努力破解加密\n\nworked tirelessly to defeat these mechanisms.\n整个战争期间，图灵和同事在布莱切利园努力破解加密\n\nAnd overall, the intelligence gained from decrypted German communications\n解密得到的德国情报，为盟军赢得了很多优势\n\ngave the allies an edge in many theaters\n解密得到的德国情报，为盟军赢得了很多优势\n\nwith some historians arguing is shortened the war by years.\n有些史学家认为他们把战争减短了好几年\n\nAfter the war, Turing return to academia\n战后，图灵回到学术界 \\N 为许多早期计算机工作做出贡献\n\nand contributed to many early electronic computing efforts\n战后，图灵回到学术界 \\N 为许多早期计算机工作做出贡献\n\nlike the Manchester Mark 1, which was an early and influential stored-program computer.\n比如曼彻斯特 1 号，一个早期有影响力的存储程序计算机\n\nBut his most famous post-war contribution was the Artificial Intelligence.\n但他最有名的战后贡献是\"人工智能\"\n\nA field's so new that it didn't get that name until 1956.\n这个领域很新，直到1956年才有名字\n\nIt's a huge topic. So we'll get to it again in future episodes.\n这个话题很大，以后再谈（第34集）\n\nIn 1950, Turing could envision a future where computers\n1950 年，图灵设想了未来的计算机\n\nwere powerful enough to exhibit intelligence equivalent to\n拥有和人类一样的智力，或至少难以区分\n\nor at least indistinguishable from that of a human.\n拥有和人类一样的智力，或至少难以区分\n\nTuring postulated that a computer would deserve to be called intelligent\n图灵提出 \\N 如果计算机能欺骗人类相信它是人类，才算是智能\n\nif it could deceive a human into believing that it was human.\n图灵提出 \\N 如果计算机能欺骗人类相信它是人类，才算是智能\n\nThis became the basis of a simple test, now called the Turing test.\n这成了智能测试的基础，如今叫\"图灵测试\"\n\nImagine that you are having a conversation with two different people\n想像你在和两个人沟通 \\N 不用嘴或面对面，而是来回发消息\n\nnot by voice or in person, but by sending type notes back and forth,\n想像你在和两个人沟通 \\N 不用嘴或面对面，而是来回发消息\n\nyou can ask any questions you want and you get replies.\n可以问任何问题，然后会收到回答\n\nBut one of those two people is actually a computer.\n但其中一个是计算机\n\nIf you can't tell which one is human and which one is a computer,\n如果你分不出哪个是人类，哪个是计算机\n\nthen the computer passes the test.\n那么计算机就通过了图灵测试\n\nThere's a modern version of this test called\n这个测试的现代版叫\n\na completely automated public turing test to tell computers and humans apart\n\"公开全自动图灵测试，用于区分计算机和人类\"\n\nor Captcha for short.\n简称\"验证码\"\n\nThese are frequently used on the internet to prevent automated systems\n防止机器人发垃圾信息等\n\nfrom doing things like posting spam on websites.\n防止机器人发垃圾信息等\n\nI'll admit sometimes I can't read what those squiggly things say.\n我承认 有时我都认不出那些扭曲的东西是什么字\n\nDoes that mean I'm a computer?\n这难道意味着我是计算机？\n\nNormally in this series, we don't delve into the personal lives of these historical figures.\n通常这个系列我们不会深入历史人物的个人生活\n\nBut in Turing's case his name has been inextricably tied to tragedy\n但图灵与悲剧密不可分\n\nso his story is worth mentioning.\n所以他的故事值得一提\n\nTuring was gained a time when homosexuality was illegal in the United Kingdom and much of the world.\n图灵那个时代，同性恋是违法的，英国和大部分国家都是\n\nAnd an investigation into a 1952 Burglary at his home\n1952 年调查他家的入室盗窃案时，向当局暴露了他的性取向\n\nrevealed his sexual orientation to the authorities,\n1952 年调查他家的入室盗窃案时，向当局暴露了他的性取向\n\nwho charged him with gross indecency.\n被起诉 \"行为严重不检点\"\n\nTuring was convicted and given a choice between imprisonment,\n图灵被定罪，有2个选择： \\N 1. 入狱  2. 接受激素来压制性欲\n\nor probation with hormonal treatments to suppress his sexuality.\n图灵被定罪，有2个选择： \\N 1. 入狱  2. 接受激素来压制性欲\n\nHe chose the latter in part to continue his academic work,\n他选了后者，部分原因是为了继续学术工作\n\nbut it altered his mood and personality.\n但药物改变了他的情绪和性格\n\nAlthough the exact circumstances will never be known,\n虽然确切情况永远无法得知\n\nit's most widely accepted that Alan Turing took his own life by poison in 1954.\n图灵于1954年服毒自尽，年仅41岁\n\nHe was only 41.\n图灵于1954年服毒自尽，年仅41岁\n\nMany things have been named in recognition of Turing's contributions to theoretical computer science\n由于图灵对计算机科学贡献巨大，许多东西以他命名\n\nBut perhaps the most prestigious among them is the Turing award\n其中最出名的是\"图灵奖\"\n\nthe highest distinction in the field of computer science.\n计算机领域的最高奖项\n\nEquivalent to a Nobel prize in Physics, chemistry or other sciences.\n相当于物理, 化学等其它领域的诺贝尔奖\n\nDespite a life cut short, Alan inspire the first generation of computer scientists\n虽然英年早逝，但图灵激励了第一代计算机科学家\n\nand lead key groundwork that enabled a digital era that we get to enjoy today.\n而且为如今便利的数字时代 做出了重要基石性工作\n\nI'll see you next week.\n我们下周见\n\nHi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nSo we've talked a lot about sorting in this series\n之前花了很多时间讲排序\n\nand often code to sort a list of numbers might only be ten lines long,\n也写了些 10 行左右的排序代码\n\nwhich is easy enough for a single programmer to write.\n对1个程序员来说很容易写\n\nPlus, it's short enough that you don't need any special tools\n而且代码很短，不必用专门工具\n\n- you could do it in Notepad.\n- 记事本就够了\n\nReally!\n真的！\n\nBut, a sorting algorithm isn't a program;\n但排序算法很少会是独立程序 \\N 更可能是大项目的一小部分\n\nit's likely only a small part of a much larger program.\n但排序算法很少会是独立程序 \\N 更可能是大项目的一小部分\n\nFor example, Microsoft Office has roughly 40 millions lines of code.\n举个例子，微软的 Office 大约有 4000 万代码\n\n40 MILLION!\n4000 万！\n\nThat's way too big for any one person to figure out and write!\n太多了，一个人不可能做到\n\nTo build huge programs like this, programmers use a set of tools and practices.\n为了写大型程序，程序员用各种工具和方法\n\nTaken together, these form the discipline of Software Engineering\n所有这些形成了\"软件工程\"学科\n\n- a term coined by engineer Margaret Hamilton,\n- 这个词由工程师 Margaret Hamilton 创造\n\nwho helped NASA prevent serious problems during the Apollo missions to the moon.\n她帮助 NASA 在阿波罗计划中避免了严重问题\n\nShe once explained it this way:\n她曾说过：\n\n\"It's kind of like a root canal: you waited till the end,\n\"有点像牙根管治疗：你总是拖到最后才做 \\N 但有些事可以预先做好\n\n[but] there are things you could have done beforehand.\n\"有点像牙根管治疗：你总是拖到最后才做 \\N 但有些事可以预先做好\n\nIt's like preventative healthcare,\n有点像预防性体检, 只不过是预防软件出错\"\n\nbut it's preventative software.\"\n有点像预防性体检, 只不过是预防软件出错\"\n\nAs I mentioned in episode 12,\n第 12 集提过\n\nbreaking big programs into smaller functions allows many people to work simultaneously.\n把大项目分解成小函数  可以让多人同时工作\n\nThey don't have to worry about the whole thing,\n不用关心整个项目，关心自己的函数就好了\n\njust the function they're working on.\n不用关心整个项目，关心自己的函数就好了\n\nSo, if you're tasked with writing a sort algorithm,\n如果你的任务是写排序算法\n\nyou only need to make sure it sorts properly and efficiently.\n你只需要确保高效和正确就可以了\n\nHowever, even packing code up into functions isn't enough.\n然而把代码打包成函数 依然不够\n\nMicrosoft Office probably contains hundreds of thousands of them.\n如果只是这样，微软 Office 会有几十万个函数\n\nThat's better than dealing with 40 million lines of code,\n虽然比 4000 万行代码要好一些，但还是太多了\n\nbut it's still way too many \"things\" for one person or team to manage.\n虽然比 4000 万行代码要好一些，但还是太多了\n\nThe solution is to package functions into hierarchies,\n解决办法是：把函数打包成层级. \\N 把相关代码都放在一起，打包成对象（objects）\n\npulling related code together into \"objects\".\n解决办法是：把函数打包成层级. \\N 把相关代码都放在一起，打包成对象（objects）\n\nFor example, car's software might have several functions related to cruise control,\n例如，汽车软件中 可能有几个和定速巡航有关的函数\n\nlike setting speed, nudging speed up or down, and stopping cruise control altogether.\n比如 设定速度，逐渐加速减速，停止定速巡航\n\nSince they're all related,\n因为这些函数都相关，可以包装成一个\"定速巡航对象\"\n\nwe can wrap them up into a unified cruise control object.\n因为这些函数都相关，可以包装成一个\"定速巡航对象\"\n\nBut, we don't have to stop there,\n但不止如此，我们还可以做更多\n\ncruise control is just one part of the engine's software.\n\"定速巡航\"只是引擎软件的一部分\n\nThere might also be sets of functions that control spark plug ignition,\n可能还有 \"火花塞点火\" \"燃油泵\" 和 \"散热器\"\n\nfuel pumps, and the radiator.\n可能还有 \"火花塞点火\" \"燃油泵\" 和 \"散热器\"\n\nSo we can create a \"parent\" Engine Object\n我们可以做一个\"引擎对象\" 来包括所有\"子\"对象\n\nthat contains all of these \"children\" objects.\n我们可以做一个\"引擎对象\" 来包括所有\"子\"对象\n\nIn addition to children *objects*,\n除了子对象，\"引擎对象\"可能有自己的函数\n\nthe engine itself might have its *own* functions.\n除了子对象，\"引擎对象\"可能有自己的函数\n\nYou want to be able to stop and start it, for example.\n比如 开关引擎\n\nIt'll also have its own variables,\n它也会有自己的变量，比如汽车行驶了多少英里\n\nlike how many miles the car has traveled.\n它也会有自己的变量，比如汽车行驶了多少英里\n\nIn general, objects can contain other objects, functions and variables.\n总的来说，对象可以包其它对象，函数和变量\n\nAnd of course, the engine is just one part of a Car Object.\n当然，\"引擎对象\"只是\"汽车对象\"的一部分\n\nThere's also the transmission, wheels, doors, windows, and so on.\n还有传动装置，车轮，门，窗等\n\nNow, as a programmer, if I want to set the cruise control,\n作为程序员，如果想设\"定速巡航\"\n\nI navigate down the object hierarchy,\n要一层层向下\n\nfrom the outermost objects to more and more deeply nested ones.\n从最外面的对象往里找\n\nEventually, I reach the function I want to trigger:\n最后找到想执行的函数：\n\n\"Car, then engine, then cruise control, then set cruise speed to 55\".\nCar. Engine.  CruiseControl.  setCruiseSpeed(55)\n\nProgramming languages often use something equivalent to the syntax shown here.\n编程语言经常用类似这样的语法\n\nThe idea of packing up functional units into nested objects is called\n把函数打包成对象的思想叫 \"面向对象编程\"\n\nObject Oriented Programming.\n把函数打包成对象的思想叫 \"面向对象编程\"\n\nThis is very similar to what we've done all series long:\n这种思想和之前类似\n\nhide complexity by encapsulating low-level details in higher-order components.\n通过封装组件，隐藏复杂度\n\nBefore we packed up things like transistor circuits into higher-level boolean gates.\n之前把晶体管  打包成了逻辑门\n\nNow we're doing the same thing with software.\n现在软件也这样做\n\nYet again, it's a way to move up a new level of abstraction!\n又提升了一层抽象！\n\nBreaking up a big program, like a car's software,\n把大型软件（如汽车软件）\\N 拆成一个个更小单元，适合团队合作\n\ninto functional units is perfect for teams.\n把大型软件（如汽车软件）\\N 拆成一个个更小单元，适合团队合作\n\nOne team might be responsible for the cruise control system,\n一个团队负责定速巡航系统\n\nand a single programmer on that team tackles a handful of functions.\n团队里的一位程序员负责其中一些函数\n\nThis is similar to how big, physical things are built, like skyscrapers.\n类似建摩天大楼\n\nYou'll have electricians running wires,\n有电工装电线\n\nplumbers fitting pipes,\n管道工配管\n\nwelders welding,\n焊接工焊接\n\npainters painting,\n油漆工涂油漆\n\nand hundreds of other people teeming all over the hull.\n还有成百上千人做其他事情\n\nThey work together on different parts simultaneously,\n在不同岗位同时工作，各尽其能\n\nleveraging their different skills.\n在不同岗位同时工作，各尽其能\n\nUntil one day, you've got a whole working building!\n直到整栋楼完成\n\nBut, returning to our cruise control example\n回到定速巡航的例子\n\nits code is going to have to make use of functions in other parts of the engine's software,\n定速巡航 要用到引擎的其它函数，来保持车速\n\nto, you know, keep the car at a constant speed.\n定速巡航 要用到引擎的其它函数，来保持车速\n\nThat code isn't part of the cruise control team's responsibility.\n定速巡航 团队不负责这些代码，另一个团队负责\n\nIt's another team's code.\n定速巡航 团队不负责这些代码，另一个团队负责\n\nBecause the cruise control team didn't write that,\n因为是其他团队的代码，\n\nthey're going to need good documentation about what each function in the code does,\n定速巡航 团队需要文档 帮助理解代码都做什么\n\nand a well-defined Application Programming Interface\n以及定义好的 \"程序编程接口\" -简称 API\n\n-- or API for short.\n以及定义好的 \"程序编程接口\" -简称 API\n\nYou can think of an API as the way that\nAPI 帮助不同程序员合作 \\N 不用知道具体细节，只要知道怎么使用就行了\n\ncollaborating programmers interact across various parts of the code.\nAPI 帮助不同程序员合作 \\N 不用知道具体细节，只要知道怎么使用就行了\n\nFor example, in the IgnitionControl object,\n例如\"点火控制\"对象中，可能有\"设置发动机转数\"函数\n\nthere might be functions to set the RPM of the engine,\n例如\"点火控制\"对象中，可能有\"设置发动机转数\"函数\n\ncheck the spark plug voltage,\n\"检查火花塞电压\"函数\n\nas well as fire the individual spark plugs.\n\"点燃单个火花塞\"函数\n\nBeing able to set the motor's RPM is really useful,\n\"设置发动机转速\"非常有用\n\nthe cruise control team is going to need to call that function.\n\"定速巡航\"团队要用到这个函数\n\nBut, they don't know much about how the ignition system works.\n但他们对点火系统不怎么了解\n\nIt's not a good idea to let them call functions that fire the individual spark plugs.\n让他们调用\"点燃单个火花塞\"函数，不是好主意\n\nOr the engine might explode!\n引擎可能会炸！\n\nMaybe.\n可能啦\n\nThe API allows the right people access to the right functions and data.\nAPI 控制哪些函数和数据让外部访问 \\N 哪些仅供内部\n\nObject Oriented Programming languages do this\n\"面向对象\"的编程语言 \\N 可以指定函数是 public 或 private，来设置权限\n\nby letting you specify whether functions are public or private.\n\"面向对象\"的编程语言 \\N 可以指定函数是 public 或 private，来设置权限\n\nIf a function is marked as \"private\",\n如果函数标记成 private\n\nit means only functions inside that object can call it.\n意味着 只有同一个对象内的其他函数能调用它\n\nSo, in this example, only other functions inside of IgnitionControl,\n在这个例子里，只有内部函数比如 setRPM\n\nlike the setRPM function,\n在这个例子里，只有内部函数比如 setRPM\n\ncan fire the sparkplugs.\n才能调用 fireSparkplug 函数\n\nOn the other hand, because the setRPM function is marked as public,\n而 setRPM 函数是 public  \\N 所以其它对象可以调用它，比如 定速巡航\n\nother objects can call it, like cruise control.\n而 setRPM 函数是 public  \\N 所以其它对象可以调用它，比如 定速巡航\n\nThis ability to hide complexity, and selectively reveal it,\n\"面向对象编程\"的核心是 \\N 隐藏复杂度，选择性的公布功能\n\nis the essence of Object Oriented Programming,\n\"面向对象\"的核心是 \\N 隐藏复杂度，选择性的公布功能\n\nand it's a powerful and popular way to tackle building large and complex programs.\n因为做大型项目很有效，所以广受欢迎\n\nPretty much every piece of software on your computer, or game running on your console,\n计算机上几乎所有软件，游戏机里几乎所有游戏\n\nwas built using an Object Oriented Programming Language,\n都是 \"面向对象\" 编程语言写的\n\nlike C++, C# or Objective-C.\n比如 C++, C#, Objective-C 等\n\nOther popular \"OO\" languages you may have heard of are Python and Java.\n其他流行 OO 语言，你可能听过 Python 和 Java\n\nIt's important to remember that code, before being compiled, is just text.\n有一点很重要：代码在编译前就只是文字而已\n\nAs I mentioned earlier,\n前面提过，你可以用记事本或任何文字处理器\n\nyou could write code in Notepad or any old word processor.\n前面提过，你可以用记事本或任何文字处理器\n\nSome people do.\n有人确实这样做\n\nBut generally, today's software developers use special-purpose applications for writing programs,\n但一般来说，现代软件开发者  会用专门的工具来写代码\n\nones that integrate many useful tools for writing, organizing, compiling and testing code.\n工具里集成了很多有用功能\\N 帮助写代码，整理，编译和测代码\n\nBecause they put everything you need in one place,\n因为集成了所有东西\n\nthey're called Integrated Development Environments ,\n因此叫 集成开发环境，简称 IDE\n\nor IDEs for short.\n因此叫 集成开发环境，简称 IDE\n\nAll IDEs provide a text editor for writing code,\n所有 IDE 都有写代码的界面\n\noften with useful features like automatic color-coding to improve readability.\n还带一些有用功能，比如代码高亮，来提高可读性\n\nMany even check for syntax errors as you type, like spell check for code.\n许多 IDE 提供实时检查，比如拼写\n\nBig programs contain lots of individual source files,\n大型项目有很多源代码文件\n\nso IDEs allow programmers to organize and efficiently navigate everything.\nIDE 帮助开发者整理和看代码\n\nAlso built right into the IDE is the ability to compile and run code.\n很多 IDE 还可以直接编译和运行代码\n\nAnd if your program crashes,\n如果程序崩了，因为你还没写完呢\n\nbecause it's still a work in progress,\n如果程序崩了，因为你还没写完呢\n\nthe IDE can take you back to the line of code where it happened,\nIDE 可以定位到出错代码\n\nand often provide additional information to help you track down and fix the bug,\n还会提供信息 帮你解决问题\n\nwhich is a process called debugging.\n这叫 调试（debug）\n\nThis is important\n调试很重要\n\nbecause most programmers spend 70 to 80% of their time testing and debugging,\n大多数程序员会花 70％~80％ 时间调试，而不是在写代码\n\nnot writing new code.\n大多数程序员会花 70％~80％ 时间调试，而不是在写代码\n\nGood tools, contained in IDEs,\n好工具能极大帮助程序员防止和解决错误\n\ncan go a long way when it comes to helping programmers prevent and find errors.\n好工具能极大帮助程序员防止和解决错误\n\nMany computer programmers can be pretty loyal to their IDEs though\n很多开发者只用一款 IDE\n\nBut let's be honest.\n但承认吧，VIM 才是最棒的编辑器\n\nVIM is where it's at.\n但承认吧，VIM 才是最棒的编辑器\n\nProviding you know how to quit.\n如果你知道怎么退出的话\n\nIn addition to coding and debugging,\n除了写代码和调试\n\nanother important part of a programmer's job is documenting their code.\n程序员工作的另一个重要部分是  给代码写文档\n\nThis can be done in standalone files called \"readme\",\n文档一般放在一个叫 README 的文件里\n\nwhich tell other programmers to read that help file before diving in.\n告诉其他程序员，看代码前先看这个文件\n\nIt can also happen right in the code itself with comment\n文档也可以直接写成\"注释\"，放在源代码里\n\nThese are specially-marked statements that the program knows\n注释是标记过的一段文字\n\nto ignore when the code is compiled.\n编译代码时  注释会被忽略\n\nThey exist only to help programmers figure out what's what in the source code.\n注释存在的唯一作用 \\N 就是帮助开发者理解代码\n\nGood documentation helps programmers when they revisit code they haven't seen for awhile,\n好文档能帮助开发者 \\N 几个月后理解自己的代码，对其他人也很重要\n\nbut it's also crucial for programmers who are totally new to it.\n好文档能帮助开发者 \\N 几个月后理解自己的代码，对其他人也很重要\n\nI just want to take a second here and reiterate that it's THE WORST\n我想花一秒 再强调一下注释很重要\n\nwhen someone parachutes a load of uncommented and undocumented code into your lap,\n最糟糕的就是拿到一堆代码，没有任何注释和文档\n\nand you literally have to go line by line to understand what the code is doing.\n结果得逐行读代码，理解到底干嘛的\n\nSeriously.\n我是认真的\n\nDon't be that person.\n别做那种人\n\nDocumentation also promotes code reuse.\n文档还可以提高复用性\n\nSo, instead of having programmers constantly write the same things over and over,\n与其让程序员一遍遍写同样的东西\n\nthey can track down someone else's code that does what they need.\n可以直接用别人写好的来解决问题\n\nThen, thanks to documentation,\n读文档看怎么用就行，不用读代码\n\nthey can put it to work in their program, without ever having to read through the code.\n读文档看怎么用就行，不用读代码\n\n\"Read the docs\" as they say.\n\"读文档啊\"\n\nIn addition to IDEs,\n除了 IDE，还有一个重要软件帮助团队协作\n\nanother important piece of software that\n除了 IDE，还有一个重要软件帮助团队协作\n\nhelps big teams work collaboratively on big coding projects is called\n除了 IDE，还有一个重要软件帮助团队协作\n\nSource Control,\n源代码管理\n\nalso known as version control or revision control.\n也叫\"版本控制\"\n\nMost often, at a big software company like Apple or Microsoft,\n苹果或微软这样的大型软件公司\n\ncode for projects is stored on centralized servers,\n会把代码放到一个中心服务器上\n\ncalled a code repository .\n叫\"代码仓库\"\n\nWhen a programmer wants to work on a piece of code,\n程序员想改一段代码时\n\nthey can check it out,\n可以 check out\n\nsort of like checking out a book out from a library.\n有点像从图书馆借书\n\nOften, this can be done right in an IDE.\n一般这种操作，可以直接在 IDE 内完成\n\nThen, they can edit this code all they want on their personal computer,\n然后开发者在自己的电脑上编辑代码\n\nadding new features and testing if they work.\n加新功能，测试\n\nWhen the programmer is confident their changes are working and there are no loose ends,\n如果代码没问题了，所有测试通过了\n\nthey can check the code back into the repository,\n可以把代码放回去\n\nknown as committing code, for everyone else to use.\n这叫  提交 (commit)\n\nWhile a piece of code is checked out,\n当代码被 check out，而且可能被改过了\n\nand presumably getting updated or modified,\n当代码被 check out，而且可能被改过了\n\nother programmers leave it alone.\n其他开发者不会动这段代码\n\nThis prevents weird conflicts and duplicated work.\n防止代码冲突和重复劳动\n\nIn this way, hundreds of programmers can be simultaneously checking in and out pieces of code,\n这样多名程序员可以同时写代码，建立庞大的系统\n\niteratively building up huge systems.\n这样多名程序员可以同时写代码，建立庞大的系统\n\nCritically, you don't want someone committing buggy code,\n重要的是，你不希望提交的代码里有问题 \\N 因为其他人可能用到了这些代码\n\nbecause other people and teams may rely on it.\n重要的是，你不希望提交的代码里有问题 \\N 因为其他人可能用到了这些代码\n\nTheir code could crash, creating confusion and lost time.\n导致他们的代码崩溃，造成困惑而且浪费时间\n\nThe master version of the code, stored on the server,\n代码的主版本 (master)\n\nshould always compile without errors and run with minimal bugs.\n应该总是编译正常，尽可能少 bug\n\nBut sometimes bugs creep in.\n但有时 bug 还是会出现\n\nFortunately, source control software keeps track of all changes,\n幸运的是，源代码管理可以跟踪所有变化\n\nand if a bug is found,\n如果发现 bug\n\nthe whole code, or just a piece,\n全部或部分代码，可以\"回滚\"到之前的稳定版\n\ncan be rolled back to an earlier, stable version.\n全部或部分代码，可以\"回滚\"到之前的稳定版\n\nIt also keeps track of who made each change,\n\"源代码管理\" 也记录了谁改了什么代码\n\nso coworkers can send nasty,\n所以同事可以给你发 讨厌的\n\nI mean, helpful\n我是说\"有帮助的\" 邮件给写代码的人\n\nand encouraging emails to the offending person.\n我是说\"有帮助的\" 邮件给写代码的人\n\nDebugging goes hand in hand with writing code,\n写代码和测代码密不可分\n\nand it's most often done by an individual or small team.\n测试一般由个人或小团队完成\n\nThe big picture version of debugging is Quality Assurance testing, or QA.\n测试可以统称 \"质量保证测试\"，简称 QA\n\nThis is where a team rigorously tests out a piece of software,\n严格测试软件的方方面面\n\nattempting to create unforeseen conditions that might trip it up.\n模拟各种可能情况，看软件会不会出错\n\nBasically, they elicit bugs.\n基本上就是找 bug\n\nGetting all the wrinkles out is a huge effort,\n解决大大小小的错误需要很多工作\n\nbut vital in making sure the software works\n但对确保软件质量至关重要\n\nas intended for as many users in as many situations as imaginable before it ships.\n让软件在各种情况下按预期运行\n\nYou've probably heard of beta software.\n你可能听过 \"beta 版\" 软件\n\nThis is a version of software that's mostly complete,\n意思是软件接近完成\n\nbut not 100% fully tested.\n但不是 100％ 完全测试过\n\nCompanies will sometimes release beta versions to the public to help them identify issues,\n公司有时会向公众发布 beta 版，以帮助发现问题\n\nit's essentially like getting a free QA team.\n用户就像免费的 QA 团队\n\nWhat you don't hear about as much\n你听过比较少的是 \\N beta 版之前的版本：alpha 版本\n\nis the version that comes before the beta: the alpha version.\n你听过比较少的是 \\N beta 版之前的版本：alpha 版本\n\nThis is usually so rough and buggy, it's only tested internally.\nalpha 版一般很粗糙，错误很多，\\N 经常只在公司内部测试\n\nSo, that's the tip of the iceberg in terms of the tools, tricks and techniques\n以上只是软件工程师用的工具和技巧的冰山一角\n\nthat allow software engineers to construct the huge pieces of software that we know and love today,\n它们帮助软件工程师制作令人喜爱的软件\n\nlike YouTube, Grand Theft Auto 5, and Powerpoint.\n如 YouTube，GTA5 和 PPT 等等\n\nAs you might expect,\n如你所料\n\nall those millions of lines of code needs some serious processing power to run at useful speeds,\n这些代码要强大的处理能力 才能高速速度运行\n\nso next episode we'll be talking about how computers got so incredibly fast.\n所以下集讨论，计算机怎么发展到如今这么快\n\nSee you then.\n到时见\n\nThis episode is brought to you by Curiosity Stream.\n本集由 Curiosity Stream 赞助播出\n\nHi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N欢迎收看计算机科学速成课！\n\nOver the past six episodes, we delved into software,\n过去 6 集我们聊了软件 \\N 从早期编程方式到现代软件工程\n\nfrom early programming efforts to modern software engineering practices.\n过去 6 集我们聊了软件 \\N 从早期编程方式到现代软件工程\n\nWithin about 50 years, software grew in complexity from machine code punched by hand onto paper tape\n在大概50年里  软件从纸带打孔  \\N 变成面向对象编程语言  在集成开发环境中写程序\n\nto object oriented programming languages, compiled in integrated development environments.\n在大概50年里  软件从纸带打孔  \\N 变成面向对象编程语言  在集成开发环境中写程序\n\nBut this growth in sophistication would not have been possible without improvements in hardware.\n但如果没有硬件的大幅度进步 \\N 软件是不可能做到这些的\n\nTo appreciate computing hardware’s explosive growth in power and sophistication,\n为了体会硬件性能的爆炸性增长 \\N 我们要回到电子计算机的诞生年代\n\nwe need to go back to the birth of electronic computing.\n为了体会硬件性能的爆炸性增长 \\N 我们要回到电子计算机的诞生年代\n\nFrom roughly the 1940’s through the mid-1960s, every computer was built from individual parts,\n大约 1940年代~1960年代中期这段时间里 \\N 计算机都由独立部件组成\n\ncalled discrete components, which were all wired together.\n叫\"分立元件\" \\N 然后不同组件再用线连在一起\n\nFor example, the ENIAC, consisted of more than 17,000 vacuum tubes, 70,000 resistors,\n举例, ENIAC 有1万7千多个真空管, 7万个电阻\n\n10,000 capacitors, and 7,000 diodes, all of which required 5 million hand-soldered connections.\n1万个电容器, 7千个二极管, 5百万个手工焊点\n\nAdding more components to increase performance meant more connections, more wires\n如果想提升性能，就要加更多部件 \\N 这导致更多电线，更复杂\n\nand just more complexity, what was dubbed the Tyranny of Numbers.\n这个问题叫 \"数字暴政''\n\nBy the mid 1950s, transistors were becoming commercially available\n1950 年代中期，晶体管开始商业化（市场上买得到） \\N 开始用在计算机里\n\nand being incorporated into computers.\n1950 年代中期，晶体管开始商业化（市场上买得到） \\N 开始用在计算机里\n\nThese were much smaller, faster and more reliable than vacuum tubes\n晶体管比电子管 更小更快更可靠\n\nbut each transistor was still one discrete component.\n但晶体管依然是分立元件\n\nIn 1959, IBM upgraded their vacuum-tube-based \"709\" computers to transistors by replacing\n1959年，IBM 把 709 计算机从原本的电子管 \\N 全部换成晶体管\n\nby replacing all the discrete vacuum tubes with discrete transistors.\n1959年，IBM 把 709 计算机从原本的电子管 \\N 全部换成晶体管\n\nThe new machine, the IBM 7090, was six times faster and half the cost.\n诞生的新机器 IBM 7090  \\N 速度快 6 倍，价格只有一半\n\nThese transistorized computers marked the second generation of electronic computing.\n晶体管标志着\"计算 2.0 时代\"的到来\n\nHowever, although faster and smaller,\n虽然更快更小 \\N 但晶体管的出现 还是没有解决\"数字暴政\"的问题\n\ndiscrete transistors didn’t solve the Tyranny of Numbers.\n虽然更快更小 \\N 但晶体管的出现 还是没有解决\"数字暴政\"的问题\n\nIt was getting unwieldy to design,\n有几十万个独立元件的计算机不但难设计 \\N 而且难生产\n\nlet alone physically manufacture computers with hundreds of thousands of individual components.\n有几十万个独立元件的计算机不但难设计 \\N 而且难生产\n\nBy the the 1960s, this was reaching a breaking point.\n1960 年代，这个问题的严重性达到顶点 \\N 电脑内部常常一大堆电线缠绕在一起\n\nThe insides of computers were often just huge tangles of wires.\n1960 年代，这个问题的严重性达到顶点 \\N 电脑内部常常一大堆电线缠绕在一起\n\nJust look at what the inside of a PDP-8 from 1965 looked like!\n看看这个 1965 年 PDP-8 计算机的内部\n\nThe answer was to bump up a new level of abstraction, and package up underlying complexity!\n解决办法是引入一层新抽象，封装复杂性\n\nThe breakthrough came in 1958, when Jack Kilby, working at Texas Instruments,\n突破性进展在 1958 年 \\N 当时 Jack Killby 在德州仪器工作\n\ndemonstrated such an electronic part, \"wherein all the components of the electronic circuit are completely integrated.\n演示了一个电子部件：\\N \"电路的所有组件都集成在一起\"\n\nPut simply: instead of building computer parts out of many discrete components\n简单说就是：\\N 与其把多个独立部件用电线连起来，拼装出计算机\n\nand wiring them all together,\n简单说就是：\\N 与其把多个独立部件用电线连起来，拼装出计算机\n\nyou put many components together, inside of a new, single component.\n我们把多个组件包在一起，变成一个新的独立组件\n\nThese are called Integrated Circuits, or ICs.\n这就是 集成电路（IC）\n\nA few months later in 1959, Fairchild Semiconductor, lead by Robert Noyce, made ICs practical.\n几个月后，在1959年 Robert Noyce 的仙童半导体 \\N 让集成电路变为现实\n\nKilby built his ICs out of germanium, a rare and unstable material.\nKilby 用锗来做集成电路，锗很稀少而且不稳定\n\nBut, Fairchild used the abundant silicon, which makes up about a quarter of the earth's crust!\n仙童半导体公司用硅 \\N 硅的蕴藏量丰富，占地壳四分之一\n\nIt’s also more stable, therefore more reliable.\n也更稳定可靠\n\nFor this reason, Noyce is widely regarded as the father of modern ICs,\n所以 Noyce 被公认为现代集成电路之父\n\nushering in the electronics era... and also Silicon Valley, where Fairchild was based\n开创了电子时代，创造了硅谷（仙童公司所在地）\n\nand where many other semiconductor companies would soon pop up.\n之后有很多半导体企业都出现在硅谷\n\nIn the early days, an IC might only contain a simple circuit with just a few transistors,\n起初，一个 IC 只有几个晶体管 \\N 例如这块早期样品，由西屋公司制造\n\nlike this early Westinghouse example.\n起初，一个 IC 只有几个晶体管 \\N 例如这块早期样品，由西屋公司制造\n\nBut even this allowed simple circuits, like the logic gates from Episode 3,\n即使只有几个晶体管 \\N 也可以把简单电路，第 3 集的逻辑门，能封装成单独组件\n\nto be packaged up into a single component.\n即使只有几个晶体管 \\N 也可以把简单电路，第 3 集的逻辑门，能封装成单独组件\n\nICs are sort of like lego for computer engineers\nIC 就像电脑工程师的乐高积木 \\N 可以组合出无数种设计\n\n\"building blocks\" that can be arranged into an infinite array of possible designs.\nIC 就像电脑工程师的乐高积木 \\N 可以组合出无数种设计\n\nHowever, they still have to be wired together at some point\n但最终还是需要连起来， \\N 创造更大更复杂的电路，比如整个计算机\n\nto create even bigger and more complex circuits, like a whole computer.\n但最终还是需要连起来， \\N 创造更大更复杂的电路，比如整个计算机\n\nFor this, engineers had another innovation: printed circuit boards, or PCB\n所以工程师们再度创新：印刷电路板，简称 PCB\n\nInstead of soldering and bundling up bazillions of wires, PCBs, which could be mass manufactured,\nPCB 可以大规模生产，无需焊接或用一大堆线. \\N 它通过蚀刻金属线的方式，把零件连接到一起\n\nhave all the metal wires etched right into them to connect components together.\nPCB 可以大规模生产，无需焊接或用一大堆线. \\N 它通过蚀刻金属线的方式，把零件连接到一起\n\nBy using PCBs and ICs together, one could achieve exactly the same functional circuit\n把 PCB 和 IC 结合使用 \\N 可以大幅减少独立组件和电线，但做到相同的功能\n\nas that made from discrete components,\n把 PCB 和 IC 结合使用 \\N 可以大幅减少独立组件和电线，但做到相同的功能\n\nbut with far fewer individual components and tangled wires.\n把 PCB 和 IC 结合使用 \\N 可以大幅减少独立组件和电线，但做到相同的功能\n\nPlus, it’s smaller, cheaper and more reliable.\n而且更小，更便宜，更可靠.  三赢！\n\nTriple win!\n而且更小，更便宜，更可靠.  三赢！\n\nMany early ICs were manufactured using teeny tiny discrete components\n许多早期 IC 都是把很小的分立元件 \\N 封装成一个独立单元，例如这块 1964 年的IBM样品\n\npackaged up as a single unit, like this IBM example from 1964.\n许多早期 IC 都是把很小的分立元件 \\N 封装成一个独立单元，例如这块 1964 年的IBM样品\n\nHowever, even when using really really itty-bitty components,\n不过，即使组件很小 \\N 塞5个以上的晶体管还是很困难\n\nit was hard to get much more than around five transistors onto a single IC.\n不过，即使组件很小 \\N 塞5个以上的晶体管还是很困难\n\nTo achieve more complex designs, a radically different fabrication process was needed that\n为了实现更复杂的设计，需要全新的制作工艺 \\N \"光刻\"登场！\n\nchanged everything: Photolithography!\n为了实现更复杂的设计，需要全新的制作工艺 \\N \"光刻\"登场！\n\nIn short, it’s a way to use light to transfer complex patterns to a material, like a semiconductor\n简单说就是 \\N用光把复杂图案印到材料上，比如半导体\n\nIt only has a few basic operations, but these can be used to create incredibly complex circuits.\n它只有几个基础操作，但可以制作出复杂电路\n\nLet’s walk through a simple, although extensive example, to make one of these!\n下面用一个简单例子，来做一片这个！\n\nWe start with a slice of silicon, which, like a thin cookie, is called a wafer.\n我们从一片硅开始，叫\"晶圆\" \\N 长得像薄饼干一样\n\nDelicious!\n美味！\n\nSilicon, as we discussed briefly in episode 2, is special because it’s a semiconductor,\n我们在第 2 集讨论过 \\N 硅很特别，它是半导体\n\nthat is, a material that can sometimes conduct electricity and other times does not.\n它有时导电，有时不导电 \\N 我们可以控制导电时机\n\nWe can control where and when this happens,\n它有时导电，有时不导电 \\N 我们可以控制导电时机\n\nmaking Silicon the perfect raw material for making transistors.\n所以硅是做晶体管的绝佳材料\n\nWe can also use a wafer as a base to lay down complex metal circuits, so everything is integrated,\n我们可以用晶圆做基础 \\N 把复杂金属电路放上面，集成所有东西\n\nperfect for... integrated circuits!\n非常适合做.. 集成电路!\n\nThe next step is to add a thin oxide layer on top of the silicon,\n下一步是在硅片顶部  \\N 加一层薄薄的氧化层, 作为保护层\n\nwhich acts as a protective coating.\n下一步是在硅片顶部  \\N 加一层薄薄的氧化层, 作为保护层\n\nThen, we apply a special chemical called a photoresist.\n然后加一层特殊化学品, 叫 \"光刻胶\" \\N 光刻胶被光照射后 会变得可溶\n\nWhen exposed to light, the chemical changes, and becomes soluble,\n然后加一层特殊化学品, 叫 \"光刻胶\" \\N 光刻胶被光照射后 会变得可溶\n\nso it can be washed away with a different special chemical.\n可以用一种特殊化学药剂洗掉\n\nPhotoresists aren’t very useful by themselves,\n单单光刻胶本身，并不是很有用 \\N 但和\"光掩膜\"配合使用会很强大\n\nbut are super powerful when used in conjunction with a photomask.\n单单光刻胶本身，并不是很有用 \\N 但和\"光掩膜\"配合使用会很强大\n\nThis is just like a piece of photographic film, but instead of a photo of\n光掩膜就像胶片一样，只不过不是 \\N 吃墨西哥卷饼的可爱仓鼠，而是要转移到晶圆上的图案\n\na hamster eating a tiny burrito, it contains a pattern to be transferred onto the wafer.\n光掩膜就像胶片一样，只不过不是 \\N 吃墨西哥卷饼的可爱仓鼠，而是要转移到晶圆上的图案\n\nWe do this by putting a photomask over the wafer, and turning on a powerful light.\n把光掩膜盖到晶圆上，用强光照射 \\N 挡住光的地方，光刻胶不会变化\n\nWhere the mask blocks the light, the photoresist is unchanged.\n把光掩膜盖到晶圆上，用强光照射 \\N 挡住光的地方，光刻胶不会变化\n\nBut where the light does hit the photoresist it changes chemically ，\n光照到的地方，光刻胶会发生化学变化 \\N 洗掉它之后，暴露出氧化层\n\nwhich lets us wash away only the photoresist that was exposed to light, selectively revealing areas of our oxide layer.\n光照到的地方，光刻胶会发生化学变化 \\N 洗掉它之后，暴露出氧化层\n\nNow, by using another special chemical, often an acid, we can remove any exposed oxide,\n用另一种化学物质 - 通常是一种酸 \\N 可以洗掉\"氧化层\"露出的部分, 蚀刻到硅层\n\nand etch a little hole the entire way down to the raw silicon.\n用另一种化学物质 - 通常是一种酸 \\N 可以洗掉\"氧化层\"露出的部分, 蚀刻到硅层\n\nNote that the oxide layer under the photoresist is protected.\n注意，氧化层被光刻胶保护住了.\n\nTo clean up, we use yet another special chemical that washes away any remaining photoresist.\n为了清理光刻胶，我们用另一种化学药品洗掉它\n\nYep, there are a lot of special chemicals in photolithography,\n是的，光刻法用很多化学品，每种都有特定用途\n\neach with a very specific function!\n是的，光刻法用很多化学品，每种都有特定用途\n\nSo now we can see the silicon again,\n现在硅又露出来了 \\N 我们想修改硅露出来的区域  让它导电性更好\n\nwe want to modify only the exposed areas to better conduct electricity.\n现在硅又露出来了 \\N 我们想修改硅露出来的区域  让它导电性更好\n\nTo do that, we need to change it chemically through a process called: doping.\n所以用一种化学过程来改变它，叫\"掺杂\"\n\nI’m not even going to make a joke. Let’s move on.\n不是开玩笑！我们继续\n\nMost often this is done with a high temperature gas, something like Phosphorus,\n\"掺杂\" 通常用高温气体来做，比如磷 \\N 渗透进暴露出的硅，改变电学性质\n\nwhich penetrates into the exposed area of silicon.\n\"掺杂\" 通常用高温气体来做，比如磷 \\N 渗透进暴露出的硅，改变电学性质\n\nThis alters its electrical properties.\n\"掺杂\" 通常用高温气体来做，比如磷 \\N 渗透进暴露出的硅，改变电学性质\n\nWe’re not going to wade into the physics and chemistry of semiconductors,\n半导体的具体物理和化学性质我们不会深究,\n\nbut if you’re interested, there’s a link in the description to an excellent video\n如果你感兴趣，描述里有个视频链接 \\N 视频制作者是 Derek Muller 他的频道叫 Veritasium\n\nby our friend Derek Muller from Veritasium.\n如果你感兴趣，描述里有个视频链接 \\N 视频制作者是 Derek Muller 他的频道叫 Veritasium\n\nBut, we still need a few more rounds of photolithography to build a transistor.\n但我们还需要几轮光刻法 来做晶体管\n\nThe process essentially starts again, first by building up a fresh oxide layer ...\n过程基本一样，先盖氧化层，再盖光刻胶\n\nwhich we coat in photoresist.\n过程基本一样，先盖氧化层，再盖光刻胶\n\nNow, we use a photomask with a new and different pattern,\n然后用新的光掩膜，这次图案不同 \\N 在掺杂区域上方开一个缺口\n\nallowing us to open a small window above the doped area.\n然后用新的光掩膜，这次图案不同 \\N 在掺杂区域上方开一个缺口\n\nOnce again, we wash away remaining photoresist.\n洗掉光刻胶\n\nNow we dope, and avoid telling a hilarious joke, again, but with a different gas that\n然后用另一种气体掺杂 \\N 把一部分硅转成另一种形式\n\nconverts part of the silicon into yet a different form.\n然后用另一种气体掺杂 \\N 把一部分硅转成另一种形式\n\nTiming is super important in photolithography in order to control things like doping diffusionand etch depth.\n为了控制深度，时机很重要 \\N 我们不想超过之前的区域\n\nIn this case, we only want to dope a little region nested inside the other.\n为了控制深度，时机很重要 \\N 我们不想超过之前的区域\n\nNow we have all the pieces we need to create our transistor!\n现在 所有需要的组件都有了\n\nThe final step is to make channels in the oxide layer\n最后一步，在氧化层上做通道 \\N 这样可以用细小金属导线，连接不同晶体管\n\nso that we can run little metal wires to different parts of our transistor.\n最后一步，在氧化层上做通道 \\N 这样可以用细小金属导线，连接不同晶体管\n\nOnce more, we apply a photoresist, and use a new photomask to etch little channels.\n再次用光刻胶和光掩膜  蚀刻出小通道\n\nNow, we use a new process, called metalization,\n现在用新的处理方法 叫\"金属化\" \\N 放一层薄薄的金属，比如铝或铜\n\nthat allows us to deposit a thin layer of metal, like aluminium or copper.\n现在用新的处理方法 叫\"金属化\" \\N 放一层薄薄的金属，比如铝或铜\n\nBut we don’t want to cover everything in metal.\n但我们不想用金属盖住所有东西 \\N 我们想蚀刻出具体的电路\n\nWe want to etch a very specific circuit design.\n但我们不想用金属盖住所有东西 \\N 我们想蚀刻出具体的电路\n\nSo, very similar to before, we apply a photoresist, use a photomask, dissolve the exposed resist,\n所以又是类似的步骤 \\N 用光刻胶+光掩膜，然后溶掉暴露的光刻胶，暴露的金属\n\nand use a chemical to remove any exposed metal.\n所以又是类似的步骤 \\N 用光刻胶+光掩膜，然后溶掉暴露的光刻胶，暴露的金属\n\nWhew!\n咻~\n\nOur transistor is finally complete!\n晶体管终于做好了！ \\N 它有三根线，连接着硅的三个不同区域\n\nIt has three little wires that connect to three different parts of the silicon\n晶体管终于做好了！ \\N 它有三根线，连接着硅的三个不同区域\n\neach doped a particular way to create, in this example, what’s called a bipolar junction transistor.\n每个区域的掺杂方式不同，这叫双极型晶体管\n\nHere’s the actual patent from 1962, an invention that changed our world forever!\n这个 1962 年的真实专利，永远改变了世界\n\nUsing similar steps, photolithography can create other useful electronic elements, like\n用类似步骤，光刻可以制作其他电子元件 \\N 比如电阻和电容，都在一片硅上\n\nresistors and capacitors, all on a single piece of silicon\n用类似步骤，光刻可以制作其他电子元件 \\N 比如电阻和电容，都在一片硅上\n\nplus all the wires needed to hook them up into circuits\n而且互相连接的电路也做好了\n\nGoodbye discrete components!\n再见了，分立元件！\n\nIn our example, we made one transistor, but in the real world,\n之前的例子 只做了一个晶体管，但现实中 \\N 光刻法一次会做上百万个细节\n\nphotomasks lay down millions of little details all at once.\n之前的例子 只做了一个晶体管，但现实中 \\N 光刻法一次会做上百万个细节\n\nHere is what an IC might look like from above, with wires crisscrossing above and below each other,\n芯片放大是这样的，导线上下交错，连接各个元件\n\ninterconnecting all the individual elements together into complex circuits.\n芯片放大是这样的，导线上下交错，连接各个元件\n\nAlthough we could create a photomask for an entire wafer,\n尽管可以把光掩膜投影到一整片晶圆上 \\N 但光可以投射成任意大小\n\nwe can take advantage of the fact that light can be focused and projected to any size we want.\n尽管可以把光掩膜投影到一整片晶圆上 \\N 但光可以投射成任意大小\n\nIn the same way that a film can be projected to fill an entire movie screen,\n就像投影仪可以投满荧幕一样\n\nwe can focus a photomask onto a very small patch of silicon, creating incredibly fine details.\n我们可以把光掩膜 \\N 聚焦到极小的区域，制作出非常精细的细节\n\nA single silicon wafer is generally used to create dozens of ICs.\n一片晶圆可以做很多 IC \\N 整块都做完后，可以切割然后包进微型芯片\n\nThen, once you’ve got a whole wafer full, you cut them up and package them into microchips,\n一片晶圆可以做很多 IC \\N 整块都做完后，可以切割然后包进微型芯片\n\nthose little black rectangles you see in electronics all the time.\n微型芯片就是在电子设备中那些小长方体\n\nJust remember: at the heart of each of those chips is one of these small pieces of silicon.\n记住，芯片的核心都是一小片 IC\n\nAs photolithography techniques improved, the size of transistors shrunk, allowing for greater densities.\n随着光刻技术发展，晶体管变小  密度变高\n\nAt the start of the 1960s, an IC rarely contained more than 5 transistors,\n1960 年代初，IC 很少超过 5 个晶体管，因为塞不下\n\nthey just couldn’t possibly fit.\n1960 年代初，IC 很少超过 5 个晶体管，因为塞不下\n\nBut, by the mid 1960s, we were starting to see ICs with over 100 transistors on the market.\n但 1960 年代中期 \\N 市场上开始出现超过 100 个晶体管的 IC\n\nIn 1965, Gordon Moore could see the trend: that approximately every two years,\n1965年，戈登·摩尔看到了趋势：每两年左右，\n\nthanks to advances in materials and manufacturing, you could fit twice the number of transistors\n得益于材料和制造技术的发展 \\N 同样大小的空间，能塞进两倍数量的晶体管！\n\ninto the same amount of space.\n得益于材料和制造技术的发展 \\N 同样大小的空间，能塞进两倍数量的晶体管！\n\nThis is called Moore’s Law.\n这叫 摩尔定律\n\nThe term is a bit of a misnomer though.\n然而这个名字不太对 \\N 因为它不是定律，只是一种趋势\n\nIt’s not really a law at all, more of a trend.\n然而这个名字不太对 \\N 因为它不是定律，只是一种趋势\n\nBut it’s a good one.\n但它是对的\n\nIC prices also fell dramatically, from an average of $50 in 1962 to around $2 in 1968.\n芯片的价格也急剧下降 \\N 1962年平均50美元，下降到1968年2美元左右\n\nToday, you can buy ICs for cents.\n如今 几美分就能买到 IC\n\nSmaller transistors and higher densities had other benefits too.\n晶体管更小密度更高 还有其他好处\n\nThe smaller the transistor, the less charge you have to move around, allowing it to switch\n晶体管越小，要移动的电荷量就越少 \\N 能更快切换状态  耗电更少\n\nstates faster and consume less power.\n晶体管越小，要移动的电荷量就越少 \\N 能更快切换状态  耗电更少\n\nPlus, more compact circuits meant less delay in signals resulting in faster clock speeds.\n电路更紧凑 还意味着信号延迟更低 \\N 导致时钟速度更快\n\nIn 1968, Robert Noyce and Gordon Moore teamed up and founded a new company,\n1968年，罗伯特·诺伊斯 和 戈登·摩尔  \\N 联手成立了一家新公司\n\ncombining the words Integrated and Electronics...\n结合 Intergrated(集成) 和 Electronics(电子) 两个词\n\nIntel. the largest chip maker today.\n取名 Intel， 如今最大的芯片制造商\n\nThe Intel 4004 CPU, from Episodes 7 and 8, was a major milestone.\nIntel 4004 CPU, 在第 7, 8 集介绍过 \\N 是个重要里程碑\n\nReleased in 1971, it was the first processor that shipped as an IC, what’s called a microprocessor,\n发布于1971年 \\N 是第一个用 IC 做的处理器，也叫微型处理器\n\nbecause it was so beautifully small!\n因为真的非常小！\n\nIt contained 2,300 transistors.\n它有2300个晶体管\n\nPeople marveled at the level of integration, an entire CPU in one chip,\n人们惊叹于它的整合水平 \\N 整个 CPU 在一个芯片里\n\nwhich just two decades earlier would have filled an entire room using discrete components.\n而仅仅 20 年前，用分立元件会占满整个屋子\n\nThis era of integrated circuits, especially microprocessors, ushered in the third generation of computing.\n集成电路的出现 \\N 尤其是用来做微处理器，开启了计算 3.0\n\nAnd the Intel 4004 was just the start.\n而 Intel 4004 只是个开始，CPU 晶体管数量爆发增长\n\nCPU transistor count exploded!\n而 Intel 4004 只是个开始，CPU 晶体管数量爆发增长\n\nBy 1980, CPUs contained 30 thousand transistors.\n1980年，3 万晶体管 \\N  1990年，100 万晶体管\n\nBy 1990, CPUs breached the 1 million transistor count.\n1980年，3 万晶体管 \\N  1990年，100 万晶体管\n\nBy 2000, 30 million transistors,\n2000年，3000 万个晶体管\n\nand by 2010, ONE. BILLION. TRANSISTORS. IN ONE. IC. OMG!\n2010年，10亿个晶体管！\\N 在一个芯片里！我的天啊！\n\nTo achieve this density, the finest resolution possible with photolithography has improved\n为了达到这种密度，光刻的分辨率 \\N 从大约一万纳米，大概是人类头发直径的 1/10\n\nfrom roughly 10 thousand nanometers, that’s about 1/10th the thickness of a human hair,\n为了达到这种密度，光刻的分辨率 \\N 从大约一万纳米，大概是人类头发直径的 1/10\n\nto around 14 nanometers today.\n发展到如今的 14 纳米 \\N 比血红细胞小 400 倍！\n\nThat’s over 400 times smaller than a red blood cell!\n发展到如今的 14 纳米 \\N 比血红细胞小 400 倍！\n\nAnd of course, CPU’s weren’t the only components to benefit.\n当然，CPU 不是唯一受益的元件\n\nMost electronics advanced essentially exponentially:\n大多数电子器件都在指数式发展：\\N 内存，显卡，固态硬盘，摄像头感光元件，等等\n\nRAM, graphics cards, solid state hard drives, camera sensors, you name it.\n大多数电子器件都在指数式发展：\\N 内存，显卡，固态硬盘，摄像头感光元件，等等\n\nToday’s processors, like the A10 CPU inside Of an iPhone 7, contains a mind melting 3.3 BILLION\n如今的处理器，比如 iPhone 7 的 A10 CPU \\N 有33亿个晶体管\n\ntransistors in an IC roughly 1cm by 1cm.\n面积仅有 1cm x 1cm，比一张邮票还小\n\nThat’s smaller than a postage stamp!\n面积仅有 1cm x 1cm，比一张邮票还小\n\nAnd modern engineers aren’t laying out these designs by hand, one transistor at a time\n现代工程师设计电路时，当然不是手工一个个设计晶体管 \\N 这不是人力能做到的\n\n- it’s not humanly possible.\n现代工程师设计电路时，当然不是手工一个个设计晶体管 \\N 这不是人力能做到的\n\nStarting in the 1970’s, very-large-scale integration, or VLSI software, has been used\n1970年代开始，超大规模集成(VLSI)软件 \\N 用来自动生成芯片设计\n\nto automatically generate chip designs instead.\n1970年代开始，超大规模集成(VLSI)软件 \\N 用来自动生成芯片设计\n\nUsing techniques like logic synthesis, where whole, high-level components can be laid down,like a memory cache\n用比如 \"逻辑综合\" 这种技术 \\N 可以放一整个高级组件，比如内存缓存\n\nthe software generates the circuit in the most efficient way possible.\n软件会自动生成电路，做到尽可能高效\n\nMany consider this to be the start of fourth generation computers.\n许多人认为这是计算 4.0 的开始\n\nUnfortunately, experts have been predicting the end of Moore’s Law for decades\n坏消息是，专家们几十年来 \\N 一直在预言摩尔定律的终结\n\nand we might finally be getting close to it.\n现在可能终于接近了\n\nThere are two significant issues holding us back from further miniaturization.\n进一步做小，会面临 2 个大问题\n\nFirst, we’re bumping into limits on how fine we can make features on a photomask and\n1. 用光掩膜把图案弄到晶圆上 \\N 因为光的波长，精度已达极限\n\nit’s resultant wafer due to the wavelengths of light used in photolithography.\n1. 用光掩膜把图案弄到晶圆上 \\N 因为光的波长，精度已达极限\n\nIn response, scientists have been developing light sources with smaller and smaller wavelengths\n所以科学家在研制波长更短的光源，投射更小的形状\n\nthat can project smaller and smaller features.\n所以科学家在研制波长更短的光源，投射更小的形状\n\nThe second issue is that when transistors get really really small, where electrodes\n2. 当晶体管非常小，电极之间可能只距离几个原子 \\N 电子会跳过间隙，这叫：量子隧道贯穿\n\nmight be separated by only a few dozen atoms, electrons can jump the gap, a phenomenon called\n2. 当晶体管非常小，电极之间可能只距离几个原子 \\N 电子会跳过间隙，这叫：量子隧穿效应\n\nquantum tunneling.\n2. 当晶体管非常小，电极之间可能只距离几个原子 \\N 电子会跳过间隙，这叫：量子隧穿效应\n\nIf transistors leak current, they don’t make very good switches.\n如果晶体管漏电，就不是好开关\n\nNonetheless, scientists and engineers are hard at work figuring out ways around these problems.\n科学家和工程师在努力找解决方法\n\nTransistors as small as 1 nanometer have been demonstrated in research labs.\n实验室中已造出小至1纳米的晶体管\n\nWhether this will ever be commercially feasible remains MASKED in mystery.\n能不能商业量产依然未知，未来也许能解决\n\nBut maybe we’ll be able to RESOLVE it in the future.\n能不能商业量产依然未知，未来也许能解决\n\nI’m DIEING to know. See you next week.\n我非常期待！下周见！\n\nThis episode is supported by Hover.\n本集由 Hover 赞助播出\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nComputers in the 1940s and early 50s ran one program at a time.\n1940,1950 年代的电脑，每次只能运行一个程序\n\nA programmer would write one at their desk, for example, on punch cards.\n程序员在打孔纸卡上写程序\n\nThen, they'd carry it to a room containing a room-sized computer,\n然后拿到一个计算机房间,  交给操作员\n\nand hand it to a dedicated computer operator.\n然后拿到一个计算机房间,  交给操作员\n\nThat person would then feed the program into the computer when it was next available.\n等计算机空下来了，操作员会把程序放入\n\nThe computer would run it, spit out some output, and halt.\n然后运行，输出结果，停机\n\nThis very manual process worked OK back when computers were slow,\n以前计算机慢，这种手动做法可以接受\n\nand running a program often took hours, days or even weeks.\n运行一个程序通常要几小时，几天甚至几周\n\nBut, as we discussed last episode,\n但上集说过，计算机越来越快，越来越快\n\ncomputers became faster... and faster... and faster\n但上集说过，计算机越来越快，越来越快\n\nexponentially so!\n指数级增长！\n\nPretty soon, having humans run around and inserting programs into readers\n很快，放程序的时间 比程序运行时间还长\n\nwas taking longer than running the actual programs themselves.\n很快，放程序的时间 比程序运行时间还长\n\nWe needed a way for computers to operate themselves,\n我们需要一种方式 让计算机自动运作\n\nand so, operating systems were born.\n于是\"操作系统\"诞生了\n\nOperating systems , or OS for short, are just programs.\n操作系统，简称 OS，其实也是程序\n\nBut, special privileges on the hardware let them run and manage other programs.\n但它有操作硬件的特殊权限  \\N 可以运行和管理其它程序\n\nThey're typically the first one to start when a computer is turned on,\n操作系统一般是开机第一个启动的程序\n\nand all subsequent programs are launched by the OS.\n其他所有程序 都由操作系统启动\n\nThey got their start in the 1950s,\n操作系统开始于 1950 年代 \\N 那时计算机开始变得更强大更流行\n\nas computers became more widespread and more powerful.\n操作系统开始于 1950 年代 \\N 那时计算机开始变得更强大更流行\n\nThe very first OS augmented the mundane, manual task of loading programs by hand.\n第一个操作系统 加强了程序加载方式\n\nInstead of being given one program at a time,\n之前只能一次给一个程序，现在可以一次多个\n\ncomputers could be given batches.\n之前只能一次给一个程序，现在可以一次多个\n\nWhen the computer was done with one,\n当计算机运行完一个程序，会自动运行下一个程序\n\nit would automatically and near-instantly start the next.\n当计算机运行完一个程序，会自动运行下一个程序\n\nThere was no downtime while someone scurried around an office to find the next program to run.\n这样就不会浪费时间，找下一个程序的纸卡\n\nThis was called batch processing .\n这叫 批处理\n\nWhile computers got faster, they also got cheaper.\n电脑变得更快更便宜，开始在出现在世界各地\n\nSo, they were popping up all over the world,\n电脑变得更快更便宜，开始在出现在世界各地\n\nespecially in universities and government offices.\n特别是大学和政府办公室\n\nSoon, people started sharing software.\n很快，人们开始分享软件，但有一个问题\n\nBut there was a problem\n很快，人们开始分享软件，但有一个问题\n\nIn the era of one-off computers, like the Harvard Mark 1 or ENIAC,\n在哈佛1号和 ENIAC 那个时代，计算都是一次性的\n\nprogrammers only had to write code for that one single machine.\n程序员只需要给那\"一台\"机器写代码\n\nThe processor, punch card readers, and printers were known and unchanging.\n处理器，读卡器，打印机都是已知的\n\nBut as computers became more widespread,\n但随着电脑越来越普遍，计算机配置并不总是相同的\n\ntheir configurations were not always identical,\n但随着电脑越来越普遍，计算机配置并不总是相同的\n\nlike computers might have the same CPU, but not the same printer.\n比如计算机可能有相同 CPU，但不同的打印机\n\nThis was a huge pain for programmers.\n这对程序员很痛苦\n\nNot only did they have to worry about writing their program,\n不仅要担心写程序，还要担心程序怎么和不同型号打印机交互\n\nbut also how to interface with each and every model of printer,\n不仅要担心写程序，还要担心程序怎么和不同型号打印机交互\n\nand all devices connected to a computer, what are called peripherals.\n以及计算机连着的其他设备，这些统称\"外部设备\"\n\nInterfacing with early peripherals was very low level,\n和早期的外部设备交互，是非常底层的\n\nrequiring programmers to know intimate hardware details about each device.\n程序员要了解设备的硬件细节\n\nOn top of that, programmers rarely had access to every model of a peripheral to test their code on.\n加重问题的是，程序员很少能拿到所有型号的设备来测代码\n\nSo, they had to write code as best they could, often just by reading manuals,\n所以一般是阅读手册来写代码，祈祷能正常运行\n\nand hope it worked when shared.\n所以一般是阅读手册来写代码，祈祷能正常运行\n\nThings weren't exactly plug-and-play\n现在是\"即插即用\"，以前是\"祈祷能用\"\n\nback then more plug-and-pray.\n现在是\"即插即用\"，以前是\"祈祷能用\"\n\nThis was clearly terrible,\n这很糟糕，所以为了程序员写软件更容易\n\nso to make it easier for programmers,\n这很糟糕，所以为了程序员写软件更容易\n\nOperating Systems stepped in as intermediaries between software programs and hardware peripherals.\n操作系统充当软件和硬件之间的媒介\n\nMore specifically, they provided a software abstraction, through APIs,\n更具体地说，操作系统提供 API 来抽象硬件，叫\"设备驱动程序\"\n\ncalled device drivers .\n更具体地说，操作系统提供 API 来抽象硬件，叫\"设备驱动程序\"\n\nThese allow programmers to talk to common input and output hardware,\n程序员可以用标准化机制  和输入输出硬件（I/O）交互\n\nor I/O for short, using standardized mechanisms.\n程序员可以用标准化机制  和输入输出硬件（I/O）交互\n\nFor example, programmers could call a function like \"print highscore\",\n比如，程序员只需调用 print(highscore)\n\nand the OS would do the heavy lifting to get it onto paper.\n操作系统会处理  输到纸上的具体细节\n\nBy the end of the 1950s, computers had gotten so fast,\n到 1950 年代尾声，电脑已经非常快了\n\nthey were often idle waiting for slow mechanical things, like printers and punch card readers.\n处理器经常闲着，等待慢的机械设备（比如打印机和读卡器）\n\nWhile programs were blocked on I/O,\n程序阻塞在 I/O 上\n\nthe expensive processor was just chillin'... not like a villain\n而昂贵的处理器则在度假，就是放松啥也不做\n\nyou know, just relaxing.\n而昂贵的处理器则在度假，就是放松啥也不做\n\nIn the late 50's, the University of Manchester, in the UK,\n50年代后期，英国曼彻斯特大学 \\N 开始研发世界上第一台超级计算机，Atlas\n\nstarted work on a supercomputer called Atlas, one of the first in the world.\n50年代后期，英国曼彻斯特大学 \\N 开始研发世界上第一台超级计算机，Atlas\n\nThey knew it was going to be wicked fast,\n他们知道机器会超级快，所以需要一种方式来最大限度的利用它\n\nso they needed a way to make maximal use of the expensive machine.\n他们知道机器会超级快，所以需要一种方式来最大限度的利用它\n\nTheir solution was a program called the Atlas Supervisor, finished in 1962.\n他们的解决方案是一个程序叫 Atlas Supervisor  \\N 于1962年完成\n\nThis operating system not only loaded programs automatically, like earlier batch systems,\n这个操作系统 \\N不仅像更早期的批处理系统那样，能自动加载程序\n\nbut could also run several at the same time on its single CPU.\n还能在单个 CPU 上同时运行几个程序\n\nIt did this through clever scheduling.\n它通过调度来做到这一点\n\nLet's say we have a game program running on Atlas,\n假设 Atlas 上有一个游戏在运行\n\nand we call the function \"print(highscore)\"\n并且我们调用一个函数 print(highscore)\n\nwhich instructs Atlas to print the value of a variable named \"highscore\"\n它让 Atlas 打印一个叫 highscore 的变量值\n\nonto paper to show our friends that we're the ultimate champion of virtual tiddlywinks.\n让朋友知道 我是最高分冠军\n\nThat function call is going to take a while, the equivalent of thousands of clock cycles,\nprint 函数运行需要一点时间，大概上千个时钟周期\n\nbecause mechanical printers are slow in comparison to electronic CPUs.\n但因为打印机比 CPU 慢，与其等着它完成操作\n\nSo instead of waiting for the I/O to finish,\n但因为打印机比 CPU 慢，与其等着它完成操作\n\nAtlas instead puts our program to sleep,\nAtlas 会把程序休眠，运行另一个程序\n\nthen selects and runs another program that's waiting and ready to run.\nAtlas 会把程序休眠，运行另一个程序\n\nEventually, the printer will report back to Atlas that it finished printing the value of \"highscore\".\n最终, 打印机会告诉 Atlas, 打印已完成\n\nAtlas then marks our program as ready to go,\nAtlas 会把程序标记成可继续运行\n\nand at some point, it will be scheduled to run again on the CPU,\n之后在某时刻会安排给 CPU 运行\n\nand continue onto the next line of code following the print statement.\n并继续 print 语句之后的下一行代码\n\nIn this way, Atlas could have one program running calculations on the CPU,\n这样, Atlas 可以在 CPU 上运行一个程序\n\nwhile another was printing out data,\n同时另一个程序在打印数据\n\nand yet another reading in data from a punch tape.\n同时另一个程序读数据\n\nAtlas' engineers doubled down on this idea,\nAtlas 的工程师做的还要多，配了4台纸带读取器，4台纸带打孔机\n\nand outfitted their computer with 4 paper tape readers, 4 paper tape punches,\nAtlas 的工程师做的还要多，配了4台纸带读取器，4台纸带打孔机\n\nand up to 8 magnetic tape drives.\n多达8个磁带驱动器\n\nThis allowed many programs to be in progress all at once,\n使多个程序可以同时运行，在单个 CPU 上共享时间\n\nsharing time on a single CPU.\n使多个程序可以同时运行，在单个 CPU 上共享时间\n\nThis ability, enabled by the Operating System, is called\n操作系统的这种能力叫\"多任务处理\"\n\nmultitasking.\n操作系统的这种能力叫\"多任务处理\"\n\nThere's one big catch to having many programs running simultaneously on a single computer, though.\n同时运行多个程序有个问题\n\nEach one is going to need some memory,\n每个程序都会占一些内存 \\N 当切换到另一个程序时，我们不能丢失数据\n\nand we can't lose that program's data when we switch to another program.\n每个程序都会占一些内存 \\N 当切换到另一个程序时，我们不能丢失数据\n\nThe solution is to allocate each program its own block of memory.\n解决办法是 给每个程序分配专属内存块\n\nSo, for example, let's say a computer has 10,000 memory locations in total.\n举个例子，假设计算机一共有 10000 个内存位置\n\nProgram A might get allocated memory addresses 0 through 999,\n程序 A 分配到内存地址 0 到 999\n\nand Program B might get 1000 through 1999, and so on.\n而程序 B 分配到内存地址 1000 到 1999，以此类推\n\nIf a program asks for more memory,\n如果一个程序请求更多内存，操作系统会决定是否同意\n\nthe operating system decides if it can grant that request,\n如果一个程序请求更多内存，操作系统会决定是否同意\n\nand if so, what memory block to allocate next.\n如果同意，分配哪些内存块\n\nThis flexibility is great, but introduces a quirk.\n这种灵活性很好，但带来一个奇怪的后果\n\nIt means that Program A could end up being allocated non-sequential blocks of memory,\n程序 A 可能会分配到非连续的内存块\n\nin say addresses 0 through 999, and 2000 through 2999.\n比如内存地址 0 到 999，以及 2000 到 2999\n\nAnd this is just a simple example\n这只是个简单例子\n\n- a real program might be allocated dozens of blocks scattered all over memory.\n真正的程序可能会分配到内存中数十个地方\n\nAs you might imagine,\n你可能想到了，这对程序员来说很难跟踪\n\nthis would get really confusing for programmers to keep track of.\n你可能想到了，这对程序员来说很难跟踪\n\nMaybe there's a long list of sales data in memory that\n也许内存里有一长串销售额，每天下班后要算销售总额\n\na program has to total up at the end of the day,\n也许内存里有一长串销售额，每天下班后要算销售总额\n\nbut this list is stored across a bunch of different blocks of memory.\n但列表 存在一堆不连续的内存块里\n\nTo hide this complexity, Operating Systems virtualize memory locations.\n为了隐藏这种复杂性，操作系统会把内存地址进行 \"虚拟化\"\n\nWith Virtual Memory, programs can assume their memory always starts at address 0,\n这叫 \"虚拟内存\"，程序可以假定内存总是从地址0开始\n\nkeeping things simple and consistent.\n简单又一致\n\nHowever, the actual, physical location in computer memory\n而实际物理位置  被操作系统隐藏和抽象了\n\nis hidden and abstracted by the operating system.\n而实际物理位置  被操作系统隐藏和抽象了\n\nJust a new level of abstraction.\n一层新的抽象\n\nLet's take our example Program B,\n用程序 B 来举例 \\N 它被分配了内存地址 1000 到 1999\n\nwhich has been allocated a block of memory from address 1000 to 1999.\n用程序 B 来举例 \\N 它被分配了内存地址 1000 到 1999\n\nAs far as Program B can tell, this appears to be a block from 0 to 999.\n对程序 B 而言，它看到的地址是 0 到 999\n\nThe OS and CPU handle the virtual-to-physical memory remapping automatically.\n操作系统会自动处理 \\N 虚拟内存和物理内存之间的映射\n\nSo, if Program B requests memory location 42,\n如果程序 B 要地址 42，实际上是物理地址 1042\n\nit really ends up reading address 1042.\n如果程序 B 要地址 42，实际上是物理地址 1042\n\nThis virtualization of memory addresses is even more useful for Program A,\n这种内存地址的虚拟化  对程序 A 甚至更有用\n\nwhich in our example, has been allocated two blocks of memory\n在例子中，A 被分配了两块隔开的内存\n\nthat are separated from one another.\n在例子中，A 被分配了两块隔开的内存\n\nThis too is invisible to Program A.\n程序 A 不知道这点.\n\nAs far as it can tell, it's been allocated a continuous block of 2000 addresses.\n以 A 的视角，它有 2000 个连续地址\n\nWhen Program A reads memory address 999,\n当程序 A 读内存地址 999 时 \\N 会刚好映射到物理内存地址 999\n\nthat does coincidentally map to physical memory address 999.\n当程序 A 读内存地址 999 时 \\N 会刚好映射到物理内存地址 999\n\nBut if Program A reads the very next value in memory, at address 1000,\n但如果程序 A 读下一个地址 1000\n\nthat gets mapped behind the scenes to physical memory address 2000.\n会映射到物理地址 2000\n\nThis mechanism allows programs to have flexible memory sizes,\n这种机制使程序的内存大小可以灵活增减 \\N 叫\"动态内存分配\"\n\ncalled dynamic memory allocation,\n这种机制使程序的内存大小可以灵活增减 \\N 叫\"动态内存分配\"\n\nthat appear to be continuous to them.\n对程序来说，内存看起来是连续的.\n\nIt simplifies everything and offers tremendous flexibility to the Operating System\n它简化了一切，为操作系统同时运行多个程序 \\N 提供了极大的灵活性\n\nin running multiple programs simultaneously.\n它简化了一切，为操作系统同时运行多个程序 \\N 提供了极大的灵活性\n\nAnother upside of allocating each program its own memory,\n给程序分配专用的内存范围，\\N 另一个好处是 这样隔离起来会更好\n\nis that they're better isolated from one another.\n给程序分配专用的内存范围，\\N 另一个好处是 这样隔离起来会更好\n\nSo, if a buggy program goes awry, and starts writing gobbledygook,\n如果一个程序出错，开始写乱七八糟的数据\n\nit can only trash its own memory, not that of other programs.\n它只能捣乱自己的内存，不会影响到其它程序.\n\nThis feature is called Memory Protection.\n这叫 \"内存保护\"\n\nThis is also really useful in protecting against malicious software, like viruses.\n防止恶意软件（如病毒）也很有用\n\nFor example, we generally don't want other programs to have the ability\n例如，我们不希望其他程序有能力 \\N 读或改邮件程序的内存\n\nto read or modify the memory of, let say, our email,\n例如，我们不希望其他程序有能力 \\N 读或改邮件程序的内存\n\nwith that kind of access,\n如果有这种权限 \\N 恶意软件可能以你的名义发邮件，甚至窃取个人信息\n\nmalware could send emails on your behalf and maybe steal personal information.\n如果有这种权限 \\N 恶意软件可能以你的名义发邮件，甚至窃取个人信息\n\nNot good!\n一点都不好！\n\nAtlas had both virtual and protected memory.\nAtlas 既有\"虚拟内存\"也有\"内存保护\"\n\nIt was the first computer and OS to support these features!\n是第一台支持这些功能的计算机和操作系统！\n\nBy the 1970s, computers were sufficiently fast and cheap.\n到 1970 年代，计算机足够快且便宜\n\nInstitutions like a university could buy a computer and let students use it.\n大学会买电脑让学生用\n\nIt was not only fast enough to run several programs at once,\n计算机不仅能同时运行多个程序，还能让多用户能同时访问\n\nbut also give several users simultaneous, interactive access.\n计算机不仅能同时运行多个程序，还能让多用户能同时访问\n\nThis was done through a terminal,\n多个用户用\"终端\"来访问计算机\n\nwhich is a keyboard and screen that connects to a big computer,\n\"终端\"只是键盘+屏幕，连到主计算机 \\N 终端本身没有处理能力\n\nbut doesn't contain any processing power itself.\n\"终端\"只是键盘+屏幕，连到主计算机 \\N 终端本身没有处理能力\n\nA refrigerator-sized computer might have 50 terminals connected to it,\n冰箱大小的计算机可能有50个终端，能让50个用户使用\n\nallowing up to 50 users.\n冰箱大小的计算机可能有50个终端，能让50个用户使用\n\nNow operating systems had to handle not just multiple programs,\n这时操作系统不但要处理多个程序，还要处理多个用户\n\nbut also multiple users.\n这时操作系统不但要处理多个程序，还要处理多个用户\n\nSo that no one person could gobble up all of a computer's resources,\n为了确保其中一个人  不会占满计算机资源\n\noperating systems were developed that offered time-sharing.\n开发了 分时操作系统\n\nWith time-sharing each individual user was only allowed to utilize\n意思是 每个用户只能用一小部分处理器，内存等\n\na small fraction of the computer's processor, memory, and so on.\n意思是 每个用户只能用一小部分处理器，内存等\n\nBecause computers are so fast,\n因为电脑很快 \\N 即使拿到 1/50 的资源也足以完成许多任务\n\neven getting just 1/50th of its resources was enough for individuals to complete many tasks.\n因为电脑很快 \\N 即使拿到 1/50 的资源也足以完成许多任务\n\nThe most influential of early time-sharing Operating Systems was\n早期分时操作系统中，最有影响力的是 \\N Multics（多任务信息与计算系统）\n\nMultics,  or Multiplexed Information and Computing Service,\n早期分时操作系统中，最有影响力的是 \\N Multics（多任务信息与计算系统）\n\nreleased in 1969.\n于 1969 年发布\n\nMultics was the first major operating system designed to be secure from the outset.\nMultics 是第一个，从设计时就考虑到安全的操作系统\n\nDevelopers didn't want mischievous users accessing data they shouldn't,\n开发人员不希望恶意用户 访问不该访问的数据\n\nlike students attempting to access the final exam on their professor's account.\n比如学生假装成教授，访问期末考试的文件\n\nFeatures like this meant Multics was really complicated for its time,\n这导致 Multics 的复杂度超过当时的平均水准\n\nusing around 1 Megabit of memory, which was a lot back then!\n操作系统会占大约 1 Mb 内存，这在当时很多！\n\nThat might be half of a computer's memory, just to run the OS!\n可能是内存的一半，只拿来运行操作系统！\n\nDennis Ritchie, one of the researchers working on Multics, once said:\nMultics 的研究人员之一 Dennis Ritchie 曾说过\n\n\"One of the obvious things that went wrong with Multics as a commercial success\n\"阻碍 Multics 获得商业成功的一个明显问题是\n\nwas just that it was sort of over-engineered in a sense.\n从某种方面来说，它被过度设计了，功能太多了\"\n\nThere was just too much in it.\"\n从某种方面来说，它被过度设计了，功能太多了\"\n\nThis lead Dennis, and another Multics researcher,\n所以 Dennis 和另一个 Multics 研究员 \\N Ken Thompson 联手打造新的操作系统\n\nKen Thompson, to strike out on their own and build a new, lean operating system\n所以 Dennis 和另一个 Multics 研究员 \\N Ken Thompson 联手打造新的操作系统\n\ncalled Unix.\n叫 Unix\n\nThey wanted to separate the OS into two parts:\n他们想把操作系统分成两部分：\n\nFirst was the core functionality of the OS,\n首先是操作系统的核心功能\n\nthings like memory management, multitasking,and dealing with I/O,\n如内存管理，多任务和输入/输出处理 \\N 这叫\"内核\"\n\nwhich is called the kernel .\n如内存管理，多任务和输入/输出处理 \\N 这叫\"内核\"\n\nThe second part was a wide array of useful tools that came bundled with,\n第二部分是一堆有用的工具\n\nbut not part of the kernel, things like programs and libraries.\n但它们不是内核的一部分（比如程序和运行库）\n\nBuilding a compact, lean kernel meant intentionally leaving some functionality out.\n紧凑的内核 意味着功能没有那么全面\n\nTom Van Vleck, another Multics developer, recalled:\nMultics 的另一个开发者 Tom Van Vleck 回忆说：\n\n\"I remarked to Dennis that easily half the code I was writing in Multics was error recovery code.\"\n\"我对 Dennis 说，我在 Multics 写的一半代码都是错误恢复代码\"\n\nHe said, \"We left all that stuff out of Unix.\n他说:\"Unix 不会有这些东西\n\nIf there's an error, we have this routine called panic,\n如果有错误发生，我们就让内核\"恐慌\"（panic）\n\nand when it is called, the machine crashes,\n当调用它时，机器会崩溃\n\nand you holler down the hall, 'Hey, reboot it.'\"\"\n你得在走廊里大喊，\"嘿，重启电脑\"\n\nYou might have heard of kernel panics.\n你可能听过 \"内核恐慌\"（kernel panic）\n\nThis is where the term came from.\n这就是这个词的来源\n\nIt's literally when the kernel crashes, has no recourse to recover,\n内核如果崩溃，没有办法恢复\n\nand so calls a function called \"panic\".\n所以调用一个叫\"恐慌\"（panic）的函数\n\nOriginally, all it did was print the word \"panic\" and then enter an infinite loop.\n起初只是打印\"恐慌\"一词，然后无限循环\n\nThis simplicity meant that Unix could be run on cheaper and more diverse hardware,\n这种简单性意味着  \\N Unix 可以在更便宜更多的硬件上运行\n\nmaking it popular inside Bell Labs, where Dennis and Ken worked.\n使 Unix 在 Dennis 和 Ken 工作的 \\N 贝尔实验室大受欢迎\n\nAs more developers started using Unix to build and run their own programs,\n越来越多开发人员用 Unix 写程序和运行程序\n\nthe number of contributed tools grew.\n工具数量日益增长\n\nSoon after its release in 1971,\n1971 年发布后不久\n\nit gained compilers for different programming languages and even a word processor,\n就有人写了不同编程语言的编译器 \\N 甚至文字处理器\n\nquickly making it one of the most popular OSes of the 1970s and 80s.\n使得 Unix 迅速成为 \\N 1970~80年代最流行的操作系统之一\n\nAt the same time, by the early 1980s,\n到 1980 年代早期\n\nthe cost of a basic computer had fallen to the point where individual people could afford one,\n计算机的价格 降到普通人买得起  \\N 这些叫\"个人电脑\"或\"家庭电脑\"\n\ncalled a personal or home computer.\n计算机的价格 降到普通人买得起  \\N 这些叫\"个人电脑\"或\"家庭电脑\"\n\nThese were much simpler than the big mainframes\n这些电脑比大型主机简单得多 \\N 主机一般在大学，公司和政府\n\nfound at universities, corporations, and governments.\n这些电脑比大型主机简单得多 \\N 主机一般在大学，公司和政府\n\nSo, their operating systems had to be equally simple.\n因此操作系统也得简单\n\nFor example, Microsoft's Disk Operating System, or MS-DOS, was just 160 kilobytes,\n举例，微软的磁盘操作系统（MS-DOS）只有 160 kB \\N 一张磁盘就可以容纳\n\nallowing it to fit, as the name suggests, onto a single disk.\n举例，微软的磁盘操作系统（MS-DOS）只有 160 kB \\N 一张磁盘就可以容纳\n\nFirst released in 1981, it became the most popular OS for early home computers,\n于 1981 年发布，成为早期家用电脑最受欢迎的操作系统\n\neven though it lacked multitasking and protected memory.\n虽然缺少\"多任务\"和\"保护内存\"这样功能\n\nThis meant that programs could,\n意味着程序经常使系统崩溃\n\nand would, regularly crash the system.\n意味着程序经常使系统崩溃\n\nWhile annoying, it was an acceptable tradeoff,\n虽然很讨厌但还可以接受，因为用户可以重启\n\nas users could just turn their own computers off and on again!\n虽然很讨厌但还可以接受，因为用户可以重启\n\nEven early versions of Windows,\n哪怕是微软 1985 年发布的早期 Windows \\N 虽然在 90 年代很流行\n\nfirst released by Microsoft in 1985  and which dominated the OS scene throughout the 1990s,\n哪怕是微软 1985 年发布的早期 Windows \\N 虽然在 90 年代很流行\n\nlacked strong memory protection.\n但却缺乏\"内存保护\"\n\nWhen programs misbehaved,\n当程序行为不当时，就会\"蓝屏\"\n\nyou could get the blue screen of death,\n当程序行为不当时，就会\"蓝屏\"\n\na sign that a program had crashed so badly that it took down the whole operating system.\n代表程序崩溃的非常严重，把系统也带崩溃了\n\nLuckily, newer versions of Windows have better protections and usually don't crash that often.\n幸运的是，新版Windows有更好的保护，不会经常崩溃\n\nToday, computers run modern operating systems,\n如今的计算机 有现代操作系统\n\nlike Mac OS X, Windows 10, Linux, iOS and Android.\n比如 Mac OS X，Windows 10 \\NLinux，iOS和Android\n\nEven though the computers we own are most often used by just a single person,\n虽然大部分设备只有一个人使用\n\nyou!\n你！\n\ntheir OS all have multitasking and virtual and protected memory.\n操作系统依然有\"多任务, \"虚拟内存\", \"内存保护\"\n\nSo, they can run many programs at once:\n因此可以同时运行多个程序：\n\nyou can watch YouTube in your web browser,\n一边在浏览器看 YouTube，一边在 Photoshop 修图\n\nedit a photo in Photoshop,\n一边在浏览器看 YouTube，一边在 Photoshop 修图\n\nplay music in Spotify and sync Dropbox all at the same time.\n用 Spotify 放音乐，同步 Dropbox\n\nThis wouldn't be possible without those decades of research and development on Operating Systems,\n如果没有操作系统这几十年的发展，这些都不可能,\n\nand of course the proper memory to store those programs.\n当然，我们也需要地方放程序\n\nWhich we'll get to next week.\n下周会讨论\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nWe've talked about computer memory several times in this series,\n系列中 我们多次谈到内存（Memory）\n\nand we even designed some in Episode 6.\n甚至在第 6 集设计了一个简单内存\n\nIn general, computer memory is non-permanent.\n一般来说，电脑内存是 \"非永久性\"\n\nIf your xbox accidently gets unplugged and turns off,\n如果 Xbox 电源线不小心拔掉了，内存里所有数据都会丢失\n\nany data saved in memory is lost.\n如果 Xbox 电源线不小心拔掉了，内存里所有数据都会丢失\n\nFor this reason, it's called volatile memory.\n所以内存叫\"易失性\"存储器\n\nWhat we haven't talked so much about this series is storage,\n我们还没谈过的话题  是存储器（Storage）\n\nwhich is a tad different.\n存储器（Storage）和内存（Memory）有点不同\n\nAny data written to storage, like your hard drive,\n任何写入\"存储器\"的数据，比如你的硬盘 \\N 数据会一直存着，直到被覆盖或删除，断电也不会丢失\n\nwill stay there until it's over-written or deleted, even if the power goes out.\n任何写入\"存储器\"的数据，比如你的硬盘 \\N 数据会一直存着，直到被覆盖或删除，断电也不会丢失\n\nIt's non-volatile.\n存储器是\"非易失性\"的\n\nIt used to be that volatile memory was fast and non-volatile storage was slow,\n以前是\"易失性\"的速度快，\"非易失性\"的速度慢\n\nbut as computing technologies have improved, this distinction is becoming less true,\n但随着技术发展，两者的差异越来越小\n\nand the terms have started to blend together.\n但随着技术发展，两者的差异越来越小\n\nNowadays, we take for granted technologies like this little USB stick,\n如今我们认为稀松平常的技术，比如这个 U 盘\n\nwhich offers gigabytes of memory, reliable over long periods of time, all at low cost,\n能低成本+可靠+长时间  存储上 GB 的数据\n\nbut this wasn't always true.\n但以前可不是这样的\n\nThe earliest computer storage was paper punch cards,\n最早的存储介质是 打孔纸卡 \\N 以及纸卡的亲戚    打孔纸带\n\nand its close cousin, punched paper tape.\n最早的存储介质是 打孔纸卡 \\N 以及纸卡的亲戚    打孔纸带\n\nBy the 1940s, punch cards had largely standardized into a grid of 80 columns and 12 rows,\n到1940年代，纸卡标准是 80列x12行\n\nallowing for a maximum of 960 bits of data to be stored on a single card.\n一张卡能存 960 位数据 (80x12=960)\n\nThe largest program ever punched onto cards, that we know of,\n据我们所知的  最大纸卡程序\n\nwas the US Military's Semi-Automatic Ground Environment, or SAGE,\n是美国军方的\"半自动地面防空系统\" 简称 SAGE\n\nan Air Defense System that became operational in 1958.\n一个在 1958 年投入使用的防空系统\n\nThe main program was stored on 62,500 punchcards,\n主程序存储在 62,500 个纸卡上\n\nroughly equivalent to 5 megabytes of data,\n大小 5MB 左右, 相当如今手机拍张照\n\nthat's the size of an average smartphone photo today.\n大小 5MB 左右, 相当如今手机拍张照\n\nPunch cards were a useful and popular form of storage for decades,\n纸卡用了十几年，因为不用电而且便宜耐用\n\nthey didn't need power, plus paper was cheap and reasonably durable.\n纸卡用了十几年，因为不用电而且便宜耐用\n\nHowever, punchcards were slow and write-once,\n然而坏处是读取慢，只能写入一次\n\nyou can't easily un-punch a hole.\n打的孔无法轻易补上\n\nSo they were a less useful form of memory,\n对于存临时值，纸卡不好用\n\nwhere a value might only be needed for a fraction of a second during a program's execution,\n对于存临时值，纸卡不好用\n\nand then discarded.\n对于存临时值，纸卡不好用\n\nA faster, larger and more flexible form of computer memory was needed.\n我们需要更快更大更灵活的存储方式\n\nAn early and practical approach was developed by J. Presper Eckert,\nJ. Presper Eckert 在 1944 年建造 ENIAC 时发明了一种方法\n\nas he was finishing work on ENIAC in 1944.\nJ. Presper Eckert 在 1944 年建造 ENIAC 时发明了一种方法\n\nHis invention was called Delay Line Memory, and it worked like this.\n叫\"延迟线存储器\"（Delay Line Memory）原理如下\n\nYou take a tube and fill it with a liquid, like mercury.\n拿一个管子装满液体，如水银\n\nThen, you put a speaker at one end and microphone at the other.\n管子一端放扬声器，另一端放麦克风\n\nWhen you pulse the speaker, it creates a pressure wave.\n扬声器发出脉冲时  会产生压力波\n\nThis takes time to propagate to the other end of the tube,\n压力波需要时间  传播到另一端的麦克风\n\nwhere it hits the microphone,\n压力波需要时间  传播到另一端的麦克风\n\nconverting it back into an electrical signal.\n麦克风将压力波 转换回电信号.\n\nAnd we can use this propagation delay to store data!\n我们可以用压力波的传播延迟  来存储数据！\n\nImagine that the presence of a pressure wave is a 1\n假设有压力波代表 1，没有代表 0\n\nand the absence of a pressure wave is a 0.\n假设有压力波代表 1，没有代表 0\n\nOur speaker can output a binary sequence like 1010 0111.\n扬声器可以输出 1​​010 0111\n\nThe corresponding waves will travel down the tube, in order,\n压力波沿管子传播，过了一会儿，撞上麦克风，\n\nand a little while later, hit the microphone,\n压力波沿管子传播，过了一会儿，撞上麦克风，\n\nwhich converts the signal back into 1's and 0's.\n将信号转换回 1 和 0\n\nIf we create a circuit that connects the microphone to the speaker,\n如果加一个电路，连接麦克风和扬声器\n\nplus a little amplifier to compensate for any loss,\n再加一个放大器（Amplifier）来弥补信号衰弱\n\nwe can create a loop that stores data.\n就能做一个存储数据的循环\n\nThe signal traveling along the wire is near instantaneous,\n信号沿电线传播几乎是瞬时的,\n\nso there's only ever one bit of data showing at any moment in time.\n所以任何时间点只显示  1 bit 数据\n\nBut in the tube, you can store many bits!\n但管子中可以存储多个位(bit)\n\nAfter working on ENIAC, Eckert and his colleague John Mauchly,\n忙完 ENIAC 后，Eckert 和同事 John Mauchly\n\nset out to build a bigger and better computer called EDVAC, incorporating Delay Line Memory.\n着手做一个更大更好的计算机叫 EDVAC，使用了延迟线存储器\n\nIn total, the computer had 128 Delay Lines,\n总共有 128 条延迟线，每条能存 352 位（bits）\n\neach capable of storing 352 bits.\n总共有 128 条延迟线，每条能存 352 位（bits）\n\nThat's a grand total of 45 thousands bits of memory,\n总共能存 45,000 位(bit)\n\nnot too shabby for 1949!\n对 1949 年来说还不错！\n\nThis allowed EDVAC to be one of the very earliest Stored-Program Computers,\n这使得 EDVAC 成为最早的 \"存储程序计算机\" 之一\n\nwhich we talked about in Episode 10.\n我们在第 10 集讨论过\n\nHowever, a big drawback with delay line memory\n但\"延迟线存储器\"的一大缺点是\n\nis that you could only read one bit of data from a tube at any given instant.\n每一个时刻只能读一位 (bit) 数据\n\nIf you wanted to access a specific bit, like bit 112,\n如果想访问一个特定的 bit，比如第 112 位(bit) \\N 你得等待它从循环中出现\n\nyou'd have to wait for it to come around in the loop,\n如果想访问一个特定的 bit，比如第 112 位(bit) \\N 你得等待它从循环中出现\n\nwhat's called sequential or cyclic-access memory,\n所以又叫 \"顺序存储器\"或\"循环存储器\"\n\nwhereas we really want random access memory,\n而我们想要的是 \"随机存取存储器\" \\N 可以随时访问任何位置\n\nwhere we can access any bit at any time.\n而我们想要的是 \"随机存取存储器\" \\N 可以随时访问任何位置\n\nIt also proved challenging to increase the density of the memory,\n增加内存密度也是一个挑战\n\npacking waves closer together meant they were more easily mixed up.\n把压力波变得更紧密  意味着更容易混在一起\n\nIn response, new forms of delay line memory were invented,\n所以出现了其他类型的 \"延迟线存储器\"\n\nsuch as magnetostrictive delay lines .\n如 \"磁致伸缩延迟存储器\"\n\nThese delay lines use a metal wire that could be twisted,\n用金属线的振动来代表数据\n\ncreating little torsional waves that represented data.\n用金属线的振动来代表数据\n\nBy forming the wire into a coil, you could store around 1000 bits in a 1 foot by 1 foot square.\n通过把线卷成线圈，1英尺×1英尺的面积能存储大概 1000位(bit)\n\nHowever, delay line memory was largely obsolete by the mid 1950s,\n然而，延迟线存储器在 1950 年代中期就基本过时了\n\nsurpassed in performance, reliability and cost by a new kid on the block:\n因为出现了新技术，性能,可靠性和成本都更好\n\nmagnetic core memory which was constructed out of little magnetic donuts,\n\"磁芯存储器\"，用了像甜甜圈的小型磁圈\n\ncalled cores.\n\"磁芯存储器\"，用了像甜甜圈的小型磁圈\n\nIf you loop a wire around this core.\n如果给磁芯绕上电线，并施加电流，可以将磁化在一个方向\n\nand run an electrical current through the wire,\n如果给磁芯绕上电线，并施加电流，可以将磁化在一个方向\n\nwe can magnetize the core in a certain direction.\n如果给磁芯绕上电线，并施加电流，可以将磁化在一个方向\n\nIf we turn the current off, the core will stay magnetized.\n如果关掉电流，磁芯保持磁化\n\nIf we pass current through the wire in the opposite direction,\n如果沿相反方向施加电流\n\nthe magnetization direction, called polarity,\n磁化的方向（极性）会翻转\n\nflips the other way.\n磁化的方向（极性）会翻转\n\nIn this way, we can store 1's and 0's!\n这样就可以存 1 和 0！\n\n1 bit of memory isn't very useful, so these little donuts were arranged into grids.\n如果只存 1 位不够有用，所以把小甜甜圈排列成网格\n\nThere were wires for selecting the right row and column, and a wire that ran through every core,\n有电线负责选行和列 \\N 也有电线贯穿每个磁芯, 用于读写一位(bit)\n\nwhich could be used to read or write a bit.\n有电线负责选行和列 \\N 也有电线贯穿每个磁芯, 用于读写一位(bit)\n\nHere is an actual piece of core memory!\n我手上有一块磁芯存储器\n\nIn each of these little yellow squares, there are 32 rows and 32 columns of tiny cores,\n每个黄色方格  有32行x32列的磁芯 \\N 每个磁芯存 1 位数据\n\neach one holding 1 bit of data.\n每个黄色方格  有32行x32列的磁芯 \\N 每个磁芯存 1 位数据\n\nSo, each of these yellow squares could hold 1024 bits.\n所以能存 1024 位(bit)  (32x32=1024)\n\nIn total, there are 9 of these,\n总共 9 个黄色方格\n\nso this memory board could hold a maximum of 9216 bits,\n所以这块板子最多能存 9216 位(bit) (1024x9=9216)\n\nwhich is around 9 kilobytes.\n换算过来大约是 9 千字节 \\N (9216 bit ~= 9 kb)\n\nThe first big use of core memory was MIT's Whirlwind 1 computer, in 1953,\n磁芯内存的第一次大规模运用\\N 是 1953 年麻省理工学院的 Whirlwind 1 计算机\n\nwhich used a 32 by 32 core arrangement.\n磁芯排列是 32×32\n\nAnd, instead of just a single plane of cores, like this,\n用了 16 块板子，能存储大约 16000 位(bit)\n\nit was 16 boards deep, providing roughly 16 thousand bits of storage.\n用了 16 块板子，能存储大约 16000 位(bit)\n\nImportantly, unlike delay line memory,\n更重要的是，不像\"延迟线存储器\" \\N 磁芯存储器能随时访问任何一位(bit)\n\nany bit could be accessed at any time.\n更重要的是，不像\"延迟线存储器\" \\N 磁芯存储器能随时访问任何一位(bit)\n\nThis was a killer feature,\n这在当时非常了不起\n\nand magnetic core memory became the predominant Random Access Memory technology\n\"磁芯存储器\" 从 1950 年代中期开始成为主流 \\N 流行了 20 多年\n\nfor two decades, beginning in the mid 1950\n\"磁芯存储器\" 从 1950 年代中期开始成为主流 \\N 流行了 20 多年\n\neven though it was typically woven by hand!\n而且一般还是手工编织的！\n\nAlthough starting at roughly 1 dollar per bit,\n刚开始时  存储成本大约 1 美元 1 位(bit) \\N 到1970年代，下降到 1 美分左右\n\nthe cost fell to around 1 cent per bit by the 1970s.\n刚开始时  存储成本大约 1 美元 1 位(bit) \\N 到1970年代，下降到 1 美分左右\n\nUnfortunately, even 1 cent per bit isn't cheap enough for storage.\n不幸的是，即使每位 1 美分也不够便宜\n\nAs previously mentioned,\n之前提过，现代手机随便拍张照片都有 5 MB\n\nan average smartphone photo is around 5 megabytes in size,\n之前提过，现代手机随便拍张照片都有 5 MB\n\nthat's roughly 40 million bits.\n5MB 约等于 4000 万 bit\n\nWould you pay 4 hundred thousand dollars to store a photo on core memory?\n你愿意花 40 万美元在\"磁芯存储器\"上存照片吗？\n\nIf you have that kind of money to drop,\n如果你有这么多钱\n\ndid you know that Crash Course is on Patreon?\n你知道 Crash Course 在 Patreon 有赞助页吗？\n\nRight? Wink wink.\n对吧？你懂的\n\nAnyway, there was tremendous research into storage technologies happening at this time.\n总之，当时对存储技术进行了大量的研究\n\nBy 1951, Eckert and Mauchly had started their own company,\n到 1951 年，Eckert 和 Mauchly 创立了自己的公司\n\nand designed a new computer called UNIVAC,\n设计了一台叫 UNIVAC 的新电脑\n\none of the earliest commercially sold computers.\n最早进行商业销售的电脑之一\n\nIt debuted with a new form of computer storage:\n它推出了一种新存储：磁带\n\nmagnetic tape.\n它推出了一种新存储：磁带\n\nThis was a long, thin and flexible strip of magnetic material, stored in reels.\n磁带是纤薄柔软的一长条磁性带子  卷在轴上\n\nThe tape could be moved forwards or backwards inside of a machine called a tape drive.\n磁带可以在\"磁带驱动器\"内前后移动\n\nInside is a write head,\n里面有一个\"写头\"绕了电线，电流通过产生磁场\n\nwhich passes current through a wound wire to generate a magnetic field,\n里面有一个\"写头\"绕了电线，电流通过产生磁场\n\ncausing a small section of the tape to become magnetized.\n导致磁带的一小部分被磁化\n\nThe direction of the current sets the polarity, again, perfect for storing 1's and 0's.\n电流方向决定了极性，代表 1 和 0\n\nThere was also a separate read head could detect the polarity non-destructively.\n还有一个\"读头\"，可以非破坏性地检测极性\n\nThe UNIVAC used half-inch-wide tape with 8 parallel data tracks,\nUNIVAC 用了半英寸宽，8条并行的磁带\n\neach able to store 128 bits of data per inch.\n磁带每英寸可存 128 位数据\n\nWith each reel containing 1200 feet of tape,\n每卷有 1200 英尺长\n\nit meant you could store roughly 15 million bits\n意味着一共可以存 1500 万位左右\n\n- that's almost 2 megabytes!\n- 接近2兆字节！（2 MB）\n\nAlthough tape drives were expensive,\n虽然磁带驱动器很贵，但磁带又便宜又小\n\nthe magnetic tape itself was cheap and compact,\n虽然磁带驱动器很贵，但磁带又便宜又小\n\nand for this reason, they're still used today for archiving data.\n因此磁带至今仍用于存档\n\nThe main drawback is access speed.\n磁带的主要缺点是访问速度\n\nTape is inherently sequential,\n磁带是连续的，必须倒带或快进到达特定位置\n\nyou have to rewind or fast-forward to get to data you want.\n磁带是连续的，必须倒带或快进到达特定位置\n\nThis might mean traversing hundreds of feet of tape to retrieve a single byte,\n可能要几百英尺才能得到某个字节(byte)，这很慢\n\nwhich is slow.\n可能要几百英尺才能得到某个字节(byte)，这很慢\n\nA related popular technology in the 1950s and 60s was Magnetic Drum Memory.\n1950,60年代，有个类似技术是 \"磁鼓存储器\"\n\nThis was a metal cylinder - called a drum - coated in a magnetic material for recording data\n有金属圆筒，盖满了磁性材料以记录数据\n\nThe drum was rotated continuously,\n滚筒会持续旋转，周围有数十个读写头\n\nand positioned along its length were dozens of read and write heads.\n滚筒会持续旋转，周围有数十个读写头\n\nThese would wait for the right spot to rotate underneath them to read or write a bit of data.\n等滚筒转到正确的位置\\N 读写头会读或写 1 位(bit) 数据\n\nTo keep this delay as short as possible,\n为了尽可能缩短延迟, 鼓轮每分钟上千转！\n\ndrums were rotated thousand of revolutions per minute!\n为了尽可能缩短延迟, 鼓轮每分钟上千转！\n\nBy 1953, when the technology started to take off,\n到 1953 年，磁鼓技术飞速发展 \\N 可以买到存 80,000 位的\"磁鼓存储器\"\n\nyou could buy units able to record 80,000 bits of data\n到 1953 年，磁鼓技术飞速发展 \\N 可以买到存 80,000 位的\"磁鼓存储器\"\n\n- that's 10 kilobytes,\n- 也就是 10 KB\n\nbut the manufacture of drums ceased in the 1970s.\n但到 1970 年代 \"磁鼓存储器\" 不再生产\n\nHowever, Magnetic Drums did directly lead to the development of Hard Disk Drives,\n然而，磁鼓导致了硬盘的发展 \\N 硬盘和磁鼓很相似\n\nwhich are very similar, but use a different geometric configuration.\n然而，磁鼓导致了硬盘的发展 \\N 硬盘和磁鼓很相似\n\nInstead of large cylinder, hard disks use,\n不过硬盘用的是盘，不像磁鼓用圆柱体，因此得名\n\nwell disks that are hard.\n不过硬盘用的是盘，不像磁鼓用圆柱体，因此得名\n\nHence the name!\n不过硬盘用的是盘，不像磁鼓用圆柱体，因此得名\n\nThe storage principle is the same,\n原理是一样的，磁盘表面有磁性\n\nthe surface of a disk is magnetic,\n原理是一样的，磁盘表面有磁性\n\nallowing write and read heads to store and retrieve 1's and 0's.\n写入头和读取头  可以处理上面的 1 和 0\n\nThe great thing about disks is that they are thin,\n硬盘的好处是薄，可以叠在一起\n\nso you can stack many of them together,\n硬盘的好处是薄，可以叠在一起\n\nproviding a lot of surface area for data storage.\n提供更多表面积来存数据\n\nThat's exactly what IBM did for the world's first computer with a disk drive:\nIBM 对世上第一台磁盘计算机就是这样做的\n\nthe RAMAC 305.\nRAMAC 305\n\nSweet name BTW.\n顺便一说名字不错\n\nIt contained fifty, 24-inch diameter disks,\n它有 50 张 24 英寸直径的磁盘，总共能存 5 MB 左右\n\noffering a total storage capacity of roughly 5 megabytes.\n它有 50 张 24 英寸直径的磁盘，总共能存 5 MB 左右\n\nYess!! We've finally gotten to a technology that can store a single smartphone photo!\n太棒啦! 终于能存一张现代手机的照片了！这年是 1956 年\n\nThe year was 1956.\n太棒啦! 终于能存一张现代手机的照片了！这年是 1956 年\n\nTo access any bit of data,\n要访问某个特定 bit\n\na read/write head would travel up or down the stack to the right disk,\n一个读/写磁头会向上或向下移动，找到正确的磁盘\n\nand then slide in between them.\n然后磁头会滑进去\n\nLike drum memory, the disks are spinning,\n就像磁鼓存储器一样，磁盘也会高速旋转\n\nso the head has to wait for the right section to come around.\n所以读写头要等到正确的部分转过来\n\nThe RAMAC 305 could access any block of data, on average, in around 6/10ths of a second,\nRAMAC 305 访问任意数据，平均只要六分之一秒左右\n\nwhat's called the seek time.\n也叫寻道时间\n\nWhile great for storage, this was not nearly fast enough for memory,\n虽然六分之一秒对存储器来说算不错 \\N 但对内存来说还不够快\n\nso the RAMAC 305 also had drum memory and magnetic core memory.\n所以 RAMAC 305 还有\"磁鼓存储器\"和\"磁芯存储器\"\n\nThis is an example of a memory hierarchy,\n这是\"内存层次结构\"的一个例子\n\nwhere you have a little bit of fast memory, which is expensive,\n一小部分高速+昂贵的内存\n\nslightly more medium-speed memory, which is less expensive,\n一部分稍慢+相对便宜些的内存\n\nand then a lot of slowish memory, which is cheap.\n还有更慢+更便宜的内存\n\nThis mixed approach strikes a balance between cost and speed.\n这种混合  在成本和速度间取得平衡\n\nHard disk drives rapidly improved and became commonplace by the 1970s.\n1970 年代，硬盘大幅度改进并变得普遍\n\nA hard disk like this can easily hold 1 terabyte of data today\n如今的硬盘可以轻易容纳 1TB 的数据\n\n- that's a trillion bytes - or roughly 200,000 five megabyte photos!\n能存 20 万张 5MB 的照片！\n\nAnd these types of drives can be bought online for as little as 40 US dollars.\n网上最低 40 美元就可以买到\n\nThat's 0.0000000005 cents per bit.\n每 bit 成本 0.0000000005 美分\n\nA huge improvement over core memory's 1 cent per bit!\n比磁芯内存 1 美分 1 bit 好多了！\n\nAlso, modern drives have an average seek time of under 1/100th of a second.\n另外，现代硬盘的平均寻道时间低于 1/100 秒\n\nI should also briefly mention a close cousin of hard disks, the floppy disk,\n我简单地提一下硬盘的亲戚，软盘\n\nwhich is basically the same thing, but uses a magnetic medium that's, floppy.\n除了磁盘是软的，其他基本一样\n\nYou might recognise it as the save icon on some of your applications,\n你可能见过某些程序的保存图标是一个软盘\n\nbut it was once a real physical object!\n软盘曾经是真实存在的东西！\n\nIt was most commonly used for portable storage,\n软盘是为了便携，在 1970~1990 非常流行\n\nand became near ubiquitous from the mid 1970s up to the mid 90s.\n软盘是为了便携，在 1970~1990 非常流行\n\nAnd today it makes a pretty good coaster.\n如今当杯垫挺不错的\n\nHigher density floppy disks, like Zip Disks,\n密度更高的软盘，如 Zip Disks，在90年代中期流行起来\n\nbecame popular in the mid 1990s,\n密度更高的软盘，如 Zip Disks，在90年代中期流行起来\n\nbut fell out of favor within a decade.\n但十年内就消失了\n\nOptical storage came onto the scene in 1972, in the form of a 12-inch \"laser disc.\"\n光学存储器于 1972 年出现，12 英寸的\"激光盘\"\n\nHowever, you are probably more familiar with its later, smaller, are more popular cousin,\n你可能对后来的产品更熟：光盘（简称 CD）\n\nthe Compact Disk, or CD,\n你可能对后来的产品更熟：光盘（简称 CD）\n\nas well as the DVD which took off in the 90s.\n以及 90 年代流行的 DVD\n\nFunctionally, these technologies are pretty similar to hard disks and floppy disks,\n功能和硬盘软盘一样，都是存数据.\n\nbut instead of storing data magnetically,\n但用的不是磁性\n\noptical disks have little physical divots in their surface that cause light to be reflected differently,\n光盘表面有很多小坑，造成光的不同反射\n\nwhich is captured by an optical sensor, and decoded into 1's and 0's.\n光学传感器会捕获到，并解码为 1 和 0\n\nHowever, today, things are moving to solid state technologies, with no moving parts,\n如今，存储技术在朝固态前进，没有机械活动部件\n\nlike this hard drive and also this USB stick.\n比如这个硬盘，以及 U 盘\n\nInside are Integrated Circuits,\n里面是集成电路，我们在第 15 集讨论过\n\nwhich we talked about in Episode 15.\n里面是集成电路，我们在第 15 集讨论过\n\nThe first RAM integrated circuits became available in 1972 at 1 cent per bit,\n第一个 RAM 集成电路出现于 1972 年 \\N 成本每比特 1 美分\n\nquickly making magnetic core memory obsolete.\n使\"磁芯存储器\"迅速过时\n\nToday, costs have fallen so far,\n如今成本下降了更多 \\N 机械硬盘 被 固态硬盘 逐渐替代，简称 SSD\n\nthat hard disk drives are being replaced with non-volatile,\n如今成本下降了更多 \\N 机械硬盘 被 固态硬盘 逐渐替代，简称 SSD\n\nSolid State Drives, or SSDs, as the cool kids say.\n如今成本下降了更多 \\N 机械硬盘 被 固态硬盘 逐渐替代，简称 SSD\n\nBecause they contain no moving parts,\n由于 SSD 没有移动部件\n\nthey don't really have to seek anywhere,\n磁头不用等磁盘转\n\nso SSD access times are typically under 1/1000th of a second.\n所以 SSD 访问时间低于 1/1000 秒\n\nThat's fast!\n这很快！\n\nBut it's still many times slower than your computer's RAM.\n但还是比 RAM 慢很多倍\n\nFor this reason, computers today still use memory hierarchies.\n所以现代计算机 仍然用存储层次结构\n\nSo, we've come along way since the 1940s.\n我们从 1940 年代到现在进步巨大\n\nMuch like transistor count and Moore's law,\n就像在第 14 集讨论过的  晶体管数量和摩尔定律\n\nwhich we talked about in Episode 14,\n就像在第 14 集讨论过的  晶体管数量和摩尔定律\n\nmemory and storage technologies have followed a similar exponential trend.\n内存和存储技术也有类似的趋势\n\nFrom early core memory costing millions of dollars per megabyte, we're steadily fallen,\n从早期每 MB 成本上百万美元，下滑到\n\nto mere cents by 2000, and only fractions of a cent today.\n2000 年只要几分钱，如今远远低于 1 分钱\n\nPlus, there's WAY less punch cards to keep track of.\n完全没有打孔纸卡\n\nSeriously, can you imagine if there was a slight breeze in that room containing the SAGE program?\n你能想象 SEGA 的纸卡房间风一吹会怎样吗？\n\n62,500 punch cards.\n62,500 张卡\n\nI don't even want to think about it.\n我想都不敢想\n\nI'll see you next week.\n我们下周见\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode we talked about data storage, how technologies like magnetic tape and hard\n上集我们讲了数据存储，磁带和硬盘这样的技术\n\ndisks can store trillions of bits of data,\n可以在断电状态长时间存上万亿个位\n\nfor long durations, even without power.\n可以在断电状态长时间存上万亿个位\n\nWhich is perfect for recording \"big blobs\" of related data,\n非常合适存一整块有关系的数据，或者说\"文件\"\n\nwhat are more commonly called computer files.\n非常合适存一整块有关系的数据，或者说\"文件\"\n\nYou've no doubt encountered many types,\n你肯定见过很多种文件 \\N 比如文本文件，音乐文件，照片和视频\n\nlike text files, music files, photos and videos.\n你肯定见过很多种文件 \\N 比如文本文件，音乐文件，照片和视频\n\nToday, we're going to talk about how files work,\n今天，我们要讨论文件到底是什么 \\N 以及计算机怎么管理文件\n\nand how computers keep them all organized with File Systems.\n今天，我们要讨论文件到底是什么 \\N 以及计算机怎么管理文件\n\nIt's perfectly legal for a file to contain arbitrary, unformatted data,\n随意排列文件数据完全没问题，但按格式排会更好\n\nbut it's most useful and practical if the data inside the file is organized somehow.\n随意排列文件数据完全没问题，但按格式排会更好\n\nThis is called a file format.\n这叫 \"文件格式\"\n\nYou can invent your own, and programmers do that from time to time,\n你可以发明自己的文件格式，程序员偶尔会这样做\n\nbut it's usually best and easiest to use an existing standard, like JPEG and MP3.\n但最好用现成标准，比如 JPEG 和 MP3\n\nLet's look at some simple file formats.\n来看一些简单文件格式，最简单的是文本文件\n\nThe most straightforward are text files,\n来看一些简单文件格式，最简单的是文本文件\n\nalso know as TXT file, which contain...surprise! text.\n也叫 TXT 文件, 里面包含的是... 文字 （惊喜吧）\n\nLike all computer files, this is just a huge list of numbers, stored as binary.\n就像所有其它文件，文本文件只是一长串二进制数\n\nIf we look at the raw values of a text file in storage, it would look something like this:\n原始值看起来会像这样：\n\nWe can view this as decimal numbers instead of binary,\n可以转成十进制看，但帮助不大\n\nbut that still doesn't help us read the text.\n可以转成十进制看，但帮助不大\n\nThe key to interpreting this data is knowing that TXT files use ASCII,\n解码数据的关键是 ASCII 编码\n\na character encoding standard we discussed way back in Episode 4.\n一种字符编码标准，第 4 集讨论过.\n\nSo, in ASCII, our first value, 72, maps to the capital letter H.\n第一个值 72 \\N 在 ASCII 中是大写字母 H\n\nAnd in this way, we decode the whole file.\n以此类推 解码其他数字\n\nLet's look at a more complicated example: a WAVE File, also called a WAV,\n来看一个更复杂的例子：波形(Wave)文件，也叫 WAV \\N 它存音频数据\n\nwhich stores audio.\n来看一个更复杂的例子：波形(Wave)文件，也叫 WAV \\N 它存音频数据\n\nBefore we can correctly read the data, we need to know some information,\n在正确读取数据前，需要知道一些信息\n\nlike the bit rate and whether it's a single track or stereo.\n比如码率(bit rate)，以及是单声道还是立体声\n\nData about data, is called meta data.\n关于数据的数据，叫\"元数据\"(meta data)\n\nThis metadata is stored at the front of the file, ahead of any actual data,\n元数据存在文件开头，在实际数据前面 \\N 因此也叫 文件头(Header)\n\nin what's known as a Header.\n元数据存在文件开头，在实际数据前面 \\N 因此也叫 文件头(Header)\n\nHere's what the first 44 bytes of a WAV file looks like.\nWAV 文件的前 44 个字节长这样\n\nSome parts are always the same, like where it spells out W-A-V-E.\n有的部分总是一样的，比如写着 WAVE 的部分\n\nOther parts contain numbers that change depending on the data contained within.\n其他部分的内容，会根据数据变化\n\nThe audio data comes right behind the metadata, and it's stored as a long list of numbers.\n音频数据紧跟在元数据后面，是一长串数字\n\nThese values represent the amplitude of sound captured many times per second, and if you\n数字代表每秒捕获多次的声音幅度\n\nwant a primer on sound, check out our video all about it in Crash Course Physics.\n如果想学声音的基础知识 \\N 可以看物理速成课第18集\n\nLink in the dobblydoo.\n如果想学声音的基础知识 \\N 可以看物理速成课第18集\n\nAs an example, let's look at a waveform of me saying: \"hello!\" Hello!\n举个例子，看一下\"你好\"的波形\n\nNow that we've captured some sound, let's zoom into a little snippet.\n现在捕获到了一些声音，我们放大看一下\n\nA digital microphone, like the one in your computer or smartphone,\n电脑和手机麦克风，每秒可以对声音进行上千次采样\n\nsamples the sound pressure thousands of times.\n电脑和手机麦克风，每秒可以对声音进行上千次采样\n\nEach sample can be represented as a number.\n每次采样可以用一个数字表示\n\nLarger numbers mean higher sound pressure, what's called amplitude.\n声压越高数字越大，也叫\"振幅\"\n\nAnd these numbers are exactly what gets stored in a WAVE file!\nWAVE 文件里存的就是这些数据！\n\nThousands of amplitudes for every single second of audio!\n每秒上千次的振幅！\n\nWhen it's time to play this file, an audio program needs to actuate the computer's speakers\n播放声音文件时，扬声器会产生相同的波形\n\nsuch that the original waveform is emitted.\n播放声音文件时，扬声器会产生相同的波形\n\n\"Hello!\"\n\"你好！\"\n\nSo, now that you're getting the hang of file formats, let's talk about bitmaps or\n现在来谈谈 位图(Bitmap)，后缀 .bmp, 它存图片\n\nBMP, which store pictures.\n现在来谈谈 位图(Bitmap)，后缀 .bmp, 它存图片\n\nOn a computer, Pictures are made up of little tiny square elements called pixels.\n计算机上，图片由很多个叫\"像素\"的方块组成\n\nEach pixel is a combination of three colors: red, green and blue.\n每个像素由三种颜色组成：红，绿，蓝\n\nThese are called additive primary colors, and they can be mixed together to create any\n叫\"加色三原色\"，混在一起可以创造其它颜色\n\nother color on our electronic displays.\n叫\"加色三原色\"，混在一起可以创造其它颜色\n\nNow, just like WAV files, BMPs start with metadata,\n就像 WAV 文件一样，BMP 文件开头也是元数据 \\N 有图片宽度，图片高度，颜色深度\n\nincluding key values like image width, image height, and color depth.\n就像 WAV 文件一样，BMP 文件开头也是元数据 \\N 有图片宽度，图片高度，颜色深度\n\nAs an example, let's say the metadata specified an image 4 pixels wide, by 4 pixels tall,\n举例，假设元数据说图是 4像素宽 x 4像素高\n\nwith a 24-bit color depth - that's 8-bits for red, 8-bits for green, and 8-bits for blue.\n颜色深度 24 位\\N  8 位红色，8 位绿色，8 位蓝色\n\nAs a reminder, 8 bits is the same as one byte.\n提醒一下，8位 (bit) 和 1字节(byte)是一回事\n\nThe smallest number a byte can store is 0, and the largest is 255.\n一个字节能表示的最小数是 0，最大 255\n\nOur image data is going to look something like this:\n图像数据看起来会类似这样：\\N 来看看第一个像素的颜色\n\nLet's look at the color of our first pixel.\n图像数据看起来会类似这样：\\N 来看看第一个像素的颜色\n\nIt has 255 for its red value, 255 for green and 255 for blue.\n红色是255，绿色是255，蓝色也是255\n\nThis equates to full intensity red, full intensity green and full intensity blue.\n这等同于全强度红色，全强度绿色和全强度蓝色\n\nThese colors blend together on your computer monitor to become white.\n混合在一起变成白色\n\nSo our first pixel is white!\n所以第一个像素是白色！\n\nThe next pixel has a Red-Green-Blue, or RGB value of 255, 255, 0.\n下一个像素的红绿蓝值，或 RGB 值 \\N  255,255,0 是黄色！\n\nThat's the color yellow!\n下一个像素的红绿蓝值，或 RGB 值 \\N  255,255,0 是黄色！\n\nThe pixel after that has a RGB value of 0,0,0 - that's zero intensity everything, which is black.\n下一个像素是 0,0,0 ，黑色\n\nAnd the next one is yellow.\n下一个是黄色\n\nBecause the metadata specified this was a 4 by 4 image, we know that we've reached\n因为元数据说图片是 4x4 \\N 我们知道现在到了第一行结尾\n\nthe end of our first row of pixels.\n因为元数据说图片是 4x4 \\N 我们知道现在到了第一行结尾\n\nSo, we need to drop down a row.\n所以换一行\n\nThe next RGB value is 255,255,0 yellow again.\n下一个 RGB 值是 255,255,0，又是黄色\n\nOkay, let's go ahead and read all the pixels in our 4x4 image tada!\n好，我们读完剩下的像素\n\nA very low resolution pac-man!\n一个低分辨率的吃豆人\n\nObviously this is a simple example of a small image,\n刚才显然只是一个简单例子，但这张图片也可以用 BMP 存\n\nbut we could just as easily store this image in a BMP.\n刚才显然只是一个简单例子，但这张图片也可以用 BMP 存\n\nI want to emphasize again that it doesn't matter if it's a text file, WAV,\n我想再次强调，不管是文本文件，WAV，BMP\n\nBMP, or fancier formats we don't have time to discuss,\n或是我们没时间讨论的其他格式\n\nUnder the hood, they're all the same: long lists of numbers, stored as binary, on a storage device.\n文件在底层全是一样的： 一长串二进制\n\nFile formats are the key to reading and understanding the data inside.\n为了知道文件是什么，文件格式至关重要\n\nNow that you understand files a little better, let's move on to\n现在你对文件更了解了 \\N 我们接下来讨论计算机怎么存文件\n\nhow computers go about storing them.\n现在你对文件更了解了 \\N 我们接下来讨论计算机怎么存文件\n\nEven though the underlying storage medium might be\n虽然硬件可能是磁带，磁鼓，磁盘或集成电路\n\na strip of tape, a drum, a disk, or integrated circuits...\n虽然硬件可能是磁带，磁鼓，磁盘或集成电路\n\nhardware and software abstractions let us think of storage as a\n通过软硬件抽象后，可以看成一排能存数据的桶\n\nlong line of little buckets that store values.\n通过软硬件抽象后，可以看成一排能存数据的桶\n\nIn the early days, when computers only performed one computation\n在很早期时，计算机只做一件事，比如算火炮射程表 \\N 整个储存器就像一整个文件\n\nlike calculating artillery range tables. the entire storage operated like one big file.\n在很早期时，计算机只做一件事，比如算火炮射程表 \\N 整个储存器就像一整个文件\n\nData started at the beginning of storage, and then filled it up in order as output was\n数据从头存到尾，直到占满\n\nproduced, up to the storage capacity.\n数据从头存到尾，直到占满\n\nHowever, as computational power and storage capacity improved, it became possible, and\n但随着计算能力和存储容量的提高 \\N 存多个文件变得非常有用\n\nuseful, to store more than one file at a time.\n但随着计算能力和存储容量的提高 \\N 存多个文件变得非常有用\n\nThe simplest option is to store files back-to-back.\n最简单的方法  是把文件连续存储\n\nThis can work... but how does the computer know where files begin and end?\n这样能用, \\N 但怎么知道文件开头和结尾在哪里？\n\nStorage devices have no notion of files C they're just a mechanism for storing lots of bits.\n储存器没有文件的概念，只是存储大量位\n\nSo, for this to work, we need to have a special file that records where other ones are located.\n所以为了存多个文件 \\N 需要一个特殊文件，记录其他文件的位置\n\nThis goes by many names, but a good general term is Directory File.\n这个特殊文件有很多名字，这里泛称 \"目录文件\"\n\nMost often, it's kept right at the front of storage, so we always know where to access it.\n这个文件经常存在最开头，方便找\n\nLocation zero!\n位置 0！\n\nInside the Directory File are the names of all the other files in storage.\n目录文件里，存所有其他文件的名字\n\nIn our example, they each have a name, followed by a period\n格式是文件名 + 一个句号 + 扩展名，比如 BMP 或 WAV\n\nand end with what's called a File Extension, like \"BMP\" or \"WAV\".\n格式是文件名 + 一个句号 + 扩展名，比如 BMP 或 WAV\n\nThose further assist programs in identifying file types.\n扩展名帮助得知文件类型\n\nThe Directory File also stores metadata about these files, like when they were created and\n目录文件还存文件的元数据，比如创建时间\n\nlast modified, who the owner is, and if it can be read, written or both.\n最后修改时间，文件所有者是谁\\N是否能读/写  或读写都行\n\nBut most importantly, the directory file contains where these files\n最重要的是，目录文件有文件起始位置和长度\n\nbegin in storage, and how long they are.\n最重要的是，目录文件有文件起始位置和长度\n\nIf we want to add a file, remove a file, change a filename, or similar,\n如果要添加文件，删除文件，更改文件名等\n\nwe have to update the information in the Directory File.\n必须更新目录文件\n\nIt's like the Table of Contents in a book, if you make a chapter shorter, or move it\n就像书的目录，如果缩短或移动了一个章节 \\N 要更新目录，不然页码对不上\n\nsomewhere else, you have to update the table of contents, otherwise the page numbers won't match!\n就像书的目录，如果缩短或移动了一个章节 \\N 要更新目录，不然页码对不上\n\nThe Directory File, and the maintenance of it, is an example of a very basic File System,\n目录文件，以及对目录文件的管理 \\N 是一个非常简单的文件系统例子\n\nthe part of an Operating System that manages and keep track of stored files.\n文件系统专门负责管理文件\n\nThis particular example is a called a Flat File System, because they're all stored at one level.\n刚刚的例子叫\"平面文件系统\" \\N因为文件都在同一个层次\n\nIt's flat!\n平的！\n\nOf course, packing files together, back-to-back, is a bit of a problem,\n当然，把文件前后排在一起  有个问题\n\nbecause if we want to add some data to let's say \"todo.txt\",\n如果给 todo.txt 加一点数据 \\N 会覆盖掉后面 carrie.bmp 的一部分\n\nthere's no room to do it without overwriting part of \"carrie.bmp\".\n如果给 todo.txt 加一点数据 \\N 会覆盖掉后面 carrie.bmp 的一部分\n\nSo modern File Systems do two things.\n所以现代文件系统会做两件事\n\nFirst, they store files in blocks.\n1. 把空间划分成一块块 \\N 导致有一些 \"预留空间\" 可以方便改动\n\nThis leaves a little extra space for changes, called slack space.\n1. 把空间划分成一块块 \\N 导致有一些 \"预留空间\" 可以方便改动\n\nIt also means that all file data is aligned to a common size, which simplifies management.\n同时也方便管理\n\nIn a scheme like this, our Directory File needs to keep track of\n用这样的方案，目录文件要记录文件在哪些块里\n\nwhat block each one is stored in.\n用这样的方案，目录文件要记录文件在哪些块里\n\nThe second thing File Systems do, is allow files to be broken up into chunks\n2. 拆分文件，存在多个块里\n\nand stored across many blocks.\n2. 拆分文件，存在多个块里\n\nSo let's say we open \"todo.txt\", and we add a few more items then the file becomes\n假设打开 todo.txt 加了些内容\\N 文件太大存不进一块里\n\ntoo big to be saved in its one block.\n假设打开 todo.txt 加了些内容\\N 文件太大存不进一块里\n\nWe don't want to overwrite the neighboring one, so instead, the File System allocates\n我们不想覆盖掉隔壁的块，所以文件系统会分配 \\N 一个没使用的块，容纳额外的数据\n\nan unused block, which can accommodate extra data.\n我们不想覆盖掉隔壁的块，所以文件系统会分配 \\N 一个没使用的块，容纳额外的数据\n\nWith a File System scheme like this, the Directory File needs to store\n目录文件会记录不止一个块，而是多个块\n\nnot just one block per file, but rather a list of blocks per file.\n目录文件会记录不止一个块，而是多个块\n\nIn this way, we can have files of variable sizes that can be easily\n只要分配块，文件可以轻松增大缩小\n\nexpanded and shrunk, simply by allocating and deallocating blocks.\n只要分配块，文件可以轻松增大缩小\n\nIf you watched our episode on Operating Systems, this should sound a lot like Virtual Memory.\n如果你看了第18集 操作系统 \\N 这听起来很像\"虚拟内存\"\n\nConceptually it's very similar!\n概念上讲的确很像！\n\nNow let's say we want to delete \"carrie.bmp\".\n假设想删掉 carrie.bmp \\N 只需要在目录文件删掉那条记录\n\nTo do that, we can simply remove the entry from the Directory File.\n假设想删掉 carrie.bmp \\N 只需要在目录文件删掉那条记录\n\nThis, in turn, causes one block to become free.\n让一块空间变成了可用\n\nNote that we didn't actually erase the file's data in storage, we just deleted the record of it.\n注意这里没有擦除数据，只是把记录删了\n\nAt some point, that block will be overwritten with new data, but until then, it just sits there.\n之后某个时候，那些块会被新数据覆盖 \\N 但在此之前，数据还在原处\n\nThis is one way that computer forensic teams can \"recover\" data from computers even\n所以计算机取证团队可以\"恢复\"数据\n\nthough people think it has been deleted. Crafty!\n虽然别人以为数据已经\"删了\", 狡猾！\n\nOk, let's say we add even more items to our todo list, which causes the File System\n假设往 todo.txt 加了更多数据 \\N 所以操作系统分配了一个新块，用了刚刚 carrie.bmp 的块\n\nto allocate yet another block to the file, in this case,\n假设往 todo.txt 加了更多数据 \\N 所以操作系统分配了一个新块，用了刚刚 carrie.bmp 的块\n\nrecycling the block freed from carrie.bmp.\n假设往 todo.txt 加了更多数据 \\N 所以操作系统分配了一个新块，用了刚刚 carrie.bmp 的块\n\nNow our \"todo.txt\" is stored across 3 blocks, spaced apart, and also out of order.\n现在 todo.txt 在 3 个块里，隔开了，顺序也是乱的\n\nFiles getting broken up across storage like this is called fragmentation.\n这叫碎片\n\nIt's the inevitable byproduct of files being created, deleted and modified.\n碎片是增/删/改文件导致的，不可避免\n\nFor many storage technologies, this is bad news.\n对很多存储技术来说，碎片是坏事\n\nOn magnetic tape, reading todo.txt into memory would require\n如果 todo.txt 存在磁带上，读取文件要\n\nseeking to block 1, then fast forwarding to block 5, and then rewinding to block 3\n先读块1, 然后快进到块5，然后往回转到块2\n\nthat's a lot of back and forth!\n来回转个半天\n\nIn real world File Systems, large files might be stored across hundreds of blocks,\n现实世界中，大文件可能存在数百个块里\n\nand you don't want to have to wait five minutes for your files to open.\n你可不想等五分钟才打开文件\n\nThe answer is defragmentation!\n答案是碎片整理！\n\nThat might sound like technobabble, but the process is really simple,\n这个词听起来好像很复杂，但实际过程很简单\n\nand once upon a time it was really fun to watch!\n以前看计算机做碎片整理 真的很有趣！\n\nThe computer copies around data so that files have blocks located together\n计算机会把数据来回移动，排列成正确的顺序\n\nin storage and in the right order.\n计算机会把数据来回移动，排列成正确的顺序\n\nAfter we've defragged, we can read our todo file,\n整理后 todo.txt 在 1 2 3，方便读取.\n\nnow located in blocks 1 through 3, in a single, quick read pass.\n整理后 todo.txt 在 1 2 3，方便读取.\n\nSo far, we've only been talking about Flat File Systems,\n目前只说了平面文件系统，文件都在同一个目录里.\n\nwhere they're all stored in one directory.\n目前只说了平面文件系统，文件都在同一个目录里.\n\nThis worked ok when computers only had a little bit of storage,\n如果存储空间不多，这可能就够用了 \\N 因为只有十几个文件\n\nand you might only have a dozen or so files.\n如果存储空间不多，这可能就够用了 \\N 因为只有十几个文件\n\nBut as storage capacity exploded, like we discussed last episode,\n但上集说过，容量爆炸式增长，文件数量也飞速增长\n\nso did the number of files on computers.\n但上集说过，容量爆炸式增长，文件数量也飞速增长\n\nVery quickly, it became impractical to store all files together at one level.\n很快，所有文件都存在同一层变得不切实际\n\nJust like documents in the real world, it's handy to store related files together in folders.\n就像现实世界\\N 相关文件放在同一个文件夹会方便很多\n\nThen we can put connected folders into folders, and so on.\n然后文件夹套文件夹.\n\nThis is a Hierarchical File System, and its what your computer uses.\n这叫\"分层文件系统\"，你的计算机现在就在用这个.\n\nThere are a variety of ways to implement this, but let's stick with the File System example\n实现方法有很多种，我们用之前的例子来讲重点好了\n\nwe've been using to convey the main idea.\n实现方法有很多种，我们用之前的例子来讲重点好了\n\nThe biggest change is that our Directory File needs to be able to point not just to files,\n最大的变化是 目录文件不仅要指向文件, 还要指向目录\n\nbut also other directories.\n最大的变化是 目录文件不仅要指向文件, 还要指向目录\n\nTo keep track of what's a file and what's a directory, we need some extra metadata.\n我们需要额外元数据  来区分开文件和目录，\n\nThis Directory File is the top-most one, known as the Root Directory.\n这个目录文件在最顶层，因此叫根目录\n\nAll other files and folders lie beneath this directory along various file paths.\n所有其他文件和文件夹，都在根目录下\n\nWe can see inside of our \"Root\" Directory File that we have 3 files\n图中可以看到根目录文件有3个文件 \\N 2个子文件夹：\"音乐\"和\"照片\"\n\nand 2 subdirectories: music and photos.\n图中可以看到根目录文件有3个文件 \\N 2个子文件夹：\"音乐\"和\"照片\"\n\nIf we want to see what's stored in our music directory, we have to go to that block and\n如果想知道\"音乐\"文件夹里有什么 \\N 必须去那边读取目录文件（格式和根目录文件一样）\n\nread the Directory File located there; the format is the same as our root directory.\n如果想知道\"音乐\"文件夹里有什么 \\N 必须去那边读取目录文件（格式和根目录文件一样）\n\nThere's a lot of great songs in there!\n有很多好歌啊！\n\nIn addition to being able to create hierarchies of unlimited depth,\n除了能做无限深度的文件夹 \\N 这个方法也让我们可以轻松移动文件\n\nthis method also allows us to easily move around files.\n除了能做无限深度的文件夹 \\N 这个方法也让我们可以轻松移动文件\n\nSo, if we wanted to move \"theme.wav\" from our root directory to the music directory,\n如果想把 theme.wav 从根目录移到音乐目录\n\nwe don't have to re-arrange any blocks of data.\n不用移动任何数据块\n\nWe can simply modify the two Directory Files, removing an entry from one and adding it to another.\n只需要改两个目录文件 \\N 一个文件里删一条记录，另一个文件里加一条记录\n\nImportantly, the theme.wav file stays in block 5.\ntheme.wav 依然在块5\n\nSo that's a quick overview of the key principles of File Systems.\n文件系统的几个重要概念  现在介绍完了.\n\nThey provide yet another way to move up a new level of abstraction.\n它提供了一层新抽象！\n\nFile systems allow us to hide the raw bits stored on magnetic tape, spinning disks and\n文件系统使我们不必关心 \\N 文件在磁带或磁盘的具体位置\n\nthe like, and they let us think of data as neatly organized and easily accessible files.\n整理和访问文件更加方便\n\nWe even started talking about users, not programmers, manipulating data,\n我们像普通用户一样直观操纵数据，比如打开和整理文件\n\nlike opening files and organizing them,\n我们像普通用户一样直观操纵数据，比如打开和整理文件\n\nforeshadowing where the series will be going in a few episodes.\n接下来几集也会从用户角度看问题\n\nI'll see  you next week.\n下周见\n\nThis episode is brought to you by Curiosity Stream.\n本集由 Curiosity Stream 赞助播出\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode we talked about Files, bundles of data, stored on a computer, that\n上集我们讨论了文件格式，如何编码文字，声音，图片\n\nare formatted and arranged to encode information, like text, sound or images.\n上集我们讨论了文件格式，如何编码文字，声音，图片\n\nWe even discussed some basic file formats, like text, wave, and bitmap.\n还举了具体例子 .txt .wav .bmp\n\nWhile these formats are perfectly fine and still used today,\n这些格式虽然管用，而且现在还在用 \\N 但它们的简单性意味着效率不高\n\ntheir simplicity also means they're not very efficient.\n这些格式虽然管用，而且现在还在用 \\N 但它们的简单性意味着效率不高\n\nIdeally, we want files to be as small as possible, so we can store lots of them without filling\n我们希望文件能小一点，这样能存大量文件，传输也会快一些\n\nup our hard drives, and also transmit them more quickly.\n我们希望文件能小一点，这样能存大量文件，传输也会快一些\n\nNothing is more frustrating than waiting for an email attachment to download. Ugh!\n等邮件附件下载烦死人了\n\nThe answer is compression, which literally squeezes data into a smaller size.\n解决方法是 压缩，把数据占用的空间压得更小\n\nTo do this, we have to encode data using fewer bits than the original representation.\n用更少的位(bit)来表示数据\n\nThat might sound like magic, but it's actually computer science!\n听起来像魔法，但其实是计算机科学！\n\nLets return to our old friend from last episode, Mr. Pac-man!\n我们继续用上集的 吃豆人例子，图像是 4像素x4像素\n\nThis image is 4 pixels by 4 pixels.\n我们继续用上集的 吃豆人例子，图像是 4像素x4像素\n\nAs we discussed, image data is typically stored as a list of pixel values.\n之前说过，图像一般存成一长串像素值\n\nTo know where rows end, image files have metadata, which defines properties like dimensions.\n为了知道一行在哪里结束 \\N 图像要有元数据，写明尺寸等属性\n\nBut, to keep it simple today, we're not going to worry about it.\n但为了简单起见，今天忽略这些细节\n\nIf you mix full intensity red, green and blue - that's 255 for all\n如果红绿蓝都是 255 会得到白色\n\nthree values - you get the color white.\n如果红绿蓝都是 255 会得到白色\n\nIf you mix full intensity red and green, but no blue (it's 0), you get yellow.\n如果混合 255红色和255绿色，会得到黄色\n\nWe have 16 pixels in our image, and each of those needs 3 bytes of color data.\n这个图像有16个像素(4x4),  每个像素3个字节\n\nThat means this image's data will consume 48 bytes of storage.\n总共占48个字节（16x3=48）\n\nBut, we can compress the data and pack it into a smaller number of bytes than 48!\n但我们可以压缩到少于 48 个字节\n\nOne way to compress data is to reduce repeated or redundant information.\n一种方法是 减少重复信息\n\nThe most straightforward way to do this is called Run-Length Encoding.\n最简单的方法叫 游程编码(Run-Length Encoding)\n\nThis takes advantage of the fact that there are often runs of identical values in files.\n适合经常出现相同值的文件\n\nFor example, in our pac-man image, there are 7 yellow pixels in a row.\n比如吃豆人 有7个连续黄色像素\n\nInstead of encoding redundant data: yellow pixel, yellow pixel, yellow pixel, and so\n与其全存下来：黄色，黄色，黄色...\n\non, we can just say \"there's 7 yellow pixels in a row\" by inserting\n可以插入一个额外字节，代表有7个连续黄色像素\n\nan extra byte that specifies the length of the run, like so:\n可以插入一个额外字节，代表有7个连续黄色像素\n\nAnd then we can eliminate the redundant data behind it.\n然后删掉后面的重复数据.\n\nTo ensure that computers don't get confused with which bytes are run lengths and which\n为了让计算机能分辨哪些字节是\"长度\" 哪些字节是\"颜色\" \\N 格式要一致\n\nbytes represent color, we have to be consistent in how we apply this scheme.\n为了让计算机能分辨哪些字节是\"长度\" 哪些字节是\"颜色\" \\N 格式要一致\n\nSo, we need to preface all pixels with their run-length.\n所以我们要给所有像素前面标上长度\n\nIn some cases, this actually adds data, but on the whole, we've dramatically reduced\n有时候数据反而会变多，但就这个例子而言\n\nthe number of bytes we need to encode this image.\n我们大大减少了字节数，之前是48 现在是24\n\nWe're now at 24 bytes, down from 48.\n我们大大减少了字节数，之前是48 现在是24\n\nThat's 50% smaller!\n小了50％！省了很多空间！\n\nA huge saving!\n小了50％！省了很多空间！\n\nAlso note that we haven't lost any data.\n还有，我们没有损失任何数据 \\N 我们可以轻易恢复到原来的数据\n\nWe can easily expand this back to the original form without any degradation.\n还有，我们没有损失任何数据 \\N 我们可以轻易恢复到原来的数据\n\nA compression technique that has this characteristic is called\n这叫\"无损压缩\"，没有丢失任何数据\n\nlossless compression, because we don't lose anything.\n这叫\"无损压缩\"，没有丢失任何数据\n\nThe decompressed data is identical to the original before compression, bit for bit.\n解压缩后，数据和压缩前完全一样\n\nLet's take a look at another type of lossless compression, where\n我们来看另一种无损压缩，它用更紧凑的方式表示数据块\n\nblocks of data are replaced by more compact representations.\n我们来看另一种无损压缩，它用更紧凑的方式表示数据块\n\nThis is sort of like \" don't forget to be awesome \" being replaced by DFTBA.\n有点像 \"别忘了变厉害\" 简写成 DFTBA\n\nTo do this, we need a dictionary that stores the mapping from codes to data.\n为此，我们需要一个字典，存储\"代码\"和\"数据\"间的对应关系\n\nLets see how this works for our example.\n我们看个例子\n\nWe can view our image as not just a string of individual pixels,\n我们可以把图像看成一块块，而不是一个个像素\n\nbut as little blocks of data.\n我们可以把图像看成一块块，而不是一个个像素\n\nFor simplicity, we're going to use pixel pairs, which are 6 bytes long,\n为了简单，我们把2个像素当成1块（占6个字节）\n\nbut blocks can be any size.\n但你也可以定成其他大小\n\nIn our example, there are only four pairings: White-yellow, black-yellow,\n我们只有四对： 白黄 黑黄 黄黄 白白\n\nyellow-yellow and white-white.\n我们只有四对： 白黄 黑黄 黄黄 白白\n\nThose are the data blocks in our dictionary we want to generate compact codes for.\n我们会为这四对  生成紧凑代码(compact codes)\n\nWhat's interesting, is that these blocks occur at different frequencies.\n有趣的是，这些块的出现频率不同\n\nOne method for generating efficient codes is building a Huffman Tree, invented by David\n1950年代 大卫·霍夫曼 发明了一种高效编码方式叫 \\N \"霍夫曼树\"（Huffman Tree） 当时他是麻省理工学院的学生\n\nHuffman while he was a student at MIT in the 1950s.\n1950年代 大卫·霍夫曼 发明了一种高效编码方式叫 \\N \"霍夫曼树\"（Huffman Tree） 当时他是麻省理工学院的学生\n\nHis algorithm goes like this.\n算法是这样的\n\nFirst, you layout all the possible blocks and their frequencies.\n首先，列出所有块和出现频率，每轮选两个最低的频率\n\nAt every round, you select the two with the lowest frequencies.\n首先，列出所有块和出现频率，每轮选两个最低的频率\n\nHere, that's Black-Yellow and White-White, each with a frequency of 1.\n这里 黑黄 和 白白 的频率最低，它们都是 1\n\nYou combine these into a little tree. which have a combined frequency of 2,\n可以把它们组成一个树，总频率 2\n\nso we record that.\n可以把它们组成一个树，总频率 2\n\nAnd now one step of the algorithm done.\n现在完成了一轮算法\n\nNow we repeat the process.\n现在我们重复这样做\n\nThis time we have three things to choose from.\n这次有3个可选\n\nJust like before, we select the two with the lowest frequency, put them into a little tree,\n就像上次一样，选频率最低的两个，放在一起，并记录总频率\n\nand record the new total frequency of all the sub items.\n就像上次一样，选频率最低的两个，放在一起，并记录总频率\n\nOk, we're almost done.\n好，我们快完成了\n\nThis time it's easy to select the two items with the lowest frequency\n这次很简单，因为只有2个选择\n\nbecause there are only two things left to pick.\n这次很简单，因为只有2个选择\n\nWe combine these into a tree, and now we're done!\n把它们组合成一棵树就完成了！\n\nOur tree looks like this, and it has a very cool property: it's arranged by frequency,\n现在看起来像这样，它有一个很酷的属性：按频率排列\n\nwith less common items lower down.\n频率低的在下面\n\nSo, now we have a tree, but you may be wondering how this gets us to a dictionary.\n现在有了一棵树，你可能在想  \"怎么把树变成字典？\"\n\nWell, we use our frequency-sorted tree to generate the codes we need\n我们可以把每个分支用 0 和 1 标注，就像这样\n\nby labeling each branch with a 0 or a 1, like so.\n我们可以把每个分支用 0 和 1 标注，就像这样\n\nWith this, we can write out our code dictionary.\n现在可以生成字典\n\nYellow-yellow is encoded as just a single 0.  White-yellow is encoded as 10\n黄黄 编码成 0  \\N 白黄 编码成 10 \\N 黑黄 编码成 110 \\N 白白 编码成 111\n\nBlack-Yellow is 1 1 0. and finally white-white is 1 1 1.\n黄黄 编码成 0  \\N 白黄 编码成 10 \\N 黑黄 编码成 110 \\N 白白 编码成 111\n\nThe really cool thing about these codewords is that there's no way to\n酷的地方是  它们绝对不会冲突\n\nhave conflicting codes, because each path down the tree is unique.\n因为树的每条路径是唯一的\n\nThis means our codes are prefix-free, that is no code starts with another complete code.\n意味着代码是\"无前缀\"的，没有代码是以另一个代码开头的\n\nNow, let's return to our image data and compress it!\n现在我们来压缩！\n\n-- NOT BYTES -- BITS!! That's less than 2 bytes of data!\n注意是位(bit)！ 不是字节(byte)！ \\N 14位(bit) 还不到2个字节(byte)！\n\nBut, don't break out the champagne quite yet!\n但，先别急着开香槟！\n\nThis data is meaningless unless we also save our code dictionary.\n字典也要保存下来，否则 14 bit 毫无意义\n\nSo, we'll need to append it to the front of the image data, like this.\n所以我们把字典 加到 14 bit 前面，就像这样\n\nNow, including the dictionary, our image data is 30 bytes long.\n现在加上字典，图像是 30 个字节(bytes)  \\N 比 48 字节好很多\n\nThat's still a significant improvement over 48 bytes.\n现在加上字典，图像是 30 个字节(bytes)  \\N 比 48 字节好很多\n\nThe two approaches we discussed,\n\"消除冗余\"和\"用更紧凑的表示方法\"，这两种方法通常会组合使用\n\nremoving redundancies and using more compact representations, are often combined,\n\"消除冗余\"和\"用更紧凑的表示方法\"，这两种方法通常会组合使用\n\nand underlie almost all lossless compressed file formats,\n几乎所有无损压缩格式都用了它们 \\N 比如 GIF, PNG, PDF, ZIP\n\nlike GIF, PNG, PDF and ZIP files.\n几乎所有无损压缩格式都用了它们 \\N 比如 GIF, PNG, PDF, ZIP\n\nBoth run-length encoding and dictionary coders are lossless compression techniques.\n游程编码 和 字典编码 都是无损压缩\n\nNo information is lost; when you decompress, you get the original file.\n压缩时不会丢失信息，解压后，数据和之前完全一样\n\nThat's really important for many types of files.\n无损对很多文件很重要\n\nLike, it'd be very odd if I zipped up a word document to send to you,\n比如我给你发了个压缩的 word 文档\\N 你解压之后发现内容变了，这就很糟糕了\n\nand when you decompressed it on your computer, the text was different.\n比如我给你发了个压缩的 word 文档\\N 你解压之后发现内容变了，这就很糟糕了\n\nBut, there are other types of files where we can get away with little changes, perhaps\n但其他一些文件，丢掉一些数据没什么关系\n\nby removing unnecessary or less important information, especially information\n丢掉那些人类看不出区别的数据\n\nthat human perception is not good at detecting.\n丢掉那些人类看不出区别的数据\n\nAnd this trick underlies most lossy compression techniques.\n大多数有损压缩技术，都用到了这点\n\nThese tend to be pretty complicated, so we're going to attack this at a conceptual level.\n实际细节比较复杂，所以我们讲概念就好\n\nLet's take sound as an example.\n以声音为例，你的听力不是完美的\n\nYour hearing is not perfect.\n以声音为例，你的听力不是完美的\n\nWe can hear some frequencies of sound better than others.\n有些频率我们很擅长，其他一些我们根本听不见，比如超声波\n\nAnd there are some we can't hear at all, like ultrasound.\n有些频率我们很擅长，其他一些我们根本听不见，比如超声波\n\nUnless you're a bat.\n除非你是蝙蝠\n\nBasically, if we make a recording of music, and there's data in the ultrasonic frequency range,\n举个例子，如果录音乐，超声波数据都可以扔掉 \\N 因为人类听不到超声波\n\nwe can discard it, because we know that humans can't hear it.\n举个例子，如果录音乐，超声波数据都可以扔掉 \\N 因为人类听不到超声波\n\nOn the other hand, humans are very sensitive to frequencies in the vocal range, like people\n另一方面，人类对人声很敏感，所以应该尽可能保持原样\n\nsinging, so it's best to preserve quality there as much as possible.\n另一方面，人类对人声很敏感，所以应该尽可能保持原样\n\nDeep bass is somewhere in between.\n低音介于两者之间，人类听得到，但不怎么敏感\n\nHumans can hear it, but we're less attuned to it.\n低音介于两者之间，人类听得到，但不怎么敏感\n\nWe mostly sense it.\n一般是感觉到震动\n\nLossy audio compressors takes advantage of this, and encode different\n有损音频压缩利用这一点，用不同精度编码不同频段\n\nfrequency bands at different precisions.\n有损音频压缩利用这一点，用不同精度编码不同频段\n\nEven if the result is rougher, it's likely that users won't perceive the difference.\n听不出什么区别，不会明显影响体验\n\nOr at least it doesn't dramatically affect the experience.\n听不出什么区别，不会明显影响体验\n\nAnd here comes the hate mail from the audiophiles!\n音乐发烧友估计要吐槽了！\n\nYou encounter this type of audio compression all the time.\n日常生活中你会经常碰到这类音频压缩\n\nIt's one of the reasons you sound different on a cellphone versus in person.\n所以你在电话里的声音 和现实中不一样\n\nThe audio data is being compressed, allowing more people to take calls at once.\n压缩音频是为了让更多人能同时打电话\n\nAs the signal quality or bandwidth get worse, compression algorithms remove more data,\n如果网速变慢了，压缩算法会删更多数据\n\nfurther reducing precision, which is why Skype calls sometimes sound like robots talking.\n进一步降低声音质量，所以 Skype 通话有时听起来像机器人\n\nCompared to an uncompressed audio format, like a WAV or FLAC (there we go, got the audiophiles back)\n和没压缩的音频格式相比，比如 WAV 或 FLAC \\N ( 这下音乐发烧友满意了）\n\ncompressed audio files, like MP3s, are often 10 times smaller.\n压缩音频文件如 MP3，能小10倍甚至更多.\n\nThat's a huge saving!\n省了超多空间！\n\nAnd it's why I've got a killer music collection on my retro iPod.\n所以我的旧 iPod 上有一堆超棒的歌\n\nDon't judge.\n别批判我\n\nThis idea of discarding or reducing precision in a manner that aligns with human perception\n这种删掉人类无法感知的数据的方法，叫\"感知编码\"\n\nis called perceptual coding,\n这种删掉人类无法感知的数据的方法，叫\"感知编码\"\n\nand it relies on models of human perception,\n它依赖于人类的感知模型，模型来自\"心理物理学\"领域\n\nwhich come from a field of study called Psychophysics.\n它依赖于人类的感知模型，模型来自\"心理物理学\"领域\n\nThis same idea is the basis of lossy compressed image formats, most famously JPEGs.\n这是各种\"有损压缩图像格式\"的基础，最著名的是 JPEG\n\nLike hearing, the human visual system is imperfect.\n就像听力一样，人的视觉系统也不是完美的.\n\nWe're really good at detecting sharp contrasts, like the edges of objects,\n我们善于看到尖锐对比，比如物体的边缘\n\nbut our perceptual system isn't so hot with subtle color variations.\n但我们看不出颜色的细微变化\n\nJPEG takes advantage of this by breaking images up into blocks of 8x8 pixels,\nJPEG 利用了这一点，把图像分解成 8x8 像素块\n\nthen throwing away a lot of the high-frequency spatial data.\n然后删掉大量高频率空间数据\n\nFor example, take this photo of our directors dog - Noodle.\n举个例子，这是导演的狗，面面\n\nSo cute!\n超可爱！\n\nLet's look at a patch of 8x8 pixels.\n我们来看其中一个 8x8 像素\n\nPretty much every pixel is different from its neighbor,\n几乎每个像素都和相邻像素不同，用无损技术很难压缩 \\N 因为太多不同点了\n\nmaking it hard to compress with loss-less techniques because there's just a lot going on.\n几乎每个像素都和相邻像素不同，用无损技术很难压缩 \\N 因为太多不同点了\n\nLots of little details.\n很多小细节\n\nBut human perception doesn't register all those details.\n但人眼看不出这些细节\n\nSo, we can discard a lot of that detail, and replace it with a simplified patch like this.\n因此可以删掉很多，用这样一个简单的块来代替\n\nThis maintains the visual essence, but might only use 10% of the data.\n这看起来一样，但可能只占10％的原始数据\n\nWe can do this for all the patches in the image and get this result.\n我们可以对所有 8x8 块做一样的操作\n\nYou can still see it's a dog, but the image is rougher.\n图片依然可以认出是一只狗，只是更粗糙一些\n\nSo, that's an extreme example, going from a slightly compressed JPEG to a highly compressed one,\n以上例子比较极端，进行了高度压缩，只有原始大小的八分之一\n\none-eighth the original file size.\n以上例子比较极端，进行了高度压缩，只有原始大小的八分之一\n\nOften, you can get away with a quality somewhere in between, and perceptually,\n通常你可以取得平衡，图片看起来差不多，但文件小不少\n\nit's basically the same as the original.\n通常你可以取得平衡，图片看起来差不多，但文件小不少\n\nCan you tell the difference between the two?\n你看得出两张图的区别吗？\n\nProbably not, but I should mention that video compression plays a role in that too,\n估计看不出，但我想提一下，视频压缩也造成了影响\n\nsince I'm literally being compressed in a video right now.\n毕竟你现在在看视频啊\n\nVideos are really just long sequences of images, so a lot of what I said\n视频只是一长串连续图片 \\N 所以图片的很多方面也适用于视频\n\nabout them applies here too.\n视频只是一长串连续图片 \\N 所以图片的很多方面也适用于视频\n\nBut videos can do some extra clever stuff, because between frames,\n但视频可以做一些小技巧 \\N 因为帧和帧之间很多像素一样\n\na lot of pixels are going to be the same.\n但视频可以做一些小技巧 \\N 因为帧和帧之间很多像素一样\n\nLike this whole background behind me!\n比如我后面的背景！\n\nThis is called temporal redundancy.\n这叫 时间冗余\n\nWe don't need to re-transmit those pixels every frame of the video.\n视频里不用每一帧都存这些像素 \\N 可以只存变了的部分\n\nWe can just copy patches of data forward.\n视频里不用每一帧都存这些像素 \\N 可以只存变了的部分\n\nWhen there are small pixel differences, like the readout on this frequency generator behind me,\n当帧和帧之间有小小的差异时，比如后面这个频率发生器\n\nmost video formats send data that encodes just the difference between patches,\n很多视频编码格式，只存变化的部分\n\nwhich is more efficient than re-transmitting all the pixels afresh, again taking advantage\n这比存所有像素更有效率 \\N 利用了帧和帧之间的相似性\n\nof inter-frame similarity.\n这比存所有像素更有效率 \\N 利用了帧和帧之间的相似性\n\nThe fanciest video compression formats go one step further.\n更高级的视频压缩格式 会更进一步\n\nThey find patches that are similar between frames, and not only copy them forward, with\n找出帧和帧之间相似的补丁 \\N 然后用简单效果实现，比如移动和旋转\n\nor without differences, but also can apply simple effects to them, like a shift or rotation.\n找出帧和帧之间相似的补丁 \\N 然后用简单效果实现，比如移动和旋转\n\nThey can also lighten or darken a patch between frames.\n变亮和变暗\n\nSo, if I move my hand side to side like this the video compressor will identify the similarity,\n如果我这样摆手，视频压缩器会识别到相似性\n\ncapture my hand in one or more patches, then just move these patches around between frames.\n用一个或多个补丁代表我的手，然后帧之间直接移动这些补丁\n\nYou're actually seeing my hand from the past kinda freaky, but it uses a lot less data.\n所以你看到的是我过去的手（不是实时的）\\N 有点可怕 但数据量少得多\n\nMPEG-4 videos, a common standard, are often 20 to 200 times\nMPEG-4 是常见标准，可以比原文件小20倍到200倍\n\nsmaller than the original, uncompressed file.\nMPEG-4 是常见标准，可以比原文件小20倍到200倍\n\nHowever, encoding frames as translations and rotations of patches from previous frames\n但用补丁的移动和旋转 来更新画面\n\ncan go horribly wrong when you compress too heavily, and there isn't\n当压缩太严重时会出错 \\N 没有足够空间更新补丁内的像素\n\nenough space to update pixel data inside of the patches.\n当压缩太严重时会出错 \\N 没有足够空间更新补丁内的像素\n\nThe video player will forge ahead, applying the right motions,\n即使补丁是错的，视频播放器也会照样播放\n\neven if the patch data is wrong.\n即使补丁是错的，视频播放器也会照样播放\n\nAnd this leads to some hilarious and trippy effects, which I'm sure you've seen.\n导致一些怪异又搞笑的结果，你肯定见过这些.\n\nOverall, it's extremely useful to have compression techniques for all the types of data I discussed today.\n总的来说，压缩对大部分文件类型都有用\n\n(I guess our imperfect vision and hearing are \"useful,\" too.)\n从这个角度来讲，人类不完美的视觉和听觉 也算有用\n\nAnd it's important to know about compression because it allows users to\n学习压缩非常重要 \\N 因为可以高效存储图片，音乐，视频\n\nstore pictures, music, and videos in efficient ways.\n学习压缩非常重要 \\N 因为可以高效存储图片，音乐，视频\n\nWithout it, streaming your favorite Carpool Karaoke videos on YouTube would be nearly impossible,\n如果没有压缩 \\N 在 YouTube 看\"明星拼车唱歌\"几乎不可能\n\ndue to bandwidth and the economics of transmitting that volume of data for free.\n因为你的带宽可能不够（会很卡） \\N 而且供应商不愿意免费传输那么多数据\n\nAnd now when your Skype calls sound like they're being taken over by demons,\n现在你知道为什么打 Skype 电话 \\N 有时像在和恶魔通话\n\nyou'll know what's really going on.\n现在你知道为什么打 Skype 电话 \\N 有时像在和恶魔通话\n\nI'll see you next week.\n下周见\n\nHi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nWe've talked a lot about inputs and outputs in this series,\n我们之前讨论过 输入输出 \\N 但都是计算机组件互相输入输出\n\nbut they've mostly been between different parts of a computer\n我们之前讨论过 输入输出 \\N 但都是计算机组件互相输入输出\n\nlike outputting data from RAM or inputting instructions to a CPU.\n比如 RAM 输出数据，或输指令进 CPU\n\nWe haven't discussed much about inputs coming from humans.\n我们还没讲 来自人类的输入\n\nWe also haven't learned how people get information out of a computer,\n也没讲怎么从电脑中拿出信息，除了用打孔纸卡\n\nother than by printing or punching it onto paper.\n也没讲怎么从电脑中拿出信息，除了用打孔纸卡\n\nOf course, there's a wide variety of input and output devices that\n当然，有很多种 \"输入输出设备\"  \\N 让我们和计算机交互\n\nallow us users to communicate with computers.\n当然，有很多种 \"输入输出设备\"  \\N 让我们和计算机交互\n\nThey provide an interface between human and computer.\n它们在人类和机器间提供了界面\n\nAnd today, there's a whole field of study called Human-Computer Interaction.\n如今有整个学科专门研究这个，叫 \"人机交互\"\n\nThese interfaces are so fundamental to the user experience\n界面对用户体验非常重要 \\N 所以是我们接下来几集的重点\n\nthat they're the focus of the next few episodes.\n界面对用户体验非常重要 \\N 所以是我们接下来几集的重点\n\nAs we discussed at the very beginning of the series,\n在系列开头的几集，我们提过\n\nthe earliest mechanical and electro-mechanical computing devices\n早期机械计算设备 \\N 用齿轮，旋钮和开关等机械结构来输入输出\n\nused physical controls for inputs and outputs, like gears, knobs and switches,\n早期机械计算设备 \\N 用齿轮，旋钮和开关等机械结构来输入输出\n\nand this was pretty much the extent of the human interface.\n这些就是交互界面\n\nEven the first electronic computers, like Colossus and ENIAC,\n甚至早期电子计算机  比如 Colossus 和 ENIAC\n\nwere configured using huge panels of mechanical controls and patch wires.\n也是用一大堆机械面板和线 来操作\n\nIt could take weeks to enter in a single program, let alone run it,\n输入一个程序可能要几星期，还没提运行时间.\n\nand to get data out after running a program, results were most often printed to paper.\n运行完毕后想拿出数据，一般是打印到纸上\n\nPaper printers were so useful\n打印机超有用\n\nthat even Babbage designed one for his Difference Engine,\n甚至 查尔斯·巴贝奇 都给差分机专门设计了一个\n\nand that was in the 1820s!\n那可是 1820 年代!\n\nHowever, by the 1950s, mechanical inputs were rendered obsolete\n然而，到 1950 年代，机械输入完全消失\n\nby programs and data stored entirely on mediums like punch cards and magnetic tape.\n因为出现了打孔纸卡和磁带\n\nPaper printouts were still used for the final output,\n但输出仍然是打印到纸上\n\nand huge banks of indicator lights were developed\n还有大量指示灯，在运行中提供实时反馈\n\nto provide real time feedback while the program was in progress.\n还有大量指示灯，在运行中提供实时反馈\n\nIt's important to recognize that computer input of this era was\n那个时代的特点是 尽可能迁就机器 \\N 对人类好不好用是其次\n\ndesigned to be as simple and robust as possible for computers.\n那个时代的特点是 尽可能迁就机器 \\N 对人类好不好用是其次\n\nEase and understanding for users was a secondary concern.\n那个时代的特点是 尽可能迁就机器 \\N 对人类好不好用是其次\n\nPunch tape is a great example\n打孔纸带就是个好例子\n\nthis was explicitly designed to be easy for computers to read.\n就是为了方便计算机读取\n\nThe continuous nature of tape made it easy to handle mechanically,\n纸带是连续的，方便机器处理\n\nand the holes could be reliably detected with a mechanical or optical system,\n纸孔可以方便地 用机械或光学手段识别\n\nwhich encoded instructions and data.\n纸孔可以编码程序和数据\n\nBut of course, humans don't think in terms of little punched holes on strips of paper.\n当然, 人类不是以纸孔方式思考的.\n\nSo, the burden was on programmers.\n所以负担放到了程序员身上\n\nThey had to spend the extra time and effort to convert their ideas and programs\n他们要花额外时间和精力 \\N 转成计算机能理解的格式\n\ninto a language and a format that was easy for computers of the era to understand\n他们要花额外时间和精力 \\N 转成计算机能理解的格式\n\noften with the help of additional staff and auxiliary devices.\n一般需要额外人员和设备帮忙\n\nIt's also important to note that early computers, basically pre-1950,\n要注意的是，基本上 1950 年前的早期计算机 \\N \"输入\"的概念很原始\n\nhad an extremely simple notion of human input.\n要注意的是，基本上 1950 年前的早期计算机 \\N \"输入\"的概念很原始\n\nYes, humans input programs and data into computers,\n是的，的确是人类负责输入程序和数据 \\N 但计算机不会交互式回应\n\nbut these machines generally didn't respond interactively to humans.\n是的，的确是人类负责输入程序和数据 \\N 但计算机不会交互式回应\n\nOnce a program was started, it typically ran until it was finished.\n程序开始运行后会一直运行  直到结束\n\nThat's because these machines were way too expensive to be\n因为机器太贵了 \\N 不能等人类慢慢敲命令和给数据\n\nwaiting around for humans to type a command or enter data.\n因为机器太贵了 \\N 不能等人类慢慢敲命令和给数据\n\nAny input needed for a computation was fed in at the same time as the program.\n要同时放入程序和数据\n\nThis started to change in the late 1950s.\n这在 1950 年代晚期开始发生变化\n\nOn one hand, smaller-scale computers started to become cheap enough\n一方面，小型计算机变得足够便宜\n\nthat it was feasible to have a human-in-the loop;\n让人类来回和计算机交互  变得可以接受\n\nthat is, a back and forth between human and computer.\n交互式就是人和计算机之间来回沟通\n\nAnd on the other hand,\n而另一方面\n\nbig fancy computers became fast and sophisticated enough to support many programs and users at once,\n大型计算机变得更快，能同时支持多个程序和多个用户\n\nwhat were called multitasking and time-sharing systems .\n这叫\"多任务\"和\"分时系统\"\n\nBut these computers needed a way to get input from users.\n但交互式操作时 \\N 计算机需要某种方法来获得用户输入\n\nFor this, computers borrowed the ubiquitous data entry mechanism of the era: keyboards.\n所以借用了当时已经存在的数据录入机制：键盘\n\nAt this point, typing machines had already been in use for a few centuries,\n当时，打字机已经存在几个世纪了\n\nbut it was Christopher Latham Sholes, who invented the modern typewriter in 1868.\n但现代打字机是 \\N克里斯托弗·莱瑟姆·肖尔斯 在 1868 年发明的\n\nIt took until 1874 to refine the design and manufacture it,\n虽然到 1874 年才完成设计和制造\n\nbut it went on to be a commercial success.\n但之后取得了商业成功\n\nSholes' typewriter adopted an unusual keyboard layout that you know well QWERTY\n肖尔斯 的打字机用了不寻常的布局，QWERTY\n\nnamed for the top-left row of letter keys.\n名字来自键盘左上角按键\n\nThere has been a lot of speculation as to why this design was used.\n为什么这么设计 有很多猜测\n\nThe most prevalent theory is that it put common letter pairings in English far apart\n最流行的理论是  这样设计是为了 \\N 把常见字母放得远一些，避免按键卡住\n\nto reduce the likelihood of typebars jamming when entered in sequence.\n最流行的理论是  这样设计是为了 \\N 把常见字母放得远一些，避免按键卡住\n\nIt's a convenient explanation, but it's also probably false,\n这个解释虽然省事，但可能是错的，或至少不够全面\n\nor at least not the full story.\n这个解释虽然省事，但可能是错的，或至少不够全面\n\nIn fact, QWERTY puts many common letter pairs together,\n事实上，QWERTY 把很多常见字母放在了一起 \\N 比如 TH 和 ER\n\nlike \"TH\" and \"ER\".\n事实上，QWERTY 把很多常见字母放在了一起 \\N 比如 TH 和 ER\n\nAnd we know that Sholes and his team went through many iterations\n我们知道 肖尔斯和他的团队设计了很多版 \\N 才进化到这个布局\n\nbefore arriving at this iconic arrangement.\n我们知道 肖尔斯和他的团队设计了很多版 \\N 才进化到这个布局\n\nRegardless of the reason, the commercial success of Sholes' typewriter meant\n总之，肖尔斯 的打字机取得了成功 \\N 所以其它公司很快开始抄他的设计\n\nthe competitor companies that soon followed duplicated his design.\n总之，肖尔斯 的打字机取得了成功 \\N 所以其它公司很快开始抄他的设计\n\nMany alternative keyboard layouts have been proposed over the last century,\n过去一个世纪有不少新的键盘布局被发明，宣称各种好处\n\nclaiming various benefits.\n过去一个世纪有不少新的键盘布局被发明，宣称各种好处\n\nBut, once people had invested the time to learn QWERTY,\n但人们已经熟悉了 QWERTY 布局 \\N 根本不想学新布局\n\nthey just didn't want to learn something new.\n但人们已经熟悉了 QWERTY 布局 \\N 根本不想学新布局\n\nThis is what economists would call a switching barrier or switching cost.\n这是经济学家所说的 转换成本\n\nAnd it's for this very basic human reason\n所以现在都快1个半世纪了 \\N 我们还在用 QWERTY 键盘布局\n\nthat we still use QWERTY keyboards almost a century and a half later!\n所以现在都快1个半世纪了 \\N 我们还在用 QWERTY 键盘布局\n\nI should mention that QWERTY isn't universal.\n我应该提一下，QWERTY 不是通用的\n\nThere are many international variants,\n有很多变体，比如法国 AZERTY 布局\n\nlike the French AZERTY layout,\n有很多变体，比如法国 AZERTY 布局\n\nor the QWERTZ layout common in central Europe.\n以及中欧常见的 QWERTZ 布局\n\nInterestingly, Sholes didn't envision that typing would ever be faster than handwriting,\n有趣的是，肖尔斯 根本没想到打字会比手写快\n\nwhich is around 20 words per minute.\n手写速度大约是每分钟 20 个\n\nTypewriters were introduced chiefly for legibility and standardization of documents, not speed.\n打字机主要为了易读性和标准化，而不是速度\n\nHowever, as they became standard equipment in offices, the desire for speedy typing grew,\n然而随着打字机成为办公室标配 \\N 对快速打字的渴望越来越大\n\nand there were two big advances that unlocked typing's true potential.\n有两个重大进步  解放了打字的潜力\n\nAround 1880, Elizabeth Longley, a teacher at the Cincinnati Shorthand and Type-Writer Institute,\n1880年左右，辛辛那提速记学院 \\N 一名叫 伊丽莎白·朗利 的老师\n\nstarted to promote ten-finger typing.\n开始推广 十指打字\n\nThis required much less finger movement than hunt-and-peck,\n比一个手指打字要移动的距离短得多，所以速度更快\n\nso it offered enhanced typing speeds.\n比一个手指打字要移动的距离短得多，所以速度更快\n\nThen, a few years later, Frank Edward McGurrin, a federal court clerk in Salt Lake City,\n几年后，弗兰克·爱德华·麦克格林 \\N 盐湖城的一位联邦法庭书记\n\ntaught himself to touch-type; as in, he didn't need to look at the keys while typing.\n学会了盲打，打字时不用看键盘\n\nIn 1888, McGurrin won a highly publicized typing-speed contest,\n1888年，麦格高林 赢了备受关注的打字速度比赛\n\nafter which ten-finger, touch-typing began to catch on.\n之后\"十指盲打\"开始流行\n\nProfessional typists were soon able to achieve speeds upwards of 100 words per minute,\n专业打字员  每分钟 100 字以上\n\nmuch faster than handwriting!\n比手写快多了！而且清晰又整洁！\n\nAnd nice and neat too!\n比手写快多了！而且清晰又整洁！\n\nSo, humans are pretty good with typewriters,\n虽然人类擅长用打字机\n\nbut we can't just plunk down a typewriter in front of a computer and have it type\n但我们没法把打字机塞到计算机面前，让它打字\n\nthey have no fingers!\n计算机又没有手指\n\nInstead, early computers adapted a special type of typewriter that was used for telegraphs,\n所以早期计算机用了一种特殊打字机，是专门用来发电报的,\n\ncalled a teletype machine.\n叫 电传打字机\n\nThese were electromechanically-augmented typewriters\n这些打字机是强化过的，可以用电报线发送和接收文本\n\nthat can send and receive text over telegraph lines.\n这些打字机是强化过的，可以用电报线发送和接收文本\n\nPressing a letter on one teletype keyboard would cause a signal to be sent,\n按一个字母，信号会通过电报线，发到另一端\n\nover telegraph wires, to a teletype machine on the other end,\n按一个字母，信号会通过电报线，发到另一端\n\nwhich would then electromechanically type that letter.\n另一端的电传打字机会打出来\n\nThis allowed two humans to type to one another over long distances.\n使得两人可以长距离沟通\n\nbasically a steampunk version of a chat room.\n基本是个蒸汽朋克版聊天室\n\nSince these teletype machines already had an electronic interface,\n因为电传打字机有电子接口，稍作修改就能用于计算机\n\nthey were easily adapted for computer use,\n因为电传打字机有电子接口，稍作修改就能用于计算机\n\nand teletype computer interfaces were common in the 1960s and 70s.\n电传交互界面在 1960~1970 很常见\n\nInteraction was pretty straightforward.\n用起来很简单\n\nUsers would type a command, hit enter, and then the computer would type back.\n输入一个命令，按回车，然后计算机会输回来\n\nThis text \"conversation\" between a user and a computer went back and forth.\n用户和计算机来回\"对话\"\n\nThese were called command line interfaces,\n这叫\"命令行界面\"\n\nand they remained the most prevalent form of human-computer interaction\n它是最主要的人机交互方式，一直到 1980 年代\n\nup until around the 1980s.\n它是最主要的人机交互方式，一直到 1980 年代\n\nCommand Line interaction on a teletype machine looks something like this.\n用电传打字机的命令行交互  类似这样：\n\nA user can type any number of possible commands.\n用户可以输入各种命令\n\nLet's check out a few,\n我们来看几个命令，先看当前目录有什么文件\n\nbeginning with seeing all of the files in the current directory we're in.\n我们来看几个命令，先看当前目录有什么文件\n\nFor this, we would type the command, \"ls\", which is short for list,\n输入命令 ls，名字来自 list 的缩写\n\nand the computer replies with a list of the files in our current directory.\n然后计算机会列出 当前目录里的所有文件\n\nIf we want to see what's in our \"secretStarTrekDiscoveryCast.txt.txt file\",\n如果想看 secretStarTrekDiscoveryCast.txt 有什么\n\nwe use yet another command to display the contents.\n要用另一个命令 显示文件内容\n\nIn unix, we can call \"cat\" - short for concatenate.\nunix 用 cat 命令显示文件内容 \\N cat 是连接(concatenate)的缩写\n\nWe need to specify which file to display, so we include that after the command, called an argument.\n然后指定文件名，指定的方法是写在 cat 命令后面 \\N 传给命令的值叫 参数\n\nIf you're connected to a network with other users,\n如果同一个网络里有其他人\n\nyou can use a primitive version of a Find My Friends app\n你可以用 finger 命令找朋友 \\N 就像是个很原始的\"找朋友\" App\n\nto get more info on them with the command \"finger\".\n你可以用 finger 命令找朋友 \\N 就像是个很原始的\"找朋友\" App\n\nElectromechanical teletype machines\n电传打字机 直到1970年代左右都是主流交互方式\n\nwere the primary computing interface for most users up until around the 1970s.\n电传打字机 直到1970年代左右都是主流交互方式\n\nAlthough computer screens first emerged in the 1950s,\n尽管屏幕最早出现在 1950 年代 \\N 但对日常使用太贵 而且分辨率低\n\nand were used for graphics they were too expensive and low resolution for everyday use.\n尽管屏幕最早出现在 1950 年代 \\N 但对日常使用太贵 而且分辨率低\n\nHowever, mass production of televisions for the consumer market, and general improvements\n然而因为针对普通消费者的电视机开始量产 \\N 同时处理器与内存也在发展\n\nin processors and memory, meant that by 1970, it was economically viable\n到1970年代，屏幕代替电传打字机 变得可行\n\nto replace electromechanical teletype machines with screen-based equivalents.\n到1970年代，屏幕代替电传打字机 变得可行\n\nBut rather than build a whole new standard to interface computers with these screens,\n但与其为屏幕  专门做全新的标准\n\nengineers simply recycled the existing text-only, teletype protocol.\n工程师直接用现有的 电传打字机协议\n\nThese machines used a screen, which simulated endless paper.\n屏幕就像无限长度的纸 \\N 除了输入和输出字，没有其它东西\n\nIt was text in and text out, nothing more.\n屏幕就像无限长度的纸 \\N 除了输入和输出字，没有其它东西\n\nThe protocol was identical, so computers couldn't even tell if it was paper or a screen.\n协议是一样的，所以计算机分不出是纸还是屏幕\n\nThese virtual teletype or glass teletype machines became known as terminals .\n这些\"虚拟电传打字机\"或\"玻璃电传打字机\"\\N 叫 终端\n\nBy 1971, it was estimated, in the United States,\n到1971年，美国大约有 7 万台电传打字机 \\N 以及 7 万个终端\n\nthere was something on the order of 70,000 electro-mechanical teletype machines\n到1971年，美国大约有 7 万台电传打字机 \\N 以及 7 万个终端\n\nand 70,000 screen-based terminals in use.\n到1971年，美国大约有 7 万台电传打字机 \\N 以及 7 万个终端\n\nScreens were so much better, faster and more flexible, though.\n屏幕又好又快又灵活\n\nLike, you could delete a mistake and it would disappear.\n如果删一个错别字 会立刻消失\n\nSo, by the end of the 1970s, screens were standard.\n所以到 1970 年代末  屏幕成了标配\n\nYou might think that command line interfaces are way too primitive to do anything interesting.\n你也许会想，命令行界面太原始了 \\N 做不了什么有意思的事\n\nBut even when the only interaction was through text, programmers found a way to make it fun.\n即便只有文字 \\N 程序员也找到了一些方法，让它变得有趣一些\n\nEarly interactive, text-based computer games include famous titles like Zork,\n早期的著名交互式文字游戏  Zork\n\ncreated in 1977.\n出现于 1977 年\n\nPlayers of these sorts of early games were expected to engage their limitless imaginations\n早期游戏玩家需要丰富的想象力\n\nas they visualized the fictional world around them, like what terrifying monster confronted them\n想像自己身在虚构世界，比如\"四周漆黑一片\n\nwhen it was pitch black and you were likely to be eaten by a grue.\n附近可能有怪物会吃掉你\"\n\nLet's go back to our command line, now on a fancy screen-based terminal, and play!\n我们用命令行玩玩看\n\nJust like before, we can see what's in our current directory with the \"ls\" command.\n就像之前，我们可以用 ls 命令，看当前目录有什么\n\nThen, let's go into our games directory by using the \"cd\" command,  for \" change directory \".\n然后用 cd 命令，进入游戏文件夹 \\N cd 的意思是 \"改变文件夹\"\n\nNow, we can use our \"ls\" command again to see what games are installed on our computer.\n再用 ls 看有哪些游戏\n\nSweet, we have Adventure!\n超棒！我们有\"冒险旅程\"！(adventure)\n\nAll we have to do to run this program is type its name.\n想运行这个程序，只需要输入它的名字\n\nUntil this application halts, or we quit it, it takes over the command line.\n在程序自行停止或我们主动退出前 \\N 它会接管命令行\n\nWhat you're seeing here is actual interaction from \"Colossal Cave Adventure\",\n你现在看到的，是\"巨大洞穴冒险\"这款游戏的真实输出\n\nfirst developed by Will Crowther in 1976.\n由 Will Crowther 在 1976 年开发\n\nIn the game, players can type in one- or two-word commands to move around,\n游戏中，玩家可以输入1个词或2个词的命令 \\N 来移动人物，和其他东西交互，捡物品等\n\ninteract with objects, pickup items and so on.\n游戏中，玩家可以输入1个词或2个词的命令 \\N 来移动人物，和其他东西交互，捡物品等\n\nThe program acts as the narrator, describing locations, possible actions,\n然后游戏会像旁白一样，输出你的当前位置， \\N 告诉你能做什么动作，以及你的动作造成的结果\n\nand the results of those actions.\n然后游戏会像旁白一样，输出你的当前位置， \\N 告诉你能做什么动作，以及你的动作造成的结果\n\nCertain ones resulted in death!\n有些动作会导致死亡！\n\nThe original version only had 66 locations to explore,\n原始版本只有 66 个地方可供探索\n\nbut it's widely considered to be the first example of interactive fiction.\n但它被广泛认为是最早的互动式小说\n\nThese text adventure games later became multiplayer, called MUDs or Multi-User Dungeons.\n游戏后来从纯文字进化成多人游戏 \\N 简称 MUD，或多人地牢游戏\n\nAnd they're the great-forbearers of the awesome graphical MMORPG's\n是如今 MMORPG 的前辈 \\N （大型多人在线角色扮演游戏）\n\n(massive, multiplayer online role playing games) we enjoy today.\n是如今 MMORPG 的前辈 \\N （大型多人在线角色扮演游戏）\n\nAnd if you want to know more about the history of these and other games\n如果你想了解游戏史，我们有游戏速成课  \\N 主持人 Andre Meadows\n\nwe've got a whole series on it hosted by Andre Meadows!\n如果你想了解游戏史，我们有游戏速成课  \\N 主持人 Andre Meadows\n\nCommand line interfaces, while simple, are very powerful.\n命令行界面虽然简单  但十分强大\n\nComputer programming is still very much a written task, and as such,\n编程大部分依然是打字活 \\N 所以用命令行比较自然\n\ncommand lines are a natural interface.\n编程大部分依然是打字活 \\N 所以用命令行比较自然\n\nFor this reason, even today, most programmers use\n因此，即使是现在  \\N 大多数程序员工作中依然用命令行界面\n\ncommand line interfaces as part of their work.\n因此，即使是现在  \\N 大多数程序员工作中依然用命令行界面\n\nAnd they're also the most common way to access computers that are far away,\n而且用命令行访问远程计算机 是最常见的方式 \\N 比如服务器在另一个国家\n\nlike a server in a different country.\n而且用命令行访问远程计算机 是最常见的方式 \\N 比如服务器在另一个国家\n\nIf you're running Windows, macOS or Linux,\n如果你用 Windows, macOS, Linux\n\nyour computer has a command line interface one you may have never used.\n你的计算机有命令行界面，但你可能从来没用过\n\nCheck it out by typing \"cmd\" in your Windows search bar,\n你可以在 Windows 搜索栏中输入 cmd\n\nor search for Terminal on Mac.\n或在 Mac 上搜 Terminal\n\nThen install a copy of Zork and play on!\n然后你可以装 Zork 玩！\n\nSo, you can see how these early advancements still have an impact on computing today.\n现在你知道了 \\N 早期计算机的发展是如何影响到现在的.\n\nJust imagine if your phone didn't have a good ol' fashioned QWERTY keyboard.\n想想要是手机没有 QWERTY 键盘 \\N 在 Instagram 给图片配标题可就麻烦了\n\nIt could take forever to type your Instagram captions.\n想想要是手机没有 QWERTY 键盘 \\N 在 Instagram 给图片配标题可就麻烦了\n\nBut, there's still something missing from our discussion.\n但我们还有一个重要话题没讲\n\nAll the sweet sweet graphics!\n美妙的图形界面！\n\nThat's our topic for next week.\n这是下周的主题\n\nSee you soon.\n下周见\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nThis 1960 PDP-1 is a great example of early computing with graphics.\n这台 1960 年的 PDP-1 \\N 是一个早期图形计算机的好例子\n\nYou can see a cabinet-sized computer on the left,\n你可以看到 左边是柜子大小的电脑\n\nan electromechanical teletype machine in the middle,\n中间是电传打字机\n\nand a round screen on the right.\n右边是一个圆形的屏幕\n\nNote how they're separated.\n注意它们是分开的\n\nThat's because text-based tasks and graphical tasks were often distinct back then.\n因为当时文本任务和图形任务是分开的.\n\nIn fact, these early computer screens had a very hard time rendering crisp text, whereas\n事实上，早期的屏幕无法显示清晰的文字\n\ntyped paper offered much higher contrast and resolution.\n而打印到纸上  有更高的对比度和分辨率\n\nThe most typical use for early computer screens was to keep track of a program's operation,\n早期屏幕的典型用途 是跟踪程序的运行情况\n\nlike values in registers.\n比如寄存器的值\n\nIt didn't make sense to have a teletype machine print this on paper\n如果用打印机 \\N 一遍又一遍打印出来没有意义\n\nover and over and over again -- that'd waste a lot of paper, and it was slow.\n不仅费纸而且慢\n\nOn the other hand, screens were dynamic and quick to update -- perfect for temporary values.\n另一方面，屏幕更新很快，对临时值简直完美\n\nComputer screens were rarely considered for program output, though.\n但屏幕很少用于输出计算结果，结果一般都打印到纸上\n\nInstead, any results from a computation were typically written to paper\n但屏幕很少用于输出计算结果，结果一般都打印到纸上\n\nor some other more permanent medium.\n或其它更永久的东西上\n\nBut, screens were so darn useful\n但屏幕超有用 \\N 到1960年代，人们开始用屏幕做很多酷炫的事情\n\nthat by the early 1960s, people started to use them for awesome things.\n但屏幕超有用 \\N 到1960年代，人们开始用屏幕做很多酷炫的事情\n\nA lot of different display technologies have been created over the decades,\n几十年间出现了很多显示技术\n\nbut the most influential, and also the earliest, were Cathode Ray Tubes, or CRT\n但最早最有影响力的是 阴极射线管（CRT）\n\nThese work by shooting electrons out of an emitter at a phosphor-coated screen.\n原理是把电子发射到 有磷光体涂层的屏幕上\n\nWhen electrons hit the coating, it glows for a fraction of a second.\n当电子撞击涂层时 会发光几分之一秒\n\nBecause electrons are charged particles,\n由于电子是带电粒子，路径可以用磁场控制\n\ntheir paths can be manipulated with electromagnetic fields.\n由于电子是带电粒子，路径可以用磁场控制\n\nPlates or coils are used inside to steer electrons to a desired position,\n屏幕内用板子或线圈  把电子引导到想要的位置\n\nboth left-right and up-down.\n上下左右都行\n\nWith this control, there are two ways you can draw graphics.\n既然可以这样控制，有 2 种方法绘制图形 \\N 1. 引导电子束描绘出形状\n\nThe first option is to direct the electron beam to trace out shapes.\n既然可以这样控制，有 2 种方法绘制图形 \\N 1. 引导电子束描绘出形状\n\nThis is called Vector Scanning.\n这叫\"矢量扫描\"\n\nBecause the glow persists for a little bit, if you repeat the path quickly enough,\n因为发光只持续一小会儿 \\N 如果重复得足够快 可以得到清晰的图像\n\nyou create a solid image.\n因为发光只持续一小会儿 \\N 如果重复得足够快 可以得到清晰的图像\n\nThe other option is to repeatedly follow a fixed path, scanning line by line,\n2. 按固定路径，一行行来 \\N 从上向下，从左到右，不断重复\n\nfrom top left to bottom right, and looping over and over again.\n2. 按固定路径，一行行来 \\N 从上向下，从左到右，不断重复\n\nYou only turn on the electron beam at certain points to create graphics.\n只在特定的点打开电子束，以此绘制图形\n\nThis is called Raster Scanning.\n这叫 \"光栅扫描\"\n\nWith this approach, you can display shapes... and even text... all made of little line segments.\n用这种方法，可以用很多小线段绘制形状  甚至文字\n\nEventually, as display technologies improved,\n最后，因为显示技术的发展\n\nit was possible to render crisp dots onto the screen, aka pixels.\n我们终于可以在屏幕上显示清晰的点，叫\"像素\"\n\nThe Liquid Crystal Displays, or LCDs,\n液晶显示器，简称 LCD\n\nthat we use today are quite a different technology.\n和以前的技术相当不同\n\nBut, they use raster scanning too,\n但 LCD 也用光栅扫描 \\N 每秒更新多次 像素里红绿蓝的颜色\n\nupdating the brightness of little tiny red, green and blue pixels many times a second.\n但 LCD 也用光栅扫描 \\N 每秒更新多次 像素里红绿蓝的颜色\n\nInterestingly, most early computers didn't use pixels\n有趣的是，很多早期计算机不用像素\n\n-- not because they couldn't physically,\n- 不是技术做不到, 而是因为像素占太多内存\n\nbut because it consumed way too much memory for computers of the time.\n- 不是技术做不到, 而是因为像素占太多内存\n\nA 200 by 200 pixel image contains 40,000 pixels.\n200像素×200像素的图像，有 40,000 个像素\n\nEven if you use just one bit of data for each pixel,\n哪怕每个像素只用一个 bit 表示 \\N 代表黑色或白色，连灰度都没有！\n\nthat's black OR white -- not grayscale!\n哪怕每个像素只用一个 bit 表示 \\N 代表黑色或白色，连灰度都没有！\n\n-- the image would consume 40,000 bits of memory.\n- 会占 40,000 bit 内存 \\N 比 PDP-1 全部内存的一半还多\n\nThat would have gobbled up more than half of a PDP-1's entire RAM.\n- 会占 40,000 bit 内存 \\N 比 PDP-1 全部内存的一半还多\n\nSo, computer scientists and engineers had to come up with clever tricks to render graphics\n所以计算机科学家和工程师，得想一些技巧来渲染图形 \\N 等内存发展到足够用\n\nuntil memory sizes caught up to our pixelicious ambitions.\n所以计算机科学家和工程师，得想一些技巧来渲染图形 \\N 等内存发展到足够用\n\nInstead of storing tens of thousands of pixels,\n所以早期计算机不存大量像素值 \\N 而是存符号，80x25个符号最典型\n\nearly computers stored a much smaller grid of letters, most typically 80 by 25 characters.\n所以早期计算机不存大量像素值 \\N 而是存符号，80x25个符号最典型\n\nThat's 2000 characters in total.\n总共 2000 个字符\n\nAnd if each is encoded in 8 bits, using something like ASCII,\n如果每个字符用 8 位表示，比如用 ASCII\n\nit would consume 16,000 bits of memory for an entire screen full of text,\n总共才 16000 位，这种大小更合理\n\nwhich is way more reasonable.\n总共才 16000 位，这种大小更合理\n\nTo pull this off, computers needed an extra piece of hardware that\n为此，计算机需要额外硬件\n\ncould read characters out of RAM, and convert them into raster graphics to be drawn onto the screen.\n来从内存读取字符，转换成光栅图形 \\N 这样才能显示到屏幕上\n\nThis was called a character generator, and they were basically the first graphics cards.\n这个硬件叫 \"字符生成器\"，基本算是第一代显卡\n\nInside, they had a little piece of Read Only Memory, a ROM,\n它内部有一小块只读存储器，简称 ROM\n\nthat stored graphics for each character, called a dot matrix pattern.\n存着每个字符的图形，叫\"点阵图案\"\n\nIf the graphics card saw the 8-bit code for the letter \"K\",\n如果图形卡看到一个 8 位二进制，发现是字母 K\n\nthen it would raster scan the 2D pattern for the letter K onto the screen, in the appropriate position.\n那么会把字母 K 的点阵图案 \\N光栅扫描显示到屏幕的适当位置\n\nTo do this, the character generator had special access to a portion of a computer's memory\n为了显示，\"字符生成器\" 会访问内存中一块特殊区域 \\N 这块区域专为图形保留，叫 屏幕缓冲区\n\nreserved for graphics, a region called the screen buffer.\n为了显示，\"字符生成器\" 会访问内存中一块特殊区域 \\N 这块区域专为图形保留，叫 屏幕缓冲区\n\nComputer programs wishing to render text to the screen\n程序想显示文字时，修改这块区域里的值就行\n\nsimply manipulated the values stored in this region,\n程序想显示文字时，修改这块区域里的值就行\n\njust as they could with any other data in RAM.\n程序想显示文字时，修改这块区域里的值就行\n\nThis scheme required much less memory,\n这个方案用的内存少得多 \\N 但也意味着 只能画字符到屏幕上\n\nbut it also meant the only thing you could draw was text.\n这个方案用的内存少得多 \\N 但也意味着 只能画字符到屏幕上\n\nEven still, people got pretty inventive with ASCII art!\n即使有这样限制 \\N 人们用 ASCII 艺术发挥了很多创意！\n\nPeople also tried to make rudimentary, pseudo-graphical interfaces out of this basic set of characters\n也有人用字符模仿图形界面\n\nusing things like underscores and plus signs to create boxes, lines and other primitive shapes.\n用下划线和加号来画盒子，线，和其他简单形状\n\nBut, the character set was really too small to do anything terribly sophisticated.\n但字符集实在太小，做不了什么复杂的事\n\nSo, various extensions to ASCII were made that added new semigraphical characters,\n因此对 ASCII 进行了各种扩展，加新字符\n\nlike IBM's CP437 character set, seen here, which was used in DOS.\n比如上图的 IBM CP437 字符集，用于 DOS.\n\nOn some systems, the text color and background color could be defined with a few extra bits.\n某些系统上 \\N 可以用额外的 bit 定义字体颜色和背景颜色\n\nThat allowed glorious interfaces like this DOS example,\n做出这样的 DOS 界面 \\N 这界面只用了刚刚提到的字符集\n\nwhich is built entirely out the character set you just saw.\n做出这样的 DOS 界面 \\N 这界面只用了刚刚提到的字符集\n\nCharacter generators were a clever way to save memory.\n字符生成器 是一种省内存的技巧 \\N 但没办法绘制任意形状\n\nBut, they didn't provide any way to draw arbitrary shapes.\n字符生成器 是一种省内存的技巧 \\N 但没办法绘制任意形状\n\nAnd that's important if you want to draw content like electrical circuits, architectural\n绘制任意形状很重要 \\N 因为电路设计，建筑平面图，地图，好多东西都不是文字！\n\nplans, maps, and... well pretty much everything that isn't text!\n绘制任意形状很重要 \\N 因为电路设计，建筑平面图，地图，好多东西都不是文字！\n\nTo do this, without resorting to memory-gobbling pixels,\n为了绘制任意形状，同时不吃掉所有内存\n\ncomputer scientists used the vector mode available on CRTs.\n计算机科学家用 CRT 上的\"矢量模式\"\n\nThe idea is pretty straightforward: all content to be drawn on screen is defined by a series of lines.\n概念非常简单：所有东西都由线组成\n\nThere's no text.\n没有文字这回事\n\nIf you need to draw text, you have to draw it out of lines.\n如果要显示文字，就用线条画出来\n\nDon't read between the lines here. There is only lines!\n只有线条，没有别的\n\nGot it? Alright, no more word play.\n明白了吗？好，我们举个实例吧\n\nI'm drawing the line here.\n明白了吗？好，我们举个实例吧\n\nLet's pretend this video is a cartesian plane, 200 units wide and 100 tall, with the\n假设这个视频是一个 笛卡尔平面 \\N 200个单位宽，100个单位高\n\norigin that's the zero-zero point in the upper left corner.\n原点 (0,0) 在左上角\n\nWe can draw a shape with the following vector commands,\n我们可以画形状，用如下矢量命令\n\nwhich we've borrowed from the Vectrex, an early vector display system.\n这些命令来自 Vectrex，一个早期矢量显示系统\n\nFirst, we reset, which clears the screen,\n首先，reset ，这个命令会清空屏幕\n\nmoves the drawing point of the electron gun to zero-zero,\n把电子枪的绘图点移动到坐标 (0,0)\n\nand sets the brightness of lines to zero.\n并把线的亮度设为 0\n\nThen we move the drawing point down to 50 50,\nMOVE_TO 50 50 \\N 把绘图点移动到坐标 (50,50)\n\nand set the line intensity to 100%.\nINTENSITY 100 \\N 把强度设为 100\n\nWith the intensity up, now we move to 100, 50, then 60, 75 and then back to 50,50.\n现在亮度提高了\\N 移动到 (100,50)  然后 (60,75)  然后 (50,50)\n\nThe last thing to do is set our line intensity back to 0%.\n最后把强度设回 0\n\nCool! We've got a triangle!\n酷，我们画了一个三角形！\n\nThis sequence of commands would consume on the order of 160 bits, which is way more efficient\n这些命令占 160 bit  \\N 比存一个庞大的像素矩阵更好\n\nthan keeping a huge matrix of pixel values!\n这些命令占 160 bit  \\N 比存一个庞大的像素矩阵更好\n\nJust like how characters were stored in memory and turned into graphics by a character generator,\n就像之前的\"字符生成器\" \\N把内存里的字符转成图形一样\n\nthese vector instructions were also stored in memory, and rendered to a screen using\n这些矢量指令也存在内存中 \\N 通过矢量图形卡画到屏幕上\n\na vector graphics card.\n这些矢量指令也存在内存中 \\N 通过矢量图形卡画到屏幕上\n\nHundreds of commands could be packed together, sequentially, in the screen buffer,\n数百个命令可以按序存在屏幕缓冲区\n\nand used to build up complex graphics. All made of lines!\n画出复杂图形，全是线段组成的！\n\nBecause all these vectors are stored in memory, computer programs can update the values freely,\n由于这些矢量都在内存中 \\N 程序可以更新这些值\n\nallowing for graphics that change over time -- Animation!\n让图形随时间变化 - 动画！\n\nOne of the very earliest video games, Spacewar!,\n最早的电子游戏之一, Spacewar!\n\nwas built on a PDP-1 in 1962 using vector graphics.\n是 1962 年在 PDP-1 上用矢量图形制作的.\n\nIt's credited with inspiring many later games, like Asteroids,\n它启发了许多后来的游戏，比如 爆破彗星(Asteroids)\n\nand even the first commercial arcade video game: Computer Space.\n甚至第一个商业街机游戏：太空大战\n\n1962 was also a huge milestone because of Sketchpad,\n1962 年是一个大里程碑 \\N  Sketchpad 诞生\n\nan interactive graphical interface\n一个交互式图形界面，用途是计算机辅助设计 (CAD)\n\nthat offered Computer-Aided Design -- called CAD Software today.\n一个交互式图形界面，用途是计算机辅助设计 (CAD)\n\nIt's widely considered the earliest example of a complete graphical application.\n它被广泛认为是第一个完整的图形程序\n\nAnd its inventor, Ivan Sutherland, later won the Turing Award for this breakthrough.\n发明人 伊万·萨瑟兰 后来因此获得图灵奖\n\nTo interact with graphics,\n为了与图形界面交互 \\N Sketchpad 用了当时发明不久的输入设备 光笔\n\nSketchpad used a recently invented input device called a light pen,\n为了与图形界面交互 \\N Sketchpad 用了当时发明不久的输入设备 光笔\n\nwhich was a stylus tethered to a computer with a wire.\n就是一个有线连着电脑的触控笔\n\nBy using a light sensor in the tip, the pen detected the refresh of the computer monitor.\n笔尖用光线传感器，可以检测到显示器刷新\n\nUsing the timing of the refresh,\n通过判断刷新时间，电脑可以知道笔的位置\n\nthe computer could actually figure out the pen's position on the screen!\n通过判断刷新时间，电脑可以知道笔的位置\n\nWith this light pen, and various buttons on a gigantic computer,\n有了光笔和各种按钮 \\N 用户可以画线和其他简单形状\n\nusers could draw lines and other simple shapes.\n有了光笔和各种按钮 \\N 用户可以画线和其他简单形状\n\nSketchpad could do things like make lines perfectly parallel, the same length, straighten\nSketchpad 可以让线条完美平行，长度相同 \\N 完美垂直90度，甚至动态缩放\n\ncorners into perfect 90 degree intersections, and even scale shapes up and down dynamically.\nSketchpad 可以让线条完美平行，长度相同 \\N 完美垂直90度，甚至动态缩放\n\nThese things that were laborious on paper, a computer now did with a press of a button!\n这些在纸上很费力，在计算机上非常简单！\n\nUsers were also able to save complex designs they created,\n用户还可以保存设计结果，方便以后再次使用 \\N 甚至和其他人分享\n\nand then paste them into later designs, and even share with other people.\n用户还可以保存设计结果，方便以后再次使用 \\N 甚至和其他人分享\n\nYou could have whole libraries of shapes, like electronic components and pieces of furniture\n你可以有一整个库 \\N 里面有电子元件和家具之类的\n\nthat you could just plop in and manipulate in your creations.\n可以直接拖进来用\n\nThis might all sound pretty routine from today's perspective.\n从如今的角度来看 好像很普通\n\nBut in 1962, when computers were still cabinet-sized behemoths chugging through punch cards,\n但在1962年 \\N 计算机还是吃纸带的大怪兽，有柜子般大小\n\nSketchpad and light pens were equal parts eye opening and brain melting.\nSketchpad 和光笔让人大开眼界\n\nThey represented a key turning point in how computers could be used.\n它们代表了人机交互方式的关键转折点\n\nThey were no longer just number crunching math machines that hummed along behind closed doors.\n电脑不再是关在门后 负责算数的机器了\n\nNow, they were potential assistants, interactively augmenting human tasks.\n可以当助手 帮人类做事\n\nThe earliest computers and displays with true pixel graphics emerged in the late 1960s.\n最早用真正像素的计算机和显示器\\N 出现于 1960 年代末\n\nBits in memory directly \"mapped\" to pixels on the screen,\n内存中的位(Bit) 对应屏幕上的像素\n\nwhat are called bitmapped displays.\n这叫 位图显示\n\nWith full pixel control, totally arbitrary graphics were possible.\n现在我们可以绘制任意图形了\n\nYou can think of a screen's graphics as a huge matrix of pixel values .\n你可以把图形想成一个巨大像素值矩阵\n\nAs before,\n就像之前\n\ncomputers reserve a special region of memory for pixel data, called the frame buffer.\n计算机把像素数据存在内存中一个特殊区域 \\N 叫\"帧缓冲区\"\n\nIn the early days, the computer's RAM was used,\n早期时，这些数据存在内存里\\N 后来存在高速视频内存里，简称 VRAM\n\nbut later systems used special high speed Video RAM, or VRAM,\n早期时，这些数据存在内存里\\N 后来存在高速视频内存里，简称 VRAM\n\nwhich was located on the graphics card itself for high speed access.\nVRAM 在显卡上，这样访问更快 \\N 如今就是这样做的.\n\nThis is how it's done today.\nVRAM 在显卡上，这样访问更快 \\N 如今就是这样做的.\n\nOn an 8-bit grayscale screen, we can set values from 0 intensity, which is black,\n在 8 位灰度屏幕上，我们可用的颜色范围是 0 强度（黑色）\n\nto 255 intensity, which is white.\n到 255 强度(白色)\n\nWell actually, it might be green... or orange, as many early displays couldn't do white.\n其实更像绿色或橙色 \\N 因为许多早期显示器不能显示白色\n\nLet's pretend this video is a really low resolution bitmapped screen,\n我们假设 这个视频在低分辨率的位图屏幕上\n\nwith a resolution of 60 by 35 pixels.\n分辨率 60x35像素\n\nIf we wanted to set the pixel at 10 10 to be white,\n如果我们想把 (10,10) 的像素设为白色 \\N 可以用这样的代码\n\nwe could do it with a piece of code like this.\n如果我们想把 (10,10) 的像素设为白色 \\N 可以用这样的代码\n\nIf we wanted to draw a line, let's say from 30, 0 to 30, 35, we can use a loop, like so.\n如果想画一条线  假设从(30,0)到(30,35) \\N 可以用这样一个循环\n\n.And this changes a whole line of pixels to white.\n把整列像素变成白色\n\nIf we want to draw something more complicated, let's say a rectangle,\n如果想画更复杂的图形，比如矩形，那么需要四个值\n\nwe need to know four values.\n如果想画更复杂的图形，比如矩形，那么需要四个值\n\nThe X and Y coordinate of its starting corner, and its width and height.\n1. 起始点X坐标  \\N2. 起始点Y坐标 \\N 3. 宽度 \\N 4. 高度\n\nSo far, we've drawn everything in white, so let's specify this rectangle to be grey.\n目前只试了白色，这次画矩形试下灰色\n\nGrey is halfway between 0 and 255, so that's a color value of 127.\n灰色介于0到255中间 \\N 所以我们用 127 (255/2=127.5)\n\nThen, with two loops C one nested in the other,\n然后用两个循环，一个套另一个\n\nso that the inner loop runs once for every iteration of the outer loop,\n这样外部每跑一次，内部会循环多次 \\N 可以画一个矩形\n\nwe can draw a rectangle.\n这样外部每跑一次，内部会循环多次 \\N 可以画一个矩形\n\nWhen the computer executes our code as part of its draw routine, it colors in all the\n计算机绘图时会用指定的颜色 127\n\npixels we specified.\n计算机绘图时会用指定的颜色 127\n\nLet's wrap this up into a \"draw rectangle function\", like this:\n我们来包装成 \"画矩形函数\"，就像这样：\n\nNow, to draw a second rectangle on the other side of the screen, maybe in black this time,\n假设要在屏幕的另一边 画第二个矩形 \\N 这次可能是黑色矩形\n\nwe can just call our rectangle drawing function. Voila!!\n可以直接调用 \"画矩形函数\", 超棒！\n\nJust like the other graphics schemes we've discussed,\n就像之前说的其他方案\n\nprograms can manipulate pixel data in the frame buffer, creating interactive graphics.\n程序可以操纵\"帧缓冲区\"中的像素数据，实现交互式图形\n\nPong time!\n乒乓球时间！\n\nOf course, programmers aren't wasting time writing drawing functions from scratch.\n当然，程序员不会浪费时间从零写绘图函数 \\N 而是用预先写好的函数来做，画直线，曲线，图形，文字等\n\nThey use graphics libraries with ready-to-go functions\n当然，程序员不会浪费时间从零写绘图函数 \\N 而是用预先写好的函数来做，画直线，曲线，图形，文字等\n\nfor drawing lines, curves, shapes, text, and other cool stuff.\n当然，程序员不会浪费时间从零写绘图函数 \\N 而是用预先写好的函数来做，画直线，曲线，图形，文字等\n\nJust a new level of abstraction!\n一层新抽象！\n\nThe flexibility of bitmapped graphics opened up a whole new world of possibilities for\n位图的灵活性，为交互式开启了全新可能 \\N 但它的高昂成本持续了十几年\n\ninteractive computing, but it remained expensive for decades.\n位图的灵活性，为交互式开启了全新可能 \\N 但它的高昂成本持续了十几年\n\nAs I mentioned last episode, by as late as 1971,\n上集提到，1971 年 \\N 整个美国也只有大约 7 万个电传打字机和 7 万个终端\n\nit was estimated there were around 70,000 electro-mechanical teletype machines\n上集提到，1971 年 \\N 整个美国也只有大约 7 万个电传打字机和 7 万个终端\n\nand 70,000 terminals in use, in the United States.\n上集提到，1971 年 \\N 整个美国也只有大约 7 万个电传打字机和 7 万个终端\n\nAmazingly, there were only around 1,000 computers in the US that had interactive graphical screens.\n令人惊讶的是 \\N 只有大约 1000 台电脑有交互式图形屏幕\n\nThat's not a lot!\n这可不多！\n\nBut the stage was set helped along by pioneering efforts like Sketchpad and Space Wars\nSketchpad 和 太空大战 这样的先驱  \\N 推动了图形界面发展\n\nfor computer displays to become ubiquitous,\n帮助普及了计算机显示器 \\N 由此，图形界面的曙光初现\n\nand with them, the dawn of graphical user interfaces,\n帮助普及了计算机显示器 \\N 由此，图形界面的曙光初现\n\nwhich we'll cover in a few episodes!\n接下来讲图形界面\n\nI'll see you next week.\n下周见\n\nHi, I'm Carrie Anne and welcome to Crash Course Computer Science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nEarly in this series we covered computing history\n之前介绍了计算机历史 \\N 从人类文明的曙光开始 (第1集）\n\nFrom roughly the dawn of civilization,\n之前介绍了计算机历史 \\N 从人类文明的曙光开始 (第1集）\n\nup to the birth of electronic general purpose computers in the mid 1940s.\n一直到 1940 年代中期  电子计算机诞生\n\nA lot of the material we've discussed over the past 23 episodes\n过去 23 集里讲的很多东西\n\nlike programming languages and compilers\n比如编程语言和编译器，算法和集成电路\n\nAlgorithms and integrated circuits\n比如编程语言和编译器，算法和集成电路\n\nFloppy disks and operating systems, telly types and screens\n软盘和操作系统，电报机和屏幕\n\nall emerged over roughly a 30-year period,\n全都是1940~1970年代，大概这30年间里出现的\n\nFrom the mid 1940s up to the mid 1970s\n全都是1940~1970年代，大概这30年间里出现的\n\nThis is the era of computing before companies like Apple and Microsoft existed\n那时苹果和微软还不存在，也没有推特，谷歌或者 Uber.\n\nand long before anyone Tweeted, Googled or Uber-d.\n那时苹果和微软还不存在，也没有推特，谷歌或者 Uber.\n\nIt was a formative period setting the stage for personal computers,\n还没到个人电脑时代\n\nworldwide web, self-driving cars, virtual reality, and many other topics\n而万维网，无人驾驶汽车，虚拟现实等主题，\\N 这个系列的后半部分会讲\n\nwe'll get to in the second half of this series.\n而万维网，无人驾驶汽车，虚拟现实等主题，\\N 这个系列的后半部分会讲\n\nToday we're going to step back from circuits and algorithms\n今天, 我们不管电路和算法 \\N 来聊聊这个影响力巨大的时代\n\nand review this influential period.\n今天, 我们不管电路和算法 \\N 来聊聊这个影响力巨大的时代\n\nWe'll pay special attention to the historical backdrop of the cold war,\n我们会把重点放在 \\N 冷战，太空竞赛，全球化，消费主义的兴起.\n\nThe space race and the rise of globalization and consumerism.\n我们会把重点放在 \\N 冷战，太空竞赛，全球化，消费主义的兴起.\n\nPretty much immediately after World War II concluded in 1945,\n1945年二战结束后不久\n\nthere was tension between the world's two new superpowers\n两个超级大国的关系越发紧张，美国和苏联开始了冷战\n\nthe United States and the USSR\n两个超级大国的关系越发紧张，美国和苏联开始了冷战\n\nThe Cold War had begun and with it,\n因此政府往科学和工程学 投入大量资金\n\nmassive government spending on science and engineering.\n因此政府往科学和工程学 投入大量资金\n\nComputing which had already demonstrated its value\n计算机在战时已经证明了自身的价值 \\N 比如曼哈顿计划 和 破解纳粹通讯加密\n\nin wartime efforts like the Manhattan Project\n计算机在战时已经证明了自身的价值 \\N 比如曼哈顿计划 和 破解纳粹通讯加密\n\nand code breaking Nazi communications,\n计算机在战时已经证明了自身的价值 \\N 比如曼哈顿计划 和 破解纳粹通讯加密\n\nwas lavished with government funding.\n所以政府大量投入资源 \\N 各种雄心勃勃的项目得以进行\n\nThey enabled huge ambitious computing projects to be undertaken,\n所以政府大量投入资源 \\N 各种雄心勃勃的项目得以进行\n\nlike ENIAC, EDVAC, Atlas and Whirlwind all mentioned in previous episodes.\n比如之前提过的 ENIAC, EDVAC, Atlas, Whirlwind\n\nThis spurred rapid advances that simply weren't possible in the commercial sector alone,\n这种高速发展，如果仅靠商业运作是根本无法做到的\n\nwhere projects were generally expected to recoup development costs through sales.\n要依靠销售收回开发成本.\n\nThis began to change in the early 1950s,\n1950年代，事情开始发生变化,\n\nespecially with Eckert and Buckley's Univac 1,\n特别是 Univac 1，它是第一台取得商业成功的电脑\n\nthe first commercially successful computer.\n特别是 Univac 1，它是第一台取得商业成功的电脑\n\nUnlike ENIAC or Atlas , this wasn't just one single computer. It was a model of computers.\n不像 ENIAC 或 Atlas \\N Univanc 1 不是一台机器，而是一个型号\n\nin total more than 40 were built.\n一共造了40多台\n\nMost of these Univacs went to government offices or large companies.\n大部分 Univac 去了政府或大公司\n\nWhich was part of the growing military industrial complex in the United States,\n成为美国日益增长的军事工业综合体的一部分\n\nwith pockets deep enough to afford the cutting edge.\n因为政府有钱承担这些尖端科技.\n\nFamously, a Univac 1 built for the U.S atomic energy commission\n一个著名的例子是，\\N 一台给 美国原子能委员会 生产的 Univac 1\n\nwas used by CBS to predict the results of the 1952 U.S. presidential election.\n被 CBS 用来预测 1952 年美国总统大选的结果\n\nWith just 1% of the vote the computer correctly predicted\n仅用1％的选票，Univac 1 正确预测了结果. \\N 艾森豪威尔 获得压倒性胜利，而专家预测 史蒂文森 会赢\n\nEisenhower landslide, while pundits favored Stevenson.\n仅用1％的选票，Univac 1 正确预测了结果. \\N 艾森豪威尔 获得压倒性胜利，而专家预测 史蒂文森 会赢\n\nIt was a media event that helped propel computing to the forefront of the public's imagination\n这次事件把计算机推到了公众面前\n\nComputing was unlike machines of the past,\n计算机和以前的机器不一样\n\nwhich generally augmented human physical abilities.\n以前的机器 增强人类的物理能力\n\nTrucks allowed us to carry more, automatic looms whoa faster,\n比如卡车能带更多东西，自动织布机更快\n\nMachine tools were more precise and so on\n机床更精确 等等. 这些东西代表了工业革命.\n\nfor a bunch of contraptions that typify the industrial revolution.\n机床更精确 等等. 这些东西代表了工业革命.\n\nBut computers on the other hand could augment human intellect.\n而计算机增强的是人类智力\n\nThis potential wasn't lost on Vannevar Bush,\n范内瓦·布什 看到了这种潜力 \\N 他在1945年发表了一篇文章\n\nwho in 1945 published an article on a\n范内瓦·布什 看到了这种潜力 \\N 他在1945年发表了一篇文章\n\nhypothetical computing device he envisioned called the Memex.\n描述了一种假想计算设备叫 Memex\n\nThis was a device in which an individual stores all his books,\n可以用这个设备 \\N 存自己所有的书, 其他资料 以及和别人沟通\n\nrecords and communications and which is mechanized,\n而且数据是按照格式存储, \\N 所以可以快速查询，有很大灵活性.\n\nso it may be consulted with exceeding speed and flexibility\n而且数据是按照格式存储, \\N 所以可以快速查询，有很大灵活性.\n\nIt is an enlarged intimate supplement to his memory.\n可以辅助我们的记忆\n\nHe also predicted that wholly new forms of encyclopedia will appear,\n他还预测会出现 新的百科全书形式\n\nready-made, with a mesh of associative trails running through them.\n信息之间相互链接\n\nSound familiar?\n听起来是不是很熟悉？（维基百科）\n\nMemex directly inspired several subsequent game-changing systems,\nMemex 启发了  之后几个重要里程碑\n\nlike Ivan Sutherland Sketchpad, which we discussed last episode,\n比如上集 伊万·萨瑟兰 的 Sketchpad(画板)\n\nand Dough Engelbart's online system, which we will cover soon.\n以及后面很快会讲到 \\N Dough Engelbart 的 oN-LINE 系统（第26集）\n\nVannevar Bush was the head of the U.S. office of Scientific Research and Development,\n范内瓦·布什 \\N 做过\"美国科学研究与开发办公室\"的头头\n\nwhich was responsible for funding and coordinating scientific research during World War 2.\n这个部门负责在二战期间 \\N 资助和安排科学研究\n\nWith the Cold War brewing, Bush lobbied for a creation of a peace time equivalent,\n冷战时 范内瓦·布什 到处游说，\\N 想建立一个职责类似，但是在和平时期运作的部门\n\nthe National Science Foundation, formed in 1950.\n因此 国家科学基金会 于1950年成立\n\nTo this day the NSF provides federal funding to support scientific research in the United States.\n至今，国家科学基金会 \\N 依然负责给科学研究 提供政府资金\n\nAnd it is a major reason the U.S. has continued to be a leader in the technology sector.\n美国的科技领先全球，主要原因之一就是这个机构.\n\nIt was also in the 1950s that consumers started to buy transistor powered gadgets,\n1950年代，消费者开始买晶体管设备\n\nnotable among them was the transistor radio,\n其中值得注意的是 收音机\n\nwhich was small, durable and battery-powered.\n它又小又耐用，用电池就够了，而且便携\n\nAnd it was portable,\n它又小又耐用，用电池就够了，而且便携\n\nunlike the vacuum tube based radio sets from the 1940s and before.\n不像 1940 年代之前的收音机，用的是真空管.\n\nIt was a runaway success, the Furby or iPhone of its day.\n收音机非常成功，卖的像\"菲比精灵\"和 iPhone 一样畅销.\n\nThe Japanese government looking for industrial opportunities,\n日本政府也在寻求工业机会，想振兴战后经济，\n\nto bolster their post-war economy, soon got in on the action.\n日本政府也在寻求工业机会，想振兴战后经济，\n\nLicensing the rights to Transistors from Bell Labs in 1952.\n他们很快动手从贝尔实验室 取得晶体管的授权\n\nHelping launch the Japanese semiconductor and electronics industry.\n帮助振兴日本的半导体和电子行业\n\nIn 1955, the first Sony product was released:\n1955年，索尼的第一款产品面世\n\nThe TR-55 Transistor Radio. Concentrating on quality and price,\nTR-55 晶体管收音机. 他们把重心放在质量和价格.\n\nJapanese companies captured half of the U.S. Market for portable radios in just five years.\n因此日本公司在短短5年内，就占有了美国便携式收音机市场的一半.\n\nThis planted the first seeds of a major industrial rivalry in the decades to come.\n这为日本成为美国的强大工业对手，埋下伏笔\n\nIn 1953, there were only around 100 computers on the entire planet\n1953年，整个地球大概有100台计算机\n\nand at this point, the USSR was only a few years behind the West in computing technology,\n苏联这时的计算机科技  只比西方落后几年\n\ncompleting their first programmable electronic computer in 1950.\n苏联在1950年 \\N完成了第一个可编程电子计算机\n\nBut the Soviets were way ahead in the burgeoning space race.\n但苏联在太空竞赛远远领先\n\nLet's go to the thought-bubble.\n我们进入思想泡泡\n\nThe Soviets launched the world's first satellite into orbit, Sputnik one,\n苏联在1957年 \\N 把第一个卫星送上轨道，史波尼克1号\n\nin 1957, and a few years later in 1961.\n不久，在1961年\n\nSoviet Cosmonaut, Yuri Gagarin became the first human in space.\n苏联宇航员 尤里·加加林 第一个进入太空\n\nThis didn't sit well with the American public\n美国民众对此不满\n\nand prompted President Kennedy, a month after Gagarin's mission,\n使得肯尼迪总统 \\N 在加加林太空任务一个月后\n\nto encourage the nation to land a man on the moon within the decade. And it was expensive!\n提出要登陆月球. 登月很贵的!\n\nNASA's budget grew almost tenfold,\nNASA 的预算增长了几乎十倍,\n\npeaking in 1966 at roughly 4.5 percent of the U.S. Federal budget\n在 1966 年达到顶峰，占了政府预算的4.5%\n\nToday, It's around half a percent\n如今, NASA 的预算只占 0.5%\n\nNASA used this funding to tackle a huge array of enormous challenges\nNASA 用这笔钱资助各种科学研究\n\nthis culminated in the Apollo program\n阿波罗计划花的钱最多，雇了40万人左右\n\nWhich is peak employed roughly 400,000 people\n阿波罗计划花的钱最多，雇了40万人左右\n\nfurther supported by over 20,000 universities and companies\n而且有2万多家大学和公司参与.\n\none of these huge challenges was navigating in space\n其中一个挑战是 怎样在太空中导航\n\nNASA needed a computer to process complex trajectories\nNASA 需要电脑计算复杂的轨道来引导太空船\n\nand issue guidance commands to the spacecraft\nNASA 需要电脑计算复杂的轨道来引导太空船\n\nFor this, they built the Apollo guidance computer,\n因此，他们造了 \"阿波罗导航计算机\"\n\nThere were three significant requirements\n有3个重要要求\n\nFirst, the computer had to be fast, no surprise there.\n1. 计算机要快, 这在意料之中.\n\nSecond, it had to be small & lightweight\n2. 计算机要又小又轻.\n\nthere's not a lot of room in a spacecraft\n太空船里的空间不多\n\nand every ounce is precious when you're flying a quarter million miles to the moon\n而且要飞去月球，能轻一点是一点\n\nAnd finally it had to be really really ridiculously reliable\n3. 要超级可靠\n\nThis is super important in a spacecraft\n这对太空船非常重要，因为太空中有很多震动，辐射，极端温度变化\n\nWhere there's lots of vibration radiation and temperature change\n这对太空船非常重要，因为太空中有很多震动，辐射，极端温度变化\n\nAnd there's no running to Best Buy, if something breaks.\n如果东西坏掉了，可没办法去\"百思买\"买新的\n\nthe technology of the era of vacuum tubes and discrete transistors\n那时的主流科技 \\N 真空管和晶体管 无法胜任这些要求\n\nJust weren't up to the task\n那个时代的主流科技，真空管和离散晶体管，无法胜任这些要求.\n\nso NASA turned to a brand-new technology, integrated circuits.\n所以 NASA 用全新科技：集成电路\n\nWhich we discussed a few episodes ago\n我们几集前聊过\n\nThe Apollo guidance computer was the first computer to use them, a huge paradigm shift\n阿波罗导航计算机 首先使用了集成电路\n\nNASA was also the only place that could afford them\nNASA 是唯一负担得起集成电路的组织\n\nInitially each chip cost around $50\n最初，一个芯片差不多50美金\n\nAnd the guidance computer needed thousands of them.\n导航计算机需要上千个芯片\n\nBut by paying that price, the Americans were able to beat the soviets to the moon\n但美国也因此成功登月，打败苏联\n\nThanks, thought-bubble\n谢了 思想泡泡\n\nAlthough the Apollo Guidance computer is credited\n虽然人们经常把集成电路的发展 \\N 归功于阿波罗导航计算机\n\nwith spurring the development and adoption of integrated circuits\n虽然人们经常把集成电路的发展 \\N 归功于阿波罗导航计算机\n\nIt was a low volume, product there are only 17 Apollo missions after all.\n但它们的产量很低，一共只有 17 次阿波罗任务\n\nit was actually military applications\n实际上是军事 大大推进了集成电路发展\n\nEspecially the minuteman and polaris nuclear missile systems\n特别是洲际导弹和核弹，使集成电路大规模生产\n\nThat allowed integrated circuits to become a mass-produced item\n特别是洲际导弹和核弹，使集成电路大规模生产\n\nThis rapid Advancement was further accelerated by the U.S.\n美国建造强大计算机时，也进一步推进了集成电路\n\nBuilding and buying huge powerful computers\n美国建造强大计算机时，也进一步推进了集成电路\n\nOften called supercomputers, because they were frequently\n一般叫\"超级计算机\"，\\N 因为它们经常比全球最快电脑还快10倍以上\n\n10 times faster than any other computer on the planet, upon their release.\n一般叫\"超级计算机\"，\\N 因为它们经常比全球最快电脑还快10倍以上\n\nbut these machines built by companies like CDC, Cray and IBM were also\n但 CDC，Cray，IBM 制造的计算机非常昂贵\n\nsuper in cost, and pretty much only governments could afford to buy them.\n几乎只有政府负担得起\n\nin the U.S. these machines went to government Agencies like the NSA.\n这些计算机用于政府机构，比如美国国家安全局\n\nand government research labs like Lawrence Livermore and Los Alamos National laboratories\n以及实验室比如  \\N 劳伦斯·利弗莫尔 实验室 \\N  洛斯·阿拉莫斯 国家实验室\n\nInitially the U.S. semiconductor industry boomed\n最初，美国的半导体行业 \\N 靠高利润政府合同起步\n\nbuoyed by High profit government contracts\n最初，美国的半导体行业 \\N 靠高利润政府合同起步\n\nHowever this meant that most U.S.companies overlooked\n因此忽略了消费者市场，因为利润小\n\nthe consumer market where profit margins were small\n因此忽略了消费者市场，因为利润小\n\nthe Japanese Semiconductor industry came to dominate this niche\n因此日本半导体行业在1950和1960年代 \\N 靠低利润率占领了消费者市场\n\nby having to operate with lean profit margins in the 1950s and 60s\n因此日本半导体行业在1950和1960年代 \\N 靠低利润率占领了消费者市场\n\nthe Japanese had invested heavily in manufacturing capacity\n日本人投入大量资金，大量制造以达到规模经济\n\nto achieve economies of scale\n日本人投入大量资金，大量制造以达到规模经济\n\nin research to improve quality and Yields and in automation to keep manufacturing costs low.\n同时研究技术，提高质量和产量 \\N 以及用自动化来降低成本\n\nin the 1970s with the Space Race and cold war subsiding\n1970年代，太空竞赛和冷战逐渐消退 \\N 高利润的政府合同变少\n\npreviously juicy defense contracts began to dry up.\n1970年代，太空竞赛和冷战逐渐消退 \\N 高利润的政府合同变少\n\nand American semi-conductor and electronics companies found it harder to compete.\n美国的半导体和电子设备公司发现更难竞争了\n\nit didn't help the many computing components had been commoditized\n虽然很多计算机组件商品化了，但并没有什么帮助\n\nDRAM was DRAM\nDRAM 就是 DRAM\n\nSo why buy expensive Intel memory when you could buy the same chip for less from Hitachi?\n能从日立买便宜的，干嘛要从英特尔买贵的？\n\nThroughout the 1970s U.S. companies began to downsize,\n1970年代 美国公司开始缩小，合并，或直接倒闭\n\nconsolidate or outright fail.\n1970年代 美国公司开始缩小，合并，或直接倒闭\n\nIntel had to lay off a third of its workforce in 1974\n1974年 英特尔不得不裁员三分之一\n\nand even the storied Fairchild semiconductor\n知名的仙童半导体也在 1979 年濒临倒闭 \\N 被其他公司收购了\n\nwas acquired in 1979 after near bankruptcy\n知名的仙童半导体也在 1979 年濒临倒闭 \\N 被其他公司收购了\n\nto survive many of these companies began to outsource their manufacturing in a bid to reduce costs.\n为了生存，很多公司把生产外包出去，降低成本\n\nIntel withdrew from its main product category, Memory IC\n英特尔不再把精力放在 内存集成电路 \\N 而是把精力放在处理器\n\nand decided to refocus on processes.\n英特尔不再把精力放在 内存集成电路 \\N 而是把精力放在处理器\n\nWhich ultimately saved the company.\n这个决定最后挽救了公司\n\nThis low and U.S.\n美国公司的无力 \\N 导致 夏普 和 卡西欧 这样的日本公司\n\nelectronics industry allowed Japanese companies like Sharp and Casio\n美国公司的无力 \\N 导致 夏普 和 卡西欧 这样的日本公司\n\nto dominate the breakout computing product of the 1970s.\n占领了1970年代的主流产品\n\nHandheld electronic calculators.\n手持计算器\n\nby using integrated circuits, these could be made small and cheap.\n因为集成电路，计算机又小又便宜\n\nThey replaced expensive desktop adding machines you find in offices.\n取代了办公室里昂贵的桌面计算器\n\nFor most people it was the first time they didn't have to do math on paper, or use a slide rule\n对大多数人 \\N 这是他们第一次不必用纸笔和计算尺来做计算\n\nThey were an instant hit, selling by the millions.\n手持计算机因此大卖\n\nThis further drove down the cost of integrated circuits\n进一步降低了集成电路的成本\n\nand led to the development and widespread use of micro processors.\n使得微处理器被广泛使用\n\nlike the Intel 4004 we've discussed previously\n比如之前讨论过的 Intel 4004\n\nThis chip was built by Intel in 1971\nIntel 在1971年 \\N 应日本计算器公司 Busicom 的要求做了这个芯片\n\nat the request of Japanese calculator company Busicom.\nIntel 在1971年 \\N 应日本计算器公司 Busicom 的要求做了这个芯片\n\nSoon, Japanese electronics were everywhere.\n很快，日本电子产品到处都是\n\nfrom televisions of VCRs to digital wristwatches and Walkmans\n从电视到手表到随身听\n\nthe availability of inexpensive microprocessor\n而廉价的微处理器，也催生了全新的产品，比如街机游戏\n\nSpawned in entirely new products like video arcades,\n而廉价的微处理器，也催生了全新的产品，比如街机游戏\n\nthe world got Pong in 1972 and Breakout in 1976.\n1972年诞生了Pong，1976年诞生了打砖块\n\nas cost continued to plummet\n因为成本不断下降\n\nsoon it became possible for regular people to afford computing devices\n很快，普通人也买得起计算机了\n\nduring this time we see the emergence of the first successful home computers\n这段期间，第一批家用电脑开始出现，比如1975年的 Altair 8800\n\nlike the 1975 Altair 8800\n这段期间，第一批家用电脑开始出现，比如1975年的 Altair 8800\n\nand also the first home gaming consoles\n以及第一款家用游戏机，比如1977年的Atari 2600\n\nlike the Atari 2600 in 1977,\n以及第一款家用游戏机，比如1977年的Atari 2600\n\nHome, now I repeat that, Home.\n家用！我再说一遍 家用！\n\nThat seems like a small thing today.\n如今没什么大不了的.\n\nBut this was the dawn of a whole new era in computing.\n但那时是计算机的全新时代\n\nin just three decades, computers have evolved from\n在短短三十年内，计算机从大到人类可以在 CPU 里走来走去\n\nmachines where you could literally walk inside of the CPU.\n在短短三十年内，计算机从大到人类可以在 CPU 里走来走去\n\nassuming you had government clearance\n当然，你要有政府许可你这样做.\n\nto the point where a child could play with a handheld toy\n发展到小到小孩都能拿住的手持玩具，而且微处理器还快得多.\n\nContaining a microprocessor many times faster,\n发展到小到小孩都能拿住的手持玩具，而且微处理器还快得多.\n\nCritically, this dramatic evolution would have been but without two powerful forces at play\n这种巨大变化是由两种力量推动的：政府和消费者\n\nGovernments and Consumers.\n这种巨大变化是由两种力量推动的：政府和消费者\n\nGovernment funding like the United States provided during the cold war\n政府资金，比如冷战期间美国投入的钱\n\nenabled early adoption of many nascent computing technologies\n推动了计算机的早期发展\n\nThis funding helped flow entire Industries relate into computing long enough\n并且让计算机行业活得足够久，使得技术成熟到可以商用\n\nfor the technology to mature and become commercially feasible.\n并且让计算机行业活得足够久，使得技术成熟到可以商用\n\nThen businesses and ultimately consumers, provided the demand to take it mainstream.\n然后是公司，最后是消费者，把计算机变成了主流\n\nThe cold war may be over, but this relationship continues today\n冷战虽然结束了，但这种关系今天仍在继续\n\nGovernments are still funding science research.\n政府依然在资助科学研究\n\nintelligence agencies are still buying supercomputers.\n情报机构依然在超级计算机\n\nhumans are still being launched into space.\n人类仍然被发射到太空里\n\nAnd you're still buying TV, Xbox, Playstation, Laptop and Smartphone\n而你依然在买电视，Xbox，Playstation，笔记本电脑和手机\n\nand for these reasons,\n因此，计算机会继续飞速发展\n\nComputing continues to advance a lightning pace.\n因此，计算机会继续飞速发展\n\nI'll see you next week\n我们下周见\n\nHi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nAs we discussed last week, the idea of having a computer all to yourself a personal\n上周说过\"个人计算机\"的概念 \\N 在计算机发展的头 30 年难以想象\n\ncomputer was elusive for the first three decades of electronic computing.\n上周说过\"个人计算机\"的概念 \\N 在计算机发展的头 30 年难以想象\n\nIt was just way too expensive for a computer to be owned and used by one single person.\n如果只让一个人用，成本实在太高\n\nBut, by the early 1970s, all the required components had fallen into place to build\n但到 70 年代初，各种组件的成本都下降了 \\N 可以做出低成本  同时性能足够强大的计算机\n\na low cost, but still usefully powerful computer.\n但到 70 年代初，各种组件的成本都下降了 \\N 可以做出低成本  同时性能足够强大的计算机\n\nNot a toy, but a tool.\n不是玩具级计算机，是真正能用的计算机\n\nMost influential in this transition was the advent of single-chip CPUs,\n这个转变中 \\N 最有影响力的是 单芯片 CPU 的出现\n\nwhich were surprisingly powerful, yet small and inexpensive.\n强大 + 体积小 + 便宜\n\nAdvances in integrated circuits also offered low-cost solid-state memory,\n集成电路的进步，也提供了低成本固态存储器\n\nboth for computer RAM and ROM.\n可以用于计算机的 RAM 和 ROM\n\nSuddenly it was possible to have an entire computer on one circuit board,\n忽然间 \\N 把整台计算机做到一张电路板上成为可能\n\ndramatically reducing manufacturing costs.\n大大地降低了制造成本\n\nAdditionally, there was cheap and reliable computer storage,\n而且，那时有便宜可靠的储存介质 \\N 比如磁带和软盘\n\nlike magnetic tape cassettes and floppy disks.\n而且，那时有便宜可靠的储存介质 \\N 比如磁带和软盘\n\nAnd finally, the last ingredient was low cost displays, often just repurposed televisions.\n最后是 低成本的显示器 \\N 通常是电视机稍作改装而成\n\nIf you blended these four ingredients together in the 1970s, you got,\n如果在 1970 年代 \\N 将这四种原料混在一起\n\nwhat was called a microcomputer,\n就得到了\"微型计算机\"\n\nbecause these things were so tiny compared to \"normal\" computers of that era, the\n因为和那个时代的\"普通\"计算机相比 \\N 这些计算机很小\n\ntypes you'd see in business or universities.\n\"普通\"计算机就是公司或大学里的那种\n\nBut more important than their size was their cost.\n但比大小更重要的是成本\n\nThese were, for the first time, sufficiently cheap.\n这是有史以来第一次，计算机的价格足够低\n\nIt was practical to buy one and only have one person ever use it.\n\"一个人专用\"的想法变得可行\n\nNo time sharing,\n不用划分时间和别人公用计算机\n\nno multi-user logins,  just a single owner and user.\n没有多用户登录，计算机只属于一个人，只有一个用户\n\nThe personal computer era had arrived.\n个人计算机时代到来\n\nComputer cost and performance eventually reached the point\n计算机成本下降+性能提升, 让个人计算机成为可能\n\nwhere personal computing became viable.\n计算机成本下降+性能提升, 让个人计算机成为可能\n\nBut, it's hard to define exactly when that happened.\n但这个时间点很难准确定义, 并没有一个具体时间点\n\nThere's no one point in time.\n但这个时间点很难准确定义, 并没有一个具体时间点\n\nAnd as such, there are many contenders for the title of \"first\" personal computer,\n因此\"第一台个人计算机\"这个名号，有很多竞争者\n\nlike the Kenback-1 and MCM/70.\n比如 Kenback-1 和 MCM/70\n\nLess disputed, however, is the first commercially successful personal computer: The Altair 8800.\n不过第一台取得商业成功的个人计算机 \\N 争议较小：Altair 8800\n\nThis machine debuted on the cover of Popular Electronics in 1975,\n首次亮相在 1975 年《Popular Electronics》封面\n\nand was sold as a $439 kit that you built yourself.\n售价 $439 美元，需要自己组装\n\nInflation adjusted, that's about $2,000 today,\n计算通货膨胀后，相当如今的 2000 美元左右\n\nwhich isn't chump change, but extremely cheap for a computer in 1975.\n不算小钱，但比起 1975 年的其它计算机，算是非常便宜了\n\nTens of thousands of kits were sold to computer hobbyists,\n各种需要自己组装的组件包  \\N卖给了计算机爱好者\n\nand because of its popularity, there were soon all sorts of nifty add-ons available...\n因为买的人多，很快相关产品出现了\n\nthings like extra memory, a paper tape reader and even a teletype interface.\n比如内存，纸带读取器，甚至电传接口\n\nThis allowed you, for example, to load a longer, more complicated program from punch tape,\n让你可以从纸带上读取更长更复杂的程序\n\nand then interact with it using a teletype terminal.\n然后用电传终端交互\n\nHowever, these programs still had to be written in machine code,\n但程序还是要用 机器码 写\n\nwhich was really low level and nasty, even for hardcore computer enthusiasts.\n写起来很麻烦，即使计算机爱好者也讨厌写\n\nThis problem didn't escape a young Bill Gates and Paul Allen,\n这没有吓跑年轻的比尔·盖茨和保罗·艾伦\n\nwho were 19 and 22 respectively.\n他们当时是19岁和22岁\n\nThey contacted MITS, the company making the Altair 8800,\n他们联系了制造 Altair 8800 的 MITS 公司\n\nsuggesting the computer would be more attractive to hobbyists\n建议说，如果能运行 BASIC 程序 \\N 会对爱好者更有吸引力\n\nif it could run programs written in BASIC,\n建议说，如果能运行 BASIC 程序 \\N 会对爱好者更有吸引力\n\na popular and simple programming language.\nBASIC 是一门更受欢迎更简单的编程语言\n\nTo do this, they needed to write a program that converted BASIC instructions\n为此，他们需要一个程序 \\N 把 BASIC 代码转成可执行机器码\n\ninto native machine code, what's called an interpreter.\n这叫 解释器 (interpreter)\n\nThis is very similar to a compiler,\n\"解释器\"和\"编译器\"类似\n\nbut happens as the programs runs instead of beforehand.\n区别是\"解释器\"运行时转换\\N而\"编译器\"提前转换\n\nLet's go to the thought bubble!\n让我们进入思想泡泡！\n\nMITS was interested,\nMITS 表示感兴趣\n\nand agreed to meet Bill and Paul for a demonstration.\n同意与 Bill 和 Paul 见个面，让他们演示一下\n\nProblem is, they hadn't written the interpreter yet.\n问题是，他们还没写好解释器\n\nSo, they hacked it together in just a few weeks\n所以他们花了几个星期赶工 \\N 而且还不是在 Altair 8800 上写的\n\nwithout even an Altair 8800 to develop on,\n所以他们花了几个星期赶工 \\N 而且还不是在 Altair 8800 上写的\n\nfinishing the final piece of code on the plane.\n最后在飞机上完成了代码\n\nThe first time they knew their code worked was at MITS headquarters\n他们在墨西哥 阿尔伯克基（城市） \\N 的 MITS 总部做演示时，才知道代码可以成功运行\n\nin Albuquerque, New Mexico, for the demo.\n他们在墨西哥 阿尔伯克基（城市） \\N 的 MITS 总部做演示时，才知道代码可以成功运行\n\nFortunately, it went well and MITS agreed to distribute their software.\n幸运的是进展顺利 \\N MITS 同意在计算机上搭载他们的软件\n\nAltair BASIC became the newly formed Microsoft's first product.\nAltair BASIC 成了微软的第一个产品\n\nAlthough computer hobbyists existed prior to 1975,\n虽然1975年之前就有计算机爱好者\n\nthe Altair 8800 really jump-started the movement.\n但 Altair 8800 大量催生了更多计算机爱好者\n\nEnthusiast groups formed, sharing knowledge and software and passion about computing.\n爱好者们组成各种小组 \\N 分享知识，软件，以及对计算机的热爱\n\nMost legendary among these is the Homebrew Computer Club,\n最具传奇色彩的小组是\"家酿计算机俱乐部\"\n\nwhich met for the first time in March 1975\n第一次小组聚会在1975年3月\n\nto see a review unit of the Altair 8800, one of the first to ship to California.\n看一台第一批运来加州的 Altair 8800\n\nAt that first meeting was 24-year-old Steve Wozniak, who was so inspired by\n第一次聚会上，24岁的 Steve Wozniak  \\N 被 Altair 8800 大大激励\n\nthe Altair 8800 that he set out to design his own computer.\n开始想设计自己的计算机\n\nIn May 1976, he demonstrated his prototype to the Club\n1976年5月，他向小组展示了原型机\n\nand shared the schematics with interested members.\n并且把电路图分享给感兴趣的其他会员\n\nUnusual for the time, it was designed to connect to a TV and offered a text interface\n他的设计不同寻常 \\N 要连到电视显示，并提供文本界面\n\na first for a low-cost computer.\n在低成本计算机上还是第一次见\n\nInterest was high, and shortly after fellow club member and college friend Steve Jobs\n同是俱乐部成员和大学朋友的 史蒂夫·乔布斯\n\nsuggested that instead of just sharing the designs for free,\n建议说与其免费分享设计，不如直接出售装好的主板\n\nthey should just sell an assembled motherboard.\n建议说与其免费分享设计，不如直接出售装好的主板\n\nHowever, you still had to add your own keyboard, power supply, and enclosure.\n但用户依然需要自己加键盘，电源和机箱\n\nIt went on sale in July 1976 with a price tag of $666.66.\n1976年7月开始发售，价格$666.66美元\n\nIt was called the Apple-I, and it was Apple Computer's first product.\n它叫 Apple-I ，苹果计算机公司的第一个产品\n\nThanks thought bubble!\n谢了 思想泡泡\n\nLike the Altair 8800, the Apple-I was sold as a kit.\n就像 Altair 8800 一样，Apple-I 也是作为套件出售\n\nIt appealed to hobbyists,\nApple-I 吸引了业余爱好者 \\N 不介意机器买回来自己组装\n\nwho didn't mind tinkering and soldering,\nApple-I 吸引了业余爱好者 \\N 不介意机器买回来自己组装\n\nbut consumers and businesses weren't interested.\n但个人消费者和公司对 Apple-I 不感兴趣\n\nThis changed in 1977,\n这在 1977 年发生变化 \\N 市场上有了三款开箱即用的计算机\n\nwith the release of three game-changing computers,  that could be used right out of the box.\n这在 1977 年发生变化 \\N 市场上有了三款开箱即用的计算机\n\nFirst was the Apple II,\n第一款是 Apple-II\n\nApple's earliest product that sold as a complete system\n苹果公司第一个提供全套设备的产品\n\nthat was professionally designed and manufactured.\n设计和制造工艺都是专业的\n\nIt also offered rudimentary color graphics and sound output,\n它还提供了简单彩色图形和声音输出\n\namazing features for a low cost machine.\n这些功能对低成本机器非常了不起\n\nThe Apple II series of computers sold by the millions and quickly\nApple-II 卖了上百万套\n\npropelled Apple to the forefront of the personal computing industry.\n把苹果公司推到了个人计算机行业的前沿\n\nThe second computer was the TRS-80 Model I,\n第二款是\"TRS-80 1型\"\n\nmade by the Tandy Corporation\n由 Tandy 公司生产\n\nand sold by RadioShack hence the \"TRS\"\n由 Radioshack 销售，所以叫 TRS\n\nAlthough less advanced than the Apple II,\n虽然不如 Apple-II 先进 \\N 但因为价格只有一半，所以卖得很火爆\n\nit was half the cost and sold like hot cakes.\n虽然不如 Apple-II 先进 \\N 但因为价格只有一半，所以卖得很火爆\n\nFinally, there was the Commodore PET 2001,\n最后一款是 Commodore PET 2001\n\nwith a unique all-in-one design\n有一体化设计\n\nthat combined computer, monitor, keyboard and tape drive into one device,\n集成了计算机，显示器，键盘和磁带驱动器\n\naimed to appeal to consumers.\n目标是吸引普通消费者\n\nIt started to blur the line between computer and appliance.\n计算机和家用电器之间的界限开始变得模糊\n\nThese three computers became known as the 1977 Trinity.\n这3台计算机被称为1977年的\"三位一体\"\n\nThey all came bundled with BASIC interpreters,\n它们都自带了 BASIC 解释器\n\nallowing non-computer-wizards to create programs.\n让不那么精通计算机的人也能用 BASIC 写程序\n\nThe consumer software industry also took off,\n针对消费者的软件行业 开始腾飞\n\noffering games and productivity tools for personal computers,\n市场上出现了各种 \\N 针对个人计算机的游戏和生产力工具\n\nlike calculators and word processors.\n比如计算器和文字处理器\n\nThe killer app of the era was 1979's VisiCalc,\n最火的是 1979 年的 VisiCalc\n\nthe first spreadsheet program\n第一个电子表格程序\n\nwhich was infinitely better than paper\n比纸好无数倍\n\nand the forbearer of programs like Microsoft Excel and Google Sheets.\n是微软 Excel 和 Google Sheets 的老祖先\n\nBut perhaps the biggest legacy of these computers was their marketing,\n但这些计算机带来的最大影响 \\N 也许是他们的营销策略\n\nthey were the first to be targeted at households, and not just businesses and hobbyists.\n它们针对普通消费者 \\N 而不是企业和爱好者\n\nAnd for the first time in a substantial way,\n这是第一次大规模地\n\ncomputers started to appear in homes, and also small businesses and schools.\n计算机出现在家庭，小公司，以及学校中\n\nThis caught the attention of the biggest computer company on the planet, IBM, who had seen its\n这引起了全球最大计算机公司 IBM 的注意\n\nshare of the overall computer market shrink from 60% in 1970 to around 30% by 1980.\n其市场份额从1970年的60％ \\N 在1980年降到了30％左右\n\nThis was mainly because IBM had ignored the microcomputer market,\n因为IBM忽略了增长的\"微型计算机\"市场\n\nwhich was growing at about 40% annually.\n这个市场每年增长约40％\n\nAs microcomputers evolved into personal computers, IBM knew it needed to get in on the action.\n随着微型计算机演变成个人计算机 \\N IBM 知道他们需要采取行动\n\nBut to do this, it would have to radically rethink its computer strategy and design.\n但要做到这一点 \\N 公司要从根本上重新思考战略和设计\n\nIn 1980, IBM's least-expensive computer, the 5120, cost roughly ten thousand dollars,\n1980年 IBM 最便宜的计算机 \\N \"5120\"的价格大概是一万美元\n\nwhich was never going to compete with the likes of the Apple II.\n永远也没法和 Apple-II 这样的计算机竞争\n\nThis meant starting from scratch.\n意味着要从头开始\n\nA crack team of twelve engineers, later nicknamed the dirty dozen,\n一个由十二名工程师组成的精干团队（后来叫\"肮脏十二人\"）\n\nwere sent off to offices in Boca Raton, Florida,\n被派往佛罗里达州的 \\N 博卡拉顿（Boca Raton）办公室\n\nto be left alone and put their talents to work.\n让他们独立工作\n\nShielded from IBM internal politics, they were able to design a machine as they desired.\n不受 IBM 内部的政治斗争干扰 \\N 他们想怎么设计怎么设计\n\nInstead of using IBM proprietary CPUs, they chose Intel chips.\n没用 IBM 的 CPU，选了 Intel 的芯片\n\nInstead of using IBM's prefered operating system, CP/M,\n也没用 IBM 的首选操作系统 CP/M\n\nthey licenced Microsoft's Disk Operating System: DOS\n而是用了微软的 DOS\n\nand so on, from the screen to the printer.\n依此类推，从屏幕到打印机都这样自由选择\n\nFor the first time, IBM divisions had to compete with outside firms\nIBM 第一次不得不与外部公司竞争\n\nto build hardware and software for the new computer.\n来给新计算机做硬件和软件\n\nThis radical break from the company tradition of in-house development kept costs low\n这和 IBM 的传统做法不同：自己做硬件来节省成本\n\nand brought partner firms into the fold.\n然后和其它公司合作\n\nAfter just a year of development,\n经过短短一年\n\nthe IBM Personal Computer, or IBM PC was released.\nIBM 个人计算机发布了，简称 IBM PC\n\nIt was an immediate success,\n产品立马取得了成功\n\nespecially with businesses that had long trusted the IBM brand.\n长期信任 IBM 品牌的企业买了很多\n\nBut, most influential to its ultimate success was that the computer featured an open architecture,\n但最有影响力的是 \\N 它使用 \"开放式架构\"\n\nwith good documentation and expansion slots,\n有良好的文档和扩展槽\n\nallowing third parties to create new hardware and peripherals for the platform.\n使得第三方可以做硬件/外设\n\nThat included things like graphics cards, sounds cards, external hard drives, joysticks,\n包括显卡，声卡，外置硬盘，游戏控制杆 \\N 以及无数其它组件\n\nand countless other add-ons.\n包括显卡，声卡，外置硬盘，游戏控制杆 \\N 以及无数其它组件\n\nThis spurred innovation, and also competition, resulting in a huge ecosystem of products.\n这刺激了创新，激发了竞争，产生了巨大的生态系统\n\nThis open architecture became known as \"IBM Compatible\".\n这个开放架构叫 IBM Compatible\"（IBM 兼容）\n\nIf you bought an \"IBM Compatible\" computer, it meant you\n意味着如果买了\"IBM兼容\"的计算机\n\ncould use that huge ecosystem of software and hardware.\n你可以用庞大生态系统中的其它软硬件\n\nBeing an open architecture also meant that competitor companies could follow the standard\n开放架构也意味着 竞争对手公司可以遵循这个标准\n\nand create their own IBM Compatible computers.\n做出自己的\"IBM 兼容\"计算机\n\nSoon, Compaq and Dell were selling their own PC clones...\n很快，康柏和戴尔也开始卖 PC\n\nAnd Microsoft was happy to license MS-DOS to them,\n微软很乐意把 MS-DOS 授权给他们\n\nquickly making it the most popular PC operating system.\n使 DOS 迅速成为最受欢迎的 PC 操作系统\n\nIBM alone sold two million PCs in the first three years, overtaking Apple.\n仅在前三年 \\N IBM就卖出了200万台 PC ，超过了苹果\n\nWith a large user base, software and hardware developers concentrated\n有了庞大用户群，软件和硬件开发人员 \\N 把精力放在\"IBM 兼容\"平台，因为潜在用户更多\n\ntheir efforts on IBM Compatible platforms, there were just more users to sell to.\n有了庞大用户群，软件和硬件开发人员 \\N 把精力放在\"IBM 兼容\"平台，因为潜在用户更多\n\nThen, people wishing to buy a computer bought the one with the\n同时，想买计算机的人 \\N 也会看哪种计算机的软硬件选择更多\n\nmost software and hardware available, and this effect snowballed.\n就像雪球效应一样\n\nCompanies producing non-IBM-compatible computers, often with superior specs,\n而那些生产非\"IBM兼容\"计算机的公司 （一般性能更好）\n\nfailed.\n都失败了\n\nOnly Apple kept significant market share without IBM compatibility.\n只有苹果公司在没有\"IBM兼容\"的情况下 \\N 保持了足够市场份额\n\nApple ultimately chose to take the opposite approach a \"closed architecture\" proprietary\n苹果公司最终选了相反的方式：\"封闭架构\"\n\ndesigns that typically prevent people from adding new hardware to their computers.\n即自己设计一切，用户一般无法加新硬件到计算机中\n\nThis meant that Apple made its own computers, with its own operating system, and often its\n意味着苹果公司要做自己的计算机，自己的操作系统\n\nown peripherals, like displays, keyboards, and printers.\n还有自己的外围设备，如显示器，键盘和打印机\n\nBy controlling the full stack, from hardware to software,\n通过控制整个范围，从硬件到软件\n\nApple was able to control the user experience and improve reliability.\n苹果能控制用户体验并提高可靠性\n\nThese competing business strategies were the genesis of the \"Mac\" versus \"PC\" division\n不同的商业策略是\"Mac vs PC 谁更好\"这种争论的起源\n\nthat still exists today... which is a misnomer, because they're both personal computers!\n这些争论如今还存在 \\N 不过\"Mac vs PC\"用词不对，因为它们都是个人计算机！\n\nBut whatever.\n但是随便啦\n\nTo survive the onslaught of low-cost PCs,\n为了在低成本个人计算机的竞争冲击下生存下来\n\nApple needed to up its game,\n苹果需要提高自身水平 \\N 提供比 PC 和 DOS 更好的用户体验\n\nand offer a user experience that PCs and DOS couldn't.\n苹果需要提高自身水平 \\N 提供比 PC 和 DOS 更好的用户体验\n\nTheir answer was the Macintosh, released in 1984.\n他们的答案是 Macintosh，于 1984 年发布\n\nThis ground breaking, reasonably-low-cost, all-in-one computer\n一台突破性 价格适中的一体式计算机 \\N 用的不是命令行界面，而是图形界面\n\nbooted not a command-line text-interface, but rather a graphical user interface,\n一台突破性 价格适中的一体式计算机 \\N 用的不是命令行界面，而是图形界面\n\nour topic for next week. See you then.\n我们下周讨论图形界面. 到时见\n\nHi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨 我是 Carrie Anne 欢迎收看计算机科学速成课\n\nWe ended last episode with the 1984 release of Apple's Macintosh personal computer.\n我们上集最后 \\N 谈了苹果在1984年发布的 Macintosh\n\nIt was the first computer a regular person could buy with a graphical user interface\n这是普通人可以买到的 \\N 第一台带图形用户界面的计算机\n\nand a mouse to interact with it.\n还带一个鼠标\n\nThis was a radical evolution from the command line interfaces\n那时的计算机全是命令行 \\N 图形界面是个革命性进展\n\nfound on all other personal computers of the era.\n那时的计算机全是命令行 \\N 图形界面是个革命性进展\n\nInstead of having to remember...\n不必记住或猜正确的命令\n\nor guess...  the right commands to type in,\n我们不必记住或猜测正确的命令\n\na graphical user interface shows you what functions are possible.\n图形界面直接显示了，你可以做什么\n\nYou just have to look around the screen for what you want to do.\n只要在屏幕上找选项就行了\n\nIt's a \"point and click\" interface.\n这是一个\"选择并点击\"的界面\n\nAll of a sudden, computers were much more intuitive.\n突然间计算机更直观了\n\nAnybody, not just hobbyists or computer scientists,\n不只是爱好者或科学家能用计算机 \\N 任何人都可以用计算机解决问题\n\ncould figure things out all by themselves.\n不只是爱好者或科学家能用计算机 \\N 任何人都可以用计算机解决问题\n\nThe Macintosh is credited with taking Graphical User Interfaces, or GUIs, mainstream,\n人们认为是 Macintosh \\N 把图形用户界面（GUI）变成主流\n\nbut in reality they were the result of many decades of research.\n但实际上图形界面是数十年研究的成果\n\nIn previous episodes, we discussed some early interactive graphical applications,\n前几集，我们讨论了早期的交互式图形程序\n\nlike Sketchpad and Spacewar!, both made in 1962.\n比如 Sketchpad 和太空战争 \\N 都是1962年制作的\n\nBut these were one-off programs,\n但都是一次性项目，不是整合良好的体验\n\nand not whole integrated computing experiences.\n但都是一次性项目，不是整合良好的体验\n\nArguably, the true forefather of modern GUIs was Douglas Engelbart.\n现代图形界面的先驱 \\N 可以说是 道格拉斯·恩格尔巴特\n\nLet's go to the thought bubble!\n让我们进入思想泡泡！\n\nDuring World War 2, while Engelbart was stationed in the Philippines as a radar operator,\n二战期间 \\N 恩格尔巴特 驻扎在菲律宾做雷达操作员\n\nhe read Vannevar Bush's article on the Memex.\n他读了 万尼瓦尔·布什 的 Memex 文章\n\nThese ideas inspired him,\n这些文章启发了他\n\nand when his Navy service ended,\n当他海军服役结束时\n\nhe returned to school, completing a Ph.D. in 1955 at U.C. Berkeley.\n他回到学校  \\N 1955年在 UCB 取得博士学位\n\nHeavily involved in the emerging computing scene,\n他沉溺于新兴的计算机领域\n\nhe collected his thoughts in a seminal 1962 report,\n他在1962年一份开创性报告中 \\N 汇集了各种想法\n\ntitled: \"Augmenting Human Intellect\".\n报告名为：\"增强人类智力\"\n\nEngelbart believed that the complexity of the problems facing mankind\n恩格尔巴特认为，人类面临的问题 \\N 比解决问题的能力增长得更快\n\nwas growing faster than our ability to solve them.\n恩格尔巴特认为，人类面临的问题 \\N 比解决问题的能力增长得更快\n\nTherefore, finding ways to augment our intellect\n因此，找到增强智力的方法 \\N 似乎是必要且值得一做的目标\n\nwould seem to be both a necessary and a desirable goal.\n因此，找到增强智力的方法 \\N 似乎是必要且值得一做的目标\n\nHe saw that computers could be useful beyond just automation,\n他构想计算机不仅做自动化工作\n\nand be essential interactive tools for future knowledge workers to tackle complex problems.\n也可以成为未来知识型员工 \\N 应对复杂问题的工具\n\nFurther inspired by Ivan Sutherland's recently demonstrated Sketchpad,\n伊凡·苏泽兰 的\"几何画板\" \\N 进一步启发了 恩格尔巴特\n\nEngelbart set out to make his vision a reality, recruiting a team to build the oN-Line System.\n他决定动手把愿景变为现实 \\N 开始招募团队来做 oN-Line System\n\nHe recognized that a keyboard alone was insufficient\n他意识到如果只有键盘 \\N 对他想搭建的程序来说是不够的\n\nfor the type of applications he was hoping to enable.\n他意识到如果只有键盘 \\N 对他想搭建的程序来说是不够的\n\nIn his words:\n用他的话说：\n\n\"We envisioned problem-solvers using computer-aided working stations to augment their efforts.\n\"我们设想人们用计算机辅助工作站来增强工作\n\nThey required the ability to interact with information displays\n用户需要和屏幕上的信息互动\n\nusing some sort of device to move [a cursor] around the screen.\"\n用某种设备在屏幕上移动[光标]\"\n\nAnd in 1964, working with colleague Bill English,\n1964年，和同事比尔·英格利希的共同努力下\n\nhe created the very first computer mouse.\n他创造了第一个计算机鼠标，尾部有一根线\n\nThe wire came from the bottom of the device\n他创造了第一个计算机鼠标，尾部有一根线\n\nand looked very much like a rodent and the nickname stuck.\n看起来很像老鼠 \\N 因此\"鼠标\"这个名字沿用了下来\n\nThanks thought bubble!\n谢了思想泡泡！\n\nIn 1968, Engelbart demonstrated his whole system at the Fall Joint Computer Conference,\n1968年 恩格尔巴特 \\N 在\"秋季计算机联合会议\"展示了他的系统\n\nin what's often referred to as \"the mother of all demos\".\n这次演示 被视为如今所有演示的祖先\n\nThe demo was 90 minutes long and demonstrated many features of modern computing:\n演示有90分钟 \\N 展现了现代计算机的许多功能：\n\nbitmapped graphics,\n包括 位图图像\n\nvideo conferencing,\n视频会议\n\nword processing,\n文字处理\n\nand collaborative real-time editing of documents.\n和 实时协作编辑文件\n\nThere were also precursors to modern GUIs,\n还有现代图形界面的原型  比如鼠标和多窗口\n\nlike the mouse and multiple windows\n还有现代图形界面的原型  比如鼠标和多窗口\n\n- although they couldn't overlap.\n- 不过窗口不能重叠\n\nIt was way ahead of its time,\n远远先于那个时代\n\nand like many products with that label, it ultimately failed,\n就像其它\"跨时代\"的产品一样，它最终失败了\n\nat least commercially.\n至少商业上是这样\n\nBut its influence on computer researchers of the day was huge.\n但它对当时的计算机研究者影响巨大\n\nEngelbart was recognized for this watershed moment in computing with a Turing Award in 1997.\n恩格尔巴特 因此获得1997年图灵奖\n\nFederal funding started to reduce in the early 1970s,\n政府资金在 1970 年代初开始减少\n\nwhich we discussed two episodes ago.\n我们在两集前说过\\N（第24集：冷战和消费主义）\n\nAt that point, many of Engelbart's team, including Bill English,\n那时，恩格尔巴特团队里的许多人，包括比尔·英格利希\n\nleft and went to Xerox's newly formed Palo Alto Research Center,\n去了施乐公司新成立的\"帕洛阿尔托研究中心\"\n\nmore commonly known as Xerox PARC.\n更为人熟知的名字是 Xerox PARC\n\nIt was here that the first true GUI computer was developed:\n他们在这里开发了第一台带真正 GUI 的计算机：\n\nthe Xerox Alto, finished in 1973.\n施乐奥托  于1973年完成\n\nFor the computer to be easy to use,\n为了让计算机易于使用，需要的不只是花哨的图形\n\nit needed more than just fancy graphics.\n为了让计算机易于使用，需要的不只是花哨的图形\n\nIt needed to be built around a concept that people were already familiar with,\n还要借助一些人们已经熟悉的概念\n\nso they could immediately recognize how to use the interface with little or no training.\n让人们不用培训 就能很快明白如何使用\n\nXerox's answer was to treat the 2D screen like the top of a desk or desktop.\n施乐的答案是将2D屏幕当作\"桌面\"\n\nJust like how you can have many papers laid out on a desk,\n就像桌面上放很多文件一样\n\na user could have several computer programs open at once.\n用户可以打开多个程序 \\N 每个程序都在一个框里，叫\"窗口\"\n\nEach was contained in their own frame,\n用户可以打开多个程序 \\N 每个程序都在一个框里，叫\"窗口\"\n\nwhich offered a view onto the application called a window.\n用户可以打开多个程序 \\N 每个程序都在一个框里，叫\"窗口\"\n\nAlso like papers on a desk,\n就像桌上的文件一样\n\nthese windows could overlap, blocking the items behind them.\n窗口可以重叠，挡住后面的东西\n\nAnd there were desk accessories, like a calculator and clock,\n还有桌面配件，比如计算器和时钟\n\nthat the user could place on the screen and move around.\n用户可以把配件在屏幕上四处移动\n\nIt wasn't an exact copy of a desktop though.\n它不是现实桌面的完美复制，而是用桌面这种隐喻\n\nInstead, it was a metaphor of a desktop.\n它不是现实桌面的完美复制，而是用桌面这种隐喻\n\nFor this reason, surprisingly, it's called the Desktop Metaphor.\n因此叫\"桌面隐喻\"\n\nThere are many ways to design an interface like this,\n有很多方法来设计界面 \\N 但 Alto 团队用窗口，图标，菜单和指针来做\n\nbut the Alto team did it with windows, icons, menus, and a pointer\n有很多方法来设计界面 \\N 但 Alto 团队用窗口，图标，菜单和指针来做\n\n- what's called a WIMP interface.\n- 因此叫 WIMP 界面\n\nIt's what most desktop GUIs use today.\n如今大部分图形界面都用这个\n\nIt also offered a basic set of widgets,\n它还提供了一套基本部件\n\nreusable graphical building blocks, things like buttons, checkboxes, sliders, and tabs\n可复用的基本元素 \\N 比如按钮，打勾框，滑动条和标签页\n\nwhich were also drawn from real world objects to make them familiar.\n这些也来自现实世界，让人们有熟悉感\n\nGUI applications are constructed from these widgets,\nGUI 程序就是这些小组件组成的\n\nso let's try coding a simple example using this new programming paradigm.\n让我们试着写一个简单例子\n\nFirst, we have to tell the operating system that we need a new window to be created for our app.\n首先，我们必须告诉操作系统 \\N 为程序创建一个窗口\n\nWe do this through a GUI API.\n我们通过 GUI API 实现 \\N 需要指定窗口的名字和大小\n\nWe need to specify the name of the window and also its size.\n我们通过 GUI API 实现 \\N 需要指定窗口的名字和大小\n\nLet's say 500 by 500 pixels.\n假设是 500×500 像素\n\nNow, let's add some widgets - a text box and a button.\n现在再加一些小组件，一个文本框和一个按钮\n\nThese require a few parameters to create.\n创建它们需要一些参数\n\nFirst, we need to specify what window they should appear in,\n首先要指定出现在哪个窗口 \\N 因为程序可以有多个窗口\n\nbecause apps can have multiple windows.\n首先要指定出现在哪个窗口 \\N 因为程序可以有多个窗口\n\nWe also need to specify the default text, the X and Y location in the window, and a width and height.\n还要指定默认文字\\N 窗口中的 X,Y 位置  以及宽度和高度\n\nOk, so now we've got something that looks like a GUI app,\n好，现在我们有个 \\N 看起来像 GUI 程序的东西\n\nbut has no functionality.\n但它还没有功能\n\nIf you click the \"roll\" button, nothing happens.\n如果点 Roll 按钮，什么也不会发生\n\nIn previous examples we've discussed,\n在之前的例子中，代码是从上到下执行的\n\nthe code pretty much executes from top to bottom.\n在之前的例子中，代码是从上到下执行的\n\nGUIs, on the other hand, use what's called event-driven programming;\n但 GUI 是 \"事件驱动编程\"\n\ncode can fire at any time, and in different orders, in response to events.\n代码可以在任意时间执行 以响应事件\n\nIn this case, it's user driven events,\n这里是用户触发事件 \\N 比如点击按钮，选一个菜单项，或滚动窗口\n\nlike clicking on a button, selecting a menu item, or scrolling a window.\n这里是用户触发事件 \\N 比如点击按钮，选一个菜单项，或滚动窗口\n\nOr if a cat runs across your keyboard,\n或一只猫踩过键盘\n\nit's a bunch of events all at once!\n就会一次触发好多事件！\n\nLet's say that when the user clicks the \"roll\" button,\n假设当用户点 Roll 按钮\n\nwe want to randomly generate a number between 1 and 20,\n我们产生1到20之间的随机数\n\nand then show that value in our text box.\n然后在文本框中，显示这个数字\n\nWe can write a function that does just that.\n我们可以写一个函数来做\n\nWe can even get a little fancy and say if we get the number 20,\n我们还可以让它变有趣些，假设随机数是 20 \\N 就把背景颜色变成血红色！\n\nset the background color of the window to blood red!\n我们还可以让它变有趣些，假设随机数是 20 \\N 就把背景颜色变成血红色！\n\nThe last thing we need to do is hook this code up\n最后，把代码与\"事件\"相连 \\N 每次点按钮时  都触发代码\n\nso that it's triggered each time our button is clicked.\n最后，把代码与\"事件\"相连 \\N 每次点按钮时  都触发代码\n\nTo do this, we need to specify that our function \"handles\" this event for our button,\n那么，要设置事件触发时 \\N 由哪个函数来处理\n\nby adding a line to our initialize function.\n我们可以在初始化函数中，加一行代码来实现\n\nThe type of event, in this case, is a click event,\n我们要处理的，是\"点击\"事件 \\N 然后函数会处理这个事件\n\nand our function is the event handler for that event.\n我们要处理的，是\"点击\"事件 \\N 然后函数会处理这个事件\n\nNow we're done.\n现在完成了\n\nWe can click that button all day long,\n可以点按钮点上一整天 \\N 每次都会执行 rollD20 函数\n\nand each time, our \"roll D20\" function gets dispatched and executed.\n可以点按钮点上一整天 \\N 每次都会执行 rollD20 函数\n\nThis is exactly what's happening behind the scenes\n这就是程序背后的原理\n\nwhen you press the little bold button in a text editor, or select shutdown from a dropdown menu\n在编辑器里点 粗体  或菜单里选 关机 \\N 一个处理该事件的函数会触发\n\n- a function linked to that event is firing.\n在编辑器里点 粗体  或菜单里选 关机 \\N 一个处理该事件的函数会触发\n\nHope I don't roll a 20.\n希望不会随机到 20\n\nAhhhh!\n啊！！！\n\nOk, back to the Xerox Alto!\n好，现在回到施乐奥托！\n\nRoughly 2000 Altos were made, and used at Xerox and given to University labs.\n大约制作了2000台奥托\\N 有的在施乐公司内部用，有的送给大学实验室\n\nThey were never sold commercially.\n从来没有商业出售过\n\nInstead, the PARC team kept refining the hardware and software,\n然而，PARC 团队不断完善硬件和软件\n\nculminating in the Xerox Star system, released in 1981.\n最终于1981年发布了 施乐之星系统\n\nThe Xerox Star extended the desktop metaphor.\n施乐之星扩展了\"桌面隐喻\"\n\nNow, files looked like pieces of paper,\n现在文件看起来就像一张纸 \\N 还可以存在文件夹里\n\nand they could be stored in little folders,\n现在文件看起来就像一张纸 \\N 还可以存在文件夹里\n\nall of which could sit on your desktop, or be put away into digital filing cabinets.\n这些都可以放桌面上，或数字文件柜里\n\nIt's a metaphor that sits ontop of the underlying file system.\n这样来隐喻底层的文件系统\n\nFrom a user's perspective, this is a new level of abstraction!\n从用户角度来看，是一层新抽象！\n\nXerox, being in the printing machine business, also advanced text and graphics creation tools.\n施乐卖的是印刷机 \\N 但在文本和图形制作工具领域也有领先\n\nFor example, they introduced the terms: cut, copy and paste.\n例如，他们首先使用了\\N  \"剪切\"\"复制\"\"粘贴\"这样的术语\n\nThis metaphor was drawn\n这个比喻来自编辑打字机文件\n\nfrom how people dealt with making edits in documents written on typewriters.\n这个比喻来自编辑打字机文件\n\nYou'd literally cut text out with scissors, and then paste it, with glue,\n真的是剪刀\"剪切\" \\N 然后胶水\"粘贴\" 到另一个文件\n\ninto the spot you wanted in another document.\n真的是剪刀\"剪切\" \\N 然后胶水\"粘贴\" 到另一个文件\n\nThen you'd photocopy the page to flatten it back down into a single layer,\n然后再复印一次，新文件就是一层了\n\nmaking the change invisible.\n看不出编辑的痕迹\n\nThank goodness for computers!\n感谢计算机的出现！\n\nThis manual process was moot with the advent of word processing software,\n文字处理软件出现后 \\N 这种手工做法就消失了\n\nwhich existed on platforms like the Apple II and Commodore PET.\nApple II 和 Commodore PET 上有文字处理软件\n\nBut Xerox went way beyond the competition\n但施乐在这点上走的更远\n\nwith the idea that whatever you made on the computer\n无论你在计算机上做什么 \\N 文件打印出来应该长得一样\n\nshould look exactly like the real world version, if you printed it out.\n无论你在计算机上做什么 \\N 文件打印出来应该长得一样\n\nThey dubbed this What-You-See-Is-What-You-Get or WYSIWYG.\n他们叫这个\"所见即所得\"\n\nUnfortunately, like Engelbart's oN-Line System,\n不幸的是，就像恩格尔巴特的 oN-Line System\n\nthe Xerox Star was ahead of its time.\n施乐之星也领先于那个时代，销售量不高\n\nSales were sluggish\n施乐之星也领先于那个时代，销售量不高\n\nbecause it had a price tag equivalent to nearly $200,000 today for an office setup.\n因为在办公室里配一个，相当如今20万美元\n\nIt also didn't help that the IBM PC launched that same year,\nIBM 同年推出了 IBM PC\n\nfollowed by a tsunami of cheap \"IBM Compatible\" PC Clones.\n之后便宜的\"IBM兼容\"计算机席卷市场\n\nBut the great ideas that PARC researchers had been cultivating\n但 PARC 研究人员花了十几年做的这些 \\N 没有被浪费\n\nand building for almost a decade didn't go to waste.\n但 PARC 研究人员花了十几年做的这些 \\N 没有被浪费\n\nIn December of 1979, a year and a half before the Xerox Star shipped,\n1979年12月，施乐之星出货前一年半\n\na guy you may have heard of visited: Steve Jobs.\n有个人去施乐公司参观 \\N 你可能听说过这个人：史蒂夫·乔布斯\n\nThere's a lot of lore surrounding this visit,\n这次参观有很多传闻\n\nwith many suggesting that Steve Jobs and Apple stole Xerox's ideas.\n许多人认为\\N 乔布斯和苹果偷走了施乐的创意\n\nBut that simply isn't true.\n但那不是事实\n\nIn fact, Xerox approached Apple, hoping to partner with them.\n事实上是施乐公司主动找苹果，希望合作\n\nUltimately, Xerox was able to buy a million dollar stake in Apple\n最终施乐还买了苹果的一百万美元股份\n\nbefore its highly anticipated I.P.O.\n在苹果备受瞩目的 首次公开募股(IPO) 前买的\n\n-but it came with an extra provision:\n但一个额外条款是：\n\n\"disclose everything cool going on at Xerox PARC\".\n\"公布一切施乐研究中心正在进行的酷工作\"\n\nSteve knew they had some of the greatest minds in computing,\n史蒂夫知道他们很厉害\n\nbut he wasn't prepared for what he saw.\n但他完全没预想到这些\n\nThere was a demonstration of Xerox's graphical user interface,\n其中有个演示是\n\nrunning on a crisp, bitmapped display,\n一个清晰的位图显示器上，运行着施乐公司的图形界面 \\N 操作全靠鼠标直观进行\n\nall driven with intuitive mouse input.\n一个清晰的位图显示器上，运行着施乐公司的图形界面 \\N 操作全靠鼠标直观进行\n\nSteve later said, \"It was like a veil being lifted from my eyes.\n史蒂夫后来说：\"就像拨开了眼前的一层迷纱\n\nI could see the future of what computing was destined to be.\"\n我可以看到计算机产业的未来\"\n\nSteve returned to Apple with his engineering entourage,\n史蒂夫和随行的工程师回到苹果公司，开始开发新功能\n\nand they got to work inventing new features,\n史蒂夫和随行的工程师回到苹果公司，开始开发新功能\n\nlike the menu bar and a trash can to store files to be deleted;\n比如菜单栏和垃圾桶，垃圾桶存删除文件\n\nit would even bulge when full - again with the metaphors.\n满了甚至会膨胀 - 再次使用了隐喻\n\nApple's first product with a graphical user interface, and mouse,\n苹果第一款有图形界面和鼠标的产品\n\nwas the Apple Lisa, released in 1983.\n是 1983 年发行的 Apple Lisa\n\nIt was a super advanced machine, with a super advanced price\n一台超级先进的机器，标了\"超级先进\"的价格\n\n- almost 25 thousand dollars today.\n- 差不多是如今的 25000 美元\n\nThat was significantly cheaper than the Xerox Star,\n虽然比施乐之星便宜不少\n\nbut it turned out to be an equal flop in the market.\n但在市场上同样失败\n\nLuckily, Apple had another project up its sleeve:\n幸运的是，苹果还有另一个项目：\n\nThe Macintosh, released a year later, in 1984.\nMacintosh，于 1984 年发布\n\nIt had a price of around 6,000 dollars today - a quarter of the Lisa's cost.\n价格大约是如今的6000美元 - Lisa 的四分之一\n\nAnd it hit the mark, selling 70,000 units in the first 100 days.\n它成功了，开售100天就卖了7万台\n\nBut after the initial craze, sales started to falter,\n但在最初的狂潮后，销售额开始波动\n\nand Apple was selling more of its Apple II computers than Macs.\n苹果公司卖的 Apple II 比 Mac 多\n\nA big problem was that no one was making software for this new machine\n一个大问题是：没人给这台新机器做软件\n\nwith it's new radical interface.\n一个大问题是：没人给这台新机器做软件\n\nAnd it got worse. The competition caught up fast.\n之后情况变得更糟，竞争对手赶上来了\n\nSoon, other personal computers had primitive,\n不久，其它价格只有 Mac 几分之一的个人计算机 \\N 有了原始但可用的图形界面\n\nbut usable graphical user interfaces on computers a fraction of the cost.\n不久，其它价格只有 Mac 几分之一的个人计算机 \\N 有了原始但可用的图形界面\n\nConsumers ate it up, and so did PC software developers.\n消费者认可它们， PC 软件开发者也认可\n\nWith Apple's finances looking increasingly dire,\n随着苹果的财务状况日益严峻 \\N 以及和苹果新 CEO 约翰·斯卡利 的关系日益紧张\n\nand tensions growing with Apple's new CEO, John Sculley,\n随着苹果的财务状况日益严峻 \\N 以及和苹果新 CEO 约翰·斯卡利 的关系日益紧张\n\nSteve Jobs was ousted.\n史蒂夫乔布斯被赶出了苹果公司\n\nA few months later, Microsoft released Windows 1.0.\n几个月后，微软发布了 Windows 1.0\n\nIt may not have been as pretty as Mac OS,\n它也许不如 Mac OS 漂亮\n\nbut it was the first salvo in what would become a bitter rivalry\n但让微软在市场中站稳脚跟 \\N 奠定了统治地位\n\nand near dominance of the industry by Microsoft.\n但让微软在市场中站稳脚跟 \\N 奠定了统治地位\n\nWithin ten years, Microsoft Windows was running on almost 95% of personal computers.\n十年内，95％的个人计算机上都有微软的 Windows\n\nInitially, fans of Mac OS could rightly claim superior graphics and ease-of-use.\n最初，Mac OS 的爱好者还可以说\\N  Mac 有卓越的图形界面和易用性\n\nThose early versions of Windows were all built on top of DOS,\nWindows 早期版本都是基于 DOS \\N 而 DOS 设计时 没想过运行图形界面\n\nwhich was never designed to run GUIs.\nWindows 早期版本都是基于 DOS \\N 而 DOS 设计时 没想过运行图形界面\n\nBut, after Windows 3.1,\n但 Windows 3.1 之后\n\nMicrosoft began to develop a new consumer-oriented OS\n微软开始开发新的，\\N 面向消费者的 GUI 操作系统\n\nwith upgraded GUI called Windows 95.\n叫 Windows 95\n\nThis was a significant rewrite that offered much more than just polished graphics.\n这是一个意义非凡的版本 \\N 不仅提供精美的界面\n\nIt also had advanced features Mac OS didn't have,\n还有 Mac OS 没有的高级功能\n\nlike program multitasking and protected memory.\n比如\"多任务\"和\"受保护内存\"\n\nWindows 95 introduced many GUI elements still seen in Windows versions today,\nWindows 95 引入了许多 \\N 如今依然见得到的 GUI 元素\n\nlike the Start menu, taskbar, and Windows Explorer file manager.\n比如开始菜单，任务栏和 Windows 文件管理器\n\nMicrosoft wasn't infallible though.\n不过微软也失败过\n\nLooking to make the desktop metaphor even easier and friendlier,\n为了让桌面更简单友好 \\N 微软开发了一个产品叫 Microsoft Bob\n\nit worked on a product called Microsoft Bob,\n为了让桌面更简单友好 \\N 微软开发了一个产品叫 Microsoft Bob\n\nand it took the idea of using metaphors to an extreme.\n将比喻用到极致\n\nNow you had a whole virtual room on your screen,\n现在屏幕上有了一个虚拟房间\n\nwith applications embodied as objects that you could put on tables and shelves.\n程序是物品，可以放在桌子和书架上\n\nIt even came with a crackling fireplace and a virtual dog to offer assistance.\n甚至还有噼啪作响的壁炉 \\N 和提供帮助的虚拟狗狗\n\nAnd you see those doors on the sides?\n你看到那边的门没？\n\nYep, those went to different rooms in your computer\n是的，那些门通往不同房间 \\N 房间里有不同程序\n\nwhere different applications were available.\n是的，那些门通往不同房间 \\N 房间里有不同程序\n\nAs you might have guessed,\n你可能猜到了，它没有获得成功\n\nit was not a success.\n你可能猜到了，它没有获得成功\n\nThis is a great example of how the user interfaces we enjoy today\n这是一个好例子，说明如今的用户界面\n\nare the product of what's essentially natural selection.\n是自然选择后的结果\n\nWhether you're running Windows, Mac, Linux, or some other desktop GUI,\n无论你用的是 \\N Windows，Mac，Linux 或其他 GUI\n\nit's almost certainly an evolved version of the WIMP paradigm first introduced on the Xerox Alto.\n几乎都是施乐奥托 WIMP 的变化版\n\nAlong the way, a lot of bad ideas were tried, and failed.\n一路上，人们试了各种做法并失败了\n\nEverything had to be invented, tested, refined, adopted or dropped.\n一切都必须发明，测试，改进，适应或抛弃\n\nToday, GUIs are everywhere and while they're good,\n如今，图形界面无处不在 \\N 使用体验一般只是可以接受，而不是非常好\n\nthey are not always great.\n如今，图形界面无处不在 \\N 使用体验一般只是可以接受，而不是非常好\n\nNo doubt you've experienced design-related frustrations\n你肯定体验过差劲的设计\n\nafter downloading an application, used someone else's phone,\n比如下载了很烂的 App，用过别人糟糕的手机\n\nor visited a website. And for this reason,\n或者看到过很差的网站，因此\n\ncomputer scientists and interface designers continue to work hard\n计算机科学家和界面设计师 \\N 会继续努力工作\n\nto craft computing experiences that are both easier and more powerful.\n做出更好更强大的界面\n\nUltimately, working towards Engelbart's vision of augmenting human intellect.\n朝着恩格尔巴特\"增强人类智能\"的愿景努力\n\nI'll see you next week.\n我们下周见\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nOver the past five episodes,\n在过去五集\n\nwe've worked up from text-based teletype interfaces to pixelated bitmapped graphics.\n我们从基于电传打字机的命令行界面 \\N 讲到图形怎么显示到屏幕上\n\nThen, last episode,we covered Graphical User Interfaces and all\n再到上集的 图形用户界面（GUI）\n\ntheir \"Ooey Gooey\" richness.\n以及图形界面的美味\n\nAll of these examples have been 2D. But of course \"we are living in a 3D world\n之前的例子都是2D, 但我们生活的世界是3D的\n\nand I'm a 3 dimensional girl!\n我也是个三维 girl~\n\nSo today, we're going to talk about some fundamental methods in 3D computer graphics\n所以今天，我们讲3D图形的基础知识\n\nand how you render them onto a 2D screen.\n以及如何渲染 3D 图形到 2D 屏幕上\n\nAs we discussed in episode 24 we can write functions that draw a line between any two points like A and B.\n24集中说过 \\N 可以写一个函数，从A到B画一条线\n\nBy manipulating the X and Y coordinates of points A and B, we can manipulate the line.\n通过控制 A 和 B 的(X,Y)坐标，可以控制一条线\n\nIn 3D graphics, points have not just two coordinates, but three -- X, Y and Z.\n在3D图像中, 点的坐标不再是两点, 而是三点, X,Y,Z\n\nOr \"zee\" but I'm going to say \"zed\".\n或读\"Zee\"，但我之后会读成\"Zed\"\n\nOf course, we don't have X/Y/Z coordinates on a 2D computer screen\n当然，2D的电脑屏幕上\\N不可能有 XYZ 立体坐标轴\n\nso graphics algorithms are responsible for \"flattening\" 3D coordinates onto a 2D plane.\n所以有图形算法 \\N 负责把3D坐标\"拍平\"显示到2D屏幕上\n\nThis process is known as 3D Projection.\n这叫\"3D投影\"\n\nOnce all of the points have been converted from 3D to 2D\n所有的点都从3D转成2D后\n\nwe can use the regular 2D line drawing function to connect the dots… literally.\n就可以用画2D线段的函数 来连接这些点\n\nThis is called Wireframe Rendering.\n这叫 \"线框渲染\"\n\nImagine building a cube out of chopsticks, and shining a flashlight on it.\n想象用筷子做一个立方体，然后用手电筒照它\n\nThe shadow it casts onto your wall - its projection - is flat.\n墙上的影子就是投射，是平的\n\nIf you rotate the cube around\n如果旋转立方体\n\nyou can see it's a 3D object, even though it's a flat projection.\n投影看起来会像 3D 物体，尽管是投影面是平的\n\nThis transformation from 3D to 2D is exactly what your computer is doing\n电脑也是这样3D转2D\n\njust with a lot more math… and less chopsticks.\n只不过用大量数学，而不是筷子\n\nThere are several types of 3D Projection.\n3D投影有好几种\n\nWhat you're seeing right now is an Orthographic Projection\n你现在看到的，叫 正交投影\n\nwhere, for example, the parallel sides in the cube appear as parallel in the projection.\n立方体的各个边，在投影中互相平行\n\nIn the real 3D world through, parallel lines converge as they get further from the viewer\n在真实3D世界中,平行线段会在远处收敛于一点\n\nlike a road going to the horizon.\n就像远处的马路汇聚到一点\n\nThis type of 3D projection is called Perspective Projection .\n这叫 透视投射\n\nIt's the same process, just with different math.\n过程是类似的，只是数学稍有不同\n\nSometimes you want perspective and sometimes you don't --\n有时你想要透视投影，有时不想\n\nthe choice is up to the developer.\n具体取决于开发人员\n\nSimple shapes, like cubes, are easily defined by straight lines.\n如果想画立方体这种简单图形，直线就够了\n\nBut for more complex shapes, triangles are better\n但更复杂的图形，三角形更好\n\n-- what are called polygons in 3D graphics.\n在3D图形学中 \\N 我们叫三角形\"多边形\"(Polygons)\n\nLook at this beautiful teapot made out of polygons.\n看看这个多边形组成的 漂亮茶壶\n\nA collection of polygons like this is a mesh\n一堆多边形的集合叫 网格\n\nThe denser the mesh, the smoother the curves and the finer the details.\n网格越密，表面越光滑，细节越多\n\nBut, that also increases the polygon count, which means more work for the computer\n但意味着更多计算量\n\nGame designers have to carefully balance model fidelity vs. polygon count,\n游戏设计者要平衡角色的真实度 \\N 和多边形数量\n\nbecause if the count goes too high\n如果数量太多 \\N 帧率会下降到肉眼可感知，用户会觉得卡\n\nthe framerate of an animation drops below what users perceive as smooth.\n如果数量太多 \\N 帧率会下降到肉眼可感知，用户会觉得卡\n\nFor this reason, there are algorithms for simplifying meshes.\n因此有算法用来简化网格\n\nThe reason triangles are used,\n之所以三角形更常用 \\N 而不是用正方形，或其它更复杂的图形\n\nand not squares, or polygons, or some other more complex shape\n之所以三角形更常用 \\N 而不是用正方形，或其它更复杂的图形\n\nis simplicity:\n是因为三角形的简单性\n\nthree points in space unambiguously define a plane.\n空间中  三点定义一个平面\n\nIf you give me three points in a 3D space, I can draw a plane through it\n如果给3个3D点，我能画出一个平面\n\nthere is only one.. single.. answer.\n而且只有这一个答案\n\nThis isn't guaranteed to be true for shapes with four or more points.\n4个或多于4个点就不一定了\n\nAlso two points aren't enough to define a plane, only a line,\n而2个点不够定义平面，只能定义线段\n\nso three is the perfect and minimal number. Triangles for the win!\n所以3是最完美的数字，三角形万岁\n\nWireframe rendering is cool and all - sorta retro - but of course 3D graphics can also be filled.\n线框渲染 虽然很酷，但3D图像需要填充\n\nThe classic algorithm for doing this is called Scanline Rendering,\n填充图形的经典算法叫 扫描线渲染 (Scanline Rendering) \\N 于1967年诞生在犹他州大学\n\nfirst developed in 1967 at the University of Utah\n填充图形的经典算法叫 扫描线渲染 (Scanline Rendering) \\N 于1967年诞生在犹他州大学\n\nFor a simple example, let's consider just one polygon.\n为了例子简单，我们只看一个多边形\n\nOur job here is to figure out how this polygon translates to filled pixels on a computer screen\n我们要思考 \\N 这个多边形如何转成一块填满像素的区域\n\nso let's first overlay a grid of pixels to fill\n我们先铺一层像素网格\n\nThe scanline algorithm starts by reading the three points that make up the polygon\n扫描线算法 先读多边形的3个点\n\nand finding the lowest and highest Y values.  It will only consider rows between these two points.\n找最大和最小的Y值，只在这两点间工作\n\nThen, the algorithm works down one row at a time.\n然后算法从上往下，一次处理一行\n\nIn each row, it calculates where a line running through\n计算每一行和多边形相交的2个点\n\nthe center of a row - intersects with the side of the polygon.\n计算每一行和多边形相交的2个点\n\nBecause polygons are triangles, if you intersect one line, you have to intersect with another.\n因为是三角形,如果相交一条边, 必然相交另一条\n\nIt's guaranteed!\n因为是三角形,如果相交一条边, 必然相交另一条\n\nThe job of the scanline algorithm is to fill in the pixels between the two intersections.\n扫描线算法 会填满2个相交点之间的像素\n\nLet's see how this works.\n来看个具体例子\n\nOn the first row we look at we intersect here and here.\n第一行 相交于这里和这里\n\nThe algorithm then colors in all pixels between those two intersections.\n算法把两点间填满颜色\n\nAnd this just continues, row by row, which is why it's called Scan... Line... Rendering.\n然后下一行，再下一行，所以叫 扫描..线..渲染\n\nWhen we hit the bottom of the polygon, we're done.\n扫到底部就完成了\n\nThe rate at which a computer fills in polygons is called the fillrate.\n填充的速度叫 fillrate（填充速率）\n\nAdmittedly, this is a pretty ugly filled polygon. It has what are known as \"Jaggies\" rough edges.\n当然 这样的三角形比较丑，边缘满是锯齿\n\nThis effect is less pronounced when using smaller pixels.\n当像素较小时 就不那么明显\n\nBut nonetheless, you see these in games all the time, especially on lower powered platforms.\n但尽管如此 \\N 你肯定在游戏里见过这种效果，特别是低配电脑\n\nOne method to soften this effect is Antialiasing.\n一种减轻锯齿的方法叫\\N  抗锯齿(Antialiasing)\n\nInstead of filling pixels in a polygon with the same color,\n与其每个像素都涂成一样的颜色\n\nwe can adjust the color based on how much the polygon cuts through each pixel\n可以判断多边形切过像素的程度，来调整颜色\n\nIf a pixel is entirely inside of a polygon,it gets fully colored.\n如果像素在多边形内部，就直接涂颜色\n\nBut if the polygon only grazes a pixel, it'll get a lighter shade.\n如果多边形划过像素，颜色就浅一些\n\nThis feathering of the edges is much more pleasant to the eyes.\n这种边缘羽化的效果 看着更舒服些\n\nAntialiasing is used all over the place, including in 2D graphics, like fonts and icons.\n抗锯齿 被广泛使用，比如字体和图标\n\nIf you lean in real close to your monitor..\n如果你把脸贴近屏幕\n\nCloser, Closer.\n近点..再近点\n\nYou'll see all the fonts in your browser are Antialiased. So smooth!\n你能看到浏览器里字体是抗锯齿的，超平滑\n\nIn a 3D scene, there are polygons that are part objects in the back, near the front,and just about everywhere.\n在3D场景中，多边形到处都是\n\nOnly some are visible,\n但只有一部分能看见\n\nbecause some objects are hidden behind other objects in the scene\n因为其它的被挡住了\n\n-- what's called occlusion .\n这叫 遮挡\n\nThe most straightforward way to handle this is to use a sort algorithm,\n最直接的处理办法是用排序算法\n\nand arrange all the polygons in the scene from farthest to nearest, then render them in that order.\n从远到近排列，然后从远到近渲染\n\nThis is called the Painter's Algorithm , because painters also have to start with the background\n这叫 画家算法 因为画家也是先画背景\n\nand then increasingly work up to foreground elements.\n然后再画更近的东西\n\nConsider this example scene with three overlapping polygons.\n看这个例子，有3个重叠的多边形\n\nTo make things easier to follow, we're going to color the polygons differently.\n为了简单，我们画成不同颜色\n\nAlso for simplicity, we'll assume these polygons are all parallel to the screen\n同时，假设3个多边形都和屏幕平行\n\nbut in a real program, like a game,\n但在实际应用中, 比如游戏里\\N多边形可能是倾斜的\n\nthe polygons can be tilted in 3D space.\n但在实际应用中, 比如游戏里\\N多边形可能是倾斜的\n\nOur three polygons, A B and C… are at distance 20, 12 and 14.\n3个多边形A,B,C，距离20,12,14\n\nThe first thing the Painter's Algorithm does is sort all the polygons, from farthest to nearest.\n画家算法的第一件事，是从远到近排序\n\nNow that they're in order, we can use scanline rendering to fill each polygon, one at a time.\n现在有序了，我们可以用 扫描线算法 填充多边形，一次填一个\n\nWe start with Polygon A, the farthest one away.\n我们从最远的A开始\n\nThen we repeat the process for the next farthest polygon, in this case, C.\n然后重复这个过程，填充第二远的C\n\nAnd then we repeat this again, for Polygon B.\n然后是 B\n\nNow we're all done, and you can see the ordering is correct. The polygons that are closer, are in front!\n现在完成了，可以看到顺序是对的，近的多边形在前面！\n\nAn alternative method for handling occlusion is called Z-Buffering .\n还有一种方法叫 深度缓冲\n\nIt achieves the same output as before, but with a different algorithm.\n它和之前的算法做的事情一样，但方法不同\n\nLet's go back to our previous example, before it was sorted.\n我们回到之前的例子，回到排序前的状态\n\nThat's because this algorithm doesn't need to sort any polygons, which makes it faster.\n因为这个算法不用排序，所以速度更快\n\nIn short, Z-buffering keeps track of the closest distance\n简而言之，Z-buffering 算法会记录\n\nto a polygon for every pixel in the scene.\n场景中每个像素和摄像机的距离\n\nIt does this by maintaining a Z-Buffer, which is just a matrix of values that sits in memory.\n在内存里存一个数字矩阵\n\nAt first, every pixel is initialized to infinity.\n首先，每个像素的距离被初始化为\"无限大\"\n\nThen Z-buffering starts with the first polygon in its list. In this case, that's A.\n然后 Z-buffering 从列表里第一个多边形开始处理，也就是A\n\nIt follows the same logic as the scanline algorithm, but instead of coloring in pixels,\n它和扫描线算法逻辑相同，但不是给像素填充颜色\n\nit checks the distance of the polygon versus what's recorded in its Z-Buffer.\n而是把多边形的距离\\N和 Z-Buffer 里的距离进行对比\n\nIt records the lower of the two values.\n它总是记录更低的值\n\nFor our Polygon A, with a distance of 20, it wins against infinity every time.\nA距离20，20小于\"无限大\"，所以缓冲区记录20\n\nWhen it's done with Polygon A, it moves on to the next polygon in its list, and the same thing happens.\n算完A之后算下一个，以此类推\n\nNow, because we didn't sort the polygons,\n因为没对多边形排序\n\nit's not always the case that later polygons overwrite high values.\n所以后处理的多边形并不总会覆盖前面的\n\nIn the case of Polygon C,\n对于多边形C\n\nonly some of the values in the Z-buffer get new minimum distances.\n缓冲区里只有一部分值会被多边形C的距离值覆盖\n\nThis completed Z-buffer is used in conjunction with a fancier version of scanline rendering\nZ缓冲区完成后，会和\"扫描线\"算法的改进高级版配合使用\n\nthat not only tests for line intersection,\n不仅可以勘测到线的交叉点\n\nbut also does a look up to see if that pixel will even be visible in the final scene.\n还可以知道某像素是否在最终场景中可见\n\nIf it's not, the algorithm skips it and moves on.\n如果不可见，扫描线算法会跳过那个部分\n\nAn interesting problem arises when two polygons have the same distance,\n当两个多边形距离相同时 \\N 会出现一个有趣问题\n\nlike if Polygon A and B are both at a distance of 20. Which one do you draw on top?\n比如多边形 A 和 B 距离都是 20, 哪个画上面?\n\nPolygons are constantly being shuffled around in memory and changing their access order.\n多边形会在内存中移来移去，访问顺序会不断变化\n\nPlus, rounding errors are inherent in floating point computations.\n另外,计算浮点数有舍入误差\n\nSo, which one gets drawn on top is often unpredictable.\n所以哪一个画在上面, 往往是不可预测的\n\nThe result is a flickering effect called Z-Fighting, which if you've played 3D games no doubt encountered.\n导致出现 Z-fighting 效果 \\N 如果你玩过3D游戏，肯定见过\n\nSpeaking of glitches, another common optimization in 3D graphics is called Back-Face Culling.\n说起 故障，3D游戏中有个优化叫 背面剔除\n\nIf you think about it, a triangle has two sides, a front and a back.\n你想想,三角形有两面,正面和背面\n\nWith something like the head of an avatar, or the ground in a game,\n游戏角色的头部或地面，只能看到朝外的一面\n\nyou should only ever see one side -- the side facing outwards.\n游戏角色的头部或地面，只能看到朝外的一面\n\nSo to save processing time, the back-side of polygons are often ignored in the rendering pipeline\n所以为了节省处理时间，会忽略多边形背面\n\nwhich cuts the number of polygon faces to consider in half.\n减了一半多边形面数\n\nThis is great, except when there's a bug that lets you get inside of those objects,and look outwards.\n这很好,但有个bug是 如果进入模型内部往外看\n\nThen the avatar head or ground becomes invisible.\n头部和地面会消失\n\nMoving on. We need to talk about lighting -- also known as shading\n继续，我们讲灯光，也叫 明暗处理\n\nbecause if it's a 3D scene, the lighting should vary over the surface of objects.\n因为3D场景中, 物体表面应该有明暗变化\n\nLet's go back to our teapot mesh.\n我们回到之前的茶壶网格\n\nWith scanline rendering coloring in all the polygons, our teapot looks like this.\n用\"扫描线\"算法渲染所有多边形后，茶壶看起来像这样\n\nNot very 3D.\n没什么 3D 感\n\nSo, let's add some lighting to enhance the realism!\n我们来加点灯光，提高真实感\n\nAs an example, we'll pick 3 polygons from different parts of our teapot.\n为了举例，我们从茶壶上挑3个不同位置的多边形\n\nUnlike our previous examples, we're now going to consider how these polygons are oriented in 3D space\n和之前的例子不同，这次要考虑这些多边形面对的方向\n\nthey're no longer parallel to the screen, but rather tilted in different 3D directions.\n它们不平行于屏幕，而是面对不同方向\n\nThe direction they face is called the Surface Normal ,\n他们面对的方向叫 \" 表面法线 \"\n\nand we can visualize that direction with a little 3D arrow that's perpendicular to the polygon's surface.\n我们可以用一个垂直于表面的小箭头\\N来显示这个方向\n\nNow let's add a light source.\n现在加个光源\n\nEach polygon is going to be illuminated a different amount. Some will appear brighter\n每个多边形被照亮的程度不同 有的更亮\n\nbecause their angle causes more light to be reflected towards the viewer.\n因为面对的角度\\N导致更多光线反射到观察者\n\nFor example, the bottom-most polygon is tilted downwards,\n举个例子，底部的多边形向下倾斜\n\naway from the light source, which means it's going to be dark.\n远离光源，所以更暗一些\n\nIn a similar way, the rightmost polygon is slightly facing away from the light,\n类似的，最右的多边形更背对光源\n\nso it will be partially illuminated.\n所以只有部分照亮\n\nAnd finally, there's the upper-left polygon.\n最后是左上角的多边形\n\nIts angle means that it will reflect light from the light source towards our view.\n因为它面对的角度  意味着会把光线反射到我们这里\n\nSo, it'll appear bright.\n所以会显得更亮\n\nIf we do this for every polygon, our teapot looks like this which is much more realistic!\n如果对每个多边形执行同样的步骤，看上去会更真实!\n\nThis approach is called Flat Shading, and it's the most basic lighting algorithm.\n这叫 平面着色，是最基本的照明算法\n\nUnfortunately, it also makes all those polygon boundaries really noticeable\n不幸的是，这使多边形的边界非常明显，看起来不光滑\n\nand the mesh doesn't look smooth.\n不幸的是，这使多边形的边界非常明显，看起来不光滑\n\nFor this reason, more advanced lighting algorithms were developed,\n因此开发了更多算法\n\nsuch as Gouraud Shading and Phong Shading .\n比如 高洛德着色 和 冯氏着色\n\nInstead of coloring in polygons using just one colour,\n不只用一种颜色给整个多边形上色\n\nthey vary the colour across the surface in clever ways,\n而是以巧妙的方式改变颜色\n\nwhich results in much nicer output.\n得到更好的效果\n\nWe also need to talk about textures ,\n我们还要说下\" 纹理 \"\n\nwhich in graphics refers to the look of a surface,rather than its feel.\n纹理在图形学中指外观，而不是手感\n\nLike with lighting, there are many algorithms with all sorts of fancy effects.\n就像照明算法一样，\\N 纹理也有多种算法，来做各种花哨效果\n\nThe simplest is texture mapping .\n最简单的是 纹理映射\n\nTo visualize this process,let's go back to our single polygon.\n为了理解纹理映射，回到单个多边形\n\nWhen we're filling this in, using scanline rendering,\n用\"扫描线算法\"填充时\n\nwe can look up what color to use at every pixel according to a texture image saved in memory.\n可以看看内存内的纹理图像 决定像素用什么颜色\n\nTo do this, we need a mapping between the polygon's coordinates and the texture's coordinates.\n为了做到这点，\\N 需要把多边形坐标和纹理坐标对应起来\n\nLet's jump to the first pixel that scanline rendering needs to fill in.\n我们来看看\"扫描线算法\"要填充的第一个像素\n\nThe texturing algorithm will consult the texture in memory,\n纹理算法会查询纹理\n\ntake the average color from the corresponding region, and fill the polygon accordingly.\n从相应区域取平均颜色，并填充多边形\n\nThis process repeats for all pixels in the polygon, and that's how we get textures.\n重复这个过程，就可以获得纹理\n\nIf you combine all the techniques we've talked about this episode, you get a wonderfully funky little teapot.\n如果结合这集提到的所有技巧 \\N 会得到一个精美的小茶壶\n\nAnd this teapot can sit in an even bigger scene, comprised of millions of polygons.\n这个茶壶可以放进更大的场景里 \\N 场景由上百万个多边形组成\n\nRendering a scene like this takes a fair amount of computation.\n渲染这样的场景需要大量计算\n\nBut importantly, it's the same type of calculations being performed\n但重要的是，再大的场景，过程都是一样的 \\N 一遍又一遍，处理所有多边形\n\nover and over and over again for many millions of polygons –\n但重要的是，再大的场景，过程都是一样的 \\N 一遍又一遍，处理所有多边形\n\nscanline filling, antialiasing, lighting, and texturing.\n扫描线填充, 抗锯齿, 光照, 纹理化\n\nHowever there are a couple of ways to make this much faster!\n然而，有几种方法可以加速渲染\n\nFirst off, we can speed things up by having special hardware\n首先，我们可以为这种特定运算 \\N 做专门的硬件来加快速度，让运算快如闪电\n\nwith extra bells and whistles just for these specific types of computations, making them lightning fast.\n首先，我们可以为这种特定运算 \\N 做专门的硬件来加快速度，让运算快如闪电\n\nAnd secondly,we can divide up a 3D scene into many smaller parts,\n其次，我们可以把3D场景分解成多个小部分\n\nand then render all the pieces in parallel,rather than sequentially.\n然后并行渲染，而不是按顺序渲染\n\nCPU's aren't designed for this, so they aren't particularly fast.\nCPU不是为此设计的，因此图形运算不快\n\nSo, computer engineers created special processors just for graphics\n所以，计算机工程师为图形做了专门的处理器\n\n– a GPU, or Graphics Processing Unit.\n叫 GPU \"图形处理单元\"\n\nThese can be found on graphics cards inside of your computer, along with RAM reserved for graphics.\nGPU 在显卡上，周围有专用的 RAM\n\nThis is where all the meshes and textures live,\n所有网格和纹理都在里面\n\nallowing them to be accessed super fast by many different cores of the GPU all at once.\n让 GPU 的多个核心可以高速访问\n\nA modern graphics card, like a GeForce GTX 1080 TI,\n现代显卡，如 GeForce GTX 1080 TI\n\ncontains 3584 processing cores, offering massive parallelization.\n有3584个处理核心，提供大规模并行处理\n\nIt can process hundreds of millions of polygons every second!\n每秒处理上亿个多边形！\n\nOk, that concludes our whistle stop tour of 3D graphics.\n好了，本集对3D图形的介绍到此结束\n\nNext week, we switch topics entirely.\n下周我们聊全新的主题\n\nI'll ping you then.\n我到时会 ping 你~\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nThe internet is amazings\n互联网太棒啦\n\nIn just a few keystrokes, we can stream videos on Youtube -- Hello!\n键盘敲几下就能在 Youtube 直播--哈喽！\n\n- read articles on Wikipedia,\n在维基百科上阅读文章\n\norder supplies on amazon, video chat with friends, and tweet about the weather.\n在亚马逊买东西  和朋友视频  发一条天气推特\n\nWithout a doubt, the ability for computers, and their users, to send and receive information\n毫无疑问，\\N 用户在全球网络中发送和接收信息的能力\n\nover a global telecommunications network forever changed the world.\n永远改变了这个世界\n\n150 years ago, sending a letter from London to California would have taken two to three\n150年前 发一封信件从伦敦到加州 要花2~3周\n\nweeks, and that’s if you paid for express mail.\n而且还是特快邮件\n\nToday, that email takes a fraction of a second.\n如今 电子邮件只要几分之一秒.\n\nThis million fold improvement in latency, that’s the time it takes for a message to\n\"时延\"改善了上百万倍 \\N (时延指传播一条信息所需的时间)\n\ntransfer, juiced up the global economy helping the modern world to\n振兴了全球经济 \\N 帮助现代世界在遍布全球的光纤中快速发展\n\nmove at the speed of light on fiber optic cables spanning the globe.\n振兴了全球经济 \\N 帮助现代世界在遍布全球的光纤中快速发展\n\nYou might think that computers and networks always went hand in hand, but actually most\n你可能觉得计算机和网络密切相关，但事实上，\n\ncomputers pre-1970 were humming away all alone.\n1970年以前 大多数计算机是独立运行的\n\nHowever, as big computers began popping up everywhere,\n然而 因为大型计算机开始随处可见\n\nand low cost machines started to show up on people’s desks,\n廉价机器开始出现在书桌上\n\nit became increasingly useful to share data and resources,\n分享数据和资源渐渐变得有用起来\n\nand the first networks of computers appeared.\n首个计算机网络出现了\n\nToday, we’re going to start a three-episode arc on how computer networks came into being\n今天起，我们花3集视频讲网络是如何发展成现在的样子\n\nand the fundamental principles and techniques that power them.\n以及支撑它们的基础原理和技术\n\nThe first computer networks appeared in the 1950s and 60s.\n第一个计算机网络出现在1950~1960年代\n\nThey were generally used within an organization – like a company or research lab\n通常在公司或研究室内部使用，为了方便信息交换\n\nto facilitate the exchange of information between different people and computers.\n通常在公司或研究室内部使用，为了方便信息交换\n\nThis was faster and more reliable than the previous method of having someone walk a pile\n比把纸卡或磁带送到另一栋楼里更快速可靠\n\nof punch cards, or a reel of magnetic tape, to a computer on the other side of a building\n比把纸卡或磁带送到另一栋楼里更快速可靠\n\n‒ which was later dubbed a sneakernet.\n这叫\"球鞋网络\"\n\nA second benefit of networks was the ability to share physical resources.\n第二个好处是能共享物理资源\n\nFor example, instead of each computer having its own printer,\n举个例子，与其每台电脑配一台打印机\n\neveryone could share one attached to the network.\n大家可以共享一台联网的打印机\n\nIt was also common on early networks to have large, shared, storage drives,\n早期网络也会共享存储空间\n\nones too expensive to have attached to every machine.\n因为每台电脑都配存储器太贵了\n\nThese relatively small networks of close-by computers\n计算机近距离构成的小型网络 \\N 叫局域网， 简称LAN\n\nare called Local Area Networks, or LANs.\n计算机近距离构成的小型网络 \\N 叫局域网， 简称LAN\n\nA LAN could be as small as two machines in the same room,\n局域网能小到是同一个房间里的两台机器\n\nor as large as a university campus with thousands of computers.\n或大到校园里的上千台机器\n\nAlthough many LAN technologies were developed and deployed,\n尽管开发和部署了很多不同 LAN 技术\n\nthe most famous and successful was Ethernet, developed in the\n其中最著名和成功的是\"以太网\"  , 开发于1970年代 \\N 在施乐的\"帕洛阿尔托研究中心\"诞生, 今日仍被广泛使用\n\nearly 1970s at Xerox PARC, and still widely used today.\n其中最著名和成功的是\"以太网\"  , 开发于1970年代 \\N 在施乐的\"帕洛阿尔托研究中心\"诞生, 今日仍被广泛使用\n\nIn its simplest form, a series of computers are connected to a single, common ethernet cable.\n以太网的最简单形式是：一条以太网电线连接数台计算机\n\nWhen a computer wants to transmit data to another computer,\n当一台计算机要传数据给另一台计算机时\n\nit writes the data, as an electrical signal, onto the cable.\n它以电信号形式，将数据传入电缆\n\nOf course, because the cable is shared, every computer plugged into the network sees the\n当然 因为电缆是共享的  \\N 连在同一个网络里的其他计算机也看得到数据\n\ntransmission, but doesn’t know if data is intended for them or another computer.\n但不知道数据是给它们的，还是给其他计算机的\n\nTo solve this problem, Ethernet requires that each computer has a unique\n为了解决这个问题 以太网需要每台计算机有唯一的 \\N 媒体访问控制地址 简称 MAC地址\n\nMedia Access Control address, or MAC address.\n为了解决这个问题 以太网需要每台计算机有唯一的 \\N 媒体访问控制地址 简称 MAC地址\n\nThis unique address is put into a header that prefixes any data sent over the network.\n这个唯一的地址放在头部，作为数据的前缀发送到网络中\n\nSo, computers simply listen to the ethernet cable,\n所以，计算机只需要监听以太网电缆 \\N 只有看到自己的 MAC 地址，才处理数据\n\nand only process data when they see their address in the header.\n所以，计算机只需要监听以太网电缆 \\N 只有看到自己的 MAC 地址，才处理数据\n\nThis works really well; every computer made today comes with its own unique MAC address\n这运作得很好 现在制造的每台计算机都自带唯一的MAC地址\n\nfor both Ethernet and WiFi.\n用于以太网和无线网络\n\nThe general term for this approach is Carrier Sense Multiple Access, or CSMA for short.\n多台电脑共享一个传输媒介，\\N 这种方法叫 \"载波侦听多路访问\" 简称\"CSMA\"\n\nThe \"carrier\", in this case, is any shared transmission medium that carries data\n载体(carrier)指运输数据的共享媒介\n\ncopper wire in the case of ethernet, and the air carrying radio waves for WiFi.\n以太网的\"载体\"是铜线 \\N  WiFi 的\"载体\"是传播无线电波的空气\n\nMany computers can simultaneously sense the carrier,\n很多计算机同时侦听载体\n\nhence the \"Sense\" and \"Multiple Access\",\n所以叫\"侦听\"和\"多路访问\"\n\nand the rate at which a carrier can transmit data is called its Bandwidth.\n而载体传输数据的速度 叫\"带宽\"\n\nUnfortunately, using a shared carrier has one big drawback.\n不幸的是 使用共享载体有个很大的弊端\n\nWhen network traffic is light, computers can simply wait for silence on the carrier,\n当网络流量较小时 计算机可以等待载体清空\n\nand then transmit their data.\n然后传送数据\n\nBut, as network traffic increases, the probability that\n但随着网络流量上升 两台计算机想同时写入数据的概率也会上升\n\ntwo computers will attempt to write data at the same time also increases.\n但随着网络流量上升 两台计算机想同时写入数据的概率也会上升\n\nThis is called a collision, and the data gets all garbled up,\n这叫冲突 数据全都乱套了\n\nlike two people trying to talk on the phone at the same time.\n就像两个人同时在电话里讲话\n\nFortunately, computers can detect these collisions by listening to the signal on the wire.\n幸运的是 计算机能够通过监听电线中的信号检测这些冲突\n\nThe most obvious solution is for computers to stop transmitting,\n最明显的解决办法是停止传输\n\nwait for silence, then try again.\n等待网络空闲, 然后再试一遍\n\nProblem is, the other computer is going to try that too,\n问题是 其他计算机也打算这样做\n\nand other computers on the network that have been waiting for the\n其他等着的计算机可能在任何停顿间隙闯入\n\ncarrier to go silent will try to jump in during any pause.\n其他等着的计算机可能在任何停顿间隙闯入\n\nThis just leads to more and more collisions.\n导致越来越多冲突\n\nSoon, everyone is talking over one another and has a backlog of things they need to say,\n很快，每个人都一个接一个地讲话 而且有一堆事要说\n\nlike breaking up with a boyfriend over a family holiday dinner.\n就像在家庭聚餐中和男朋友分手一样\n\nTerrible idea!\n馊主意！\n\nEthernet had a surprisingly simple and effective fix.\n以太网有个超简单有效的解决方法\n\nWhen transmitting computers detect a collision,\n当计算机检测到冲突 就会在重传之前等待一小段时间\n\nthey wait for a brief period before attempting to re-transmit.\n当计算机检测到冲突 就会在重传之前等待一小段时间\n\nAs an example, let’s say 1 second.\n因为要举例，假设是 1 秒好了\n\nOf course, this doesn’t work if all the computers use the same wait duration\n当然 如果所有计算机用同样的等待时间 是不行的\n\n-- they’ll just collide again one second later.\n它们会在一秒后再次冲突\n\nSo, a random period is added: one computer might wait 1.3 seconds,\n所以加入一个随机时间 一台计算机可能等1.3秒\n\nwhile another waits 1.5 seconds.\n另一台计算机等待1.5秒\n\nWith any luck, the computer that waited 1.3 seconds will wake up,\n要是运气好 等1.3秒的计算机会醒来\n\nfind the carrier to be silent, and start transmitting.\n发现载体是空闲的 然后开始传输\n\nWhen the 1.5 second computer wakes up a moment later, it’ll see the carrier is in use,\n当1.5秒的计算机醒来后 会发现载体被占用 \\N 会等待其他计算机完成\n\nand will wait for the other computer to finish.\n当1.5秒的计算机醒来后 会发现载体被占用 \\N 会等待其他计算机完成\n\nThis definitely helps, but doesn’t totally solve the problem, so an extra trick is used.\n这有用 但不能完全解决问题 所以要用另一个小技巧\n\nAs I just explained, if a computer detects a collision while transmitting,\n正如我刚才说的 \\N如果一台计算机在传输数据期间检测到冲突\n\nit will wait 1 second, plus some random extra time.\n会等一秒+随机时间\n\nHowever, if it collides again, which suggests network congestion,\n然而 如果再次发生冲突 表明有网络拥塞\n\ninstead of waiting another 1 second, this time it will wait 2 seconds.\n这次不等1秒，而是等2秒\n\nIf it collides again, it’ll wait 4 seconds, and then 8, and then 16,\n如果再次发生冲突 等4秒 然后8秒 16秒等等\n\nand so on, until it’s successful.\n直到成功传输\n\nWith computers backing off, the rate of collisions goes down,\n因为计算机的退避 冲突次数降低了 \\N 数据再次开始流动起来 网络变得顺畅\n\nand data starts moving again, freeing up the network.\n因为计算机的退避 冲突次数降低了 \\N 数据再次开始流动起来 网络变得顺畅\n\nFamily dinner saved!\n家庭晚餐有救啦！\n\nThis \"backing off\" behavior using an exponentially growing wait time is called\n这种指数级增长等待时间的方法叫：\n\nExponential Backoff.\n指数退避\n\nBoth Ethernet and WiFi use it, and so do many transmission protocols.\n以太网和WiFi都用这种方法 很多其他传输协议也用\n\nBut even with clever tricks like Exponential Backoff,\n但即便有了\"指数退避\"这种技巧\n\nyou could never have an entire university’s\n想用一根网线链接整个大学的计算机还是不可能的\n\nworth of computers on one shared ethernet cable.\n想用一根网线链接整个大学的计算机还是不可能的\n\nTo reduce collisions and improve efficiency,\n为了减少冲突+提升效率\n\nwe need to shrink the number of devices on any given shared carrier\n我们需要减少同一载体中设备的数量 \\N 载体和其中的设备总称 \"冲突域\"\n\n-- what’s called the Collision Domain.\n我们需要减少同一载体中设备的数量 \\N 载体和其中的设备总称 \"冲突域\"\n\nLet go back to our earlier Ethernet example, where we had six computers on one shared cable,\n让我们回到之前以太网的例子  一根电缆连6台计算机\n\na.k.a. one collision domain.\n也叫一个冲突域\n\nTo reduce the likelihood of collisions, we can break this network\n为了减少冲突  我们可以用交换机把它拆成两个冲突域\n\ninto two collision domains by using a Network Switch.\n为了减少冲突  我们可以用交换机把它拆成两个冲突域\n\nIt sits between our two smaller networks, and only passes data between them if necessary.\n交换机位于两个更小的网络之间 \\N 必要时才在两个网络间传数据\n\nIt does this by keeping a list of what MAC addresses are on what side of the network.\n交换机会记录一个列表 \\N 写着哪个 MAC 地址在哪边网络\n\nSo if A wants to transmit to C, the switch doesn’t forward the data to the other network\n如果A想传数据给C \\N 交换机不会把数据转发给另一边的网络\n\n– there’s no need.\n没必要\n\nThis means if E wants to transmit to F at the same time, the network is wide open, and\n如果E想同一时间传数据给F，网络仍然是空的\n\ntwo transmissions can happen at once.\n两个传输可以同时发生\n\nBut, if F wants to send data to A, then the switch passes it through,\n但如果F想发数据给A  数据会通过交换机\n\nand the two networks are both briefly occupied.\n两个网络都会被短暂占用\n\nThis is essentially how big computer networks are constructed,\n大的计算机网络也是这样构建的\n\nincluding the biggest one of all – The Internet –\n包括最大的网络 - 互联网\n\nwhich literally inter-connects a bunch of smaller networks,\n也是多个连在一起的稍小一点网络\n\nallowing inter-network communication.\n使不同网络间可以传递信息\n\nWhat’s interesting about these big networks,\n这些大型网络有趣之处是\n\nis that there’s often multiple paths to\n从一个地点到另一个地点通常有多条路线\n\nget data from one location to another.\n从一个地点到另一个地点通常有多条路线\n\nAnd this brings us to another fundamental networking topic, routing.\n这就带出了另一个话题 路由\n\nThe simplest way to connect two distant computers, or networks,\n连接两台相隔遥远的计算机或网路，最简单的办法 \\N 是分配一条专用的通信线路\n\nis by allocating a communication line for their exclusive use.\n连接两台相隔遥远的计算机或网路，最简单的办法 \\N 是分配一条专用的通信线路\n\nThis is how early telephone systems worked.\n早期电话系统就是这样运作的\n\nFor example, there might be 5 telephone lines running between Indianapolis and Missoula.\n假设\"印第安纳波利斯\"和\"米苏拉\"之间，有五条电话线\n\nIf John picked up the phone wanting to call Hank, in the 1910s,\n如果在1910年代，John 想打电话给 Hank\n\nJohn would tell a human operator where he wanted to call,\nJohn要告诉操作员他想打到什么地方\n\nand they’d physically connect John’s phone line into\n然后工作人员手动将 John 的电话连到 \\N 通往米苏拉的未使用线路\n\nan unused line running to Missoula.\n然后工作人员手动将 John 的电话连到 \\N 通往米苏拉的未使用线路\n\nFor the length of the call, that line was occupied, and if all 5 lines were already\n通话期间 这条线就被占用了 如果五条线都被占用了 \\N John 要等待某条线空出来\n\nin use, John would have to wait for one to become free.\n通话期间 这条线就被占用了 如果五条线都被占用了 \\N John 要等待某条线空出来\n\nThis approach is called Circuit Switching,\n这叫 \"电路交换\"\\N因为是把电路连接到正确目的地\n\nbecause you’re literally switching whole\n这叫 \"电路交换\"\\N因为是把电路连接到正确目的地\n\ncircuits to route traffic to the correct destination.\n这叫 \"电路交换\"\\N因为是把电路连接到正确目的地\n\nIt works fine, but it’s relatively inflexible and expensive,\n能用倒是能用 \\N 但不灵活而且价格昂贵 因为总有闲置的线路\n\nbecause there’s often unused capacity.\n能用倒是能用 \\N 但不灵活而且价格昂贵 因为总有闲置的线路\n\nOn the upside, once you have a line to yourself – or if you have the money to buy one for\n好处是 如果有一条专属于自己的线路 \\N 你可以最大限度地随意使用，无需共享\n\nyour private use – you can use it to its full capacity, without having to share.\n好处是 如果有一条专属于自己的线路 \\N 你可以最大限度地随意使用，无需共享\n\nFor this reason, the military, banks and other high importance operations\n因此军队, 银行和其他一些机构\n\nstill buy dedicated circuits to connect their data centers.\n依然会购买专用线路来连接数据中心\n\nAnother approach for getting data from one place to another is Message Switching,\n传输数据的另一个方法是 \"报文交换\"\n\nwhich is sort of like how the postal system works.\n\"报文交换\" 就像邮政系统一样\n\nInstead of dedicated route from A to B, messages are passed through several stops.\n不像之前A和B有一条专有线路 \\N 消息会经过好几个站点\n\nSo if John writes a letter to Hank,\n如果 John 写一封信给 Hank\n\nit might go from Indianapolis to Chicago, and then\n信件可能从\"印第安纳波利斯\"到\"芝加哥\"\n\nhop to Minneapolis, then Billings, and then finally make it to Missoula.\n然后\"明尼阿波利斯\" 然后\"比林斯\" 最后到\"米苏拉\"\n\nEach stop knows where to send it next\n每个站点都知道下一站发哪里 \\N 因为站点有表格，记录到各个目的地，信件该怎么传\n\nbecause they keep a table of where to pass letters given a destination address.\n每个站点都知道下一站发哪里 \\N 因为站点有表格，记录到各个目的地，信件该怎么传\n\nWhat’s neat about Message Switching is that it can use different routes,\n报文交换的好处是 可以用不同路由 \\N 使通信更可靠更能容错\n\nmaking communication more reliable and fault-tolerant.\n报文交换的好处是 可以用不同路由 \\N 使通信更可靠更能容错\n\nSticking with our mail example,\n回到邮件的例子\n\nif there’s a blizzard in Minneapolis grinding things to a halt,\n如果\"明尼阿波利斯\"有暴风雪中断了通信 \\N \"芝加哥\"可以传给\"奥马哈\"\n\nthe Chicago mail hub can decide to route the letter through Omaha instead.\n如果\"明尼阿波利斯\"有暴风雪中断了通信 \\N \"芝加哥\"可以传给\"奥马哈\"\n\nIn our example, cities are acting like network routers.\n在这个例子里，城市就像路由器一样\n\nThe number of hops a message takes along a route is called the hop count.\n消息沿着路由跳转的次数 \\N 叫\"跳数\"(hop count)\n\nKeeping track of the hop count is useful because it can help identify routing problems.\n记录跳数很有用，因为可以分辨出路由问题\n\nFor example, let’s say Chicago thinks the fastest route to Missoula is through Omaha,\n举例，假设芝加哥认为 \\N 去米苏拉的最快路线是 奥马哈\n\nbut Omaha thinks the fastest route is through Chicago.\n但奥马哈认为 \\N 去米苏拉的最快路线是 芝加哥\n\nThat's bad, because both cities are going to look at the destination address, Missoula,\n这就糟糕了\\N 因为2个城市看到目的地是米苏拉\n\nand end up passing the message back and forth between them, endlessly.\n结果报文会在2个城市之间\\N不停传来传去\n\nNot only is this wasting bandwidth, but it’s a routing error that needs to get fixed!\n不仅浪费带宽 而且这个路由错误需要修复!\n\nThis kind of error can be detected because the hop count is\n这种错误会被检测到，因为跳数记录在消息中 \\N 而且传输时会更新跳数\n\nstored with the message and updated along its journey.\n这种错误会被检测到，因为跳数记录在消息中 \\N 而且传输时会更新跳数\n\nIf you start seeing messages with high hop counts,\n如果看到某条消息的跳数很高 \\N 就知道路由肯定哪里错了\n\nyou can bet something has gone awry in the routing!\n如果看到某条消息的跳数很高 \\N 就知道路由肯定哪里错了\n\nThis threshold is the Hop Limit.\n这叫\"跳数限制\"\n\nA downside to Message Switching is that messages are sometimes big.\n报文交换的缺点之一是有时候报文比较大\n\nSo, they can clog up the network, because the whole message has to be transmitted from\n会堵塞网络 因为要把整个报文从一站传到下一站后 \\N 才能继续传递其他报文\n\none stop to the next before continuing on its way.\n会堵塞网络 因为要把整个报文从一站传到下一站后 \\N 才能继续传递其他报文\n\nWhile a big file is transferring, that whole link is tied up.\n传输一个大文件时  整条路都阻塞了\n\nEven if you have a tiny, one kilobyte email trying to get through,\n即便你只有一个1KB的电子邮件要传输 \\N 也只能等大文件传完，或是选另一条效率稍低的路线\n\nit either has to wait for the big file transfer to finish or take a less efficient route.\n即便你只有一个1KB的电子邮件要传输 \\N 也只能等大文件传完，或是选另一条效率稍低的路线\n\nThat’s bad.\n这就糟了\n\nThe solution is to chop up big transmissions into many small pieces, called packets.\n解决方法是 将大报文分成很多小块，叫\"数据包\"\n\nJust like with Message Switching, each packet contains a destination address on the network,\n就像报文交换 每个数据包都有目标地址 \\N 因此路由器知道发到哪里\n\nso routers know where to forward them.\n就像报文交换 每个数据包都有目标地址 \\N 因此路由器知道发到哪里\n\nThis format is defined by the \"Internet Protocol\", or IP for short,\n报文具体格式由\"互联网协议\"定义，简称 IP \\N 这个标准创建于 1970 年代\n\na standard created in the 1970s.\n报文具体格式由\"互联网协议\"定义，简称 IP \\N 这个标准创建于 1970 年代\n\nEvery computer connected to a network gets an IP Address.\n每台联网的计算机都需要一个IP地址\n\nYou’ve probably seen these as four, 8-bit numbers written with dots in between.\n你可能见过，以点分隔的4组数字\n\nFor example,172.217.7.238 is an IP Address for one of Google’s servers.\n例如 172.217.7.238 是 Google 其中一个服务器的IP地址\n\nWith millions of computers online, all exchanging data,\n数百万台计算机在网络上不断交换数据 \\N 瓶颈的出现和消失是毫秒级的\n\nbottlenecks can appear and disappear in milliseconds.\n数百万台计算机在网络上不断交换数据 \\N 瓶颈的出现和消失是毫秒级的\n\nNetwork routers are constantly trying to balance the load across whatever routes they know\n路由器会平衡与其他路由器之间的负载 \\N 以确保传输可以快速可靠，这叫\"阻塞控制\"\n\nto ensure speedy and reliable delivery, which is called congestion control.\n路由器会平衡与其他路由器之间的负载 \\N 以确保传输可以快速可靠，这叫\"阻塞控制\"\n\nSometimes different packets from the same message take different routes through a network.\n有时，同一个报文的多个数据包 \\N 会经过不同线路\n\nThis opens the possibility of packets arriving at their destination out of order,\n到达顺序可能会不一样，这对一些软件是个问题\n\nwhich is a problem for some applications.\n到达顺序可能会不一样，这对一些软件是个问题\n\nFortunately, there are protocols that run on top of IP,\n幸运的是，在 IP 之上还有其他协议\n\nlike TCP/IP, that handle this issue.\n比如 TCP/IP, 可以解决乱序问题\n\nWe’ll talk more about that next week.\n我们下周会讲\n\nChopping up data into small packets,\n将数据拆分成多个小数据包，然后通过灵活的路由传递\n\nand passing these along flexible routes with spare capacity,\n将数据拆分成多个小数据包，然后通过灵活的路由传递\n\nis so efficient and fault-tolerant, it’s what the whole internet runs on today.\n非常高效且可容错，如今互联网就是这么运行的\n\nThis routing approach is called Packet Switching.\n这叫\"分组交换\"\n\nIt also has the nice property of being decentralized,\n有个好处是 它是去中心化的\n\nwith no central authority or single point of failure.\n没有中心权威机构  没有单点失败问题\n\nIn fact, the threat of nuclear attack is why\n事实上 因为冷战期间有核攻击的威胁，所以创造了分组交换\n\npacket switching was developed during the cold war!\n事实上 因为冷战期间有核攻击的威胁，所以创造了分组交换\n\nToday, routers all over the globe work cooperatively to find efficient routings,\n如今，全球的路由器协同工作，找出最高效的线路\n\nexchanging information with each other using special protocols,\n用各种标准协议运输数据\n\nlike the Internet Control Message Protocol (ICMP)\n比如 \"因特网控制消息协议\"(ICMP)\n\nand the Border Gateway Protocol (BGP).\n和 \"边界网关协议\"(BGP)\n\nThe world's first packet-switched network,\n世界上第一个分组交换网络\n\nand the ancestor to the modern internet, was the ARPANET,\n以及现代互联网的祖先是 ARPANET\n\nnamed after the US agency that funded it,\n名字来源于赞助这个项目的机构，美国高级研究计划局\n\nthe Advanced Research Projects Agency.\n名字来源于赞助这个项目的机构，美国高级研究计划局\n\nHere’s what the entire ARPANET looked like in 1974.\n这是 1974 年整个 ARPANET 的样子\n\nEach smaller circle is a location,\n每个小圆表示一个地点 \\N 比如大学或实验室，那里运行着一个路由器\n\nlike a university or research lab, that operated a router.\n每个小圆表示一个地点 \\N 比如大学或实验室，那里运行着一个路由器\n\nThey also plugged in one or more computers\n并且有一台或多台计算机\n\n– you can see PDP-1’s, IBM System 360s,\n能看到 \"PDP-1\" 和\"IBM 360系统\"\n\nand even an ATLAS in London connected over a satellite link.\n甚至还有一个伦敦的 ATLAS \\N 是通过卫星连到网络里的\n\nObviously the internet has grown by leaps and bounds in the decades since.\n显然 互联网在这几十年间发展迅速\n\nToday, instead of a few dozen computers online, it’s estimated to be nearing 10 billion.\n如今不再只有几十台计算机联网 \\N 据估计 有接近100亿台联网设备\n\nAnd it continues to grow rapidly,\n而且互联网会继续快速发展\n\nespecially with the advent of wifi-connected refrigerators, thermostat\n特别是如今各种智能设备层出不穷 \\N 比如联网冰箱，恒温器\n\nand other smart appliances, forming an \"internet of things\".\n以及其他智能家电，它们组成了\"物联网\"\n\nSo that’s part one – an overview of computer networks.\n第一部分到此结束  \\N 我们对计算机网络进行了概览\n\nIs it a series of tubes?\n网络是一堆管子组成的吗？\n\nWell, sort of.\n额 算是吧\n\nNext week we’ll tackle some higher-level transmission protocols,\n下周我们会讨论一些高级传输协议\n\nslowly working our way up to the World Wide Web.\n然后讲万维网\n\nI’ll see you then!\n到时见啦\n\nHi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nAs we talked about last episode, your computer is connected to a large, distributed network,\n上集讲到，你的计算机和一个巨大的分布式网络连在一起\n\ncalled The Internet.\n这个网络叫互联网\n\nI know this because you’re watching a YouTube video,\n你现在就在网上看视频呀\n\nwhich is being streamed over that very internet.\n你现在就在网上看视频呀\n\nIt’s arranged as an ever-enlarging web of interconnected devices.\n互联网由无数互联设备组成，而且日益增多\n\nFor your computer to get this video,\n计算机为了获取这个视频 \\N 首先要连到局域网，也叫 LAN\n\nthe first connection is to your local area network, or LAN,\n计算机为了获取这个视频 \\N 首先要连到局域网，也叫 LAN\n\nwhich might be every device in your house that’s connected to your wifi router.\n你家 WIFI 路由器连着的所有设备，组成了局域网.\n\nThis then connects to a Wide Area Network, or WAN,\n局域网再连到广域网，广域网也叫 WAN\n\nwhich is likely to be a router run by your Internet Service Provider, or ISP，\nWAN 的路由器一般属于你的\"互联网服务提供商\"，简称 ISP\n\ncompanies like Comcast, AT&T or Verizon.\n比如 Comcast，AT&T 和 Verizon 这样的公司\n\nAt first, this will be a regional router, like one for your neighborhood,\n广域网里，先连到一个区域性路由器，这路由器可能覆盖一个街区。\n\nand then that router connects to an even bigger WAN,\n然后连到一个更大的 WAN，可能覆盖整个城市\n\nmaybe one for your whole city or town.\n然后连到一个更大的 WAN，可能覆盖整个城市\n\nThere might be a couple more hops, but ultimately you’ll connect to the backbone of the internet\n可能再跳几次，但最终会到达互联网主干\n\nmade up of gigantic routers with super high-bandwidth connections running between them.\n互联网主干由一群超大型、带宽超高路由器组成\n\nTo request this video file from YouTube,\n为了从 YouTube 获得这个视频，\n\na packet had to work its way up to the backbone,\n数据包（packet）要先到互联网主干\n\ntravel along that for a bit, and then work its way back down to a YouTube server that had the file.\n沿着主干到达有对应视频文件的 YouTube 服务器\n\nThat might be four hops up, two hops across the backbone,\n数据包从你的计算机跳到 Youtube 服务器，可能要跳个10次，\n\nand four hops down, for a total of ten hops.\n先跳4次到互联网主干，2次穿过主干，\\N主干出来可能再跳4次，然后到 Youtube 服务器\n\nIf you’re running Windows, Mac OS or Linux, you can see the route data takes to different\n如果你在用 Windows, Mac OS 或 Linux系统，可以用 traceroute 来看跳了几次\n\nplaces on the internet by using the traceroute program on your computer.\n如果你在用 Windows, Mac OS 或 Linux系统，可以用 traceroute 来看跳了几次\n\nInstructions in the Doobly Doo.\n更多详情看视频描述（YouTube原视频下）\n\nFor us here at the Chad & Stacey Emigholz Studio in Indianapolis,\n我们在\"印第安纳波利斯\"的 Chad&Stacy Emigholz 工作室，\\N 访问加州的 DFTBA 服务器，\n\nthe route to the DFTBA server in California goes through 11 stops.\n经历了11次中转\n\nWe start at 192.168.0.1 -- that's the IP address for my computer on our LAN.\n从 192.168.0.1 出发，这是我的电脑在 局域网（LAN）里的 IP 地址\n\nThen there’s the wifi router here at the studio,\n然后到工作室的 WIFI 路由器\n\nthen a series of regional routers, then we get onto the backbone,\n然后穿过一个个地区路由器，到达主干.\n\nand then we start working back down to the computer hosting \"DFTBA.com”,\n然后从主干出来，又跳了几次，到达\"DFTBA.com”的服务器\n\nwhich has the IP address 104.24.109.186.\nIP 地址是 104.24.109.186.\n\nBut how does a packet actually get there?\n但数据包*到底*是怎么过去的？\n\nWhat happens if a packet gets lost along the way?\n如果传输时数据包被弄丢了，会发生什么？\n\nIf I type \"DFTBA.com” into my web browser, how does it know the server’s address?\n如果在浏览器里输 \"DFTBA.com\"，浏览器怎么知道服务器的地址多少？\n\nThese are our topics for today!\n我们今天会讨论这些话题.\n\nAs we discussed last episode, the internet is a huge distributed network\n上集说过，互联网是一个巨型分布式网络 \\N 会把数据拆成一个个数据包来传输\n\nthat sends data around as little packets.\n上集说过，互联网是一个巨型分布式网络 \\N 会把数据拆成一个个数据包来传输\n\nIf your data is big enough, like an email attachment,\n如果要发的数据很大，比如邮件附件 \\N 数据会被拆成多个小数据包\n\nit might get broken up into many packets.\n如果要发的数据很大，比如邮件附件 \\N 数据会被拆成多个小数据包\n\nFor example, this video stream is arriving to your computer right now\n举例，你现在看的这个视频 \\N 就是一个个到达你电脑的数据包\n\nas a series of packets, and not one gigantic file.\n而不是一整个大文件发过来\n\nInternet packets have to conform to a standard called the Internet Protocol, or IP.\n数据包（packet）想在互联网上传输 \\N 要符合\"互联网协议\"的标准，简称 IP\n\nIt’s a lot like sending physical mail through the postal system\n就像邮寄手写信一样，邮寄是有标准的\\N 每封信需要一个地址，而且地址必须是独特的\n\n– every letter needs a unique and legible address written on it,\n就像邮寄手写信一样，邮寄是有标准的\\N 每封信需要一个地址，而且地址必须是独特的\n\nand there are limits to the size and weight of packages.\n并且大小和重量是有限制的\n\nViolate this, and your letter won’t get through.\n违反这些规定，信件就无法送达.\n\nIP packets are very similar.\nIP 数据包也是如此\n\nHowever, IP is a very low level protocol\n因为 IP 是一个非常底层的协议\n\n– there isn’t much more than a destination address in a packet’s header\n数据包的头部（或者说前面）只有目标地址\n\nwhich is the metadata that’s stored in front of the data payload.\n头部存 \"关于数据的数据\" \\N 也叫 元数据(metadata)\n\nThis means that a packet can show up at a computer, but the computer may not know\n这意味着当数据包到达对方电脑 \\N 对方不知道把包交给哪个程序，是交给 Skype 还是使命召唤？\n\nwhich application to give the data to; Skype or Call of Duty.\n这意味着当数据包到达对方电脑 \\N 对方不知道把包交给哪个程序，是交给 Skype 还是使命召唤？\n\nFor this reason, more advanced protocols were developed that sit on top of IP.\n因此需要在 IP 之上，开发更高级的协议.\n\nOne of the simplest and most common is the User Datagram Protocol, or UDP.\n这些协议里 \\N 最简单最常见的叫\"用户数据报协议\"，简称 UDP\n\nUDP has its own header, which sits inside the data payload.\nUDP 也有头部，这个头部位于数据前面\n\nInside of the UDP header is some useful, extra information.\n头部里包含有用的信息\n\nOne of them is a port number.\n信息之一是端口号\n\nEvery program wanting to access the internet will\n每个想访问网络的程序 \\N 都要向操作系统申请一个端口号.\n\nask its host computer’s Operating System to be given a unique port.\n每个想访问网络的程序 \\N 都要向操作系统申请一个端口号.\n\nLike Skype might ask for port number 3478.\n比如 Skype 会申请端口 3478\n\nWhen a packet arrives to the computer, the Operating System\n当一个数据包到达时 \\N 接收方的操作系统会读 UDP 头部，读里面的端口号\n\nwill look inside the UDP header and read the port number.\n当一个数据包到达时 \\N 接收方的操作系统会读 UDP 头部，读里面的端口号\n\nThen, if it sees, for example, 3478, it will give the packet to Skype.\n如果看到端口号是 3478，就把数据包交给 Skype\n\nSo to review, IP gets the packet to the right computer,\n总结：\\NIP 负责把数据包送到正确的计算机 \\N UDP 负责把数据包送到正确的程序\n\nbut UDP gets the packet to the right program running on that computer.\n总结：\\NIP 负责把数据包送到正确的计算机 \\N UDP 负责把数据包送到正确的程序\n\nUDP headers also include something called a checksum,\nUDP 头部里还有\"校验和\"，用于检查数据是否正确\n\nwhich allows the data to be verified for correctness.\nUDP 头部里还有\"校验和\"，用于检查数据是否正确\n\nAs the name suggests, it does this by checking the sum of the data.\n正如\"校验和\"这个名字所暗示的 \\N 检查方式是把数据求和来对比\n\nHere’s a simplified version of how this works.\n以下是个简单例子\n\nLet's imagine the raw data in our UDP packet is\n假设 UDP 数据包里 \\N 原始数据是 89 111 33 32 58 41\n\n89 111 33 32 58 and 41.\n假设 UDP 数据包里 \\N 原始数据是 89 111 33 32 58 41\n\nBefore the packet is sent, the transmitting computer calculates the checksum\n在发送数据包前 \\N 电脑会把所有数据加在一起，算出\"校验和\"\n\nby adding all the data together: 89 plus 111 plus 33 and so on.\n89+111+33+... 以此类推\n\nIn our example, this adds up to a checksum of 364.\n得到 364，这就是\"校验和\".\n\nIn UDP, the checksum value is stored in 16 bits.\nUDP 中，\\N\"校验和\"以 16 位形式存储 (就是16个0或1)\n\nIf the sum exceeds the maximum possible value, the upper-most bits overflw,\n如果算出来的和，超过了 16 位能表示的最大值 \\N 高位数会被扔掉，保留低位\n\nand only the lower bits are used.\n如果算出来的和，超过了 16 位能表示的最大值 \\N 高位数会被扔掉，保留低位\n\nNow, when the receiving computer gets this packet,\n当接收方电脑收到这个数据包\n\nit repeats the process, adding up all the data.\n它会重复这个步骤 \\N 把所有数据加在一起，89+111+33... 以此类推\n\n89 plus 111 plus 33 and so on.\n它会重复这个步骤 \\N 把所有数据加在一起，89+111+33... 以此类推\n\nIf that sum is the same as the checksum sent in the header, all is well.\n如果结果和头部中的校验和一致 \\N 代表一切正常\n\nBut, if the numbers don’t match, you know that the data got corrupted\n如果不一致，数据肯定坏掉了\n\nat some point in transit, maybe because of a power fluctuation or faulty cable.\n也许传输时碰到了功率波动，或电缆出故障了\n\nUnfortunately, UDP doesn’t offer any mechanisms to fix the data, or request a new copy\n不幸的是，UDP 不提供数据修复或数据重发的机制\n\nreceiving programs are alerted to the corruption, but typically just discard the packet.\n接收方知道数据损坏后，一般只是扔掉.\n\nAlso, UDP provides no mechanisms to know if packets are getting through\n而且，UDP 无法得知数据包是否到达.\n\na sending computer shoots the UDP packet off,\n发送方发了之后，无法知道数据包是否到达目的地\n\nbut has no confirmation it ever gets to its destination successfully.\n发送方发了之后，无法知道数据包是否到达目的地\n\nBoth of these properties sound pretty catastrophic, but some applications are ok with this,\n这些特性听起来很糟糕，但是有些程序不在意这些问题\n\nbecause UDP is also really simple and fast.\n因为 UDP 又简单又快.\n\nSkype, for example, which uses UDP for video chat, can handle corrupt or missing packets.\n拿 Skype 举例 \\N 它用 UDP 来做视频通话，能处理坏数据或缺失数据\n\nThat’s why sometimes if you’re on a bad internet connection,\n所以网速慢的时候 Skype 卡卡的 \\N 因为只有一部分数据包到了你的电脑\n\nSkype gets all glitchy – only some of the UDP packets are making it to your computer.\n所以网速慢的时候 Skype 卡卡的 \\N 因为只有一部分数据包到了你的电脑\n\nBut this approach doesn’t work for many other types of data transmission.\n但对于其他一些数据，这个方法不适用.\n\nLike, it doesn’t really work if you send an email, and it shows up with the middle missing.\n比如发邮件，\\N 邮件不能只有开头和结尾 没有中间.\n\nThe whole message really needs to get there correctly!\n邮件要完整到达收件方\n\nWhen it \"absolutely, positively needs to get there”,\n如果\"所有数据必须到达\" \\N 就用\"传输控制协议\"，简称 TCP\n\nprograms use the Transmission Control Protocol, or TCP,\n如果\"所有数据必须到达\" \\N 就用\"传输控制协议\"，简称 TCP\n\nwhich like UDP, rides inside the data payload of IP packets.\nTCP 和 UDP 一样，头部也在存数据前面\n\nFor this reason, people refer to this combination of protocols as TCP/IP.\n因此，人们叫这个组合 TCP/IP\n\nLike UDP, the TCP header contains a destination port and checksum.\n就像 UDP ，TCP 头部也有\"端口号\"和\"校验和\"\n\nBut, it also contains fancier features, and we’ll focus on the key ones.\n但 TCP 有更高级的功能，我们这里只介绍重要的几个\n\nFirst off, TCP packets are given sequential numbers.\n1. TCP 数据包有序号\n\nSo packet 15 is followed by packet 16, which is followed by 17, and so on...\n15号之后是16号，16号之后是17号，以此类推 \\N 发上百万个数据包也是有可能的.\n\nfor potentially millions of packets sent during that session.\n15号之后是16号，16号之后是17号，以此类推 \\N 发上百万个数据包也是有可能的.\n\nThese sequence numbers allow a receiving computer to put the packets into the correct order,\n序号使接收方可以把数据包排成正确顺序，即使到达时间不同.\n\neven if they arrive at different times across the network.\n序号使接收方可以把数据包排成正确顺序，即使到达时间不同.\n\nSo if an email comes in all scrambled, the TCP implementation in your computer’s operating\n哪怕到达顺序是乱的，TCP 协议也能把顺序排对\n\nsystem will piece it all together correctly.\n哪怕到达顺序是乱的，TCP 协议也能把顺序排对\n\nSecond, TCP requires that once a computer has correctly received a packet\n2. TCP 要求接收方的电脑收到数据包 \\N 并且\"校验和\"检查无误后（数据没有损坏）\\N 给发送方发一个确认码，代表收到了\n\n– and the data passes the checksum – that it send back an acknowledgement,\n2. TCP 要求接收方的电脑收到数据包 \\N 并且\"校验和\"检查无误后（数据没有损坏）\\N 给发送方发一个确认码，代表收到了\n\nor \"ACK” as the cool kids say, to the sending computer.\n\"确认码\" 简称 ACK \\N 得知上一个数据包成功抵达后，发送方会发下一个数据包\n\nKnowing the packet made it successfully, the sender can now transmit the next packet.\n\"确认码\" 简称 ACK \\N 得知上一个数据包成功抵达后，发送方会发下一个数据包\n\nBut this time, let’s say, it waits, and doesn’t get an acknowledgement packet back.\n假设这次发出去之后，没收到确认码 \\N 那么肯定哪里错了\n\nSomething must be wrong. If enough time elapses,\n如果过了一定时间还没收到确认码 \\N 发送方会再发一次\n\nthe sender will go ahead and just retransmit the same packet.\n如果过了一定时间还没收到确认码 \\N 发送方会再发一次\n\nIt’s worth noting here  that the original packet might have actually gotten there,\n注意 数据包可能的确到了\n\nbut the acknowledgment is just really delayed.\n只是确认码延误了很久，或传输中丢失了\n\nOr perhaps it was the acknowledgment that was lost.\n只是确认码延误了很久，或传输中丢失了\n\nEither way, it doesn’t matter, because the receiver has those sequence numbers,\n但这不碍事 因为收件方有序列号\n\nand if a duplicate packet arrives, it can be discarded.\n如果收到重复的数据包就删掉\n\nAlso, TCP isn’t limited to a back and forth conversation – it can send many packets,\n还有，TCP 不是只能一个包一个包发\n\nand have many outstanding ACKs, which increases bandwidth significantly, since you aren’t\n可以同时发多个数据包，收多个确认码 \\N 这大大增加了效率，不用浪费时间等确认码\n\nwasting time waiting for acknowledgment packets to return.\n可以同时发多个数据包，收多个确认码 \\N 这大大增加了效率，不用浪费时间等确认码\n\nInterestingly, the success rate of ACKs, and also the round trip time\n有趣的是，确认码的成功率和来回时间 \\N 可以推测网络的拥堵程度\n\nbetween sending and acknowledging, can be used to infer network congestion.\n有趣的是，确认码的成功率和来回时间 \\N 可以推测网络的拥堵程度\n\nTCP uses this information to adjust how aggressively it sends packets –\nTCP 用这个信息，调整同时发包数量，解决拥堵问题\n\na mechanism for congestion control.\nTCP 用这个信息，调整同时发包数量，解决拥堵问题\n\nSo, basically, TCP can handle out-of-order packet delivery, dropped packets\n简单说，TCP 可以处理乱序和丢失数据包，丢了就重发.\n\n– including retransmission – and even throttle its transmission rate according to available bandwidth.\n还可以根据拥挤情况自动调整传输率\n\nPretty awesome!\n相当厉害！\n\nYou might wonder why anyone would use UDP when TCP has all those nifty features.\n你可能会奇怪，既然 TCP 那么厉害，还有人用 UDP 吗？\n\nThe single biggest downside are all those acknowledgment packets\nTCP 最大的缺点是 \\N 那些\"确认码\"数据包把数量翻了一倍\n\n– it doubles the number of messages on the network,\nTCP 最大的缺点是 \\N 那些\"确认码\"数据包把数量翻了一倍\n\nand yet, you're not transmitting any more data.\n但并没有传输更多信息\n\nThat overhead, including associated delays, is sometimes not worth the improved robustness,\n有时候这种代价是不值得的 \\N 特别是对时间要求很高的程序，比如在线射击游戏\n\nespecially for time-critical applications, like Multiplayer First Person Shooters.\n有时候这种代价是不值得的 \\N 特别是对时间要求很高的程序，比如在线射击游戏\n\nAnd if it’s you getting lag-fragged you’ll definitely agree!\n如果你玩游戏很卡，你也会觉得这样不值!\n\nWhen your computer wants to make a connection to a website, you need two things\n当计算机访问一个网站时 \\N 需要两个东西：1.IP地址 2.端口号\n\n- an IP address and a port.\n当计算机访问一个网站时 \\N 需要两个东西：1.IP地址 2.端口号\n\nLike port 80, at 172.217.7.238.\n例如 172.217.7.238 的 80 端口 \\N 这是谷歌的 IP 地址和端口号\n\nThis example is the IP address and port for the Google web server.\n例如 172.217.7.238 的 80 端口 \\N 这是谷歌的 IP 地址和端口号\n\nIn fact, you can enter this into your browser’s address bar, like so,\n事实上，你可以输到浏览器里，然后你会进入谷歌首页\n\nand you’ll end up on the google homepage.\n事实上，你可以输到浏览器里，然后你会进入谷歌首页\n\nThis gets you to the right destination,\n有了这两个东西就能访问正确的网站 \\N 但记一长串数字很讨厌\n\nbut remembering that long string of digits would be really annoying.\n有了这两个东西就能访问正确的网站 \\N 但记一长串数字很讨厌\n\nIt’s much easier to remember: google.com.\ngoogle.com 比一长串数字好记\n\nSo the internet has a special service that maps these domain names to addresses.\n所以互联网有个特殊服务 \\N 负责把域名和 IP 地址一一对应\n\nIt’s like the phone book for the internet.\n就像专为互联网的电话簿 \\N 它叫\"域名系统\"，简称 DNS\n\nAnd it’s called the Domain Name System, or DNS for short.\n就像专为互联网的电话簿 \\N 它叫\"域名系统\"，简称 DNS\n\nYou can probably guess how it works.\n它的运作原理你可能猜到了\n\nWhen you type something like \"youtube.com” into your web browser,\n在浏览器里输 youtube.com \\N 浏览器会去问 DNS 服务器，它的 IP 地址是多少\n\nit goes and asks a DNS server – usually one provided by your ISP – to lookup the address.\n一般 DNS 服务器 \\N 是互联网供应商提供的\n\nDNS consults its huge registry, and replies with the address... if one exists.\nDNS 会查表，如果域名存在，就返回对应 IP 地址.\n\nIn fact, if you try mashing your keyboard, adding \".com”, and then hit enter in your\n如果你乱敲键盘加个.com 然后按回车\n\nbrowser, you’ll likely be presented with an error that says DNS failed.\n你很可能会看到 DNS 错误\n\nThat’s because that site doesn’t exist, so DNS couldn’t give your browser an address.\n因为那个网站不存在，所以 DNS 无法返回给你一个地址\n\nBut, if DNS returns a valid address, which it should for \"YouTube.com”, then your\n如果你输的是有效地址，比如 youtube.com \\N DNS 按理会返回一个地址\n\nbrowser shoots off a request over TCP for the website’s data.\n然后浏览器会给这个 IP 地址 \\N 发 TCP 请求\n\nThere’s over 300 million registered domain names, so to make out DNS Lookup a little\n如今有三千万个注册域名，所以为了更好管理\n\nmore manageable, it’s not stored as one gigantically long list,\nDNS 不是存成一个超长超长的列表，而是存成树状结构\n\nbut rather in a tree data structure.\nDNS 不是存成一个超长超长的列表，而是存成树状结构\n\nWhat are called Top Level Domains, or TLDs, are at the very top.\n顶级域名（简称 TLD）在最顶部，比如 .com 和 .gov\n\nThese are huge categories like .com and .gov.\n顶级域名（简称 TLD）在最顶部，比如 .com 和 .gov\n\nThen, there are lower level domains that sit below that, called second level domains; Examples\n下一层是二级域名，比如 .com 下面有 \\N google.com 和 dftba.com\n\nunder .com include google.com and dftba.com.\n下一层是二级域名，比如 .com 下面有 \\N google.com 和 dftba.com\n\nThen, there are even lower level domains, called subdomains,\n再下一层叫子域名，\\N 比如 images.google.com, store.dftba.com\n\nlike images.google.com, store.dftba.com.\n再下一层叫子域名，\\N 比如 images.google.com, store.dftba.com\n\nAnd this tree is absolutely HUGE!\n这个树超！级！大！\n\nLike I said, more than 300 million domain names, and that's just second level domain\n我前面说的\"三千万个域名\"只是二级域名 \\N 不是所有子域名\n\nnames, not all the sub domains.\n我前面说的\"三千万个域名\"只是二级域名 \\N 不是所有子域名\n\nFor this reason, this data is distributed across many DNS servers,\n因此，这些数据散布在很多 DNS 服务器上\n\nwhich are authorities for different parts of the tree.\n不同服务器负责树的不同部分\n\nOkay, I know you’ve been waiting for it...\n好了 我知道你肯定在等这个梗：\n\nWe’ve reached a new level of abstraction!\n我们到了一层新抽象！\n\nOver the past two episodes, we’ve worked up from electrical signals on wires,\n过去两集里 \\N 我们讲了线路里的电信号，以及无线网络里的无线信号\n\nor radio signals transmitted through the air in the case of wireless networks.\n过去两集里 \\N 我们讲了线路里的电信号，以及无线网络里的无线信号\n\nThis is called the Physical Layer.\n这些叫\"物理层\"\n\nMAC addresses, collision detection,\n而\"数据链路层\"负责操控\"物理层\"，\\N 数据链路层有：媒体访问控制地址（MAC），碰撞检测，\n\nexponential backoff and similar low level protocols that\n而\"数据链路层\"负责操控\"物理层\"，\\N 数据链路层有：媒体访问控制地址（MAC），碰撞检测，\n\nmediate access to the physical layer are part of the Data Link Layer.\n指数退避，以及其他一些底层协议\n\nAbove this is the Network Layer,\n再上一层是\"网络层\"\n\nwhich is where all the switching and routing technologies that we discussed operate.\n负责各种报文交换和路由\n\nAnd today, we mostly covered the Transport layer, protocols like UDP and TCP,\n而今天，我们讲了\"传输层\"里一大部分， 比如 UDP 和 TCP 这些协议,\n\nwhich are responsible for point to point data transfer between computers,\n负责在计算机之间进行点到点的传输\n\nand also things like error detection and recovery when possible.\n而且还会检测和修复错误\n\nWe’ve also grazed the Session Layer –\n我们还讲了一点点\"会话层\"\n\nwhere protocols like TCP and UDP are used to open a connection,\n\"会话层\"会使用 TCP 和 UDP 来创建连接，传递信息，然后关掉连接\n\npass information back and forth, and then close the connection when finished\n\"会话层\"会使用 TCP 和 UDP 来创建连接，传递信息，然后关掉连接\n\n– what’s called a session.\n这一整套叫\"会话\"\n\nThis is exactly what happens when you, for example, do a DNS Lookup, or request a webpage.\n查询 DNS 或看网页时，就会发生这一套流程\n\nThese are the bottom five layers of the Open System Interconnection (OSI) model,\n这是 开放式系统互联通信参考模型(OSI) 的底下5层\n\na conceptual framework for compartmentalizing all these different network processes.\n这个概念性框架 把网络通信划分成多层\n\nEach level has different things to worry about and solve,\n每一层处理各自的问题\n\nand it would be impossible to build one huge networking implementation.\n如果不分层 \\N 直接从上到下捏在一起实现网络通信，是完全不可能的\n\nAs we’ve talked about all series, abstraction allows computer scientists and engineers to\n抽象使得科学家和工程师能分工同时改进多个层 \\N 不被整体复杂度难倒.\n\nbe improving all these different levels of the stack simultaneously,\n抽象使得科学家和工程师能分工同时改进多个层 \\N 不被整体复杂度难倒.\n\nwithout being overwhelmed by the full complexity.\n抽象使得科学家和工程师能分工同时改进多个层 \\N 不被整体复杂度难倒.\n\nAnd amazingly, we’re not quite done yet\n而且惊人的是！我们还没讲完呢！\n\nThe OSI model has two more layers, the Presentation Layer and the Application Layer,\nOSI 模型还有两层，\"表示层\"和\"应用程序层\"\n\nwhich include things like web browsers, Skype,\n其中有浏览器，Skype，HTML解码，在线看电影等\n\nHTML decoding, streaming movies and more.\n其中有浏览器，Skype，HTML解码，在线看电影等\n\nWhich we’ll talk about next week.  See you then.\n我们下周说，到时见\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science.\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nOver the past two episodes, we’ve delved into the wires, signals, switches, packets,\n前两集我们深入讨论了电线 信号 交换机 数据包 \\N 路由器以及协议，它们共同组成了互联网.\n\nrouters and protocols that make up the internet.\n前两集我们深入讨论了电线 信号 交换机 数据包 \\N 路由器以及协议，它们共同组成了互联网.\n\nToday we’re going to move up yet another level of abstraction\n今天我们向上再抽象一层，来讨论万维网\n\nand talk about the World Wide Web.\n今天我们向上再抽象一层，来讨论万维网\n\nThis is not the same thing as the Internet,\n万维网(World Wide Web) \\N 和互联网(Internet)不是一回事\n\neven though people often use the two terms interchangeably.\n尽管人们经常混用这两个词\n\nThe World Wide Web runs on top of the internet,\n万维网在互联网之上运行\n\nin the same way that Skype, Minecraft or Instagram do.\n互联网之上还有 Skype, Minecraft 和 Instagram\n\nThe Internet is the underlying plumbing that conveys the data for all these different applications.\n互联网是传递数据的管道，各种程序都会用，\n\nAnd The World Wide Web is the biggest of them all\n其中传输最多数据的程序是万维网\n\n– a huge distributed application running on millions of servers worldwide,\n分布在全球数百万个服务器上\n\naccessed using a special program called a web browser.\n可以用\"浏览器\"来访问万维网\n\nWe’re going to learn about that, and much more, in today’s episode.\n这集我们会深入讲解万维网\n\nThe fundamental building block of the World Wide Web – or web for short\n万维网的最基本单位，是单个页面\n\n– is a single page.\n万维网的最基本单位，是单个页面\n\nThis is a document, containing content, which can include links to other pages.\n页面有内容，也有去往其他页面的链接 \\N 这些链接叫\"超链接\"\n\nThese are called hyperlinks.\n页面有内容，也有去往其他页面的链接 \\N 这些链接叫\"超链接\"\n\nYou all know what these look like: text or images that you can click,\n你们都见过：可以点击的文字或图片，把你送往另一个页面\n\nand they jump you to another page.\n你们都见过：可以点击的文字或图片，把你送往另一个页面\n\nThese hyperlinks form a huge web of interconnected information,\n这些超链接形成巨大的互联网络\n\nwhich is where the whole thing gets its name.\n这就是\"万维网\"名字的由来\n\nThis seems like such an obvious idea.\n现在说起来觉得很简单，但在超链接做出来之前\n\nBut before hyperlinks were implemented,\n现在说起来觉得很简单，但在超链接做出来之前\n\nevery time you wanted to switch to another piece of information on a computer,\n计算机上每次想看另一个信息时\n\nyou had to rummage through the file system to find it, or type it into a search box.\n你需要在文件系统中找到它 \\N 或是把地址输入搜索框\n\nWith hyperlinks, you can easily flow from one related topic to another.\n有了超链接，你可以在相关主题间轻松切换\n\nThe value of hyperlinked information was conceptualized by Vannevar Bush way back in 1945.\n超链接的价值早在 1945 年 \\N 就被 Vannevar Bush 意识到了\n\nHe published an article describing a hypothetical machine called a Memex,\n在第 24 集中我们说过，他发过一篇文章 \\N 描述一个假想的机器 Memex\n\nwhich we discussed in Episode 24.\n在第 24 集中我们说过，他发过一篇文章 \\N 描述一个假想的机器 Memex\n\nBush described it as \"associative indexing... whereby any item may be caused\nBush的形容是\"关联式索引.. 选一个物品会引起\n\nat will to select another immediately and automatically.\"\n另一个物品被立即选中\"\n\nHe elaborated: \"The process of tying two things together is the important thing...\n他解释道：\"将两样东西联系在一起的过程十分重要\n\nthereafter, at any time, when one of those items is in view,\n在任何时候，当其中一件东西进入视线\n\nthe other [item] can be instantly recalled merely by tapping a button.\"\n只需点一下按钮，立马就能回忆起另一件\"\n\nIn 1945, computers didn’t even have screens, so this idea was way ahead of its time!\n1945年的时候计算机连显示屏都没有，\\N 所以这个想法非常超前！\n\nText containing hyperlinks is so powerful,\n因为文字超链接是如此强大\n\nit got an equally awesome name: hypertext!\n它得到了一个同样厉害的名字：\"超文本\"！\n\nWeb pages are the most common type of hypertext document today.\n如今超文本最常指向的，是另一个网页\n\nThey’re retrieved and rendered by web browsers\n然后网页由浏览器渲染，我们待会会讲\n\nwhich we'll get to in a few minutes.\n然后网页由浏览器渲染，我们待会会讲\n\nIn order for pages to link to one another, each hypertext page needs a unique address.\n为了使网页能相互连接，每个网页需要一个唯一的地址\n\nOn the web, this is specified by a Uniform Resource Locator, or URL for short.\n这个地址叫 \"统一资源定位器\"，简称 URL\n\nAn example web page URL is thecrashcourse.com/courses.\n一个网页URL的例子是 \"thecrashcourse.com/courses\"\n\nLike we discussed last episode, when you request a site,\n就像上集讨论的，当你访问一个网站时\n\nthe first thing your computer does is a DNS lookup.\n计算机首先会做\"DNS查找\"\n\nThis takes a domain name as input – like \"thecrashcourse.com\"\n\"DNS查找\"的输入是一个域名 \\N 比如 thecrashcourse.com\n\nand replies back with the corresponding computer’s IP address.\nDNS 会输出对应的IP地址\n\nNow, armed with the IP address of the computer you want,\n现在有了IP地址 \\N 你的浏览器会打开一个 TCP 连接到这个 IP 地址\n\nyour web browser opens a TCP connection to a computer\n现在有了IP地址 \\N 你的浏览器会打开一个 TCP 连接到这个 IP 地址\n\nthat’s running a special piece of software called a web server.\n这个地址运行着\"网络服务器\"\n\nThe standard port number for web servers is port 80.\n网络服务器的标准端口是 80 端口\n\nAt this point, all your computer has done is connect to\n这时，你的计算机连到了 \\N thecrashcourse.com 的服务器\n\nthe web server at the address thecrashcourse.com\n这时，你的计算机连到了 \\N thecrashcourse.com 的服务器\n\nThe next step is to ask that web server for the \"courses\" hypertext page.\n下一步是向服务器请求\"courses\"这个页面\n\nTo do this, it uses the aptly named Hypertext Transfer Protocol, or HTTP.\n这里会用\"超文本传输协议\"(HTTP)\n\nThe very first documented version of this spec, HTTP 0.9, created in 1991,\nHTTP的第一个标准，HTTP 0.9，创建于1991年\n\nonly had one command – \"GET\".\n只有一个指令，\"GET\" 指令\n\nFortunately, that’s pretty much all you need.\n幸运的是，对当时来说也够用\n\nBecause we’re trying to get the \"courses\" page,\n因为我们想要的是\"courses\"页面\n\nwe send the server the following command– GET /courses.\n我们向服务器发送指令:\"GET /courses\"\n\nThis command is sent as raw ASCII text to the web server,\n该指令以\"ASCII编码\"发送到服务器\n\nwhich then replies back with the web page hypertext we requested.\n服务器会返回该地址对应的网页 \\N 然后浏览器会渲染到屏幕上\n\nThis is interpreted by your computer's web browser and rendered to your screen.\n服务器会返回该地址对应的网页 \\N 然后浏览器会渲染到屏幕上\n\nIf the user follows a link to another page, the computer just issues another GET request.\n如果用户点了另一个链接，计算机会重新发一个GET请求\n\nAnd this goes on and on as you surf around the website.\n你浏览网站时，这个步骤会不断重复\n\nIn later versions, HTTP added status codes,\n在之后的版本，HTTP添加了状态码\n\nwhich prefixed any hypertext that was sent following a GET request.\n状态码放在请求前面\n\nFor example, status code 200 means OK – I’ve got the page and here it is!\n举例，状态码 200 代表 \"网页找到了,给你\"\n\nStatus codes in the four hundreds are for client errors.\n状态码400~499代表客户端出错\n\nLike, if a user asks the web server for a page that doesn’t exist,\n比如网页不存在，就是可怕的404错误\n\nthat’s the dreaded 404 error!\n比如网页不存在，就是可怕的404错误\n\nWeb page hypertext is stored and sent as plain old text,\n\"超文本\"的存储和发送都是以普通文本形式\n\nfor example, encoded in ASCII or UTF-16, which we talked about in Episodes 4 and 20.\n举个例子，编码可能是 ASCII 或 UTF-16  \\N 我们在第4集和第20集讨论过\n\nBecause plain text files don’t have a way to specify what’s a link and what’s not,\n因为如果只有纯文本 \\N 无法表明什么是链接，什么不是链接\n\nit was necessary to develop a way to \"mark up\" a text file with hypertext elements.\n所以有必要开发一种标记方法\n\nFor this, the Hypertext Markup Language was developed.\n因此开发了 超文本标记语言（HTML)\n\nThe very first version of HTML version 0.8, created in 1990,\nHTML 第一版的版本号是 0.8，创建于 1990 年\n\nprovided 18 HTML commands to markup pages.\n有18种HTML指令\n\nThat’s it!\n仅此而已\n\nLet’s build a webpage with these!\n我们来做一个网页吧！\n\nFirst, let’s give our web page a big heading.\n首先，给网页一个大标题\n\nTo do this, we type in the letters \"h1\", which indicates the start of a first level\n我们输 h1 代表一级标题，然后用<>括起来\n\nheading, and we surround that in angle brackets.\n我们输 h1 代表一级标题，然后用<>括起来\n\nThis is one example of an HTML tag.\n这就是一个HTML标签\n\nThen, we enter whatever heading text we want.\n然后输入想要的标题\n\nWe don’t want the whole page to be a heading.\n我们不想一整页都是标题 \\N 所以加 </h1> 作为结束标签\n\nSo, we need to \"close\" the \"h1\" tag like so, with a little slash in the front.\n我们不想一整页都是标题 \\N 所以加 </h1> 作为结束标签\n\nNow lets add some content.\n现在来加点内容\n\nVisitors may not know what Klingons are, so let’s make that word a hyperlink to the\n读者可能不知道\"克林贡\"是什么，所以我们给这个词\n\nKlingon Language Institute for more information.\n加一个超链接到\"克林贡语言研究院\"\n\nWe do this with an \"A\" tag, inside of which we include an attribute\n我们用 <a> 标签来做，它有一个 href 属性\n\nthat specifies a hyperlink reference.\n说明链接指向哪里，当点击链接时就会进入那个网页\n\nThat’s the page to jump to if the link is clicked.\n说明链接指向哪里，当点击链接时就会进入那个网页\n\nAnd finally, we need to close the A tag.\n最后用 </a> 关闭标签\n\nNow lets add a second level heading, which uses an \"h2\" tag.\n接下来用 <h2> 标签做二级标题\n\nHTML also provides tags to create lists.\nHTML也有做列表的标签\n\nWe start this by adding the tag for an ordered list.\n我们先写<ol> \\N 代表 有序列表（ordered list）\n\nThen we can add as many items as we want,\n然后想加几个列表项目  就加几个 \\N 用 <li> 包起来就行\n\nsurrounded in \"<li>\" tags, which stands for list item.\n然后想加几个列表项目  就加几个 \\N 用 <li> 包起来就行\n\nPeople may not know what a bat'leth is, so let’s make that a hyperlink too.\n读者可能不知道Bat'leth是什么，那么也加上超链接\n\nLastly, for good form, we need to close the ordered list tag.\n最后，为了保持良好格式，用</ol>代表列表结束\n\nAnd we’re done – that’s a very simple web page!\n这就完成了 - 一个很简单的网页！\n\nIf you save this text into notepad or textedit, and name it something like \"test.html\",\n如果把这些文字存入记事本或文本编辑器，\\N 然后文件取名\"test.html\"\n\nyou should be able to open it by dragging it into your computer’s web browser.\n就可以拖入浏览器打开\n\nOf course, today’s web pages are a tad more sophisticated.\n当然，如今的网页更复杂一些\n\nThe newest version of HTML, version 5, has over a hundred different tags –\n最新版的 HTML，HTML5，有100多种标签\n\nfor things like images, tables, forms and buttons.\n图片标签，表格标签，表单标签，按钮标签，等等\n\nAnd there are other technologies we’re not going to discuss, like Cascading Style Sheets\n还有其他相关技术就不说了\\N 比如 层叠样式表 (CSS)\n\nor CSS and JavaScript, which can be embedded into HTML pages and do even fancier things.\n和 JavaScript，这俩可以加进网页，做一些更厉害的事\n\nThat brings us back to web browsers.\n让我们回到浏览器\n\nThis is the application on your computer that lets you talk with all these web servers.\n网页浏览器可以和网页服务器沟通\n\nBrowsers not only request pages and media,\n浏览器不仅获取网页和媒体，获取后还负责显示.\n\nbut also render the content that’s being returned.\n浏览器不仅获取网页和媒体，获取后还负责显示.\n\nThe first web browser, and web server,\n第一个浏览器和服务器\n\nwas written by (now Sir) Tim Berners-Lee over the course of two months in 1990.\n是 Tim Berners-Lee 在 1990 年写的，一共花了2个月\n\nAt the time, he was working at CERN in Switzerland.\n那时候他在瑞士的\"欧洲核子研究所\"工作\n\nTo pull this feat off, he simultaneously created several of the fundamental web standards\n为了做出来，他同时建立了几个最基本的网络标准\n\nwe discussed today: URL, HTML and HTTP.\nURL, HTML 和 HTTP.\n\nNot bad for two months work!\n两个月能做这些很不错啊！\n\nAlthough to be fair, he’d been researching hypertext systems for over a decade.\n不过公平点说，他研究超文本系统已经有十几年了\n\nAfter initially circulating his software amongst colleagues at CERN,\n和同事在 CERN 内部使用一阵子后\n\nit was released to the public in 1991.\n在 1991 年发布了出去\n\nThe World Wide Web was born.\n万维网就此诞生\n\nImportantly, the web was an open standard,\n重要的是，万维网有开放标准\n\nmaking it possible for anyone to develop new web servers and browsers.\n大家都可以开发新服务器和新浏览器\n\nThis allowed a team at the University of Illinois at Urbana-Champaign to\n因此\"伊利诺伊大学香槟分校\"的一个小组\n\ncreate the Mosaic web browser in 1993.\n在 1993 年做了 Mosaic 浏览器\n\nIt was the first browser that allowed graphics to be embedded alongside text;\n第一个可以在文字旁边显示图片的浏览器\n\nprevious browsers displayed graphics in separate windows.\n之前浏览器要单开一个新窗口显示图片\n\nIt also introduced new features like bookmarks, and had a friendly GUI interface,\n还引进了书签等新功能，界面友好，使它很受欢迎\n\nwhich made it popular.\n还引进了书签等新功能，界面友好，使它很受欢迎\n\nEven though it looks pretty crusty, it’s recognizable as the web we know today!\n尽管看上去硬邦邦的，但和如今的浏览器长的差不多\n\nBy the end of the 1990s, there were many web browsers in use,\n1990年代末有许多浏览器面世\n\nlike Netscape Navigator, Internet Explorer, Opera, OmniWeb and Mozilla.\nNetscape Navigator, Internet Explorer \\N Opera, OmniWeb, Mozilla\n\nMany web servers were also developed,\n也有很多服务器面世\n\nlike Apache and Microsoft’s Internet Information Services (IIS).\n比如 Apache 和 微软互联网信息服务(IIS)\n\nNew websites popped up daily, and web mainstays\n每天都有新网站冒出来，如今的网络巨头\n\nlike Amazon and eBay were founded in the mid-1990s.\n比如亚马逊和 eBay，创始于 1990 年代中期\n\nIt was a golden era!\n那是个黄金时代！\n\nThe web was flourishing and people increasingly needed ways to find things.\n随着万维网日益繁荣，人们越来越需要搜索\n\nIf you knew the web address of where you wanted to go –\n如果你知道网站地址 \\N 比如 ebay.com，直接输入浏览器就行\n\nlike ebay.com – you could just type it into the browser.\n如果你知道网站地址 \\N 比如 ebay.com，直接输入浏览器就行\n\nBut what if you didn’t know where to go?\n如果不知道地址呢？\n\nLike, you only knew that you wanted pictures of cute cats.\n比如想找可爱猫咪的图片\n\nRight now!\n现在就要！\n\nWhere do you go?\n去哪里找呢？\n\nAt first, people maintained web pages\n起初人们会维护一个目录，链接到其他网站\n\nwhich served as directories hyperlinking to other websites.\n起初人们会维护一个目录，链接到其他网站\n\n\"Most famous among these was \"Jerry and David's guide to the World Wide Web\",\n其中最有名的叫\"Jerry和David的万维网指南\"\n\nrenamed Yahoo in 1994.\n1994年改名为Yahoo\n\nAs the web grew, these human-edited directories started to get unwieldy,\n随着网络越来越大，人工编辑的目录变得不便利\n\nand so search engines were developed.\n所以开发了搜索引擎\n\nLet’s go to the thought bubble!\n让我们进入思想泡泡!\n\nThe earliest web search engine that operated like the ones we use today, was JumpStation,\n长的最像现代搜索引擎的最早搜素引擎，叫JumpStation\n\ncreated by Jonathon Fletcher in 1993 at the University of Stirling.\n由Jonathon Fletcher于1993年在斯特林大学创建\n\nThis consisted of three pieces of software that worked together.\n它有 3 个部分\n\nThe first was a web crawler, software that followed all the links it could find on the web;\n第一个是爬虫，一个跟着链接到处跑的软件\n\nanytime it followed a link to a page that had new links,\n每当看到新链接，就加进自己的列表里\n\nit would add those to its list.\n每当看到新链接，就加进自己的列表里\n\nThe second component was an ever enlarging index,\n第二个部分是不断扩张的索引\n\nrecording what text terms appeared on what pages the crawler had visited.\n记录访问过的网页上，出现过哪些词\n\nThe final piece was a search algorithm that consulted the index;\n最后一个部分，是查询索引的搜索算法\n\nfor example, if I typed the word \"cat\" into JumpStation,\n举个例子，如果我在 JumpStation 输入\"猫\"\n\nevery webpage where the word \"cat\" appeared would come up in a list.\n每个有\"猫\"这个词的网页都会出现\n\nEarly search engines used very simple metrics to rank order their search results, most often\n早期搜索引擎的排名方式 非常简单\n\njust the number of times a search term appeared on a page.\n取决于 搜索词在页面上的出现次数\n\nThis worked okay, until people started gaming the system,\n刚开始还行，直到有人开始钻空子\n\nlike by writing \"cat\" hundreds of times on their web pages just to steer traffic their way.\n比如在网页上写几百个\"猫\"，把人们吸引过来\n\nGoogle’s rise to fame was in large part\n谷歌成名的一个很大原因是 \\N 创造了一个聪明的算法来规避这个问题\n\ndue to a clever algorithm that sidestepped this issue.\n谷歌成名的一个很大原因是 \\N 创造了一个聪明的算法来规避这个问题\n\nInstead of trusting the content on a web page,\n与其信任网页上的内容 \\N 搜索引擎会看其他网站 有没有链接到这个网站\n\nthey looked at how other websites linked to that page.\n与其信任网页上的内容 \\N 搜索引擎会看其他网站 有没有链接到这个网站\n\nIf it was a spam page with the word cat over and over again, no site would link to it.\n如果只是写满\"猫\"的垃圾网站，没有网站会指向它\n\nBut if the webpage was an authority on cats, then other sites would likely link to it.\n如果有关于猫的有用内容，有网站会指向它\n\nSo the number of what are called \"backlinks\", especially from reputable sites,\n所以这些\"反向链接\"的数量，特别是有信誉的网站\n\nwas often a good sign of quality.\n代表了网站质量\n\nThis started as a research project called BackRub at Stanford University in 1996, before\nGoogle 一开始时是 1996 年斯坦福大学 \\N 一个叫 BackRub 的研究项目\n\nbeing spun out, two years later, into the Google we know today.\n两年后分离出来，演变成如今的谷歌\n\nThanks thought bubble!\n谢谢思想泡泡！\n\nFinally, I want to take a second to talk about a term you’ve probably heard a lot recently,\n最后 我想讲一个词，你最近可能经常听到\n\n\"Net Neutrality\".\n网络中立性\n\nNow that you’ve built an understanding of packets, internet routing, and the World Wide\n现在你对数据包，路由和万维网，有了个大体概念\n\nWeb, you know enough to understand the essence, at least the technical essence, of this big debate.\n足够你理解这个争论的核心点，至少从技术角度\n\nIn short, network neutrality is the principle that\n简单说\"网络中立性\"是\n\nall packets on the internet should be treated equally.\n应该平等对待所有数据包\n\nIt doesn’t matter if the packets are my email or you streaming this video,\n不论这个数据包是我的邮件，或者是你在看视频\n\nthey should all chug along at the same speed and priority.\n速度和优先级应该是一样的\n\nBut many companies would prefer that their data arrive to you preferentially.\n但很多公司会乐意让它们的数据优先到达\n\nTake for example, Comcast, a large ISP that also owns many TV channels,\n拿 Comcast 举例，它们不但是大型互联网服务提供商\\N 而且拥有多家电视频道\n\nlike NBC and The Weather Channel, which are streamed online.\n比如 NBC 和 The Weather Channel，可以在线看.\n\nNot to pick on Comcast, but in the absence of Net Neutrality rules,\n我不是特意找Comcast麻烦 \\N 但要是没有网络中立性\n\nthey could for example say that they want their content to be delivered silky smooth, with high priority…\nComcast 可以让自己的内容优先到达 \\N 节流其他线上视频\n\nBut other streaming videos are going to get throttled,\nComcast 可以让自己的内容优先到达 \\N 节流其他线上视频\n\nthat is, intentionally given less bandwidth and lower priority.\n节流(Throttled) 意思是故意给更少带宽和更低优先级\n\nAgain I just want to reiterate here this is just conjecture.\n再次重申，这只是举例，不是说 Comcast 很坏\n\nAt a high level, Net Neutrality advocates argue that giving internet providers this\n支持网络中立性的人说 \\N 没有中立性后，服务商可以推出提速的\"高级套餐\"\n\nability to essentially set up tolls on the internet – to provide premium packet delivery\n支持网络中立性的人说 \\N 没有中立性后，服务商可以推出提速的\"高级套餐\"\n\nplants the seeds for an exploitative business model.\n给剥削性商业模式埋下种子\n\nISPs could be gatekeepers to content, with strong incentives to not play nice with competitors.\n互联网服务供应商成为信息的\"守门人\"，\\N 它们有着强烈的动机去碾压对手\n\nAlso, if big companies like Netflix and Google can pay to get special treatment,\n另外，Netflix和Google这样的大公司可以花钱买特权\n\nsmall companies, like start-ups, will be at a disadvantage, stifling innovation.\n而小公司，比如刚成立的创业公司，\\N 会处于劣势，阻止了创新\n\nOn the other hand, there are good technical reasons why you might\n另一方面，从技术原因看\n\nwant different types of data to flow at different speeds.\n也许你会希望不同数据传输速度不同\n\nThat skype call needs high priority,\n你希望Skype的优先级更高，邮件晚几秒没关系\n\nbut it’s not a big deal if an email comes in a few seconds late.\n你希望Skype的优先级更高，邮件晚几秒没关系\n\nNet-neutrality opponents also argue that market forces and competition would discourage bad\n而反对\"网络中立性\"的人认为，市场竞争会阻碍不良行为\n\nbehavior, because customers would leave ISPs that are throttling sites they like.\n如果供应商把客户喜欢的网站降速 \\N 客户会离开供应商\n\nThis debate will rage on for a while yet, and as we always encourage on Crash Course,\n这场争辩还会持续很久，\\N 就像我们在 Crash Course 其他系列中说过\n\nyou should go out and learn more\n你应该自己主动了解更多信息\n\nbecause the implications of Net Neutrality are complex and wide-reaching.\n因为\"网络中立性\"的影响十分复杂而且广泛\n\nI’ll see you next week.\n我们下周再见\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nOver the last three episodes, we’ve talked about how computers have become interconnected,\n过去3集 我们讲了计算机如何互连\n\nallowing us to communicate near-instantly across the globe.\n让我们能瞬时跨全球沟通\n\nBut, not everyone who uses these networks is going to play by the rules,\n但不是每个使用网络的人都会规规矩矩  不损害他人利益\n\nor have our best interests at heart.\n但不是每个使用网络的人都会规规矩矩  不损害他人利益\n\nJust as how we have physical security like locks, fences\n就像现实世界中我们用锁和栅栏保证物理安全\n\nand police officers to minimize crime in the real world,\n有警察减少犯罪\n\nwe need cybersecurity to minimize crime and harm in the virtual world.\n我们需要网络安全减少虚拟世界中的犯罪\n\nComputers don’t have ethics.\n计算机没有道德观念\n\nGive them a formally specified problem and\n只要给计算机写清具体问题  它们很乐意地闪电般算出答案\n\nthey’ll happily pump out an answer at lightning speed.\n只要给计算机写清具体问题  它们很乐意地闪电般算出答案\n\nRunning code that takes down a hospital’s computer systems\n破坏医院计算机系统的代码 和 保持病人心跳的代码 \\N 对计算机来说没有区别\n\nis no different to a computer than code that keeps a patient's heart beating.\n破坏医院计算机系统的代码 和 保持病人心跳的代码 \\N 对计算机来说没有区别\n\nLike the Force, computers can be pulled to the light side or the dark side.\n就像\"原力\"一样 \\N 计算机可以被拉到\"光明面\"或\"黑暗面\"\n\nCybersecurity is like the Jedi Order, trying to bring peace and justice to the cyber-verse.\n网络安全就像 绝地武士团 \\N 给网络世界带来和平与正义\n\nThe scope of cybersecurity evolves as fast as the capabilities of computing,\n计算机安全的范围，和计算能力的发展速度一样快\n\nbut we can think of it as a set of techniques to protect the secrecy,\n我们可以把计算机安全，看成是保护系统和数据的：\n\nintegrity and availability of computer systems and data against threats.\n保密性，完整性和可用性\n\nLet’s unpack those three goals:\n我们逐个细说：\n\nSecrecy, or confidentiality, means that only authorized people\n\"保密性\"是只有有权限的人 \\N 才能读取计算机系统和数据\n\nshould be able to access or read specific computer systems and data.\n\"保密性\"是只有有权限的人 \\N 才能读取计算机系统和数据\n\nData breaches, where hackers reveal people’s credit card information,\n黑客泄露别人的信用卡信息，就是攻击保密性.\n\nis an attack on secrecy.\n黑客泄露别人的信用卡信息，就是攻击保密性.\n\nIntegrity means that only authorized people\n\"完整性\"是只有有权限的人 \\N 才能使用和修改系统和数据\n\nshould have the ability to use or modify systems and data.\n\"完整性\"是只有有权限的人 \\N 才能使用和修改系统和数据\n\nHackers who learn your password and send e-mails masquerading as you, is an integrity attack.\n黑客知道你的邮箱密码，假冒你发邮件\\N 就是攻击\"完整性\"\n\nAnd availability means that authorized people should\n\"可用性\"是有权限的人 \\N 应该随时可以访问系统和数据\n\nalways have access to their systems and data.\n\"可用性\"是有权限的人 \\N 应该随时可以访问系统和数据\n\nThink of Denial of Service Attacks, where hackers overload a website\n拒绝服务攻击(DDOS) 就是黑客\n\nwith fake requests to make it slow or unreachable for others.\n发大量的假请求到服务器，让网站很慢或者挂掉\n\nThat’s attacking the service’s availability.\n这就是攻击\"可用性\"\n\nTo achieve these three general goals, security experts start with\n为了实现这三个目标，安全专家会从 \\N 抽象层面想象\"敌人\"可能是谁，这叫\"威胁模型分析\"\n\na specification of who your \"enemy\" is, at an abstract level, called a threat model.\n为了实现这三个目标，安全专家会从 \\N 抽象层面想象\"敌人\"可能是谁，这叫\"威胁模型分析\"\n\nThis profiles attackers: their capabilities, goals, and probable means of attack\n模型会对攻击者有个大致描述：\\N 能力如何，目标可能是什么，可能用什么手段\n\n– what’s called, awesomely enough, an attack vector.\n攻击手段又叫\"攻击矢量\"\n\nThreat models let you prepare against specific threats, rather than\n\"威胁模型分析\"让你能为特定情境做准备\n\nbeing overwhelmed by all the ways hackers could get to your systems and data.\n不被可能的攻击手段数量所淹没 \\N 因为手段实在有太多种了\n\nAnd there are many, many ways.\n不被可能的攻击手段数量所淹没 \\N 因为手段实在有太多种了\n\nLet’s say you want to \"secure\" physical access to your laptop.\n假设你想确保笔记本计算机的\"物理安全\" \\N 你的威胁模型是\"好管闲事的室友\"\n\nYour threat model is a nosy roommate.\n假设你想确保笔记本计算机的\"物理安全\" \\N 你的威胁模型是\"好管闲事的室友\"\n\nTo preserve the secrecy, integrity and availability of your laptop,\n为了保证保密性，完整性和可用性 \\N 你可以藏在脏兮兮的洗衣篮里\n\nyou could keep it hidden in your dirty laundry hamper.\n为了保证保密性，完整性和可用性 \\N 你可以藏在脏兮兮的洗衣篮里\n\nBut, if your threat model is a mischievous younger sibling\n但如果威胁模型是调皮的兄弟姐妹，知道你喜欢藏哪里\n\nwho knows your hiding spots,\n但如果威胁模型是调皮的兄弟姐妹，知道你喜欢藏哪里\n\nthen you’ll need to do more: maybe lock it in a safe.\n那么你需要更多保护：比如锁在保险箱里\n\nIn other words, how a system is secured depends heavily on who it’s being secured against.\n换句话说，要怎么保护，具体看对抗谁\n\nOf course, threat models are typically a bit more formally defined than just \"nosy roommate\".\n当然，威胁模型通常比\"好管闲事的室友\"更正式一些\n\nOften you’ll see threat models specified in terms of technical capabilities.\n通常威胁模型分析里 会以能力水平区分\n\nFor example, \"someone who has physical access to your laptop along with unlimited time\".\n比如\"某人可以物理接触到笔记本计算机，而且时间无限\"\n\nWith a given threat model, security architects need to come up\n在给定的威胁模型下，安全架构师要\n\nwith a solution that keeps a system secure –\n提供解决方案，保持系统安全\n\nas long as certain assumptions are met,\n只要某些假设不被推翻\n\nlike no one reveals their password to the attacker.\n比如没人会告诉攻击者密码\n\nThere are many methods for protecting computer systems, networks and data.\n保护计算机系统，网络和数据的方法有很多\n\nA lot of security boils down to two questions:\n很多安全问题可以总结成2个问题：\n\nwho are you, and what should you have access to?\n你是谁？你能访问什么？\n\nClearly, access should be given to the right people, but refused to the wrong people.\n权限应该给合适的人，拒绝错误的人\n\nLike, bank employees should be able to open ATMs to restock them, but not me…\n比如银行员工可以打开取款机来补充现金。\\N 但我不应该有权限打开\n\nbecause I’d take it all... all of it!\n因为我会把钱拿走 全拿走！\n\nThat ceramic cat collection doesn’t buy itself!\n陶瓷猫收藏品可不会从天上掉下来哟！\n\nSo, to differentiate between right and wrong people, we use authentication\n所以，为了区分谁是谁，\\N 我们用 \"身份认证\"(authentication)\n\n- the process by which a computer understands who it’s interacting with.\n- 让计算机得知使用者是谁\n\nGenerally, there are three types, each with their own pros and cons:\n身份认证有三种，各有利弊：\n\nWhat you know.\n你知道什么\n\nWhat you have.\n你有什么\n\nAnd what you are.\n你是什么\n\nWhat you know authentication is based on knowledge of a secret that\n\"你知道什么\" 是基于某个秘密\n\nshould be known only by the real user and the computer,\n只有用户和计算机知道\n\nfor example, a username and password.\n比如 用户名和密码\n\nThis is the most widely used today because it’s the easiest to implement.\n这是如今使用最广泛的，因为最容易实现\n\nBut, it can be compromised if hackers guess or otherwise come to know your secret.\n但如果黑客通过猜测或其他方式，知道你的密码，就惨了\n\nSome passwords are easy for humans to figure out, like 12356 or qwerty.\n有些密码很容易猜中，比如12356或qwerty\n\nBut, there are also ones that are easy for computers.\n但有些密码对计算机很容易\n\nConsider the PIN: 2580.\n比如PIN码：2580\n\nThis seems pretty difficult to guess – and it is – for a human.\n看起来很难猜中 - 起码对人类来说是这样\n\nBut there are only ten thousand possible combinations of 4-digit PINs.\n但4位数字，只有一万种可能\n\nA computer can try entering 0000, then try 0001, and then 0002,\n一台计算机可以尝试0000，然后0001，然后0002，\n\nall the way up to 9999... in a fraction of a second.\n然后到9999，不到一秒内试完\n\nThis is called a brute force attack, because it just tries everything.\n这叫\"暴力攻击\"，因为只是试遍一切可能\n\nThere’s nothing clever to the algorithm.\n这种算法没什么聪明的地方\n\nSome computer systems lock you out, or have you wait a little, after say three wrong attempts.\n如果你错误尝试3次，\\N 有些系统会阻止你继续尝试，或让你等一会儿\n\nThat’s a common and reasonable strategy,\n这个策略普遍而且合理\n\nand it does make it harder for less sophisticated attackers.\n对于一般的攻击者确实很难\n\nBut think about what happens if hackers have already taken over\n但假设黑客控制了\n\ntens of thousands of computers, forming a botnet.\n数以万计的计算机，形成一个僵尸网络\n\nUsing all these computers, the same pin – 2580 –\n用这么多计算机尝试密码 2580\n\ncan be tried on many tens of thousands of bank accounts simultaneously.\n同时尝试很多银行账户\n\nEven with just a single attempt per account, they’ll very likely\n即使每个账户只试一次，也很可能\n\nget into one or more that just happen to use that PIN.\n碰到某个账户刚好用这个 PIN\n\nIn fact, we’ve probably guessed the pin of someone watching this video!\n事实上，看视频的某人可能刚好用这个 PIN\n\nIncreasing the length of PINs and passwords can help,\n增加密码长度有帮助\n\nbut even 8 digit PINs are pretty easily cracked.\n但即使8位数字的PIN码也很容易破解\n\nThis is why so many websites now require you to use a mix of upper and lowercase letters,\n这就是为什么现在很多网站 要求大写+小写字母\n\nspecial symbols, and so on – it explodes the number of possible password combinations.\n还有特殊符号等，大大增加可能的密码\n\nAn 8-digit numerical PIN only has a hundred million combinations\n8位数字的PIN只有一亿种组合\n\n– computers eat that for breakfast!\n对计算机轻而易举\n\nBut an 8-character password with all those funky things mixed in\n但包含各种字符的8位长度密码\n\nhas more than 600 trillion combinations.\n有超过600万亿种组合\n\nOf course, these passwords are hard for us mere humans to remember,\n当然，这些密码会难以记住，\n\nso a better approach is for websites to let us pick something more memorable,\n所以更好的方法是 选一些更好记的东西\n\nlike three words joined together:\n比如三个单词连在一起：\n\n\"green brothers rock\" or \"pizza tasty yum\".\n\"格林兄弟好厉害\"或\"披萨尝起来好好吃\"\n\nEnglish has around 100,000 words in use,\n英文大约有10万个单词\n\nso putting three together would give you roughly\n所以三个单词连一起大概有\n\n1 quadrillion possible passwords. Good luck trying to guess that!\n1亿亿种可能，想猜中的话，祝你好运！\n\nI should also note here that using non-dictionary words\n另外使用不在字典内的单词\n\nis even better against more sophisticated kinds of attacks,\n被猜中的可能性更低\n\nbut we don’t have time to get into that here.\n但我们没时间细说这个\n\nComputerphile has a great video on choosing a password - link in the dooblydoo.\nComputerphile 频道有个视频讲怎么选择好密码 - \\N 链接请看 Youtube 描述\n\nWhat you have authentication, on the other hand,\n\"你有什么\"这种验证方式\n\nis based on possession of a secret token that only the real user has.\n是基于用户有特定物体\n\nAn example is a physical key and lock.\n比如钥匙和锁\n\nYou can only unlock the door if you have the key.\n如果你有钥匙，就能开门\n\nThis escapes this problem of being \"guessable\".\n这避免了被人\"猜中\"的问题\n\nAnd they typically require physical presence,\n而且通常需要人在现场\n\nso it’s much harder for remote attackers to gain access.\n所以远程攻击就更难了\n\nSomeone in another country can’t gain access to your front door in Florida\n另一个国家的人，得先来佛罗里达州\n\nwithout getting to Florida first.\n才能到你家前门\n\nBut, what you have authentication can be compromised if an attacker is physically close.\n但如果攻击者离你比较近，那么也不安全\n\nKeys can be copied, smartphones stolen, and locks picked.\n钥匙可以被复制，手机可能被偷，锁可以撬开\n\nFinally, what you are authentication is based on... you!\n最后，\"你是什么\"这种验证，是基于你\n\nYou authenticate by presenting yourself to the computer.\n把特征展示给计算机进行验证\n\nBiometric authenticators, like fingerprint readers and iris scanners are classic examples.\n生物识别验证器，\\N 比如指纹识别器和虹膜扫描仪就是典型例子\n\nThese can be very secure, but the best technologies are still quite expensive.\n这些非常安全，但最好的识别技术仍然很贵\n\nFurthermore, data from sensors varies over time.\n而且，来自传感器的数据每次会不同\n\nWhat you know and what you have authentication have the nice property of being deterministic\n\"你知道什么\"和\"你有什么\"。这两种验证是\"确定性\"的\n\n– either correct or incorrect.\n- 要么正确，要么错误\n\nIf you know the secret, or have the key, you’re granted access 100% of the time.\n如果你知道密码，或有钥匙，那么100％能获得访问权限\n\nIf you don’t, you get access zero percent of the time.\n如果没有，就绝对进不去\n\nBiometric authentication, however, is probabilistic.There’s some chance the system won’t recognize you…\n但\"生物识别\"是概率性的，系统有可能认不出你\n\nmaybe you’re wearing a hat or the lighting is bad.\n可能你戴了帽子，或者光线不好\n\nWorse, there’s some chance the system will recognize the wrong person as you\n更糟的是，系统可能把别人错认成你\n\n– like your evil twin!\n比如你的邪恶双胞胎\n\nOf course, in production systems, these chances are low, but not zero.\n当然，在现实世界中几率很低，但不是零\n\nAnother issue with biometric authentication is it can’t be reset.\n生物认证的另一个问题是无法重设\n\nYou only have so many fingers, so what happens if an attacker compromises your fingerprint data?\n你只有这么多手指，如果攻击者拿到你的指纹数据怎么办\n\nThis could be a big problem for life.\n你一辈子都麻烦了\n\nAnd, recently, researchers showed it’s possible to forge your iris\n最近还有研究人员表示，拍个照都有可能伪造虹膜\n\njust by capturing a photo of you, so that’s not promising either.\n所以也不靠谱\n\nBasically, all forms of authentication have strengths and weaknesses,\n所有认证方法都有优缺点，\n\nand all can be compromised in one way or another.\n它们都可以被攻破\n\nSo, security experts suggest using two or more forms of authentication\n所以，对于重要账户，\\N 安全专家建议用两种或两种以上的认证方式\n\nfor important accounts.\n所以，对于重要账户，\\N 安全专家建议用两种或两种以上的认证方式\n\nThis is known as two-factor or multi-factor authentication.\n这叫\"双因素\"或\"多因素\"认证\n\nAn attacker may be able to guess your password or steal your phone:\n攻击者可能猜出你密码，或偷走你的手机：\n\nbut it’s much harder to do both.\n但两个都做到，会比较难\n\nAfter authentication comes Access Control.\n\"身份验证\"后，就来到了\"访问控制\"\n\nOnce a system knows who you are, it needs to know what you should be able to access,\n一旦系统知道你是谁，它需要知道你能访问什么，\n\nand for that there’s a specification of who should be able to see, modify and use what.\n因此应该有个规范，\\N 说明谁能访问什么，修改什么，使用什么。\n\nThis is done through Permissions or Access Control Lists (ACL),\n这可以通过\"权限\"或\"访问控制列表\"（ACL）来实现\n\nwhich describe what access each user has for every file, folder and program on a computer.\n其中描述了用户对每个文件，文件夹和程序的访问权限\n\n\"Read\" permission allows a user to see the contents of a file,\n\"读\"权限允许用户查看文件内容，\n\n\"write\" permission allows a user to modify the contents,\n\"写\"权限允许用户修改内容，\n\nand \"execute\" permission allows a user to run a file, like a program.\n\"执行\"权限允许用户运行文件，比如程序\n\nFor organizations with users at different levels of access privilege\n有些组织需要不同层级的权限\n\n– like a spy agency – it’s especially important for Access Control Lists\n比如间谍机构，\"访问控制列表\"的正确配置非常重要\n\nto be configured correctly to ensure secrecy, integrity and availability.\n以确保保密性，完整性和可用性\n\nLet’s say we have three levels of access: public, secret and top secret.\n假设我们有三个访问级别：公开，机密，绝密\n\nThe first general rule of thumb is that people shouldn’t be able to \"read up\".\n第一个普遍的好做法是，\\N 用户不能\"读上\", 不能读等级更高的信息\n\nIf a user is only cleared to read secret files, they shouldn’t be able to read top secret\n如果用户能读\"机密\"文件\\N 那么不应该有权限读\"绝密\"文件\n\nfiles, but should be able to access secret and public ones.\n但能访问\"机密\"和\"公开\"文件\n\nThe second general rule of thumb is that people shouldn’t be able to \"write down\".\n第二个法则是用户不能\"写下\"\n\nIf a member has top secret clearance, then they should be able to\n如果用户等级是\"绝密\"\n\nwrite or modify top secret files, but not secret or public files.\n那么能写入或修改\"绝密\"文件，\\N 但不能修改\"机密\"或\"公共\"文件\n\nIt may seem weird that even with the highest clearance,\n听起来好像很奇怪 \\N 有最高等级也不能改等级更低的文件\n\nyou can’t modify less secret files.\n听起来好像很奇怪 \\N 有最高等级也不能改等级更低的文件\n\nBut, it guarantees that there’s no accidental leakage of\n但这样确保了\"绝密\" \\N 不会意外泄露到\"机密\"文件或\"公共\"文件里\n\ntop secret information into secret or public files.\n但这样确保了\"绝密\" \\N 不会意外泄露到\"机密\"文件或\"公共\"文件里\n\nThis \"no read up, no write down\" approach is called the Bell-LaPadula model.\n这个\"不能向上读，不能向下写\"的方法\\N 叫 Bell-LaPadula 模型\n\nIt was formulated for the U.S. Department of Defense’s Multi-Level Security policy.\n它是为美国国防部\"多层安全政策\"制定的\n\nThere are many other models for access control – like the Chinese Wall model and Biba model.\n还有许多其他的访问控制模型 - 比如\"中国墙\"模型和\"比伯\"模型\n\nWhich model is best depends on your use-case.\n哪个模型最好，取决于具体情况\n\nAuthentication and access control help a computer determine who you are\n\"身份验证\"和\"访问控制\"帮助计算机知道\"你是谁\"\n\nand what you should access,\n以及\"你可以访问什么\"，\n\nbut depend on being able to trust the hardware and software\n但做这些事情的软硬件必须是可信的\n\nthat run the authentication and access control programs.\n但做这些事情的软硬件必须是可信的\n\nThat’s a big dependence.\n这个依赖很重要\n\nIf an attacker installs malicious software – called malware\n如果攻击者给计算机装了恶意软件\n\n– compromising the host computer’s operating system,\n- 控制了计算机的操作系统\n\nhow can we be sure security programs don’t have a backdoor that let attackers in?\n我们怎么确定安全程序没有给攻击者留后门？\n\nThe short answer is… we can’t.\n短回答是...无法确定\n\nWe still have no way to guarantee the security of a program or computing system.\n我们仍然无法保证程序或计算机系统的安全\n\nThat’s because even while security software might be \"secure\" in theory,\n因为安全软件在理论上可能是\"安全的\"\n\nimplementation bugs can still result in vulnerabilities.\n实现时可能会不小心留下漏洞\n\nBut, we do have techniques to reduce the likelihood of bugs,\n但我们有办法减少漏洞出现的可能性\n\nlike quickly find and patch bugs when they do occur,\n比如一找到就马上修复\n\nand mitigate damage when a program is compromised.\n以及当程序被攻破时尽可能减少损害\n\nMost security errors come from implementation error.\n大部分漏洞都是具体实现的时候出错了\n\nTo reduce implementation error, reduce implementation.\n为了减少执行错误，减少执行\n\nOne of the holy grails of system level security is a \"security kernel\"\n系统级安全的圣杯之一是\"安全内核\"\n\nor a \"trusted computing base\": a minimal set of operating system software\n或\"可信计算基础\"：一组尽可能少的操作系统软件\n\nthat’s close to provably secure.\n安全性都是接近可验证的\n\nA challenge in constructing these security kernels is deciding what should go into it.\n构建安全内核的挑战在于 决定内核应该有什么\n\nRemember, the less code, the better!\n记住，代码越少越好！\n\nEven after minimizing code bloat, it would be great to \"guarantee\"\n在最小化代码数量之后，\\N 要是能\"保证\"代码是安全的，会非常棒\n\nthat’s code is written in secure.\n在最小化代码数量之后，\\N 要是能\"保证\"代码是安全的，会非常棒\n\nFormally verifying the security of code is an active area of research.\n正式验证代码的安全性 是一个活跃的研究领域\n\nThe best we have right now is a process called Independent Verification and Validation.\n我们现在最好的手段，叫\"独立安全检查和质量验证\"\n\nThis works by having code audited by a crowd of security-minded developers.\n让一群安全行业内的软件开发者来审计代码\n\nThis is why security code is almost always open-sourced.\n这就是为什么安全型代码几乎都是开源的\n\nIt’s often difficult for people who wrote the original code to find bugs,\n写原始代码的人通常很难找到错误\n\nbut external developers, with fresh eyes and different expertise, can spot problems.\n但外部开发人员有新鲜的眼光 \\N和不同领域的专业知识，可以发现问题.\n\nThere are also conferences where like-minded hackers and security experts\n另外还有一些安全大会，安全专家可以相互认识，分享想法.\n\ncan mingle and share ideas,\n另外还有一些安全大会，安全专家可以相互认识，分享想法.\n\nthe biggest of which is DEF CON, held annually in Las Vegas.\n一年一次在拉斯维加斯举办的 DEF CON \\N 是全球最大的安全大会\n\nFinally, even after reducing code and auditing it,\n最后，即便尽可能减少代码 并进行了安全审计\n\nclever attackers are bound to find tricks that let them in.\n聪明的攻击者还是会找到方法入侵\n\nWith this in mind, good developers should take the approach that,\n因为如此，优秀的开发人员\n\nnot if, but when their programs are compromised,\n应该计划当程序被攻破后，\\N如何限制损害，控制损害的最大程度\n\nthe damage should be limited and contained,\n应该计划当程序被攻破后，\\N如何限制损害，控制损害的最大程度\n\nand not let it compromise other things running on the computer.\n并且不让它危害到计算机上其他东西\n\nThis principle is called isolation.\n这叫\"隔离\"\n\nTo achieve isolation, we can \"sandbox\" applications.\n要实现隔离，我们可以\"沙盒\"程序\n\nThis is like placing an angry kid in a sandbox; when the kid goes ballistic,\n这好比把生气的小孩放在沙箱里，\n\nthey only destroy the sandcastle in their own box,\n他们只能摧毁自己的沙堡，不会影响到其他孩子\n\nbut other kids in the playground continue having fun.\n他们只能摧毁自己的沙堡，不会影响到其他孩子\n\nOperating Systems attempt to sandbox applications\n操作系统会把程序放到沙盒里\n\nby giving each their own block of memory that others programs can’t touch.\n方法是给每个程序独有的内存块，其他程序不能动\n\nIt’s also possible for a single computer to run multiple Virtual Machines, essentially\n一台计算机可以运行多个虚拟机\n\nsimulated computers, that each live in their own sandbox.\n虚拟机模拟计算机，每个虚拟机都在自己的沙箱里\n\nIf a program goes awry, worst case is that it crashes or\n如果一个程序出错，最糟糕的情况是它自己崩溃\n\ncompromises only the virtual machine on which it’s running.\n或者搞坏它处于的虚拟机\n\nAll other Virtual Machines running on the computer are isolated and unaffected.\n计算机上其他虚拟机是隔离的，不受影响\n\nOk, that’s a broad overview of some key computer security topics.\n好，一些重要安全概念的概览 \\N 我们到此就介绍完了\n\nAnd I didn’t even get to network security, like firewalls.\n我都还没讲网络安全，比如防火墙\n\nNext episode, we’ll discuss some methods\n下集我们会讨论  黑客侵入系统的一些方法\n\nhackers use to get into computer systems.\n下集我们会讨论  黑客侵入系统的一些方法\n\nAfter that, we’ll touch on encryption.\n然后我们学加密\n\nUntil then, make your passwords stronger, turn on 2-factor authentication,\n在此之前，别忘了加强你的密码，打开两步验证\n\nand NEVER click links in unsolicited emails!\n永远不要点可疑邮件\n\nI’ll see you next week.\n我们下周见\n\nHi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nLast episode, we talked about the basics of computer security,\n上集我们讲了计算机安全的基础知识，\n\nprinciples and techniques used to keep computer systems safe and sound.\n包括各种原则和技术\n\nBut, despite our best efforts, the news is full of stories of individuals, companies\n但尽管尽了最大努力，新闻上还是各种 \\N 个人，公司，政府被黑客攻击的故事\n\nand governments getting cyberattacked by hackers, people who,\n但尽管尽了最大努力，新闻上还是各种 \\N 个人，公司，政府被黑客攻击的故事\n\nwith their technical knowledge, break into computer systems.\n那些黑客凭技术知识 闯入计算机系统\n\nNot all hackers are bad though.\n不是所有黑客都是坏人\n\nThere are hackers who hunt for bugs and try to close security holes\n有些黑客会寻找并修复软件漏洞 \\N 让系统更安全\n\nin software to make systems safer and more resilient.\n有些黑客会寻找并修复软件漏洞 \\N 让系统更安全\n\nThey’re often hired by companies and governments to perform security evaluations.\n他们经常被公司和政府雇来做安全评估\n\nThese hackers are called White Hats, they’re the good guys.\n这些黑客叫\"白帽子\"，他们是好人\n\nOn the flip side, there are Black Hats, malicious hackers with\n另一方面，也有\"黑帽\"黑客，他们窃取，\n\nintentions to steal, exploit and sell computer vulnerabilities and data.\n利用和销售计算机漏洞和数据\n\nHackers’ motivations also differ wildly.\n黑客的动机有很多种\n\nSome hack for amusement and curiosity,\n有些是好玩和好奇\n\nwhile cybercriminals hack most often for monetary gain.\n而网络罪犯一般是为了钱\n\nAnd then there are hacktivists, who use their skills to promote a social or political goal.\n还有的叫\"黑客行动主义者\"，\\N 通过黑客手段影响社会或达到政治目的\n\nAnd that’s just the tip of the iceberg.\n这只是冰山一角\n\nBasically, the stereotypical view of a hacker as some unpopular kid sitting in a dark room\n一般对黑客的刻板印象是 \\N 某个不受欢迎的小孩在黑暗的房间里\n\nfull of discarded pizza boxes probably better describes John Green in college than it does hackers.\n到处都是吃完的比萨盒，这个印象是错的，\\N形容约翰·格林的宿舍还更贴切些\n\nToday, we’re not going to teach you how to be a hacker.\n今天，我们不会教你如何成为黑客\n\nInstead, we’ll discuss some classic examples of how hackers\n而是讨论一些入侵原理，给你一个大概概念\n\nbreak into computer systems to give you an idea of how it’s done.\n而是讨论一些入侵原理，给你一个大概概念\n\nThe most common way hackers get into computer systems isn’t\n黑客入侵最常见的方式\n\nby hacking at all; it’s by tricking users into letting them in.\n不是通过技术，而是欺骗别人\n\nThis is called social engineering, where a person is manipulated into divulging confidential\n这叫\"社会工程学\"，欺骗别人让人泄密信息\n\ninformation, or configuring a computer system so that it permits entry by attackers.\n或让别人配置电脑系统，变得易于攻击\n\nThe most common type of attack is phishing, which you most often encounter as an email\n最常见的攻击是网络钓鱼，你可能见过\n\nasking you to login to an account on a website, say your bank.\n银行发邮件叫你点邮件里的链接，登陆账号\n\nYou’ll be asked to click a link in the email, which takes you to a site that looks legit\n然后你会进入一个像官网的网站\n\nto the casual observer, but is really an evil clone.\n但实际上是个假网站\n\nWhen you enter your username and password, that information goes straight to the hackers,\n当你输入用户名和密码时，信息会发给黑客，\n\nwho then can login to the real website as you.\n然后黑客就可以假扮你登陆网站\n\nBad news!\n坏消息！\n\nEven with a 1/10th of one percent success rate, a million phishing emails might yield\n即使成功率只有1/1000，发一百万封钓鱼邮件\n\na thousand compromised accounts.\n也有一千个帐户中招\n\nAnother social engineering attack is pretexting, where attackers call up, let's say a company,\n另一种方法叫 假托(Pretexting)，\\N 攻击者给某个公司打电话\n\nand then confidently pretend to be from their IT department.\n假装是IT部门的人\n\nOften attackers will call a first number, and then ask to be transferred to a second,\n攻击者的第一通电话一般会叫人转接\n\nso that the phone number appears to be internal to the company.\n这样另一个人接的时候，电话看起来像内部的\n\nThen, the attacker can instruct an unwitting user to configure their computer in a compromising\n然后让别人把电脑配置得容易入侵\n\nway, or get them to reveal confidential details, like passwords or network configurations.\n或让他们泄露机密信息，比如密码或网络配置\n\nSorry, one sec…\n不好意思，等一下\n\nOh. Hey, it's Susan from It.\n嘿，我是 IT 部门的苏珊\n\nWe’re having some network issues down here, can you go ahead and check a setting for me?\"\n我们遇到一些网络问题，你能帮我检查一个配置吗？\n\n... and it begins.\n然后就开始了\n\nAttackers can be very convincing, especially with a little bit\n只要预先做一点研究，攻击者可以装得很像真的\n\nof research beforehand to find things like key employees’ names.\n比如关键员工的名字\n\nIt might take ten phone calls to find an victim, but you only need one to get in.\n也许要10通电话才能找到一个受害者，\\N 但只要一个人上当就够了\n\nEmails are also a common delivery mechanism for trojan horses,\n邮件里带\"木马\"也是常见手段\n\nprograms that masquerade as harmless attachments, like a photo or invoice,\n木马会伪装成无害的东西，比如照片或发票\n\nbut actually contain malicious software, called malware.\n但实际上是恶意软件\n\nMalware can take many forms.\n恶意软件有很多种\n\nSome might steal your data, like your banking credentials.\n有的会偷数据，比如银行凭证\n\nOthers might encrypt your files and demand a ransom, what's known as ransomware.\n有的会加密文件，交赎金才解密，也就是\"勒索软件\"\n\nIf they can’t run malware or get a user to let them in,\n如果攻击者无法用木马或电话欺骗\n\nattackers have to force their way in through other means.\n攻击者只能被迫用其他手段\n\nOne method, which we briefly discussed last episode, is to brute force a password\n方法之一是暴力尝试，我们上集讨论过\n\ntry every combination of password until you gain entry.\n尝试所有可能的密码，直到进入系统\n\nMost modern systems defend against this type of attack by having you wait incrementally\n大多数现代系统会加长等待时间，来抵御这种攻击\n\nlonger periods of time following each failed attempt,\n每次失败就加长等待时间\n\nor even lock you out entirely after a certain number of tries.\n甚至失败超过一定次数后，完全锁住\n\nOne recent hack to get around this is called NAND Mirroring,\n最近出现一种攻破方法叫 \"NAND镜像\"\n\nwhere if you have physical access to the computer,\n如果能物理接触到电脑\n\nyou can attach wires to the device's memory chip\n可以往内存上接几根线\n\nand make a perfect copy of its contents.\n复制整个内存\n\nWith this setup, you can try a series of passwords, until the device starts making you wait.\n复制之后，暴力尝试密码，直到设备让你等待\n\nWhen this happens, you just reflash the memory with the original copy you made,\n这时只要把复制的内容覆盖掉内存\n\nessentially resetting it, allowing you to try more passwords immediately, with no waiting.\n本质上重置了内存，就不用等待，可以继续尝试密码了\n\nThis technique was shown to be successful on an iPhone 5C,\n这项方法在 iPhone 5C 上管用\n\nbut many newer devices include mechanisms to thwart this type of attack.\n更新的设备有机制阻止这种攻击\n\nIf you don’t have physical access to a device,\n如果你无法物理接触到设备\n\nyou have to find a way to hack it remotely, like over the internet.\n就必须远程攻击，比如通过互联网.\n\nIn general, this requires an attacker to find and take advantage of a bug in a system, and\n远程攻击一般需要攻击者利用系统漏洞\n\nsuccessfully utilizing a bug to gain capabilities or access is called an exploit.\n来获得某些能力或访问权限，这叫\"漏洞利用\"(Exploit)\n\nOne common type of exploit is a buffer overflow.\n一种常见的漏洞利用叫\"缓冲区溢出\"\n\nBuffers are a general term for a block of memory reserved for storing data.\n\"缓冲区\"是一种概称，指预留的一块内存空间\n\nWe talked about video buffers for storing pixel data in Episode 23.\n我们在第23集，讨论过存像素数据的视频缓冲区\n\nAs a simple example, we can imagine an operating system’s login prompt,\n举个简单例子，假设我们在系统登陆界面\n\nwhich has fields for a username and password.\n要输入用户名和密码\n\nBehind the scenes, this operating system uses buffers for storing the text values that are entered.\n在幕后，系统用缓冲区存输入的值\n\nFor illustration, let's say these buffers were specified to be of size ten.\n假设缓冲区大小是10\n\nIn memory, the two text buffers would look something like this:\n两个文本缓冲区看起来会像这样：\n\nOf course, the operating system is keeping track of a lot more than just a username and\n当然，操作系统记录的远不止用户名和密码\n\npassword, so there’s going to be data stored both before and after in memory.\n所以缓冲区前后 肯定有其他数据\n\nWhen a user enters a username and password, the values are copied into the buffers,\n当用户输入用户名和密码时，这些值会复制到缓冲区\n\nwhere they can be verified.\n然后验证是否正确\n\nA buffer overflow attack does exactly what the name suggests: overflows the buffer.\n\"缓冲区溢出\"正如名字所暗示的：它会溢出缓冲区\n\nIn this case, any password longer than ten characters\n在这个例子中，超过十个字符的密码\n\nwill overwrite adjacent data in memory.\n会覆盖掉相邻的数据\n\nSometimes this will just cause a program or operating system to crash,\n有时只会让程序或系统崩溃，\n\nbecause important values are overwritten with gobbledygook.\n因为重要值被垃圾数据覆盖了\n\nCrashing a system is bad, and maybe that’s all that\n系统崩溃是坏事\n\na mischievous hacker wants to do, be a nuisance.\n但也许恶作剧黑客就只是想系统崩溃，当个讨厌鬼\n\nBut attackers can also exploit this bug more cleverly by injecting purposeful new values\n但攻击者可以更巧妙地利用这个漏洞(bug)，\\N 注入有意义的新值\n\ninto a program’s memory, for example, setting an \"is admin\" variable to true.\n到程序的内存中，比如把\"is_admin\"的值改成true\n\nWith the ability to arbitrarily manipulate a program’s memory,\n有了任意修改内存的能力，\n\nhackers can bypass things like login prompts,\n黑客可以绕过\"登录\"之类的东西，\n\nand sometimes even use that program to hijack the whole system.\n甚至使用那个程序劫持整个系统\n\nThere are many methods to combat buffer overflow attacks.\n有很多方法阻止缓冲区溢出\n\nThe easiest is to always test the length of input before copying it into a buffer,\n最简单的方法是，复制之前先检查长度，\n\ncalled bounds checking.\n这叫 \"边界检查\"\n\nMany modern programming languages implement bounds checking automatically.\n许多现代编程语言自带了边界检查\n\nPrograms can also randomize the memory location of variables,\n程序也会随机存放变量在内存中的位置，\n\nlike our hypothetical \"is admin\" flag,\n比如我们之前假设的\"is_admin\"\n\nso that hackers don’t know what memory location to overwrite,\n这样黑客就不知道应该覆盖内存的哪里\n\nand are more likely to crash the program than gain access.\n导致更容易让程序崩溃，而不是获得访问权限\n\nPrograms can also leave unused space after buffers,\n程序也可以在缓冲区后，留一些不用的空间\n\nand keep an eye on those values to see if they change;\n然后跟踪里面的值，看是否发生变化\n\nif they do, they know an attacker is monkeying around with memory.\n如果发生了变化，说明有攻击者在乱来\n\nThese regions are called canaries, named after the small birds miners\n这些不用的内存空间叫\"金丝雀\"，因为以前矿工会带\n\nused to take underground to warn them of dangerous conditions.\n金丝雀下矿，金丝雀会警告危险\n\nAnother classic hack is code injection.\n另一种经典手段叫\"代码注入\"\n\nIt’s most commonly used to attack websites that use databases,\n最常用于攻击用数据库的网站，\n\nwhich pretty much all big websites do.\n几乎所有大网站都用数据库\n\nWe won’t be covering databases in this series,\n我们这个系列中不会讲解数据库，\n\nso here’s a simple example to illustrate this type of attack.\n所以以下是个简单例子\n\nWe’ll use Structured Query Language, S-Q-L, also called sequel, a popular database API.\n我们会用\"结构化查询语言\"，也叫SQL，\\N 一种流行的数据库API\n\nLet’s imagine our login prompt is now running on a webpage.\n假设网页上有登录提示\n\nWhen a user clicks \"login\", the text values are sent to a server, which executes code\n当用户点击\"登录\"时，值会发到服务器\n\nthat checks if that username exists, and if it does, verifies the password matches.\n服务器会运行代码，检查用户名是否存在，\\N 如果存在，看密码是否匹配\n\nTo do this, the server will execute code, known as a SQL query,\n为了做检查，服务器会执行一段叫 \"SQL查询\" 的代码\n\nthat looks something like this.\n看起来像这样\n\nFirst, it needs to specify what data we’re retrieving from the database.\n首先，语句要指定从数据库里查什么数据\n\nIn this case, we want to fetch the password.\n在这个例子中，我们想查的是密码 (password)  \\N (SELECT password)\n\nThe server also needs to specify from what place in the database\n还要指定从哪张表查数据 \\N (FROM users)\n\nto retrieve the value from.\n还要指定从哪张表查数据 \\N (FROM users)\n\nIn this case, let’s imagine all the users’ data is stored\n在这个例子里，\\N 我们假设所有用户数据都存在 \"users\" 表里\n\nin a data structure called a table labeled \"users\".\n在这个例子里，\\N 我们假设所有用户数据都存在 \"users\" 表里\n\nFinally, the server doesn’t want to get back a giant list of passwords for every user\n最后，服务器不想每次取出一个巨大密码列表，\\N 包含所有用户密码\n\nin the database, so it specifies that it only wants data for the account\n所以用 username = '用户名'\\N 代表只要这个用户\n\nwhose username equals a certain value.\n所以用 username = '用户名'\\N 代表只要这个用户\n\nThat value is copied into the SQL query by the server, based on what the user typed in,\n用户输的值会复制到\"SQL查询\"\n\nso the actual command that’s sent to the SQL database would look something like this,\n所以实际发到 SQL 数据库的命令，是这样的.\n\nwhere username='philbin'\nWhere username='philbin'\n\nNote also that SQL commands end with a semicolon.\n还要注意，SQL命令以分号结尾\n\nSo how does someone hack this?\n那怎么破解这个？\n\nBy sending in a malicious username, with embedded SQL commands!\n做法是把\"SQL命令\"输入到用户名里！\n\nLike, we could send the server this funky username:\n比如我们可以发这个奇怪的用户名：\n\nWhen the server copies this text into the SQL Query, it ends up looking like this:\n当服务器把值复制到SQL查询中，会变成这样：\n\nAs I mentioned before, semicolons are used to separate commands,\n正如之前提的，分号用于分隔命令，\n\nso the first command that gets executed is this:\n所以第一条被执行的命令是：\n\nIf there is a user named ‘whatever’, the database will return the password.\n如果有个用户叫\"whateer\"，数据库将返回密码\n\nOf course, we have no idea what ‘whatever’s’ password is,\n当然，我们不知道密码是什么\n\nso we’ll get it wrong and the server will reject us.\n所以会出错，服务器会拒绝我们\n\nIf there’s no user named ‘whatever’, the database will return\n如果没有一个用户叫\"whatever\"，数据库会返回 \\N 空密码或直接错误，服务器也会拒绝我们\n\nno password or provide an error, and the server will again reject us.\n如果没有一个用户叫\"whatever\"，数据库会返回 \\N 空密码或直接错误，服务器也会拒绝我们\n\nEither way, we don’t care, because it’s the next SQL command we’re interested in:\n总之 我们不在乎，\\N 我们感兴趣的是下一个SQL命令：\n\n\"drop table users\" – a command that we injected by manipulating the username field.\n\"drop table users\" - 我们注入的命令\n\nThis command instructs the SQL database to delete the table containing all user data.\n这条命令的意思是  删掉 users 这张表\n\nWiped clean!\n全删干净！\n\nWhich would cause a lot of headaches at a place like a bank... or really anywhere.\n这会造成很多麻烦，不管是银行或什么其他地方\n\nAnd notice that we didn’t even break into the system –\n注意，我们甚至不需要侵入系统\n\nit’s not like we correctly guessed a username and password.\n我们没有猜到正确的用户名和密码\n\nEven with no formal access, we were able to create mayhem by exploiting a bug.\n即使没有正式访问权限，还是可以利用 bug 来制造混乱\n\nThis is a very simple example of code injection,\n这是代码注入的一个简单例子，\n\nwhich almost all servers today have defenses against.\n如今几乎所有服务器都会防御这种手段\n\nWith more sophisticated attacks, it’s possible to add records to the database\n如果指令更复杂一些，也许可以添加新记录到数据库\n\n– like a new administrator account –\n- 比如一个新管理员帐户 -\n\nor even get the database to reveal data, allowing hackers\n甚至可以让数据库泄露数据，使得黑客\n\nto steal things like credit card numbers, social security numbers\n窃取信用卡号码，社会安全号码\n\nand all sorts of nefarious goodies.\n以及各种其他信息\n\nBut we’re not going to teach you how to do that.\n但我们不会教你具体怎么做\n\nAs with buffer overflows, programmers should always assume input coming from the outside\n就像缓冲区溢出攻击一样，应该总是假设外部数据\n\nto be potentially dangerous, and examine it carefully.\n是危险的，应该好好检查\n\nMost username and password forms on the web don’t let you\n很多用户名和密码表单，不让你输入\n\ninclude special symbols like semicolons or quotes as a first level of defense.\n特殊字符，比如分号或者括号，作为第一道防御\n\nGood servers also sanitize input by removing or\n好的服务器也会清理输入\n\nmodifying special characters before running database queries.\n比如修改或删除特殊字符，然后才放到数据库查询语句里\n\nWorking exploits are often sold or shared online.\n管用的漏洞利用(Exploits)一般会在网上贩卖或分享\n\nThe more prevalent the bug, or the more damaging the exploit,\n如果漏洞很流行，或造成的危害很大\n\nthe higher the price or prestige it commands.\n价格会越高，或者名气越大\n\nEven governments sometimes buy exploits,\n有时甚至政府也会买漏洞利用\n\nwhich allow them to compromise computers for purposes like spying.\n让他们侵入系统做间谍工作\n\nWhen a new exploitable bug is discovered that the software creators weren’t aware of,\n当软件制造者不知道软件有新漏洞被发现了\n\nit’s called a zero day vulnerability.\n那么这个漏洞叫 \"零日漏洞\"\n\nBlack Hat Hackers rush to use the exploit for maximum benefit\n黑帽黑客经常赶时间，抢在白帽程序员做出补丁之前\n\nbefore white hat programmers release a patch for the bug.\n尽可能利用漏洞\n\nThis is why it’s so important to keep your computer’s software up to date;\n所以保持系统更新非常重要\n\na lot of those downloads are security patches.\n很多更新都是安全性补丁\n\nIf bugs are left open on enough systems, it allows hackers to\n如果有足够多的电脑有漏洞\n\nwrite a program that jump from computer to computer automatically\n让恶意程序可以在电脑间互相传播\n\nwhich are called worms.\n那么叫\"蠕虫\"\n\nIf a hacker can take over a large number of computers, they can be used together,\n如果黑客拿下大量电脑，这些电脑可以组成\n\nto form what’s called a botnet.\n\"僵尸网络\"\n\nThis can have many purposes, like sending huge volumes of spam,\n可以用于很多目的，比如发大量垃圾邮件，\n\nmining bitcoins using other people's computing power and electricity,\n用别人电脑的计算能力和电费挖 Bitcoin，\n\nand launching Distributed Denial of Service or DDoS attacks against servers.\n或发起\"拒绝服务攻击\"简称DDoS，攻击服务器\n\nDDoS is where all the computers in the botnet send a flood of dummy messages.\nDDoS 就是僵尸网络里的所有电脑发一大堆垃圾信息\n\nThis can knock services offline, either to force owners\n堵塞服务器，要么迫使别人交钱消灾\n\nto pay a ransom or just to be evil.\n或纯粹为了作恶\n\nDespite all of the hard working white hats, exploits documented online,\n尽管白帽黑客非常努力工作，漏洞利用的文档都在网上，\n\nand software engineering best practices, cyberattacks happen on a daily basis.\n编写软件有很多\"最佳实践\"，网络攻击每天都在发生\n\nThey cost the global economy roughly half a trillion dollars annually,\n每年损害全球经济差不多5000亿\n\nand that figure will only increase as we become more reliant on computing systems.\n并且随着我们越来越依赖计算机系统，这个数字只会增加.\n\nThis is especially worrying to governments, as infrastructure is increasingly computer-driven,\n这使得政府非常担心，因为基础设施越来越电脑化\n\nlike powerplants, the electrical grid, traffic lights, water treatment plants, oil refineries,\n比如电力厂，电网，交通灯，水处理厂，炼油厂\n\nair traffic control, and lots of other key systems.\n空管，还有很多其他关键系统\nMany experts predict that the next major war will be fought in cyberspace,\n很多专家预测下一次大战会主要是网络战争\n\nwhere nations are brought to their knees not by physical attack,\n国家不是被物理攻击打败\n\nbut rather crippled economically and infrastructurally through cyberwarfare.\n而是因为网络战争导致经济和基础设施崩溃\n\nThere may not be any bullets fired, but the potential for lives lost is still very high...\n也许不会发射一颗子弹，但是人员伤亡的可能性依然很高\n\nmaybe even higher than conventional warfare.\n甚至可能高于传统战争\n\nSo, we should all adopt good cybersecurity practices.\n所以大家都应该知道一些方法保证网络安全\n\nAnd, as a community interconnected over the internet,\n全球社区因为互联网而互相连接，\n\nwe should ensure our computers are secured against those\n我们应该确保自己的电脑安全\n\nwho wish to use their great potential for harm.\n抵御其他想做坏事的人\n\nSo maybe stop ignoring that update notification?\n也许不要再忽略更新提示？\n\nI’ll see you next week.\n我们下周见\n\nHi, I'm Carrie Anne, and welcome to CrashCourse Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nOver the past two episodes, we’ve talked a lot about computer security.\n在过去两集，我们聊了很多计算机安全话题\n\nBut the fact is, there’s no such thing as a perfectly, 100% secure, computer system.\n但事实是 世上不存在100%安全的系统\n\nThere will always be bugs and security experts know that.\n总会有漏洞存在，而且安全专家知道这一点\n\nSo system architects employ a strategy called defence in depth\n所以系统架构师会部署\"多层防御\"\n\nwhich uses many layers of varying security mechanisms to frustrate attackers.\n用多层不同的安全机制来阻碍攻击者\n\nIt’s a bit like how castles are designed\n有点像城堡的设计一样\n\nfirst you’ve got to dodge the archers\n首先要避开弓箭手\n\nthen cross the moat, scale the walls, avoid the hot oil, get over the ramparts, and defeat the guards\n穿过护城河,翻过城墙,避开热油,打败守卫\n\nbefore you get to the throne room\n才能达到王座\n\nbut in this case we’re talking about one of the most common forms of computer security\n不过我们这里要说的是，计算机安全中最常见的防御形式\n\nCryptography\n密码学\n\nThe word cryptography comes from the roots ‘crypto’ and ‘graphy’, roughly translating to \"secret writing\".\n密码学(cryptography) 一词 \\N 来自 crypto 和 graphy，大致翻译成\"秘密写作\"\n\nIn order to make information secret, you use a cipher – an algorithm that converts plain text into ciphertext\n为了加密信息，要用加密算法(Cipher) 把明文转为密文\n\nwhich is gibberish unless you have a key that lets you undo the cipher.\n除非你知道如何解密，不然密文看起来只是一堆乱码\n\nThe process of making text secret is called encryption\n把明文转成密文叫\"加密\"(encryption)\n\nand the reverse process is called decryption\n把密文恢复回明文叫\"解密\"(decryption)\n\nCiphers have been used long before computers showed up.\n加密算法早在计算机出现前就有了\n\nJulius Caesar used what’s now called a Caesar cipher, to encrypt private correspondence.\n朱利叶斯·凯撒 用如今我们叫\"凯撒加密\"的方法 来加密私人信件\n\nHe would shift the letters in a message forward by three places.\n他会把信件中的字母 向前移动三个位置\n\nSo, A became D, and the word \"brutus\" became this: \"euxwxv\".\n所以A会变成D，brutus变成euxwxv\n\nTo decipher the message, recipients had to know both the algorithm and the number to shift by, which acted as the key.\n为了解密，接收者要知道 \\N 1. 用了什么算法 2. 要偏移的字母位数\n\nThe Caesar cipher is one example of a larger class of techniques called substitution ciphers.\n有一大类算法叫\"替换加密\"，凯撒密码是其中一种\n\nThese replace every letter in a message with\\Nsomething else according to a translation.\n算法把每个字母替换成其他字母\n\nA big drawback of basic substitution ciphers is that letter frequencies are preserved.\n但有个巨大的缺点是，字母的出现频率是一样的\n\nFor example, E is the most common letter in English\n举个例子，E在英语中是最常见的字母\n\nso if your cipher translates E to an X\n如果把E加密成X\n\nthen X will show up the most frequently in the ciphertext.\n那么密文中 X 的出现频率会很高\n\nA skilled cryptanalyst can work backwards from these kinds of statistics to figure out the message.\n熟练的密码破译师可以从统计数据中发现规律，进而破译密码\n\nIndeed, it was the breaking of a substitution cipher that led to the execution of Mary Queen of Scots,in 1587 for plotting to kill Queen Elizabeth.\n1587年，正因为一个\"替换加密\"的密文被破译，\\n导致杀伊丽莎白女王的阴谋暴露，使得玛丽女王被处决\n\nAnother fundamental class of techniques are permutation ciphers.\n另一类加密算法叫 \"移位加密\"\n\nLet’s look at a simple example, called a columnar transposition cipher.\n我们来看一个简单例子叫 \"列移位加密\"\n\nHere, we take a message, and fill the letters into a grid.\n我们把明文填入网格\n\nIn this case, we’ve chosen 5 by 5\n网格大小我们这里选择 5x5\n\nTo encrypt our message, we read out the characters in a different order\n为了加密信息，我们换个顺序来读\n\nlet’s say from the bottom left, working upwards, one column at a time.\n比如从左边开始，从下往上，一次一列。\n\nThe new letter ordering, what’s called a permutation, is the encrypted message.\n加密后字母的排列不同了\n\nThe ordering direction, as well as the 5 by 5 grid size, serves as the key.\n解密的关键是，知道读取方向和网格大小是5x5\n\nLike before, if the cipher and key are known, a recipient can reverse the process to reveal the original message.\n就像之前，如果接收者知道密文和加密方法 \\N 才能解密得到原始消息\n\nBy the 1900s, cryptography was mechanized in the form of encryption machines.\n到了1900年代，人们用密码学做了加密机器\n\nThe most famous was the German Enigma, used by the Nazis to encrypt their wartime communications.\n其中最有名的是德国的英格玛（Enigma）\\N 纳粹在战时用英格玛加密通讯信息\n\nAs we discussed back in Episode 15, the Enigma was a typewriter-like machine, with a keyboard and lampboard, both showing the full alphabet.\n正如第15集中说过，Enigma 是一台像打字机的机器，\\N 有键盘和灯板，两者都有完整的字母表\n\nAbove that, there was a series of configurable rotors that were the key to the Enigma’s encryption capability.\n而且它有一系列\"转子\"(rotros) ，是加密的关键\n\nFirst, let’s look at just one rotor.\n首先，我们只看一个转子\n\nOne side had electrical contacts for all 26 letters.\n它一面有26个接触点，代表26个字母\n\nThese connected to the other side of the rotor using cross-crossing wires that swapped one letter for another.\n然后线会连到另一面，替换字母\n\nIf ‘H’ went in, ‘K’ might come out the other side.\n如果输入'H'，'K'会从另一边出来\n\nIf \"K’ went in, ‘F’ might come out, and so on.\n如果输入'K'，'F'会从另一边出来，以此类推\n\nThis letter swapping behavior should sound familiar: it’s a substitution cipher!\n这个字母替换过程你应该听起来很熟悉：它是\"替换加密\"!\n\nBut, the Enigma was more sophisticated becauseit used three or more rotors in a row, each feeding into the next.\n但英格玛(Enigma)更复杂一些，因为它有3个或更多转子，\\N 一个转子的输出作为下一个转子的输入。\n\nRotors could also be rotated to one of 26 possible starting positions\n转子还有26个起始位置\n\nand they could be inserted in different orders, providinga lot of different substitution mappings.\n还可以按不同顺序放入转子，提供更多字母替换映射\n\nFollowing the rotors was a special circuit called a reflector.\n转子之后是一个叫\"反射器\"的特殊电路\n\nInstead of passing the signal on to another rotor, it connected every pin to another,\n它每个引脚会连到另一个引脚\n\nand sent the electrical signal back through the rotors.\n并把信号发回给转子\n\nFinally, there was a plug board at the front of the machine\n最后，机器前方有一个插板\n\nthat allowed letters coming from the keyboard to be optionally swapped,\n可以把输入键盘的字母预先进行替换\n\nadding another level of complexity.\n又加了一层复杂度\n\nWith our simplified circuit, let’s encrypta letter on this example enigma configuration.\n让我们用这里的简化版电路，加密一些字母\n\nIf we press the ‘H’ key, electricity flows through the plugboard, then the rotors\n如果我们按下\"H\"键，电流会先通过插板，然后通过转子\n\nhits the reflector, comes back through the rotorsand plugboard, and illuminates the letter ‘L’ on the lampboard.\n到达反射器，然后回来转子，回来插板，并照亮键盘灯板的字母\"L\"。\n\nSo H is encrypted to L.\nH 就加密成了 L\n\nNote that the circuit can flow both ways –\n注意, 电路是双向的\n\nso if we typed the letter ‘L’, ‘H’ would light up.\n所以如果我们按下 L，H 会亮起来\n\nIn other words, it’s the same process for encrypting and decrypting;\n换句话说，加密和解密的步骤是一样的\n\nyou just have to make sure the sending and receiving machineshave the same initial configuration.\n你只需要确保 发送机和接收机的初始配置一样就行\n\nIf you look carefully at this circuit, you’ll notice it’s impossible for a letter to be encrypted as itself\n如果你有仔细观察，会注意到字母加密后一定会变成另一个字母\n\nwhich turned out to be a fatal cryptographic weakness.\n之后这成为最大的弱点\n\nFinally, to prevent the Enigma from being a simple substitution cipher\n最后，为了让英格玛不只是简单的\"替换加密\"\n\nevery single time a letter was entered, the rotors advanced by one spot, sort of like an odometer in a car.\n每输入一个字母，转子会转一格，有点像汽车里程表。\n\nSo if you entered the text A-A-A, it might come out as B-D-K, where the substitution mapping changed with every key press.\n如果你输入A-A-A，可能会变成B-D-K，\\n映射会随着每次按键而改变\n\nThe Enigma was a tough cookie to crack, for sure.\n英格玛当然是一块难啃的骨头\n\nBut as we discussed in Episode 15, Alan Turingand and his colleagues\n但正如我们第15集中说的，艾伦·图灵和同事\n\nat Bletchley Park were able to break Enigma codes and largely automate the process.\n破解了英格玛加密，并把大部分破解流程做成了自动化\n\nBut with the advent of computers, cryptography moved from hardware into software.\n但随着计算机出现，加密从硬件转往软件\n\nOne of the earliest software ciphers to become widespread\n早期加密算法中，应用最广泛的\n\nwas the Data Encryption Standard developed by IBM and the NSA in 1977\n是 IBM 和 NSA 于1977年开发的\"数据加密标准\"\n\nDES, as it was known, originally used binary keys that were 56 bits long,\nDES最初用的是56 bit长度的二进制密钥，\n\nwhich means that there are 2 to the 56, or about 72 quadrillion different keys.\n意味着有2的56次方，或大约72千万亿个不同密钥\n\nBack in 1977, that meant that nobody – except perhaps the NSA –\n在1977年时，也许 NSA 有这能力，\n\nhad enough computing power to brute-force all possible keys.\n但没有其他人有足够计算能力 来暴力破解所有可能密钥。\n\nBut, by 1999, a quarter-million dollar computer could try every possible DES key in just two days, rendering the cipher insecure.\n但到1999年，一台25万美元的计算机能在两天内 \\N 把 DES 的所有可能密钥都试一遍，让 DES 算法不再安全\n\nSo, in 2001, the Advanced Encryption Standard(AES) was finalized and published.\n因此 2001 年出了：高级加密标准（AES）\n\nAES is designed to use much bigger keys – 128,192 or 256 bits in size – making brute force attacks much, much harder.\nAES 用更长的密钥 - 128位/192位/256位 - 让暴力破解更加困难\n\nFor a 128-bit keys, you'd need trillions of years to try every combination, even if you used every single computer on the planet today.\n128位的密钥，哪怕用现在地球上的所有计算机\\N 也要上万亿年才能试遍所有组合\n\nSo you better get started!\n你最好赶紧开始!\n\nAES chops data up into 16-byte blocks, and then applies a series of substitutions and permutations,\nAES将数据切成一块一块，每块16个字节，\\N 然后用密钥进行一系列替换加密和移位加密\n\nbased on the key value plus some other operations to obscure the message,\n再加上一些其他操作，进一步加密信息\n\nand this process is repeated ten or more times for each block.\n每一块数据，会重复这个过程10次或以上\n\nYou might be wondering: why only ten rounds?\n你可能想知道：为什么只重复10次？\n\nOr why only 128 bit keys, and not ten thousand bit keys?\n为什么用128位密钥，而不是10000位？\n\nWell, it’s a performance tradeoff.\n这其实是基于性能的权衡\n\nIf it took hours to encrypt and send an email,or minutes to connect to a secure website, people wouldn't use it\n如果要花几小时加密和发邮件，或几分钟载入网站，没人愿意用\n\nAES balances performance and security to provide practical cryptography.\nAES 在性能和安全性间取得平衡\n\nToday, AES is used everywhere, from encrypting files on iPhones\n如今AES被广泛使用，比如iPhone上加密文件\n\nand transmitting data over WiFi with WPA2 to accessing websites using HTTPS.\n用 WPA2 协议在 WiFi 中访问 HTTPS 网站\n\nSo far, the cryptographic techniques we’ve discussed rely on keys that are known by both sender and recipient.\n到目前为止 我们讨论过的加密技术\\N 依赖于发送者和接收者都知道密钥\n\nThe sender encrypts a message using a key, and the recipient decrypts it using the same key.\n发件人用密钥加密，收件人用相同的密钥解密\n\nIn the old days, keys would be shared by voice, or physically;\n以前，密钥可以口头约定，或依靠物品\n\nfor example, the Germans distributed codebooks with daily settings for their Enigma machines.\n比如德国人给英格玛配了密码本，上面有每天的配置\n\nBut this strategy could never work in the internet era.\n但互联网时代没法这样做\n\nImagine having to crack open a codebook to connect to youtube\n你能想象 要打开密码本才能访问 YouTube 吗？\n\nWhat’s needed is a way for a server to send a secret key over the public internet to a user wishing to connect securely.\n我们需要某种方法 在公开的互联网上传递密钥给对方\n\nIt seems like that wouldn’t be secure, because if the key is sent in the open and intercepted by a hacker\n这看起来好像不安全，如果密钥被黑客拦截了\n\ncouldn’t they use that to decrypt all communication between the two?\n黑客不就能解密通信了吗？\n\nThe solution is key exchange!\n解决方案是 \"密钥交换\"！\n\n– An algorithm that lets two computers agreeon a key without ever sending one.\n密钥交换是一种不发送密钥，\\N 但依然让两台计算机在密钥上达成共识的算法\n\nWe can do this with one-way functions –\n我们可以用\"单向函数\"来做\n\nmathematical operations that are very easy to do in one direction, but hard to reverse.\n单项函数是一种数学操作，很容易算出结果，\\N 但想从结果逆向推算出输入非常困难\n\nTo show you how one-way functions work, let’ s use paint colors as an analogy.\n为了让你明白单项函数，我们拿颜色作比喻\n\nIt’s easy to mix paint colors together, but it’s not so easy to figure\n将颜色混合在一起很容易，\n\nout the constituent colors that were used to make a mixed paint color.\n但想知道混了什么颜色很难\n\nYou’d have to test a lot of possibilities to figure it out.\n要试很多种可能才知道\n\nIn this metaphor, our secret key is a unique shade of paint.\n用这个比喻，那么我们的密钥是一种独特的颜色\n\nFirst, there’s a public paint color that everyone can see.\n首先，有一个公开的颜色，所有人都可以看到\n\nThen, John and I each pick a secret paint color.\n然后，约翰和我各自选一个秘密颜色，只有自己知道.\n\nTo exchange keys, I mix my secret paint color with the public paint color.\n为了交换密钥，我把我的 秘密颜色 和 公开颜色 混在一起\n\nThen, I send that mixed color to John by anymeans – mail, carrier pigeon, whatever.\n然后发给约翰，可以写信发，用信鸽发，什么方式都行.\n\nJohn does the same – mixing his secret paint color with the public color, then sending that to me.\n约翰也这样做，把他的秘密颜色和公开颜色混在一起，然后发我\n\nWhen I receive John’s color, I simply add my private color to create a blend of all three paints.\n我收到约翰的颜色之后，把我的秘密颜色加进去，\\N  现在3种颜色混合在一起\n\nJohn does the same with my mixed color.\nJohn 也一样做\n\nAnd Voila!\n瞧!\n\nWe both end up with the same paint color!\n我们有了一样的颜色\n\nWe can use this as a shared secret, even though we never sent each other our individual secret colors.\n我们可以把这个颜色当密钥，尽管我们从来没有给对方发过这颜色\n\nA snooping outside observer would know partial information, but they’d find it very difficult to figure out our shared secret color.\n外部窥探者可以知道部分信息，但无法知道最终颜色\n\nOf course, sending and mixing paint colors isn’t going to work well for transmitting computer data.\n当然，计算机要传输数据时，混合颜料和发颜料不太合适\n\nBut luckily, mathematical one-way functions are perfect,\n但幸运的是，数学单向函数是完美的\n\nand this is what Diffie-Hellman Key Exchange uses.\n我们可以用 \"迪菲-赫尔曼密钥交换\"\n\nIn Diffie-Hellman, the one-way function is modular exponentiation.\n在 Diffie-Hellman 中，单向函数是模幂运算\n\nThis means taking one number, the base, to the power of another number,\n意思是先做幂运算，拿一个数字当底数，拿一个数字当指数，比如 A\n\nb\n\nthe exponent, and taking the remainder when dividing by a third number, the modulus.\n然后除以第三个数字，最后拿到我们想要的余数\n\nSo, for example, if we wanted to calculate 3 to the 5th power, modulo 31,\n举个例子，假设我们想算3的5次方，模31\n\nwe would calculate 3 to the 5th, which is 243,\n我们先算3的5次方，得到243\n\nthen take the remainder when divided by 31, which is 26.\n\\N然后除31，取余数，得到26\n\nThe hard part is figuring out the exponent given only the result and the base.\n重点是  如果只给余数和基数。很难得知指数是多少\n\nIf I tell you I raised 3 to some secret number, modulo 31, and got 7 as the remainder\n如果我告诉你，3的某次方 模31，余数是7\n\nyou'd have to test a lot of exponents to know which one I picked.\n你要试很多次，才能知道次方是多少\n\nIf we make these numbers big, say hundreds of digits long,\n如果把数字变长一些，比如几百位长\n\nthen finding the secret exponent is nearly impossible.\n想找到秘密指数是多少，几乎是不可能的。\n\nNow let’s talk about how Diffie-Hellman\n现在我们来讨论 Diffie-Hellman 是怎么\n\nuses modular exponentiation to calculate a shared key.\n用模幂运算 算出双方共享的密钥\n\nFirst, there's a set of public values – the base and the modulus,\n首先，我们有公开的值 - 基数和模数\n\nthat, like our public paint color, everyone gets to know... even the bad guys!\n就像公开的油漆颜色，所有人都看的到，甚至坏人!\n\nTo send a message securely to John, I would pick a secret exponent: X.\n为了安全向 John 发信息，我选一个秘密指数：X\n\nThen, I’d calculate B to the power of X, modulo M.\n然后算  B^X mod M 的结果\n\nI send this big number over to John.\n然后把这个大数字发给 John.\n\nJohn does the same, picking a secret exponent Y, and sending me B to the Y modulo M.\nJohn 也一样做，选一个秘密指数Y，然后把 B^Y mod M 的结果发我\n\nTo create a shared secret key,\n为了算出 双方共用的密钥\n\nI take what John sent me, and take it to the power of X, my secret exponent.\n我把 John 给我的数，用我的秘密指数 X，进行模幂运算 (看上图)\n\nThis is mathematically equivalent to B to the XY modulus M.\n数学上相等于  B的XY次方 模M\n\nJohn does the same, taking what I sent to him to the power of Y, and we both end up with the exact same number!\nJohn也一样做，拿我给他的数 进行模幂运算，最终得到一样的数\n\nIt’s a secret shared key, even though we never sent each other our secret number.\n双方有一样的密钥，即使我们从来没给对方发过各自的秘密指数\n\nWe can use this big number as a shared key for encrypted communication, using something like AES for encryption.\n我们可以用这个大数字当密钥，用 AES 之类的加密技术来加密通信\n\nDiffie-Hellman key exchange is one method for establishing a shared key.\n\"Diffie-Hellman 密钥交换\"是建立共享密钥的一种方法。\n\nThese keys that can be used by both sender and receiver, to encrypt and decrypt messages\n双方用一样的密钥加密和解密消息，这叫\"对称加密\", 因为密钥一样\n\nare called symmetric keys because the key is the same on both sides.\n双方用一样的密钥加密和解密消息，这叫\"对称加密\", 因为密钥一样\n\nThe Caesar Cipher, Enigma and AES are all symmetric encryption.\n凯撒加密，英格玛，AES 都是\"对称加密\"\n\nThere’s also asymmetric encryption, where there are two different keys\n还有\"非对称加密\"，有两个不同的密钥\n\nmost often one that’s public and another that’s private.\n一个是公开的，另一个是私有的\n\nSo, people can encrypt a message using a public key that\n人们用公钥加密消息 \\N 只有有私钥的人能解密\n\nonly the recipient, with their private key, can decrypt.\n人们用公钥加密消息 \\N 只有有私钥的人能解密\n\nIn other words, knowing the public key only lets you encrypt, but not decrypt – it’s asymmetric!\n换句话说，知道公钥只能加密但不能解密 \\N - 它是\"不对称\"的！\n\nSo, think about boxes with padlocks that you can open with a key.\n想象一个可以锁上的盒子\n\nTo receive a secure message, I can give a sender a box and padlock.\n为了收到安全的信息，我们可以给别人箱子和锁\n\nThey put their message in it and lock it shut.\n别人把信息放箱子，然后锁起来\n\nNow, they can send that box back to me and only I can open it, with my private key.\n把盒子寄回给我，只有我的钥匙能打开\n\nAfter locking the box, neither the sender,\n上锁后，如果发件人或其他人想打开盒子 \\N 除了暴力尝试没有其他办法.\n\nnor anyone else who finds the box, can open it without brute force.\n上锁后，如果发件人或其他人想打开盒子 \\N 除了暴力尝试没有其他办法.\n\nIn the same way, a digital public key can encrypt something that can only be decrypted with a private key.\n和盒子例子一样，公钥加密后只能私钥来解密.\n\nThe reverse is possible too: encrypting something with a\n反过来也是可以的：私钥加密后 用公钥解密\n\nprivate key that can be decrypted with a public key.\n反过来也是可以的：私钥加密后 用公钥解密\n\nThis is used for signing, where a server encrypts data using their private key.\n这种做法用于签名，服务器可以用私钥加密，\n\nAnyone can decrypt it using the server's public key.\n任何人都可以用服务器的公钥解密\n\nThis acts like an unforgeable signature,\n就像一个不可伪造的签名\n\nas only the owner, using their private key, can encrypt.\n因为只有私钥的持有人 能加密\n\nIt proves that you're getting data from the right server or person, and not an imposter.\n这能证明数据来自正确的服务器或个人，而不是某个假冒者\n\nThe most popular asymmetric encryption technique used today is RSA,\n目前最流行的\"非对称加密\"技术是 RSA\n\nnamed after its inventors: Rivest, Shamir and Adleman.\n名字来自发明者： Rivest, Shamir, Adleman.\n\nSo, now you know all the \"key\" parts of modern cryptography:\n现在你学会了现代密码学的所有\"关键\"部分：\n\nsymmetric encryption, key exchange and public-key cryptography.\n对称加密，密钥交换，公钥密码学\n\nWhen you connect to a secure website, like your bank,\n当你访问一个安全的网站，比如银行官网\n\nthat little padlock icon means that your computer has used public key cryptography\n绿色锁图标代表 用了公钥密码学\n\nto verify the server key exchange to establish a secret temporary key,\n验证服务器的密钥，然后建立临时密钥\n\nand symmetric encryption to protect all the back-and-forth communication from prying eyes.\n然后用对称加密保证通信安全\n\nWhether you're buying something online, sending emails to BFFs,\n不管你是网上购物，发邮件给朋友，还是看猫咪视频\n\nor just browsing cat videos\n不管你是网上购物，发邮件给朋友，还是看猫咪视频\n\ncryptography keeps all that safe, private and secure.\n密码学都在保护你的隐私和安全\n\nThanks cryptography!\n谢啦密码学！\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne，欢迎收看计算机科学速成课！\n\nAs we've touched on many times in this series,\n我们之前说过 \\N 计算机很擅长存放，整理，获取和处理大量数据\n\ncomputers are incredible at storing, organizing,\n我们之前说过 \\N 计算机很擅长存放，整理，获取和处理大量数据\n\nfetching and processing huge volumes of data.\n我们之前说过 \\N 计算机很擅长存放，整理，获取和处理大量数据\n\nThat's perfect for things like e-commerce websites with millions of items for sale,\n很适合有上百万商品的电商网站\n\nand for storing billions of health records for quick access by doctors.\n或是存几十亿条健康记录，方便医生看.\n\nBut what if we want to use computers not just to fetch and display data,\n但如果想根据数据做决定呢？\n\nbut to actually make decisions about data?\n但如果想根据数据做决定呢？\n\nThis is the essence of machine learning\n这是机器学习的本质\n\nalgorithms that give computers the ability to learn from data,\n机器学习算法让计算机可以从数据中学习，\\N 然后自行做出预测和决定\n\nand then make predictions and decisions.\n机器学习算法让计算机可以从数据中学习，\\N 然后自行做出预测和决定\n\nComputer prosgrams with this ability\n能自我学习的程序很有用 \\N 比如判断是不是垃圾邮件\n\nare extremely useful in answering questions like Is an email spam?\n能自我学习的程序很有用 \\N 比如判断是不是垃圾邮件\n\nDoes a person's heart have arrhythmia?\n这人有心律失常吗？\n\nor what video should youtube recommend after this one?\nYouTube 的下一个视频该推荐哪个？\n\nWhile useful, we probably wouldn't describe these programs as \"intelligent\"\n虽然有用，但我们不会说它有人类一般的智能\n\nin the same way we think of human intelligence.\n虽然有用，但我们不会说它有人类一般的智能\n\nSo, even though the terms are often interchanged,\n虽然 AI 和 ML 这两词经常混着用\n\nmost computer scientists would say that machine learning is a set of techniques\n大多数计算机科学家会说 \\N机器学习是为了实现人工智能这个更宏大目标的技术之一\n\nthat sits inside the even more ambitious goal of Artificial Intelligence,\n大多数计算机科学家会说 \\N机器学习是为了实现人工智能这个更宏大目标的技术之一\n\nor AI for short.\n人工智能简称 AI\n\nMachine Learning and AI algorithms tend to be pretty sophisticated.\n机器学习和人工智能算法一般都很复杂\n\nSo rather than wading into the mechanics of how they work,\n所以我们不讲具体细节  重点讲概念\n\nwe're going to focus on what the algorithms do conceptually.\n所以我们不讲具体细节  重点讲概念\n\nLet's start with a simple example:\n我们从简单例子开始：\n\ndeciding if a moth is a Luna Moth or an Emperor Moth.\n判断飞蛾是\"月蛾\"还是\"帝蛾\"\n\nThis decision process is called classification,\n这叫\"分类\"\n\nand an algorithm that does it is called a classifier.\n做分类的算法叫 \"分类器\"\n\nAlthough there are techniques that can use raw data for training\n虽然我们可以用 照片和声音 来训练算法\n\n- like photos and sounds -\n虽然我们可以用 照片和声音 来训练算法\n\nmany algorithms reduce the complexity of real world objects\n很多算法会减少复杂性\n\nand phenomena into what are called features.\n把数据简化成 \"特征\"\n\nFeatures are values that usefully characterize the things we wish to classify.\n\"特征\"是用来帮助\"分类\"的值\n\nFor our moth example, we're going to use two features: \"wingspan\" and \"mass\".\n对于之前的飞蛾分类例子\\N 我们用两个特征:\"翼展\"和\"重量\"\n\nIn order to train our machine learning classifier to make good predictions,\n为了训练\"分类器\"做出好的预测，\n\nwe're going to need training data.\n我们需要\"训练数据\"\n\nTo get that,\n为了得到数据\n\nwe'd send an entomologist out into a forest to collect data for both luna and emperor moths.\n我们派昆虫学家到森林里 收集\"月蛾\"和\"帝蛾\"的数据\n\nThese experts can recognize different moths,\n专家可以认出不同飞蛾，\n\nso they not only record the feature values,\n所以专家不只记录特征值，还会把种类也写上\n\nbut also label that data with the actual moth species.\n所以专家不只记录特征值，还会把种类也写上\n\nThis is called labeled data.\n这叫 \"标记数据\"\n\nBecause we only have two features,\n因为只有两个特征\n\nit's easy to visualize this data in a scatterplot.\n很容易用散点图把数据视觉化\n\nHere, I've plotted data for 100 Emperor Moths in red and 100 Luna Moths in blue.\n红色标了100个帝蛾\\N 蓝色标了100个月蛾\n\nWe can see that the species make two groupings, but.\n可以看到大致分成了两组\n\nthere's some overlap in the middle\n但中间有一定重叠\n\nso it's not entirely obvious how to best separate the two.\n所以想完全区分两个组比较困难\n\nThat's what machine learning algorithms do\n所以机器学习算法登场\n\n- find optimal separations!\n- 找出最佳区分\n\nI'm just going to eyeball it\n我用肉眼大致估算下\n\nand say anything less than 45 millimeters in wingspan is likely to be an Emperor Moth.\n然后判断 翼展小于45毫米的 很可能是帝蛾\n\nWe can add another division that says additionally mass must be less than .75\n可以再加一个条件，重量必须小于.75\n\nin order for our guess to be Emperor Moth.\n才算是帝蛾。\n\nThese lines that chop up the decision space are called decision boundaries.\n这些线叫 \"决策边界\"\n\nIf we look closely at our data,\n如果仔细看数据\n\nwe can see that 86 emperor moths would correctly end up inside the emperor decision region,\n86只帝蛾在正确的区域\n\nbut 14 would end up incorrectly in luna moth territory.\n但剩下14只在错误的区域\n\nOn the other hand, 82 luna moths would be correct,\n另一方面，82只月蛾在正确的区域\n\nwith 18 falling onto the wrong side.\n18个在错误的区域\n\nA table, like this, showing where a classifier gets things right and wrong\n这里有个表 记录正确数和错误数\n\nis called a confusion matrix...\n这表叫\"混淆矩阵\"\n\nwhich probably should have also been the title of the last two movies in the Matrix Trilogy!\n\"黑客帝国三部曲\"的后两部也许该用这个标题\n\nNotice that there's no way for us to draw lines that give us 100% accuracy.\n注意我们没法画出 100% 正确分类的线\n\nIf we lower our wingspan decision boundary,\n降低翼展的决策边界，会把更多\"帝蛾\"误分类成\"月蛾\"\n\nwe misclassify more Emperor moths as Lunas.\n降低翼展的决策边界，会把更多\"帝蛾\"误分类成\"月蛾\"\n\nIf we raise it, we misclassify more Luna moths.\n如果提高，会把更多月蛾分错类.\n\nThe job of machine learning algorithms,\n机器学习算法的目的\n\nat a high level,\n机器学习算法的目的\n\nis to maximize correct classifications while minimizing errors\n是最大化正确分类 + 最小化错误分类\n\nOn our training data, we get 168 moths correct, and 32 moths wrong,\n在训练数据中，有168个正确，32个错误\n\nfor an average classification accuracy of 84%.\n平均准确率84％\n\nNow, using these decision boundaries,\n用这些决策边界\n\nif we go out into the forest and encounter an unknown moth,\n如果我们进入森林，碰到一只不认识的飞蛾，\n\nwe can measure its features and plot it onto our decision space.\n我们可以测量它的特征, 并绘制到决策空间上\n\nThis is unlabeled data.\n这叫 \"未标签数据\"\n\nOur decision boundaries offer a guess as to what species the moth is.\n决策边界可以猜测飞蛾种类\n\nIn this case, we'd predict it's a Luna Moth.\n这里我们预测是\"月蛾\"\n\nThis simple approach, of dividing the decision space up into boxes,\n这个把决策空间 切成几个盒子的简单方法\n\ncan be represented by what's called a decision tree,\n可以用\"决策树\"来表示\n\nwhich would look like this pictorially or could be written in code using If-Statements, like this.\n画成图像，会像左侧 \\N 用 if 语句写代码，会像右侧\n\nA machine learning algorithm that produces decision trees\n生成决策树的 机器学习算法\n\nneeds to choose what features to divide on\n需要选择用什么特征来分类\n\nand then for each of those features, what values to use for the division.\n每个特征用什么值\n\nDecision Trees are just one basic example of a machine learning technique.\n\"决策树\"只是机器学习的一个简单例子\n\nThere are hundreds of algorithms in computer science literature today.\n如今有数百种算法，而且新算法不断出现\n\nAnd more are being published all the time.\n如今有数百种算法，而且新算法不断出现\n\nA few algorithms even use many decision trees working together to make a prediction.\n一些算法甚至用多个\"决策树\"来预测\n\nComputer scientists smugly call those Forests\n计算机科学家叫这个\"森林\"，因为有多颗树嘛\n\nbecause they contain lots of trees.\n计算机科学家叫这个\"森林\"，因为有多颗树嘛\n\nThere are also non-tree-based approaches,\n也有不用树的方法，比如\"支持向量机\"\n\nlike Support Vector Machines,\n也有不用树的方法，比如\"支持向量机\"\n\nwhich essentially slice up the decision space using arbitrary lines.\n本质上是用任意线段来切分\"决策空间\"\n\nAnd these don't have to be straight lines;\n不一定是直线\n\nthey can be polynomials or some other fancy mathematical function.\n可以是多项式或其他数学函数\n\nLike before, it's the machine learning algorithm's job\n就像之前，机器学习算法负责\n\nto figure out the best lines to provide the most accurate decision boundaries.\n找出最好的线，最准的决策边界\n\nSo far, my examples have only had two features,\n之前的例子只有两个特征，人类也可以轻松做到\n\nwhich is easy enough for a human to figure out.\n之前的例子只有两个特征，人类也可以轻松做到\n\nIf we add a third feature,\n如果加第3个特征，比如\"触角长度\"\n\nlet's say, length of antennae,\n如果加第3个特征，比如\"触角长度\"\n\nthen our 2D lines become 3D planes,\n那么2D线段，会变成3D平面\n\ncreating decision boundaries in three dimensions.\n在三个维度上做决策边界\n\nThese planes don't have to be straight either.\n这些平面不必是直的\n\nPlus, a truly useful classifier would contend with many different moth species.\n而且 真正有用的分类器 会有很多飞蛾种类\n\nNow I think you'd agree this is getting too complicated to figure out by hand\n你可能会同意 现在变得太复杂了\n\nBut even this is a very basic example\n但这也只是个简单例子\n\n- just three features and five moth species.\n- 只有3个特征和5个品种\n\nWe can still show it in this 3D scatter plot.\n我们依然可以用 3D散点图 画出来\n\nUnfortunately, there's no good way to visualize four features at once, or twenty features,\n不幸的是，一次性看4个或20个特征，没有好的方法\n\nlet alone hundreds or even thousands of features.\n更别说成百上千的特征了\n\nBut that's what many real-world machine learning problems face.\n但这正是机器学习要面临的问题\n\nCan YOU imagine trying to figure out the equation for a hyperplane\n你能想象靠手工 在一个上千维度的决策空间里\n\nrippling through a thousand-dimensional decision space?\n给超平面(Hyperplane)找出一个方程吗\n\nProbably not,\n大概不行\n\nbut computers, with clever machine learning algorithms can\n但聪明的机器学习算法可以做到\n\nand they do, all day long, on computers at places like Google, Facebook, Microsoft and Amazon.\nGoogle，Facebook，微软和亚马逊的计算机里\\N 整天都在跑这些算法\n\nTechniques like Decision Trees and Support Vector Machines are strongly rooted in the field of statistics,\n\"决策树\"和\"支持向量机\"这样的技术 \\N 发源自统计学\n\nwhich has dealt with making confident decisions,\n统计学早在计算机出现前，就在用数据做决定\n\nusing data, long before computers ever existed.\n统计学早在计算机出现前，就在用数据做决定\n\nThere's a very large class of widely used statistical machine learning techniques,\n有一大类机器学习算法用了统计学\n\nbut there are also some approaches with no origins in statistics.\n但也有不用统计学的算法\n\nMost notable are artificial neural networks,\n其中最值得注意的是 人工神经网络\n\nwhich were inspired by neurons in our brains!\n灵感来自大脑里的神经元\n\nFor a primer of biological neurons,\n想学习神经元知识的人，可以看这3集\n\ncheck out our three-part overview here,\n想学习神经元知识的人，可以看这3集\n\nbut basically neurons are cells\n神经元是细胞\n\nthat process and transmit messages using electrical and chemical signals.\n用电信号和化学信号 来处理和传输消息\n\nThey take one or more inputs from other cells,\n它从其他细胞 得到一个或多个输入\n\nprocess those signals,\n然后处理信号并发出信号\n\nand then emit their own signal.\n然后处理信号并发出信号\n\nThese form into huge interconnected networks that are able to process complex information.\n形成巨大的互联网络，能处理复杂的信息\n\nJust like your brain watching this youtube video.\n就像你的大脑 在看这个视频\n\nArtificial Neurons are very similar.\n人造神经元很类似\n\nEach takes a series of inputs, combines them, and emits a signal.\n可以接收多个输入，然后整合并发出一个信号\n\nRather than being electrical or chemical signals,\n它不用电信号或化学信号\n\nartificial neurons take numbers in, and spit numbers out.\n而是吃数字进去，吐数字出来\n\nThey are organized into layers that are connected by links,\n它们被放成一层层\n\nforming a network of neurons, hence the name.\n形成神经元网络，因此得名神经网络\n\nLet's return to our moth example to see how neural nets can be used for classification.\n回到飞蛾例子，看如何用神经网络分类\n\nOur first layer - the input layer -\n我们的第一层 - 输入层 -\n\nprovides data from a single moth needing classification.\n提供需要被分类的单个飞蛾数据\n\nAgain, we'll use mass and wingspan.\n同样，这次也用重量和翼展\n\nAt the other end, we have an output layer, with two neurons:\n另一边是输出层，有两个神经元：\n\none for Emperor Moth and another for Luna Moth.\n一个是帝蛾，一个是月蛾\n\nThe most excited neuron will be our classification decision.\n2个神经元里最兴奋的 就是分类结果\n\nIn between, we have a hidden layer,\n中间有一个隐藏层\n\nthat transforms our inputs into outputs, and does the hard work of classification.\n负责把输入变成输出，负责干分类这个重活\n\nTo see how this is done,\n为了看看它是如何分类的\n\nlet's zoom into one neuron in the hidden layer.\n我们放大\"隐藏层\"里的一个神经元\n\nThe first thing a neuron does is multiply each of its inputs by a specific weight,\n神经元做的第一件事  \\N 是把每个输入乘以一个权重\n\nlet's say 2.8 for its first input, and .1 for it's second input.\n假设2.8是第一个输入，0.1是第二个输入。\n\nThen, it sums these weighted inputs together,\n然后它会相加输入\n\nwhich is in this case, is a grand total of 9.74.\n总共是9.74\n\nThe neuron then applies a bias to this result\n然后对这个结果，用一个偏差值处理\n\n- in other words, it adds or subtracts a fixed value,\n意思是 加或减一个固定值\n\nfor example, minus six, for a new value of 3.74.\n比如-6，得到3.74\n\nThese bias and inputs weights are initially set to random values when a neural network is created.\n做神经网络时，这些偏差和权重，\\N一开始会设置成随机值\n\nThen, an algorithm goes in, and starts tweaking all those values to train the neural network,\n然后算法会调整这些值 来训练神经网络\n\nusing labeled data for training and testing.\n使用\"标记数据\"来训练和测试\n\nThis happens over many interactions, gradually improving accuracy\n逐渐提高准确性\n\n- a process very much like human learning.\n- 很像人类学习的过程\n\nFinally, neurons have an activation function, also called a transfer function,\n最后，神经元有激活函数，它也叫传递函数，\n\nthat gets applied to the output, performing a final mathematical modification to the result.\n会应用于输出，对结果执行最后一次数学修改\n\nFor example, limiting the value to a range from negative one and positive one,\n例如，把值限制在-1和+1之间\n\nor setting any negative values to 0.\n或把负数改成0\n\nWe'll use a linear transfer function that passes the value through unchanged,\n我们用线性传递函数，它不会改变值\n\nso 3.74 stays as 3.74.\n所以3.74还是3.74\n\nSo for our example neuron,\n所以这里的例子\n\ngiven the inputs .55 and 82, the output would be 3.74.\n输入0.55和82，输出3.74\n\nThis is just one neuron,\n这只是一个神经元，\n\nbut this process of weighting, summing, biasing\n但加权，求和，偏置，激活函数\n\nand applying an activation function is computed for all neurons in a layer,\n会应用于一层里的每个神经元\n\nand the values propagate forward in the network, one layer at a time.\n并向前传播，一次一层\n\nIn this example, the output neuron with the highest value is our decision:\n数字最高的就是结果：\n\nLuna Moth.\n月蛾\n\nImportantly, the hidden layer doesn't have to be just one layer\n重要的是，隐藏层不是只能有一层，可以有很多层\n\nit can be many layers deep.\n重要的是，隐藏层不是只能有一层，可以有很多层\n\nThis is where the term deep learning comes from.\n\"深度学习\"因此得名\n\nTraining these more complicated networks takes a lot more computation and data.\n训练更复杂的网络 需要更多的计算量和数据\n\nDespite the fact that neural networks were invented over fifty years ago,\n尽管神经网络50多年前就发明了\n\ndeep neural nets have only been practical very recently,\n深层神经网络直到最近才成为可能\n\nthanks to powerful processors,\n感谢强大的处理器和超快的GPU\n\nbut even more so, wicked fast GPUs.\n感谢强大的处理器和超快的GPU\n\nSo, thank you gamers for being so demanding about silky smooth framerates!\n感谢游戏玩家对帧率的苛刻要求！\n\nA couple of years ago, Google and Facebook\n几年前，Google和Facebook\n\ndemonstrated deep neural nets that could find faces in photos as well as humans\n展示了深度神经网络 \\N 在照片中识别人脸的准确率，和人一样高\n\n- and humans are really good at this!\n- 人类可是很擅长这个的！\n\nIt was a huge milestone.\n这是个巨大的里程碑\n\nNow deep neural nets are driving cars,\n现在有深层神经网络开车，翻译，诊断医疗状况等等\n\ntranslating human speech,\n现在有深层神经网络开车，翻译，诊断医疗状况等等\n\ndiagnosing medical conditions and much more.\n现在有深层神经网络开车，翻译，诊断医疗状况等等\n\nThese algorithms are very sophisticated,\n这些算法非常复杂，但还不够\"聪明\"\n\nbut it's less clear if they should be described as \"intelligent\".\n这些算法非常复杂，但还不够\"聪明\"\n\nThey can really only do one thing like classify moths, find faces, or translate languages.\n它们只能做一件事，分类飞蛾，找人脸，翻译\n\nThis type of AI is called Weak AI or Narrow AI.\n这种AI叫\"弱AI\"或\"窄AI\"，只能做特定任务\n\nIt's only intelligent at specific tasks.\n这种AI叫\"弱AI\"或\"窄AI\"，只能做特定任务\n\nBut that doesn't mean it's not useful;\n但这不意味着它没用\n\nI mean medical devices that can make diagnoses,\n能自动做出诊断的医疗设备，\n\nand cars that can drive themselves are amazing!\n和自动驾驶的汽车真是太棒了！\n\nBut do we need those computers to compose music\n但我们是否需要这些计算机来创作音乐\n\nand look up delicious recipes in their free time?\n在空闲时间找美味食谱呢？\n\nProbably not.\n也许不要\n\nAlthough that would be kinda cool.\n如果有的话 还挺酷的\n\nTruly general-purpose AI, one as smart and well-rounded as a human,\n真正通用的，像人一样聪明的AI，叫 \"强AI\"\n\nis called Strong AI.\n真正通用的，像人一样聪明的AI，叫 \"强AI\"\n\nNo one has demonstrated anything close to human-level artificial intelligence yet.\n目前没人能做出来 接近人类智能的 AI\n\nSome argue it's impossible,\n有人认为不可能做出来\n\nbut many people point to the explosion of digitized knowledge\n但许多人说 数字化知识的爆炸性增长\n\n- like Wikipedia articles, web pages, and Youtube videos -\n- 比如维基百科，网页和Youtube视频 -\n\nas the perfect kindling for Strong AI.\n是\"强 AI\"的完美引燃物\n\nAlthough you can only watch a maximum of 24 hours of youtube a day,\n你一天最多只能看24小时的 YouTube \\N 计算机可以看上百万小时\n\na computer can watch millions of hours.\n你一天最多只能看24小时的 YouTube \\N 计算机可以看上百万小时\n\nFor example, IBM's Watson consults and synthesizes information from 200 million pages of content,\n比如，IBM 的沃森吸收了 2 亿个网页的内容\n\nincluding the full text of Wikipedia.\n包括维基百科的全文\n\nWhile not a Strong AI, Watson is pretty smart,\n虽然不是\"强AI\" 但沃森也很聪明 \\N 在2011年的知识竞答中碾压了人类\n\nand it crushed its human competition in Jeopardy way back in 2011.\n虽然不是\"强AI\" 但沃森也很聪明 \\N 在2011年的知识竞答中碾压了人类\n\nNot only can AIs gobble up huge volumes of information,\nAI不仅可以吸收大量信息 \\N 也可以不断学习进步，而且一般比人类快得多\n\nbut they can also learn over time, often much faster than humans.\nAI不仅可以吸收大量信息 \\N 也可以不断学习进步，而且一般比人类快得多\n\nIn 2016, Google debuted AlphaGo,\n2016 年 Google 推出 AlphaGo\n\na Narrow AI that plays the fiendishly complicated board game Go.\n一个会玩围棋的窄AI\n\nOne of the ways it got so good and able to beat the very best human players,\n它和自己的克隆版下无数次围棋 \\N 从而打败最好的人类围棋选手\n\nwas by playing clones of itself millions and millions of times.\n它和自己的克隆版下无数次围棋 \\N 从而打败最好的人类围棋选手\n\nIt learned what worked and what didn't,\n学习什么管用，什么不管用 \\N 自己发现成功的策略\n\nand along the way, discovered successful strategies all by itself.\n学习什么管用，什么不管用 \\N 自己发现成功的策略\n\nThis is called Reinforcement Learning,\n这叫 \"强化学习\" 是一种很强大的方法\n\nand it's a super powerful approach.\n这叫 \"强化学习\" 是一种很强大的方法\n\nIn fact, it's very similar to how humans learn.\n和人类的学习方式非常类似\n\nPeople don't just magically acquire the ability to walk...\n人类不是天生就会走路，是上千小时的试错学会的\n\nit takes thousands of hours of trial and error to figure it out.\n人类不是天生就会走路，是上千小时的试错学会的\n\nComputers are now on the cusp of learning by trial and error,\n计算机现在才刚学会反复试错来学习\n\nand for many narrow problems,\n对于很多狭窄的问题，强化学习已被广​​泛使用\n\nreinforcement learning is already widely used.\n对于很多狭窄的问题，强化学习已被广​​泛使用\n\nWhat will be interesting to see, is if these types of learning techniques can be applied more broadly,\n有趣的是，如果这类技术可以更广泛地应用\n\nto create human-like, Strong AIs that learn much like how kids learn, but at super accelerated rates.\n创造出类似人类的\"强AI\" \\N 能像人类小孩一样学习，但学习速度超快\n\nIf that happens, there are some pretty big changes in store for humanity\n如果这发生了，对人类可能有相当大的影响\n\n- a topic we'll revisit later.\n- 我们以后会讨论\n\nThanks for watching. See you next week.\n感谢收看.  我们下周见\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨 我是Carrie Anne，欢迎收看计算机科学速成课\n\nToday, let's start by thinking about how important vision can be.\n今天 我们来思考视觉的重要性\n\nMost people rely on it to prepare food,\n大部分人靠视觉来做饭\n\nwalk around obstacles,\n越过障碍\n\nread street signs,\n读路牌\n\nwatch videos like this,\n看视频\n\nand do hundreds of other tasks.\n以及无数其它任务\n\nVision is the highest bandwidth sense,\n视觉是信息最多的感官 \\N 比如周围的世界是怎样的，如何和世界交互\n\nand it provides a firehose of information about the state of the world and how to act on it.\n视觉是信息最多的感官 \\N 比如周围的世界是怎样的，如何和世界交互\n\nFor this reason, computer scientists have been trying to give computers vision for half a century,\n因此半个世纪来\\N 计算机科学家一直在想办法让计算机有视觉\n\nbirthing the sub-field of computer vision.\n因此诞生了\"计算机视觉\"这个领域\n\nIts goal is to give computers the ability\n目标是让计算机理解图像和视频\n\nto extract high-level understanding from digital images and videos.\n目标是让计算机理解图像和视频\n\nAs everyone with a digital camera or smartphone knows,\n用过相机或手机的都知道 \\N 可以拍出有惊人保真度和细节的照片\n\ncomputers are already really good at capturing photos with incredible fidelity and detail\n用过相机或手机的都知道 \\N 可以拍出有惊人保真度和细节的照片\n\n- much better than humans in fact.\n- 比人类强得多\n\nBut as computer vision professor Fei-Fei Li recently said,\n但正如计算机视觉教授 李飞飞 最近说的\n\n\"Just like to hear is the not the same as to listen.\n\"听到\"不等于\"听懂\"\n\nTo take pictures is not the same as to see.\"\n\"看到\"不等于\"看懂\"\n\nAs a refresher, images on computers are most often stored as big grids of pixels.\n复习一下，图像是像素网格\n\nEach pixel is defined by a color, stored as a combination of three additive primary colors:\n每个像素的颜色  通过三种基色定义：红，绿，蓝\n\nred, green and blue.\n每个像素的颜色  通过三种基色定义：红，绿，蓝\n\nBy combining different intensities of these three colors,\n通过组合三种颜色的强度 \\N 可以得到任何颜色, 也叫 RGB 值\n\nwe can represent any color.  what's called a RGB value,\n通过组合三种颜色的强度 \\N 可以得到任何颜色, 也叫 RGB 值\n\nPerhaps the simplest computer vision algorithm\n最简单的计算机视觉算法\n\n- and a good place to start -\n最合适拿来入门的\n\nis to track a colored object, like a bright pink ball.\n是跟踪一个颜色物体，比如一个粉色的球\n\nThe first thing we need to do is record the ball's color.\n首先，我们记下球的颜色，保存最中心像素的 RGB 值\n\nFor that, we'll take the RGB value of the centermost pixel.\n首先，我们记下球的颜色，保存最中心像素的 RGB 值\n\nWith that value saved, we can give a computer program an image,\n然后给程序喂入图像，让它找最接近这个颜色的像素\n\nand ask it to find the pixel with the closest color match.\n然后给程序喂入图像，让它找最接近这个颜色的像素\n\nAn algorithm like this might start in the upper right corner,\n算法可以从左上角开始，逐个检查像素\n\nand check each pixel, one at time,\n算法可以从左上角开始，逐个检查像素\n\ncalculating the difference from our target color.\n计算和目标颜色的差异\n\nNow, having looked at every pixel,\n检查了每个像素后，最贴近的像素，很可能就是球\n\nthe best match is very likely a pixel from our ball.\n检查了每个像素后，最贴近的像素，很可能就是球\n\nWe're not limited to running this algorithm on a single photo;\n不只是这张图片 \\N 我们可以在视频的每一帧图片跑这个算法\n\nwe can do it for every frame in a video,\n不只是这张图片 \\N 我们可以在视频的每一帧图片跑这个算法\n\nallowing us to track the ball over time.\n跟踪球的位置\n\nOf course, due to variations in lighting, shadows, and other effects,\n当然，因为光线，阴影和其它影响\n\nthe ball on the field is almost certainly not going to be the exact same RGB value as our target color,\n球的颜色会有变化，不会和存的 RGB 值完全一样\n\nbut merely the closest match.\n但会很接近\n\nIn more extreme cases, like at a game at night,\n如果情况更极端一些 \\N 比如比赛是在晚上，追踪效果可能会很差\n\nthe tracking might be poor.\n如果情况更极端一些 \\N 比如比赛是在晚上，追踪效果可能会很差\n\nAnd if one of the team's jerseys used the same color as the ball,\n如果球衣的颜色和球一样，算法就完全晕了\n\nour algorithm would get totally confused.\n如果球衣的颜色和球一样，算法就完全晕了\n\nFor these reasons, color marker tracking and similar algorithms are rarely used,\n因此很少用这类颜色跟踪算法\n\nunless the environment can be tightly controlled.\n除非环境可以严格控制\n\nThis color tracking example was able to search pixel-by-pixel,\n颜色跟踪算法是一个个像素搜索 \\N 因为颜色是在一个像素里\n\nbecause colors are stored inside of single pixels.\n颜色跟踪算法是一个个像素搜索 \\N 因为颜色是在一个像素里\n\nBut this approach doesn't work for features larger than a single pixel,\n但这种方法 不适合占多个像素的特征\n\nlike edges of objects, which are inherently made up of many pixels.\n比如物体的边缘，是多个像素组成的.\n\nTo identify these types of features in images,\n为了识别这些特征，算法要一块块像素来处理\n\ncomputer vision algorithms have to consider small regions of pixels,\n为了识别这些特征，算法要一块块像素来处理\n\ncalled patches.\n每一块都叫\"块\"\n\nAs an example, let's talk about an algorithm that finds vertical edges in a scene,\n举个例子，找垂直边缘的算法\n\nlet's say to help a drone navigate safely through a field of obstacles.\n假设用来帮无人机躲避障碍\n\nTo keep things simple, we're going to convert our image into grayscale,\n为了简单，我们把图片转成灰度 \\N 不过大部分算法可以处理颜色\n\nalthough most algorithms can handle color.\n为了简单，我们把图片转成灰度 \\N 不过大部分算法可以处理颜色\n\nNow let's zoom into one of these poles to see what an edge looks like up close.\n放大其中一个杆子，看看边缘是怎样的\n\nWe can easily see where the left edge of the pole starts,\n可以很容易地看到 杆子的左边缘从哪里开始\n\nbecause there's a change in color that persists across many pixels vertically.\n因为有垂直的颜色变化\n\nWe can define this behavior more formally by creating a rule\n我们可以弄个规则说\n\nthat says the likelihood of a pixel being a vertical edge\n某像素是垂直边缘的可能性 \\N 取决于左右两边像素的颜色差异程度\n\nis the magnitude of the difference in color\n某像素是垂直边缘的可能性 \\N 取决于左右两边像素的颜色差异程度\n\nbetween some pixels to its left and some pixels to its right.\n某像素是垂直边缘的可能性 \\N 取决于左右两边像素的颜色差异程度\n\nThe bigger the color difference between these two sets of pixels,\n左右像素的区别越大，这个像素越可能是边缘\n\nthe more likely the pixel is on an edge.\n左右像素的区别越大，这个像素越可能是边缘\n\nIf the color difference is small, it's probably not an edge at all.\n如果色差很小，就不是边缘\n\nThe mathematical notation for this operation looks like this\n这个操作的数学符号 看起来像这样\n\nit's called a kernel or filter.\n这叫\"核\"或\"过滤器\"\n\nIt contains the values for a pixel-wise multiplication,\n里面的数字用来做像素乘法\n\nthe sum of which is saved into the center pixel.\n总和 存到中心像素里\n\nLet's see how this works for our example pixel.\n我们来看个实际例子\n\nI've gone ahead and labeled all of the pixels with their grayscale values.\n我已经把所有像素转成了灰度值\n\nNow, we take our kernel, and center it over our pixel of interest.\n现在把\"核\"的中心，对准感兴趣的像素\n\nThis specifies what each pixel value underneath should be multiplied by.\n这指定了每个像素要乘的值\n\nThen, we just add up all those numbers.\n然后把所有数字加起来\n\nIn this example, that gives us 147.\n在这里，最后结果是 147\n\nThat becomes our new pixel value.\n成为新像素值\n\nThis operation, of applying a kernel to a patch of pixels,\n把 核 应用于像素块，这种操作叫\"卷积\"\n\nis call a convolution.\n把 核 应用于像素块，这种操作叫\"卷积\"\n\nNow let's apply our kernel to another pixel.\n现在我们把\"核\"应用到另一个像素\n\nIn this case, the result is 1. Just 1.\n结果是 1\n\nIn other words, it's a very small color difference, and not an edge.\n色差很小，不是边缘\n\nIf we apply our kernel to every pixel in the photo,\n如果把\"核\"用于照片中每个像素\n\nthe result looks like this,\n结果会像这样\n\nwhere the highest pixel values are where there are strong vertical edges.\n垂直边缘的像素值很高\n\nNote that horizontal edges, like those platforms in the background,\n注意，水平边缘（比如背景里的平台）\n\nare almost invisible.\n几乎看不见\n\nIf we wanted to highlight those features,\n如果要突出那些特征\n\nwe'd have to use a different kernel\n要用不同的\"核\"\n\n- one that's sensitive to horizontal edges.\n用对水平边缘敏感的\"核\"\n\nBoth of these edge enhancing kernels are called Prewitt Operators,\n这两个边缘增强的核叫\"Prewitt 算子\"\n\nnamed after their inventor.\n以发明者命名\n\nThese are just two examples of a huge variety of kernels,\n这只是众多\"核\"的两个例子\n\nable to perform many different image transformations.\n\"核\"能做很多种图像转换\n\nFor example, here's a kernel that sharpens images.\n比如这个\"核\"能锐化图像\n\nAnd here's a kernel that blurs them.\n这个\"核\"能模糊图像\n\nKernels can also be used like little image cookie cutters that match only certain shapes.\n\"核\"也可以像饼干模具一样，匹配特定形状\n\nSo, our edge kernels looked for image patches\n之前做边缘检测的\"核\"\n\nwith strong differences from right to left or up and down.\n会检查左右或上下的差异\n\nBut we could also make kernels that are good at finding lines, with edges on both sides.\n但我们也可以做出 擅长找线段的\"核\"\n\nAnd even islands of pixels surrounded by contrasting colors.\n或者包了一圈对比色的区域\n\nThese types of kernels can begin to characterize simple shapes.\n这类\"核\"可以描述简单的形状\n\nFor example, on faces, the bridge of the nose tends to be brighter than the sides of the nose,\n比如鼻梁往往比鼻子两侧更亮\n\nresulting in higher values for line-sensitive kernels.\n所以线段敏感的\"核\"对这里的值更高\n\nEyes are also distinctive\n眼睛也很独特\n\n- a dark circle sounded by lighter pixels -\n- 一个黑色圆圈被外层更亮的一层像素包着\n\na pattern other kernels are sensitive to.\n有其它\"核\"对这种模式敏感\n\nWhen a computer scans through an image,\n当计算机扫描图像时，最常见的是用一个窗口来扫\n\nmost often by sliding around a search window,\n当计算机扫描图像时，最常见的是用一个窗口来扫\n\nit can look for combinations of features indicative of a human face.\n可以找出人脸的特征组合\n\nAlthough each kernel is a weak face detector by itself,\n虽然每个\"核\"单独找出脸的能力很弱 \\N 但组合在一起会相当准确\n\ncombined, they can be quite accurate.\n虽然每个\"核\"单独找出脸的能力很弱 \\N 但组合在一起会相当准确\n\nIt's unlikely that a bunch of face-like features will cluster together if they're not a face.\n不是脸但又有一堆脸的特征在正确的位置，\\N 这种情况不太可能\n\nThis was the basis of an early and influential algorithm\n这是一个早期很有影响力的算法的基础\n\ncalled Viola-Jones Face Detection.\n叫 维奥拉·琼斯 人脸检测算法\n\nToday, the hot new algorithms on the block are Convolutional Neural Networks.\n如今的热门算法是 \"卷积神经网络\"\n\nWe talked about neural nets last episode, if you need a primer.\n我们上集谈了神经网络，如果需要可以去看看\n\nIn short, an artificial neuron\n总之，神经网络的最基本单位，是神经元\n\n- which is the building block of a neural network -\n总之，神经网络的最基本单位，是神经元\n\ntakes a series of inputs, and multiplies each by a specified weight,\n它有多个输入，然后会把每个输入 乘一个权重值\n\nand then sums those values all together.\n然后求总和\n\nThis should sound vaguely familiar, because it's a lot like a convolution.\n听起来好像挺耳熟，因为它很像\"卷积\"\n\nIn fact, if we pass a neuron 2D pixel data, rather than a one-dimensional list of inputs,\n实际上，如果我们给神经元输入二维像素\n\nit's exactly like a convolution.\n完全就像\"卷积\"\n\nThe input weights are equivalent to kernel values,\n输入权重等于\"核\"的值\n\nbut unlike a predefined kernel,\n但和预定义\"核\"不同\n\nneural networks can learn their own useful kernels\n神经网络可以学习对自己有用的\"核\"\n\nthat are able to recognize interesting features in images.\n来识别图像中的特征\n\nConvolutional Neural Networks use banks of these neurons to process image data,\n\"卷积神经网络\"用一堆神经元处理图像数据\n\neach outputting a new image, essentially digested by different learned kernels.\n每个都会输出一个新图像，\\N 本质上是被不同的\"核\"处理了\n\nThese outputs are then processed by subsequent layers of neurons,\n输出会被后面一层神经元处理\n\nallowing for convolutions on convolutions on convolutions.\n卷积卷积再卷积\n\nThe very first convolutional layer might find things like edges,\n第一层可能会发现\"边缘\"这样的特征\n\nas that's what a single convolution can recognize, as we've already discussed.\n单次卷积可以识别出这样的东西，之前说过\n\nThe next layer might have neurons that convolve on those edge features\n下一层可以在这些基础上识别\n\nto recognize simple shapes, comprised of edges, like corners.\n比如由\"边缘\"组成的角落\n\nA layer beyond that might convolve on those corner features,\n然后下一层可以在\"角落\"上继续卷积\n\nand contain neurons that can recognize simple objects,\n下一些可能有识别简单物体的神经元\n\nlike mouths and eyebrows.\n比如嘴和眉毛\n\nAnd this keeps going, building up in complexity,\n然后不断重复，逐渐增加复杂度\n\nuntil there's a layer that does a convolution that puts it together:\n直到某一层把所有特征放到一起：\n\neyes, ears, mouth, nose, the whole nine yards,\n眼睛，耳朵，嘴巴，鼻子\n\nand says \"ah ha, it's a face!\"\n然后说：\"啊哈，这是脸！\"\n\nConvolutional neural networks aren't required to be many layers deep,\n\"卷积神经网络\"不是非要很多很多层\n\nbut they usually are, in order to recognize complex objects and scenes.\n但一般会有很多层，来识别复杂物体和场景\n\nThat's why the technique is considered deep learning.\n所以算是\"深度学习\"\n\nBoth Viola-Jones and Convolutional Neural Networks can be applied to many image recognition problems,\n\"维奥拉·琼斯\"和\"卷积神经网络\"\\N 不只是认人脸，还可以识别手写文字\n\nbeyond faces, like recognizing handwritten text,\n\"维奥拉·琼斯\"和\"卷积神经网络\"\\N 不只是认人脸，还可以识别手写文字\n\nspotting tumors in CT scans and monitoring traffic flow on roads.\n在 CT 扫描中发现肿瘤，监测马路是否拥堵\n\nBut we're going to stick with faces.\n但我们这里接着用人脸举例\n\nRegardless of what algorithm was used, once we've isolated a face in a photo,\n不管用什么算法，识别出脸之后\n\nwe can apply more specialized computer vision algorithms to pinpoint facial landmarks,\n可以用更专用的计算机视觉算法 \\N 来定位面部标志\n\nlike the tip of the nose and corners of the mouth.\n比如鼻尖和嘴角\n\nThis data can be used for determining things like if the eyes are open,\n有了标志点，判断眼睛有没有张开就很容易了\n\nwhich is pretty easy once you have the landmarks\n有了标志点，判断眼睛有没有张开就很容易了\n\nit's just the distance between points.\n只是点之间的距离罢了\n\nWe can also track the position of the eyebrows;\n也可以跟踪眉毛的位置\n\ntheir relative position to the eyes can be an indicator of surprise, or delight.\n眉毛相对眼睛的位置  可以代表惊喜或喜悦\n\nSmiles are also pretty straightforward to detect based on the shape of mouth landmarks.\n根据嘴巴的标志点，检测出微笑也很简单\n\nAll of this information can be interpreted by emotion recognition algorithms,\n这些信息可以用\"情感识别算法\"来识别\n\ngiving computers the ability to infer when you're happy, sad, frustrated, confused and so on.\n让电脑知道你是开心，忧伤，沮丧，困惑等等\n\nIn turn, that could allow computers to intelligently adapt their behavior...\n然后计算机可以做出合适的行为.\n\nmaybe offer tips when you're confused,\n比如当你不明白时 给你提示\n\nand not ask to install updates when you're frustrated.\n你心情不好时，就不弹更新提示了\n\nThis is just one example of how vision can give computers the ability to be context sensitive,\n这只是计算机通过视觉感知周围的一个例子\n\nthat is, aware of their surroundings.\n这只是计算机通过视觉感知周围的一个例子\n\nAnd not just the physical surroundings\n不只是物理环境 - 比如是不是在上班，或是在火车上\n\n- like if you're at work or on a train -\n不只是物理环境 - 比如是不是在上班，或是在火车上\n\nbut also your social surroundings\n还有社交环境 - 比如是朋友的生日派对，还是正式商务会议\n\n- like if you're in a formal business meeting versus a friend's birthday party.\n还有社交环境 - 比如是朋友的生日派对，还是正式商务会议\n\nYou behave differently in those surroundings, and so should computing devices,\n你在不同环境会有不同行为，计算机也应如此\n\nif they're smart.\n如果它们够聪明的话...\n\nFacial landmarks also capture the geometry of your face,\n面部标记点 也可以捕捉脸的形状\n\nlike the distance between your eyes and the height of your forehead.\n比如两只眼睛之间的距离，以及前额有多高\n\nThis is one form of biometric data,\n做生物识别\n\nand it allows computers with cameras to recognize you.\n让有摄像头的计算机能认出你\n\nWhether it's your smartphone automatically unlocking itself when it sees you,\n不管是手机解锁 还是政府用摄像头跟踪人\n\nor governments tracking people using CCTV cameras,\n不管是手机解锁 还是政府用摄像头跟踪人\n\nthe applications of face recognition seem limitless.\n人脸识别有无限应用场景\n\nThere have also been recent breakthroughs in landmark tracking for hands and whole bodies,\n另外  跟踪手臂和全身的标记点，最近也有一些突破\n\ngiving computers the ability to interpret a user's body language,\n让计算机理解用户的身体语言\n\nand what hand gestures they're frantically waving at their internet connected microwave.\n比如用户给联网微波炉的手势\n\nAs we've talked about many times in this series,\n正如系列中常说的，抽象是构建复杂系统的关键\n\nabstraction is the key to building complex systems,\n正如系列中常说的，抽象是构建复杂系统的关键\n\nand the same is true in computer vision.\n计算机视觉也是一样\n\nAt the hardware level, you have engineers building better and better cameras,\n硬件层面，有工程师在造更好的摄像头 \\N 让计算机有越来越好的视力\n\ngiving computers improved sight with each passing year,\n硬件层面，有工程师在造更好的摄像头 \\N 让计算机有越来越好的视力\n\nwhich I can't say for myself.\n我自己的视力却不能这样\n\nUsing that camera data,\n用来自摄像头的数据  可以用视觉算法找出脸和手\n\nyou have computer vision algorithms crunching pixels to find things like faces and hands.\n用来自摄像头的数据  可以用视觉算法找出脸和手\n\nAnd then, using output from those algorithms,\n然后可以用其他算法接着处理，解释图片中的东西\n\nyou have even more specialized algorithms for interpreting things\n然后可以用其他算法接着处理，解释图片中的东西\n\nlike user facial expression and hand gestures.\n比如用户的表情和手势\n\nOn top of that, there are people building novel interactive experiences,\n有了这些，人们可以做出新的交互体验\n\nlike smart TVs and intelligent tutoring systems,\n比如智能电视和智能辅导系统 \\N 会根据用户的手势和表情来回应\n\nthat respond to hand gestures and emotion.\n比如智能电视和智能辅导系统 \\N 会根据用户的手势和表情来回应\n\nEach of these levels are active areas of research,\n这里的每一层都是活跃的研究领域\n\nwith breakthroughs happening every year.\n每年都有突破，这只是冰山一角\n\nAnd that's just the tip of the iceberg.\n每年都有突破，这只是冰山一角\n\nToday, computer vision is everywhere\n如今 计算机视觉无处不在\n\n- whether it's barcodes being scanned at stores,\n- 商店里扫条形码 \\N 等红灯的自动驾驶汽车\n\nself-driving cars waiting at red lights,\n- 商店里扫条形码 \\N 等红灯的自动驾驶汽车\n\nor snapchat filters superimposing mustaches.\n或是 Snapchat 里添加胡子的滤镜\n\nAnd, the most exciting thing is that computer scientists are really just getting started,\n令人兴奋的是  一切才刚刚开始\n\nenabled by recent advances in computing, like super fast GPUs.\n最近的技术发展，比如超快的GPU，\\N 会开启越来越多可能性\n\nComputers with human-like ability to see is going to totally change how we interact with them.\n视觉能力达到人类水平的计算机 \\N 会彻底改变交互方式\n\nOf course, it'd also be nice if they could hear and speak,\n当然，如果计算机能听懂我们然后回话，就更好了\n\nwhich we'll discuss next week. I'll see you then.\n我们下周讨论  到时见\n\nHi, I'm Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨 我是Carrie Anne，欢迎收看计算机科学速成课\n\nLast episode we talked about computer vision\n上集我们讨论了计算机视觉 - 让电脑能看到并理解\n\n- giving computers the ability to see and understand visual information.\n上集我们讨论了计算机视觉 - 让电脑能看到并理解\n\nToday we're going to talk about how to give computers the ability to understand language.\n今天我们讨论  怎么让计算机理解语言\n\nYou might argue they've always had this capability.\n你可能会说：计算机已经有这个能力了\n\nBack in Episodes 9 and 12,\n在第9和第12集\n\nwe talked about machine language instructions,\n我们聊了机器语言和更高层次的编程语言\n\nas well as higher-level programming languages.\n我们聊了机器语言和更高层次的编程语言\n\nWhile these certainly meet the definition of a language,\n虽然从定义来说 它们也算语言\n\nthey also tend to have small vocabularies and follow highly structured conventions.\n但词汇量一般很少，而且非常结构化\n\nCode will only compile and run if it's 100 percent free of spelling and syntactic errors.\n代码只能在拼写和语法完全正确时，编译和运行\n\nOf course, this is quite different from human languages\n当然，这和人类语言完全不同 \\N - 人类语言叫\"自然语言\"\n\n- what are called natural languages -\n当然，这和人类语言完全不同 \\N - 人类语言叫\"自然语言\"\n\ncontaining large, diverse vocabularies,\n自然语言有大量词汇\n\nwords with several different meanings,\n有些词有多种含义\n\nspeakers with different accents,\n不同口音\n\nand all sorts of interesting word play.\n以及各种有趣的文字游戏\n\nPeople also make linguistic faux pas when writing and speaking,\n人们在写作和说话时也会犯错\n\nlike slurring words together, leaving out key details so things are ambiguous,\n比如单词拼在一起发音 \\N 关键细节没说 导致意思模糊两可\n\nand mispronouncing things.\n以及发错音\n\nBut, for the most part, humans can roll right through these challenges.\n但大部分情况下，另一方能理解\n\nThe skillful use of language is a major part of what makes us human.\n人类有强大的语言能力\n\nAnd for this reason,\n因此，让计算机拥有语音对话的能力\n\nthe desire for computers to understand and speak our language\n因此，让计算机拥有语音对话的能力\n\nhas been around since they were first conceived.\n这个想法从构思计算机时就有了\n\nThis led to the creation of Natural Language Processing, or NLP,\n\"自然语言处理\"因此诞生，简称 NLP\n\nan interdisciplinary field combining computer science and linguistics.\n结合了计算机科学和语言学的 一个跨学科领域\n\nThere's an essentially infinite number of ways to arrange words in a sentence.\n单词组成句子的方式有无限种\n\nWe can't give computers a dictionary of all possible sentences\n我们没法给计算机一个字典，包含所有可能句子\n\nto help them understand what humans are blabbing on about.\n让计算机理解人类在嘟囔什么\n\nSo an early and fundamental NLP problem was deconstructing sentences into bite-sized pieces,\n所以 NLP 早期的一个基本问题是 \\N 怎么把句子切成一块块\n\nwhich could be more easily processed.\n这样更容易处理\n\nIn school, you learned about nine fundamental types of English words:\n上学时，老师教你 英语单词有九种基本类型：\n\nnouns, pronouns, articles, verbs, adjectives,\n名词，代词，冠词，动词，形容词\n\nadverbs, prepositions, conjunctions, and interjections.\n副词，介词，连词和感叹词\n\nThese are called parts of speech.\n这叫\"词性\"\n\nThere are all sorts of subcategories too,\n还有各种子类，比如\n\nlike singular vs. plural nouns and superlative vs. comparative adverbs,\n单数名词 vs 复数名词 \\N 副词最高级 vs 副词比较级\n\nbut we're not going to get into that.\n但我们不会深入那些.\n\nKnowing a word's type is definitely useful,\n了解单词类型有用\n\nbut unfortunately, there are a lot words that have multiple meanings - like \"rose\" and \"leaves\",\n但不幸的是，很多词有多重含义 比如 rose 和 leaves\n\nwhich can be used as nouns or verbs.\n可以用作名词或动词\n\nA digital dictionary alone isn't enough to resolve this ambiguity,\n仅靠字典，不能解决这种模糊问题\n\nso computers also need to know some grammar.\n所以电脑也要知道语法\n\nFor this, phrase structure rules were developed, which encapsulate the grammar of a language.\n因此开发了 \"短语结构规则\" 来代表语法规则\n\nFor example, in English there's a rule\n例如，英语中有一条规则\n\nthat says a sentence can be comprised of a noun phrase followed by a verb phrase.\n句子可以由一个名词短语和一个动词短语组成\n\nNoun phrases can be an article, like \"the\",\n名词短语可以是冠词，如 the\n\nfollowed by a noun or they can be an adjective followed by a noun.\n然后一个名词，或一个形容词后面跟一个名词\n\nAnd you can make rules like this for an entire language.\n你可以给一门语言制定出一堆规则\n\nThen, using these rules, it's fairly easy to construct what's called a parse tree,\n用这些规则，可以做出\"分析树\"\n\nwhich not only tags every word with a likely part of speech,\n它给每个单词标了可能是什么词性\n\nbut also reveals how the sentence is constructed.\n也标明了句子的结构\n\nThese smaller chunks of data allow computers to more easily access,\n数据块更小 更容易处理\n\nprocess and respond to information.\n数据块更小 更容易处理\n\nEquivalent processes are happening every time you do a voice search,\n每次语音搜索，都有这样的流程\n\nlike: \"where's the nearest pizza\".\n比如 \"最近的披萨在哪里\"\n\nThe computer can recognize that this is a \"where\" question,\n计算机能明白这是\"哪里\"（where）的问题\n\nknows you want the noun \"pizza\",\n知道你想要名词\"披萨\"（pizza）\n\nand the dimension you care about is \"nearest\".\n而且你关心的维度是\"最近的\"（nearest）\n\nThe same process applies to \"what is the biggest giraffe?\" or \"who sang thriller?\"\n\"最大的长颈鹿是什么？\"或\"Thriller是谁唱的？\" \\N 也是这样处理\n\nBy treating language almost like lego,\n把语言像乐高一样拆分，方便计算机处理\n\ncomputers can be quite adept at natural language tasks.\n把语言像乐高一样拆分，方便计算机处理\n\nThey can answer questions and also process commands,\n计算机可以回答问题 以及处理命令\n\nlike \"set an alarm for 2:20\"\n比如\"设 2:20 的闹钟\"\n\nor \"play T-Swizzle on spotify\".\n或\"用 Spotify 播放 T-Swizzle\"\n\nBut, as you've probably experienced, they fail when you start getting too fancy,\n但你可能体验过，如果句子复杂一点\n\nand they can no longer parse the sentence correctly, or capture your intent.\n计算机就没法理解了\n\nHey Siri... me thinks the mongols doth roam too much,\n嘿Siri ...... 俺觉得蒙古人走得太远了\n\nwhat think ye on this most gentle mid-summer's day?\n在这个最温柔的夏日的日子里，你觉得怎么样？\n\nSiri: I'm not sure I got that.\nSiri：我没明白\n\nI should also note that phrase structure rules, and similar methods that codify language,\n还有，\"短语结构规则\"和其他把语言结构化的方法\n\ncan be used by computers to generate natural language text.\n可以用来生成句子\n\nThis works particularly well when data is stored in a web of semantic information,\n数据存在语义信息网络时，这种方法特别有效\n\nwhere entities are linked to one another in meaningful relationships,\n实体互相连在一起\n\nproviding all the ingredients you need to craft informational sentences.\n提供构造句子的所有成分\n\nSiri: Thriller was released in 1983 and sung by Michael Jackson\nSiri：Thriller 于1983年发行，由迈克尔杰克逊演唱\n\nGoogle's version of this is called Knowledge Graph.\nGoogle 版的叫\"知识图谱\"\n\nAt the end of 2016,\n在2016年底\n\nit contained roughly seventy billion facts about, and relationships between, different entities.\n包含大概七百亿个事实，以及不同实体间的关系\n\nThese two processes, parsing and generating text,\n处理, 分析, 生成文字 \\N 是聊天机器人的最基本部件\n\nare fundamental components of natural language chatbots\n处理, 分析, 生成文字 \\N 是聊天机器人的最基本部件\n\n- computer programs that chat with you.\n- 聊天机器人就是能和你聊天的程序\n\nEarly chatbots were primarily rule-based,\n早期聊天机器人大多用的是规则.\n\nwhere experts would encode hundreds of rules mapping what a user might say,\n专家把用户可能会说的话，和机器人应该回复什么，\\N 写成上百个规则\n\nto how a program should reply.\n专家把用户可能会说的话，和机器人应该回复什么，\\N 写成上百个规则\n\nObviously this was unwieldy to maintain and limited the possible sophistication.\n显然，这很难维护，而且对话不能太复杂.\n\nA famous early example was ELIZA, created in the mid-1960s at MIT.\n一个著名早期例子叫 Eliza\\N 1960年代中期 诞生于麻省理工学院\n\nThis was a chatbot that took on the role of a therapist,\n一个治疗师聊天机器人\n\nand used basic syntactic rules to identify content in written exchanges,\n它用基本句法规则 来理解用户打的文字\n\nwhich it would turn around and ask the user about.\n然后向用户提问\n\nSometimes, it felt very much like human-human communication,\n有时候会感觉像和人类沟通一样\n\nbut other times it would make simple and even comical mistakes.\n但有时会犯简单 甚至很搞笑的错误\n\nChatbots, and more advanced dialog systems,\n聊天机器人和对话系统\n\nhave come a long way in the last fifty years, and can be quite convincing today!\n在过去五十年发展了很多，如今可以和真人很像!\n\nModern approaches are based on machine learning,\n如今大多用机器学习\n\nwhere gigabytes of real human-to-human chats are used to train chatbots.\n用上GB的真人聊天数据 来训练机器人\n\nToday, the technology is finding use in customer service applications,\n现在聊天机器人已经用于客服回答\n\nwhere there's already heaps of example conversations to learn from.\n客服有很多对话可以参考\n\nPeople have also been getting chatbots to talk with one another,\n人们也让聊天机器人互相聊天\n\nand in a Facebook experiment, chatbots even started to evolve their own language.\n在 Facebook 的一个实验里，\\N 聊天机器人甚至发展出自己的语言\n\nThis experiment got a bunch of scary-sounding press,\n很多新闻把这个实验 报导的很吓人\n\nbut it was just the computers crafting a simplified protocol to negotiate with one another.\n但实际上只是计算机 \\N 在制定简单协议来帮助沟通\n\nIt wasn't evil, it's was efficient.\n这些语言不是邪恶的，而是为了效率\n\nBut what about if something is spoken\n但如果听到一个句子\n\n- how does a computer get words from the sound?\n- 计算机怎么从声音中提取词汇？\n\nThat's the domain of speech recognition,\n这个领域叫\"语音识别\"\n\nwhich has been the focus of research for many decades.\n这个领域已经重点研究了几十年\n\nBell Labs debuted the first speech recognition system in 1952,\n贝尔实验室在1952年推出了第一个语音识别系统\n\nnicknamed Audrey, the automatic digit recognizer.\n绰号 Audrey，自动数字识别器\n\nIt could recognize all ten numerical digits,\n如果你说得够慢，它可以识别全部十位数字\n\nif you said them slowly enough.\n如果你说得够慢，它可以识别全部十位数字\n\n5\n\n9\n\n7？\n\nThe project didn't go anywhere\n这个项目没有实际应用，因为手输快得多\n\nbecause it was much faster to enter telephone numbers with a finger.\n这个项目没有实际应用，因为手输快得多\n\nTen years later, at the 1962 World's Fair,\n十年后，1962年的世界博览会上\n\nIBM demonstrated a shoebox-sized machine capable of recognizing sixteen words.\nIBM展示了一个鞋盒大小的机器，能识别16个单词\n\nTo boost research in the area,\n为了推进\"语音识别\"领域的研究\n\nDARPA kicked off an ambitious five-year funding initiative in 1971,\nDARPA 在1971年启动了一项雄心勃勃的五年筹资计划\n\nwhich led to the development of Harpy at Carnegie Mellon University.\n之后诞生了卡内基梅隆大学的 Harpy\n\nHarpy was the first system to recognize over a thousand words.\nHarpy 是第一个可以识别1000个单词以上的系统\n\nBut, on computers of the era,\n但那时的电脑\n\ntranscription was often ten or more times slower than the rate of natural speech.\n语音转文字，经常比实时说话要慢十倍或以上\n\nFortunately, thanks to huge advances in computing performance in the 1980s and 90s,\n幸运的是，1980,1990年代 计算机性能的大幅提升\n\ncontinuous, real-time speech recognition became practical.\n实时语音识别变得可行\n\nThere was simultaneous innovation in the algorithms for processing natural language,\n同时也出现了处理自然语言的新算法\n\nmoving from hand-crafted rules,\n不再是手工定规则\n\nto machine learning techniques\n而是用机器学习\n\nthat could learn automatically from existing datasets of human language.\n从语言数据库中学习\n\nToday, the speech recognition systems with the best accuracy are using deep neural networks,\n如今准确度最高的语音识别系统 用深度神经网络\n\nwhich we touched on in Episode 34.\n我们在第34集讲过\n\nTo get a sense of how these techniques work,\n为了理解原理\n\nlet's look at some speech, specifically,\n我们来看一些对话声音\n\nthe acoustic signal.\n我们来看一些对话声音\n\nLet's start by looking at vowel sounds,\n先看元音\n\nlike aaaaa and eeeeee.\n比如 a 和 e\n\nThese are the waveforms of those two sounds, as captured by a computer's microphone.\n这是两个声音的波形\n\nAs we discussed in Episode 21 - on Files and File Formats -\n我们在第21集（文件格式）说过\n\nthis signal is the magnitude of displacement,\n这个信号来自 麦克风内部隔膜震动的频率\n\nof a diaphragm inside of a microphone, as sound waves cause it to oscillate.\n这个信号来自 麦克风内部隔膜震动的频率\n\nIn this view of sound data, the horizontal axis is time,\n在这个视图中，横轴是时间\n\nand the vertical axis is the magnitude of displacement, or amplitude.\n竖轴是隔膜移动的幅度，或者说振幅\n\nAlthough we can see there are differences between the waveforms,\n虽然可以看到2个波形有区别\n\nit's not super obvious what you would point at to say,\n但不能看出\n\n\"ah ha! this is definitely an eeee sound\".\n\"啊！这个声音肯定是 e\"\n\nTo really make this pop out, we need to view the data in a totally different way:\n为了更容易识别，我们换个方式看：\n\na spectrogram.\n谱图\n\nIn this view of the data, we still have time along the horizontal axis,\n这里横轴还是时间\n\nbut now instead of amplitude on the vertical axis,\n但竖轴不是振幅\n\nwe plot the magnitude of the different frequencies that make up each sound.\n而是不同频率的振幅\n\nThe brighter the color, the louder that frequency component.\n颜色越亮，那个频率的声音越大\n\nThis conversion from waveform to frequencies is done with a very cool algorithm called\n这种波形到频率的转换 是用一种很酷的算法做的\n\na Fast Fourier Transform.\n快速傅立叶变换（FFT）\n\nIf you've ever stared at a stereo system's EQ visualizer,\n如果你盯过立体声系统的 EQ 可视化器\n\nit's pretty much the same thing.\n它们差不多是一回事\n\nA spectrogram is plotting that information over time.\n谱图是随着时间变化的\n\nYou might have noticed that the signals have a sort of ribbed pattern to them\n你可能注意到，信号有种螺纹图案\n\nthat's all the resonances of my vocal tract.\n那是我声道的回声\n\nTo make different sounds,\n为了发出不同声音\n\nI squeeze my vocal chords, mouth and tongue into different shapes,\n我要把声带，嘴巴和舌头变成不同形状\n\nwhich amplifies or dampens different resonances.\n放大或减少不同的共振\n\nWe can see this in the signal, with areas that are brighter, and areas that are darker.\n可以看到有些区域更亮，有些更暗\n\nIf we work our way up from the bottom, labeling where we see peaks in the spectrum\n如果从底向上看，标出高峰\n\n- what are called formants -\n- 叫\"共振峰\"  -\n\nwe can see the two sounds have quite different arrangements.\n可以看到有很大不同\n\nAnd this is true for all vowel sounds.\n所有元音都是如此\n\nIt's exactly this type of information that lets computers recognize spoken vowels,\n这让计算机可以识别元音\n\nand indeed, whole words.\n然后识别出整个词\n\nLet's see a more complicated example,\n让我们看一个更复杂的例子\n\nlike when I say: \"she.. was.. happy\"\n当我说\"她..很开心\"的时候\n\nWe can see our \"eee\" sound here, and \"aaa\" sound here.\n可以看到 e 声，和 a 声\n\nWe can also see a bunch of other distinctive sounds,\n以及其它不同声音\n\nlike the \"shh\" sound in \"she\",\n比如 she 中的 shh 声\n\nthe \"wah\" and \"sss\" in \"was\", and so on.\nwas 中的 wah 和 sss，等等\n\nThese sound pieces, that make up words,\n这些构成单词的声音片段\n\nare called phonemes.\n叫\"音素\"\n\nSpeech recognition software knows what all these phonemes look like.\n语音识别软件 知道这些音素\n\nIn English, there are roughly forty-four,\n英语有大概44种音素\n\nso it mostly boils down to fancy pattern matching.\n所以本质上变成了音素识别\n\nThen you have to separate words from one another,\n还要把不同的词分开\n\nfigure out when sentences begin and end...\n弄清句子的开始和结束点\n\nand ultimately, you end up with speech converted into text,\n最后把语音转成文字\n\nallowing for techniques like we discussed at the beginning of the episode.\n使这集视频开头里讨论的那些技术成为可能\n\nBecause people say words in slightly different ways,\n因为口音和发音错误等原因\n\ndue to things like accents and mispronunciations,\n人们说单词的方式略有不同\n\ntranscription accuracy is greatly improved when combined with a language model,\n所以结合语言模型后，语音转文字的准确度会大大提高\n\nwhich contains statistics about sequences of words.\n里面有单词顺序的统计信息\n\nFor example \"she was\" is most likely to be followed by an adjective, like \"happy\".\n比如：\"她\"后面很可能跟一个形容词，\\N 比如\"很开心\"\n\nIt's uncommon for \"she was\" to be followed immediately by a noun.\n\"她\"后面很少是名词\n\nSo if the speech recognizer was unsure between, \"happy\" and \"harpy\",\n如果不确定是 happy 还是 harpy，会选 happy\n\nit'd pick \"happy\",\n如果不确定是 happy 还是 harpy，会选 happy\n\nsince the language model would report that as a more likely choice.\n因为语言模型认为可能性更高\n\nFinally, we need to talk about Speech Synthesis,\n最后, 我们来谈谈 \"语音合成\"\n\nthat is, giving computers the ability to output speech.\n让计算机输出语音\n\nThis is very much like speech recognition, but in reverse.\n它很像语音识别，不过反过来\n\nWe can take a sentence of text, and break it down into its phonetic components,\n把一段文字，分解成多个声音\n\nand then play those sounds back to back, out of a computer speaker.\n然后播放这些声音\n\nYou can hear this chaining of phonemes very clearly with older speech synthesis technologies,\n早期语音合成技术，可以清楚听到音素是拼在一起的\n\nlike this 1937, hand-operated machine from Bell Labs.\n比如这个1937年贝尔实验室的手动操作机器\n\nSay, \"she saw me\" with no expression.\n不带感情的说\"她看见了我\"\n\nShe saw me.\n她看见了我\n\nNow say it in answer to these questions.\n现在回答问题\n\nWho saw you?\n谁看见你了？\n\nShe saw me.\n她看见了我\n\nWho did she see?\n她看到了谁？\n\nShe saw me.\n她看见了我\n\nDid she see you or hear you?\n她看到你还是听到你说话了？\n\nShe saw me.\n她看见了我\n\nBy the 1980s, this had improved a lot,\n到了1980年代，技术改进了很多\n\nbut that discontinuous and awkward blending of phonemes\n但音素混合依然不够好，产生明显的机器人声\n\nstill created that signature, robotic sound.\n但音素混合依然不够好，产生明显的机器人声\n\nThriller was released in 1983 and sung by Michael Jackson.\nThriller 于1983年发行，迈克尔·杰克逊 演唱.\n\nToday, synthesized computer voices, like Siri, Cortana and Alexa,\n如今，电脑合成的声音，比如 Siri, Cortana, Alexa\n\nhave gotten much better, but they're still not quite human.\n好了很多，但还不够像人\n\nBut we're soo soo close,\n但我们非常非常接近了\n\nand it's likely to be a solved problem pretty soon.\n这个问题很快会被解决\n\nEspecially because we're now seeing an explosion of voice user interfaces on our phones,\n现在语音界面到处都是，手机里\n\nin our cars and homes, and maybe soon, plugged right into our ears.\n汽车里，家里，也许不久之后耳机也会有.\n\nThis ubiquity is creating a positive feedback loop,\n这创造一个正反馈循环\n\nwhere people are using voice interaction more often,\n人们用语音交互的频率会提高\n\nwhich in turn, is giving companies like Google, Amazon and Microsoft\n这又给了谷歌，亚马逊，微软等公司\n\nmore data to train their systems on.\n更多数据来训练语音系统.\n\nWhich is enabling better accuracy,\n提高准确性\n\nwhich is leading to people using voice more,\n准确度高了，人们更愿意用语音交互\n\nwhich is enabling even better accuracy and the loop continues!\n越用越好，越好越用\n\nMany predict that speech technologies will become as common a form of interaction\n很多人预测，语音交互会越来越常见\n\nas screens, keyboards, trackpads and other physical input-output devices that we use today.\n就像如今的屏幕，键盘，触控板等设备\n\nThat's particularly good news for robots,\n这对机器人发展是个好消息\n\nwho don't want to have to walk around with keyboards in order to communicate with humans.\n机器人就不用走来走去时  带个键盘和人类沟通\n\nBut, we'll talk more about them next week. See you then.\n下周我们讲机器人.  到时见\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n嗨，我是 Carrie Anne，欢迎收看计算机速成课\n\nToday we’re going to talk about robots.\n今天 我们要讨论机器人\n\nThe first image that jumps to your mind is probably a humanoid robot,\n你脑中冒出来的第一个印象估计是 类人机器人\n\nlike we usually see in shows or movies.\n经常在电视剧和电影里看到.\n\nSometimes they’re our friends and colleagues,\n有时候它们是朋友和同事\n\nbut more often, they're sinister, apathetic and battle-hardened.\n但更常见的是阴险无情，身经百战\n\nWe also tend to think of robots as a technology of the future.\n我们经常把机器人看成未来科技\n\nBut the reality is: they’re already here – by the millions\n但事实是：机器人时代已经来临了\n\n– and they're our workmates,\n- 它们是同事\n\nhelping us to do things harder, better, faster, and stronger.\n帮我们把困难的工作，做得更快更好\n\nThere are many definitions for robots, but in general,\n机器人的定义有很多种，但总的来说，\n\nthese are machines capable of carrying out a series of actions automatically\n机器人由计算机控制，可以自动执行一系列动作的机器\n\nguided by computer control.\n机器人由计算机控制，可以自动执行一系列动作的机器\n\nHow they look isn’t part of the equation –\n外观并不重要\n\nrobots can be industrial arms that spray paint cars,\n可以是给汽车喷漆的机械臂\n\ndrones that fly, snake-like medical robots that assist surgeons,\n无人机，或辅助外科医生的蛇状机器人\n\nas well as humanoid robotic assistants.\n以及人形机器人\n\nAlthough the term \"robot\" is sometimes\n有时我们叫虚拟人物\"机器人\"\n\napplied to interactive virtual characters,\n有时我们叫虚拟人物\"机器人\"\n\nit’s more appropriate to call these \"bots\", or even better, \"agents.\"\n但叫 bot 甚至 agent 会更合适\n\nThat’s because the term \"robot\" carries a physical connotation\n因为\"机器人\"的潜在含义是  存在于现实世界中的机器\n\na machine that lives in and acts on the real world.\n因为\"机器人\"的潜在含义是  存在于现实世界中的机器\n\nThe word \"robot\" was first used in a 1920 Czech play\nrobot (机器人) 一词 \\N 首次出现在1920年的一部捷克戏剧\n\nto denote artificial, humanoid characters.\n代表人造的类人角色\n\nThe word was derived from \"robota\", the slavic-language word for a forced laborer,\nrobot 源于斯拉夫语词汇 robota  \\N 代表强迫劳动\n\nindicating peasants in compulsory service in feudal, nineteenth century Europe.\n代表农民在十九世纪 \\N 欧洲封建社会的强迫劳动\n\nThe play didn’t go too much into technological details.\n戏剧没讲太多技术细节\n\nBut, even a century later, it’s still a common portrayal:\n但即使一个世纪后，这种描述依然很普遍：\n\nmass-produced, efficient, tireless creatures that look human-esque,\n机器人都是大规模生产，高效不知疲倦，看起来像人的东西\n\nbut are emotionless, indifferent to self-preservation and lack creativity.\n但毫无情感，不会保护自己，没有创造力\n\nThe more general idea of self-operating machines\n更广义的自动运行机器，早在1920年代前就有了\n\ngoes back even further than the 1920s.\n更广义的自动运行机器，早在1920年代前就有了\n\nMany ancient inventors created mechanical devices that\n很多古代发明家 \\N 发明了能自动运行的机械装置\n\nperformed functions automatically,\n很多古代发明家 \\N 发明了能自动运行的机械装置\n\nlike keeping the time and striking bells on the hour.\n比如计时和定时敲钟\n\nThere are plenty of examples of automated animal and humanoid figures,\n有很多装置 有动物和人类的形象 \\N 能跳舞，唱歌，打鼓等\n\nthat would perform dances, sing songs, strike drums and do other physical actions.\n有很多装置 有动物和人类的形象 \\N 能跳舞，唱歌，打鼓等\n\nThese non-electrical and certainly non-electronic machines were called automatons.\n这些不用电，而且肯定没有电子部件的机器，叫\"自动机\"\n\nFor instance, an early automaton created in 1739\n举个例子 \\N 1739年法国人 Jacques de Vaucans 做了个自动机\n\nby the Frenchman Jacques de Vaucanson\n举个例子 \\N 1739年法国人 Jacques de Vaucans 做了个自动机\n\nwas the Canard Digerateur or Digesting Duck,\n法语叫 Canard Digerateur，翻译过来是 \"吃饭鸭\"\n\na machine in the shape of a duck that appeared\n一个像鸭子的机器，能吃东西然后排便\n\nto eat grain and then defecate.\n一个像鸭子的机器，能吃东西然后排便\n\nIn 1739 Voltaire wrote,\n伏尔泰在1739年写\n\n\"Without the voice of le Maure and Vaucanson’s duck,\n\"如果没有吃饭鸭的声音\n\nyou would have nothing to remind you of the glory of France.\"\n还有什么能提醒你法国的荣光呢？\"\n\nOne of the most infamous examples was the \"Mechanical Turk\":\n一个名声很臭的例子是\"土耳其行棋傀儡\"\n\na chess-playing, humanoid automaton.\n一个能下国际象棋的人形机器人\n\nAfter construction in 1770, it toured all over Europe,\n在1770年建造完成后，就在欧洲各地展览\n\nwowing audiences with its surprisingly good chess-playing.\n好棋艺惊叹观众\n\nIt appeared to be a mechanical, artificial intelligence.\n像某种机械人工智能\n\nUnfortunately, it was a hoax – there was a dainty human stuffed inside the machine.\n不幸的是，这是个骗局 - 机器里有人控制\n\nThe first machines controlled by computers emerged in the late 1940s.\n第一台计算机控制的机器，出现在1940年代晚期\n\nThese Computer Numerical Control, or CNC machines,\n这些计算机数控的机器，简称 CNC 机器\n\ncould run programs that instructed a machine to perform a series of operations.\n可以执行一连串 程序指定的操作\n\nThis level of control also enabled the creation of new manufactured goods,\n精细的控制 让我们能生产之前很难做的物品\n\nlike milling a complex propellor design out of a block of aluminum\n比如从一整块铝 加工出复杂的螺旋桨\n\n– something that was difficult to do using standard machine tools,\n- 这用普通机械工具很难做到\n\nand with tolerances too small to be done by hand.\n并且误差容忍度很小，无法手工加工\n\nCNC machines were a huge boon to industry,\nCNC 机器大大推进了制造业\n\nnot just due to increased capability and precision,\n不仅提高了制造能力和精确度 还降低了生产成本\n\nbut also in terms of reducing labor costs by automating human jobs\n不仅提高了制造能力和精确度 还降低了生产成本\n\n– a topic we'll revisit in a later episode.\n- 我们之后会深入讨论这个（第40集）\n\nThe first commercial deployment was a programmable industrial robot\n第一个商业贩卖的 可编程工业机器人\n\ncalled the Unimate, sold to General Motors in 1960\n叫 Unimate，于1960年卖给通用汽车公司\n\nto lift hot pieces of metal from a die casting machine and stack them.\n它可以把压铸机做出来的热金属成品提起来，然后堆起来\n\nThis was the start of the robotics industry.\n机器人行业由此开始\n\nSoon, robots were stacking pallets, welding parts, painting cars and much more.\n很快，机器人开始堆叠货盘，焊接，给汽车喷漆等等\n\nFor simple motions – like a robotic gripper that moves back and forth on a track\n对于简单运动 - 比如机器爪子 在轨道上来回移动\n\na robot can be instructed to move to a particular position,\n可以指示它移动到特定位置\n\nand it'll keep moving in that direction until the desired position is reached\n它会一直朝那个方向移动，直到到达 \\N 然后停下来\n\nat which point it’ll stop.\n它会一直朝那个方向移动，直到到达 \\N 然后停下来\n\nThis behavior can be achieved through a simple control loop.\n这种行为 可以用简单控制回路做\n\nFirst, sense the robot position.\n首先，判断机器人的位置\n\nAre we there yet?\n我们到了吗？\n\nNope.\n没有\n\nSo keep moving.\n那么继续前进\n\nNow sense position again.\n再次判断位置\n\nAre we there yet?\n我们到了吗？\n\nNope, so keep moving.\n没有，所以继续前进\n\nAre we there yet?\n我们到了吗？\n\nYes!\n是的!\n\nSo we can stop moving, and also please be quiet!\n现在可以停下来了，别问了！\n\nBecause we’re trying to minimize the distance between\n因为我们在不断缩小 当前位置和目标位置的距离\n\nthe sensed position and the desired position,\n因为我们在不断缩小 当前位置和目标位置的距离\n\nthis control loop is, more specifically, a negative feedback loop.\n这个控制回路 更准确的叫\"负反馈回路\"\n\nA negative feedback control loop has three key pieces.\n负反馈回路 有三个重要部分\n\nThere’s a sensor, that measures things in the real world,\n首先是一个传感器，可以测量现实中的东西\n\nlike water pressure, motor position, air temperature,\n比如水压，马达位置，气温，\n\nor whatever you’re trying to control.\n或任何你想控制的东西\n\nFrom this measurement, we calculate how far we are from\n根据传感器，计算和目标值相差多大\n\nwhere we want to be – the error.\n得到一个\"错误\"\n\nThe error is then interpreted by a controller,\n然后\"控制器\"会处理这个\"错误\"\n\nwhich decides how to instruct the system to minimize that error.\n决定怎么减小错误\n\nThen, the system acts on the world though pumps, motors,\n然后用泵，电机，加热元件，或其他物理组件来做出动作\n\nheating elements, and other physical actuators.\n然后用泵，电机，加热元件，或其他物理组件来做出动作\n\nIn tightly controlled environments, simple control loops, like this, work OK.\n在严格控制的环境中，这种简单控制回路也够用了\n\nBut in many real world applications, things are a tad more complicated.\n但在很多现实应用中，情况复杂得多\n\nImagine that our gripper is really heavy, and even when the control loop says to stop,\n假设爪子很重，哪怕控制回路叫停了\n\nmomentum causes the gripper to overshoot the desired position.\n惯性让爪子超过了预期位置\n\nThat would cause the control loop to take over again,\n然后控制回路又开始运行\n\nthis time backing the gripper up.\n叫爪子移动回去\n\nA badly tuned control loop might overshoot and overshoot and overshoot,\n一个糟糕的控制回路 可能会让爪子不断来回移动\n\nand maybe even wobble forever.\n甚至永远循环\n\nTo make matters worse, in real world settings,\n更糟糕的是，现实世界中\n\nthere are typically external and variable forces acting on a robot,\n机器人会受到各种外力影响\n\nlike friction, wind and items of different weight.\n比如摩擦力，风，等等\n\nTo handle this gracefully, more sophisticated control logic is needed.\n为了处理这些外力，我们需要更复杂的控制逻辑\n\nA widely used control-loop, feedback mechanism is a\n一个使用广泛的机制，有控制回路和反馈机制。\n\nproportional–integral–derivative controller.\n叫 \"比例-积分-微分控制器\"\n\nThat’s a bit of a mouthful, so people call them PID controllers.\n这个有点绕口，所以一般简称 \"PID控制器\"\n\nThese used to be mechanical devices, but now it’s all done in software.\n它以前是机械设备，现在全是纯软件了\n\nLet’s imagine a robot that delivers coffee.\n想象有一个机器人，端咖啡给客人\n\nIts goal is to travel between customers at two meters per second,\n设计目标是 每秒两米的速度在顾客间穿行\n\nwhich has been determined to be the ideal speed\n这个速度是理想速度\n\nthat’s both safe and expedient.\n安全又合适\n\nOf course, the environment doesn’t always cooperate.\n当然，环境是会变化的\n\nSometimes there’s wind, and sometimes there's uphills and downhills\n有时候有风，有时候有上坡下坡\n\nand all sorts of things that affect the speed of the robot.\n以及其他影响机器人速度的因素\n\nSo, it’s going to have to increase and decrease power\n所以，给马达的动力要加大或减少，以保持目标速度\n\nto its motors to maintain the desired speed.\n所以，给马达的动力要加大或减少，以保持目标速度\n\nUsing the robot's speed sensor, we can keep track of its\n用机器人的速度传感器，我们可以\n\nactual speed and plot that alongside its desired speed.\n把当前速度和目标速度画张图\n\nPID controllers calculate three values from this data.\nPID 控制器根据这些数据，算出3个值\n\nFirst is the proportional value, which is the difference between\n首先是\"比例值\"，就是\"实际值\"和\"理想值\"差多少\n\nthe desired value and the actual value\n首先是\"比例值\"，就是\"实际值\"和\"理想值\"差多少\n\nat the most recent instant in time or the present.\n\"实际值\"可能有一定滞后，或者是实时的。\n\nThis is what our simpler control loop used before.\n之前的简单控制回路，用的就是这个值\n\nThe bigger the gap between actual and desired,\n\"实际值\"和\"理想值\"的差距越大，\n\nthe harder you'll push towards your target.\n就越用力\n\nIn other words, it’s proportional control.\n换句话说，它是\"比例控制\"的\n\nNext, the integral value is computed,\n接下来，算\"积分值\"\n\nwhich is the sum of error over a window of time,\n就是一段时间内 误差的总和\n\nlike the last few seconds.\n比如最近几秒\n\nThis look back helps compensate for steady state errors,\n帮助弥补误差\n\nresulting from things like motoring up a long hill.\n比如上坡时可能就会产生误差\n\nIf this value is large, it means proportional control is not enough,\n如果这个值很大，说明比例控制不够，\n\nand we have to push harder still.\n要继续用力前进\n\nFinally, there’s the derivative value,\n最后有\"导数值\"\n\nwhich is the rate of change between the desired and actual values.\n是期望值与实际值之间的变化率\n\nThis helps account for possible future error,\n有助于解决 未来可能出现的错误，\n\nand is sometimes called \"anticipatory control\".\n有时也叫\"预期控制\"\n\nFor example, if you are screaming in towards your goal too fast,\n比如前进的太快\n\nyou'll need to ease up a little to prevent overshoot.\n要稍微放松一点，避免冲过头\n\nThese three values are summed together, with different relative weights,\n这三个值会一起使用，它们有不同权重\n\nto produce a controller output that’s passed to the system.\n然后用来控制系统\n\nPID controllers are everywhere,\nPID 控制器到处都是\n\nfrom the cruise control in your car,\n比如汽车里的巡航控制\n\nto drones that automatically adjust their rotor speeds to maintain level flight,\n无人机调整螺旋桨速度，以保持水平\n\nas well as more exotic robots,\n以及一些更奇怪的机器人，\n\nlike this one that balances on a ball to move around.\n比如这个用球来平衡和移动的机器人\n\nAdvanced robots often require many control loops running in parallel,\n更高级的机器人一般需要多个控制回路同时运行\n\nworking together, managing everything from robot balance to limb position.\n来保持机器人平衡，调整肢体位置，等等\n\nAs we’ve discussed, control loops are responsible for\n之前说过，控制回路负责\n\ngetting robot attributes  like location to desired values.\n把机器人的属性（比如当前位置）变成期望值\n\nSo, you may be wondering where these values come from.\n你可能好奇这些值 是哪里来的\n\nThis is the responsibility of higher-level robot software,\n这是更高层软件的责任\n\nwhich plans and executes robot actions,\n软件负责做出计划 并让机器人执行动作，\n\nlike plotting a path around sensed obstacles, or breaking down physical tasks,\n比如制定一条路线来绕过障碍物，或者把任务分成一步步\n\nlike picking up a ball, into simple, sequential motions.\n比如把拿起一个球，分解成一个个简单连续动作\n\nUsing these techniques, robots have racked up some impressive achievements\n用这些技术，机器人已经取得不少令人印象深刻的成就\n\n– they've been to the deepest depths of Earth's oceans\n- 它们潜到了海洋最深处\n\nand roved around on Mars for over a decade.\n在火星上跑了十几年\n\nBut interestingly, lots of problems that are trivial for many humans\n但有趣的是，许多对人类来说很简单的任务\n\nhave turned out to be devilishly difficult for robots:\n对机器人很困难：\n\nlike walking on two legs, opening a door, picking up objects\n比如两条腿走路，开门，拿东西时不要捏碎了\n\nwithout crushing them, putting on a t-shirt, or petting a dog.\n或是穿T恤，或是摸狗\n\nThese are tasks you may be able to do without thinking,\n这些你可能想都不用想\n\nbut a supercomputer-powered robot fails at spectacularly.\n但有超级计算机能力的机器人却做不到\n\nThese sorts of tasks are all active areas of robotics research.\n机器人研究领域在全力解决这些问题\n\nArtificial intelligence techniques,\n我们前几集聊过的 人工智能\n\nwhich we discussed a few episodes ago, are perhaps\n我们前几集聊过的 人工智能\n\nthe most promising avenue to overcome these challenges.\n最有可能解决这些问题\n\nFor example, Google has been running an experiment\n例如，谷歌在进行一项实验\n\nwith a series of robotic arms that spend their days\n让一堆机器人手臂把各种东西\n\nmoving miscellaneous objects from one box to another, learning from trial and error.\n从一个盒子拿到另一个盒子，不断试错学习\n\nAfter thousands of hours of practice, the robots had cut their error rate in half.\n经过数千小时的练习，机器人把错误率降低了一半\n\nOf course, unlike humans, robots can run twenty-four hours a day\n不像人类，机器人可以24小时全天运行\n\nand practice with many arms at the same time.\n而且多个手臂同时练习\n\nSo, it may just be a matter of time until they become adept at grasping things.\n所以机器人擅长抓东西只是时间问题\n\nBut, for the time being, toddlers can out-grasp them.\n但现在，小婴儿都比机器人更会抓东西\n\nOne of the biggest and most visible robotic breakthrough\n近年最大的突破之一\n\nin recent years has been self-driving, autonomous cars.\n是无人驾驶汽车\n\nIf you think about it, cars don’t have too many system inputs\n如果你仔细想想，汽车没几个输入\n\n– you can speed up or slow down, and you can steer left or right.\n- 只是加速减速，左转右转\n\nThe tough part is sensing lanes, reading signs,\n难的问题是 判断车道，理解路标\n\nand anticipating and navigating traffic, pedestrians,\n预测车流，车流中穿行，留心行人和骑自行车的。\n\nbicyclists, and a whole host of obstacles.\n以及各种障碍\n\nIn addition to being studded with proximity sensors,\n车上布满了传感器\n\nthese robotic vehicles heavily rely\n无人驾驶汽车非常依赖\n\non Computer Vision algorithms, which we discussed in Episode 35.\n计算机视觉算法，我们在第35集讨论过\n\nWe’re also seeing the emergence of very primitive androids\n现在也开始出现类人机器人\n\n– robots that look and act like humans.\n- 外貌和行为像人类的机器人\n\nArguably, we’re not close on either of those goals,\n不过现在两个目标都没接近（外貌和行为）\n\nas they tend to look pretty weird and act even weirder.\n因为看起来一般怪怪的，行为也怪怪的.\n\nAt least we’ll always have Westworld.\n但至少有《西部世界》可以看看\n\nBut anyway, these remain a tantalizing goal for roboticists\n无论如何，对机器人研究者来说，把各种技术结合起来\n\ncombine many computer science topics\n比如人工智能，计算机视觉和自然语言处理\n\nwe’ve touched on over the last few episodes, like artificial intelligence,\n比如人工智能，计算机视觉和自然语言处理\n\ncomputer vision and natural language processing.\n来让机器人越来越像人，是个诱人的目标\n\nAs for why humans are so fascinated by\n至于人类为什么如此着迷 做出和我们一样的机器人\n\ncreating artificial embodiments of ourselves.\n至于人类为什么如此着迷 做出和我们一样的机器人\n\nyou'll have to go to Crash Course Philosophy for that.\n你得去看《哲学速成课》\n\nAnd for the foreseeable future,\n在未来好一段时间里\n\nrealistic androids will continue to be the stuff of science fiction.\n和人类一样的机器人 依然只能存在科幻小说里。\n\nMilitaries also have a great interest in robots –\n军队也对机器人很有兴趣 -\n\nthey're not only replaceable, but can surpass humans\n因为机器人可以替换，\n\nin attributes like strength, endurance, attention, and accuracy.\n而且力量，耐力，注意力，准确性可以远超人类\n\nBomb disposal robots and reconnaissance drones are fairly common today.\n拆弹机器人和无人侦察机如今很常见\n\nBut fully autonomous, armed-to-the-teeth robots are slowly appearing,\n但完全自主决定，全副武装的机器人也在慢慢出现\n\nlike the Samsung SGR-A1 sentry gun deployed by South Korea.\n比如韩国的三星 SGR-A1 哨兵炮\n\nRobots with the intelligence and capability to take human lives\n有智力并且可以杀人的机器人\n\nare called lethal autonomous weapons.\n叫 \"致命自主武器\"\n\nAnd they’re widely considered a complex and thorny issue.\n这种武器是复杂又棘手的问题\n\nWithout doubt, these systems could save soldiers lives\n毫无疑问，它们可以把士兵从战场带离 挽救生命\n\nby taking them off the battlefield and out of harm’s way.\n毫无疑问，它们可以把士兵从战场带离 挽救生命\n\nIt might even discourage war all together.\n甚至阻止战争的发生\n\nThough it’s worth noting that people said the same thing\n值得注意的是 人们对炸药和核弹也说过一样的话\n\nabout dynamite and nuclear weapons.\n值得注意的是 人们对炸药和核弹也说过一样的话\n\nOn the flip side, we might be creating ruthlessly\n另一方面，我们可能会不小心创造出 \\N 无情又高效的杀人机器\n\nefficient killing machines that don't apply human judgment\n没有人类般的判断力和同情心\n\nor compassion to complex situations.\n没有人类般的判断力和同情心\n\nAnd the fog of war is about as complex and murky as they come.\n战争的硝烟会变得更加黑暗和复杂\n\nThese robots would be taking orders and executing them\n机器人会接受命令并高效执行\n\nas efficiently as they can and sometimes\n机器人会接受命令并高效执行\n\nhuman orders turn out to be really bad.\n但有时人类的命令是错的\n\nThis debate is going to continue for a long time,\n这场辩论会持续很长时间，\n\nand pundits on both sides will grow louder as robotic technology improves.\n而且随着机器人技术的进步，两边的辩论会越来越激烈\n\nIt’s also an old debate –\n这也是个老话题了\n\nthe danger was obvious to science fiction writer Isaac Asimov,\n科幻作家 艾萨克·阿西莫夫 早预见了这种危险\n\nwho introduced a fictional \"Three Laws of Robotics\" in his 1942 short story \"Runaround\".\n他在1942年短篇小说 Runaround 中写了\"机器人三定律\"\n\nAnd then, later he added a zeroth rule.\n之后又加了\"定律0\"\n\nIn short, it’s a code of conduct or moral compass for robots –\n简单说 这些定律指导机器人的行为准则 或者说道德指南\n\nguiding them to do no harm, especially to humans.\n让机器人不要伤害，特别是不要伤害人类\n\nIt’s pretty inadequate for practical application and it leaves plenty of room for equivocation.\n这些规则实践起来相当不足，并且有很多模糊的地方\n\nBut still, Asimov’s laws inspired a ton of science fiction and academic discussion,\n但阿西莫夫三定律 激发了大量科幻小说讨论和学术讨论，\n\nand today there are whole conferences on robot ethics.\n如今有专门讨论机器人伦理的会议\n\nImportantly, Asimov crafted his fictional rules\n重要的是，阿西莫夫写这些虚构规则\n\nas a way to push back on \"Robot as a Menace\" memes\n是为了反对 \"机器人都很邪恶\" 这种常见描述\n\ncommon in fiction from his childhood.\n他童年读的小说里，这样的场景很常见\n\nThese were stories where robots went off the rails,\n机器人脱离控制，然后伤害甚至毁灭创造者\n\nharming or even destroying their creators in the process.\n机器人脱离控制，然后伤害甚至毁灭创造者\n\nAsimov, on the other hand, envisioned robots as useful,\n阿西莫夫认为 机器人有用，可靠，甚至可以让人喜爱\n\nreliable, and even loveable machines.\n阿西莫夫认为 机器人有用，可靠，甚至可以让人喜爱\n\nAnd it’s this duality I want to leave you thinking about today.\n我想让你思考这种两面性\n\nLike many of the technologies we’ve discussed throughout this series,\n我们讨论过的许多技术，有好的一面也有坏的一面\n\nthere are benevolent and malicious uses.\n我们讨论过的许多技术，有好的一面也有坏的一面\n\nOur job is to carefully reflect on computing's potential and peril,\n我们要认真思考计算机的潜力和危害\n\nand wield our inventive talents to improve the state of the world.\n来改善这个世界\n\nAnd robots are one of the most potent reminders of this responsibility.\n而机器人最能提醒我们这一点了\n\nI’ll see you next week.\n我 们 下 周 见\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nSo, over the course of this series,\n在这个系列中，\n\nwe’ve focused almost exclusively on computers –\n我们聊的话题几乎全是计算机-比如电路和算法\n\nthe circuits and algorithms that make them tick.\n我们聊的话题几乎全是计算机-比如电路和算法\n\nBecause...this is Crash Course Computer Science.\n毕竟这是*计算机*速成课\n\nBut ultimately, computers are tools employed by people.\n但归根结底，计算机只是给人用的工具\n\nAnd humans are… well… messy.\n而人类有点... 乱\n\nWe haven’t been designed by human engineers from the ground up\n人类不是被工程师设计的，没有具体性能规格\n\nwith known performance specifications.\n人类不是被工程师设计的，没有具体性能规格\n\nWe can be logical one moment and irrational the next.\n我们一会儿是理性的，一会儿是不理性的\n\nHave you ever gotten angry at your navigation system? Surfed wikipedia aimlessly?\n你有没有对导航生过气？或是漫无目的的刷维基百科？\n\nBegged your internet browser to load faster?\n求浏览器加载快点？\n\nNicknamed your roomba?\n给扫地机器人取名？\n\nThese behaviors are quintessentially human!\n这些是人类行为！\n\nTo build computer systems that are useful, usable and enjoyable,\n为了做出使用愉快的计算机\n\nwe need to understand the strengths and weaknesses of both computers and humans.\n我们需要了解计算机和人类的优缺点\n\nAnd for this reason, when good system designers are creating software,\n优秀的系统设计师在创造软件时\n\nthey employ social, cognitive, behavioral, and perceptual psychology principles.\n会运用社会心理学，认知心理学，\\N 行为心理学，感知心理学的原理\n\nNo doubt you’ve encountered a physical or computer interface\n你肯定见过难用的物理界面/计算机界面 \\N 阻碍你做事\n\nthat was frustrating to use, impeding your progress.\n你肯定见过难用的物理界面/计算机界面 \\N 阻碍你做事\n\nMaybe it was so badly designed that you couldn’t figure it out and just gave up.\n甚至糟糕到放弃使用\n\nThat interface had poor usability.\n那个界面的\"易用度\"很差\n\nUsability is the degree to which a human-made artifact – like software\n\"易用度\"指的是人造物体，比如软件 \\N 达到目的的效率有多高\n\n– can be used to achieve an objective effectively and efficiently.\n\"易用度\"指的是人造物体，比如软件 \\N 达到目的的效率有多高\n\nTo facilitate human work, we need to understand humans\n为了帮助人类工作，我们需要了解人类 \\N  - 怎么看，思考，反应和互动\n\n- from how they see and think, to how they react and interact.\n为了帮助人类工作，我们需要了解人类 \\N  - 怎么看，思考，反应和互动\n\nFor instance, the human visual system has been well studied by Psychologists.\n举个例子，心理学家已经对 \\N 人类的视觉系统做了全面的研究\n\nLike, we know that people are good at ordering intensities of colors.\n我们知道人类擅长给颜色强度排序\n\nHere are three.\n这里有三个颜色\n\nCan you arrange these from lightest to darkest?\n你能从浅色到深色排序吗？\n\nYou probably don’t have to think too much about it.\n你可以轻易做到\n\nBecause of this innate ability, color intensity is a great choice\n所以颜色强度很适合显示连续值\n\nfor displaying data with continuous values.\n所以颜色强度很适合显示连续值\n\nOn the other hand, humans are terrible at ordering colors.\n另一方面，人类很不擅长排序颜色\n\nHere’s another example for you to put in order.\n这是另一个例子\n\nis orange before blue, or after blue?\n把橙色放到蓝色前面还是后面？绿色放哪里？\n\nWhere does green go?\n把橙色放到蓝色前面还是后面？绿色放哪里？\n\nYou might be thinking we could order this by wavelength of light,\n你可能想通过光的波长排序 \\N 就像彩虹一样，但这样太累了\n\nlike a rainbow, but that’s a lot more to think about.\n你可能想通过光的波长排序 \\N 就像彩虹一样，但这样太累了\n\nMost people are going to be much slower and error-prone at ordering.\n大部分人会很慢而且容易出错\n\nBecause of this innate ineptitude of your visual system,\n由于视觉系统天生是这样\n\ndisplaying continuous data using colors can be a disastrous design choice.\n所以用不同颜色显示连续性数据，是个糟糕的选择\n\nYou’ll find yourself constantly referring back to a color legend to compare items.\n你得经常看表格来对比数据\n\nHowever, colors are perfect for when the data is discrete with no ordering,\n然而，如果数据没有顺序，用不同颜色就很合适\n\nlike categorical data.\n比如分类数据\n\nThis might seem obvious, but you’d be amazed at\n也许这些看起来很明显 \\N 但你会惊讶有多少设计把这些基本事情搞错\n\nhow many interfaces get basic things like this wrong.\n也许这些看起来很明显 \\N 但你会惊讶有多少设计把这些基本事情搞错\n\nBeyond visual perception, understanding human cognition helps us\n除了视觉 \\N 理解人类的认知系统能帮我们设计更好的界面\n\ndesign interfaces that align with how the mind works.\n除了视觉 \\N 理解人类的认知系统能帮我们设计更好的界面\n\nLike, humans can read, remember and process information more effectively\n比如，如果信息分块了 \\N 会更容易读，更容易记\n\nwhen it's chunked–that is, when items are put together into small, meaningful groups.\n分块是指把信息分成更小，更有意义的块\n\nHumans can generally juggle seven items, plus-or-minus two, in short-term memory.\n人类的短期记忆能记住5到9个东西\n\nTo be conservative, we typically see groupings of five or less.\n保守一点，分组一般是5个或更少\n\nThat’s why telephone numbers are broken into chunks, like 317, 555, 3897.\n所以电话号码一般分块，比如 317-555-3897\n\nInstead of being ten individual digits that we’d likely forget, it’s three chunks,\n10个连续数可能会忘，分成3块更好记\n\nwhich we can handle better.\n10个连续数可能会忘，分成3块更好记\n\nFrom a computer's standpoint, this needlessly takes more time and space,\n从计算机的角度来看，分块更费时费空间\n\nso it's less efficient.\n效率更低\n\nBut, it’s way more efficient for us humans –\n但这对人类更有效率\n\na tradeoff we almost always make in our favor,\n- 碰到这种抉择时，我们总是以人类优先\n\nsince we’re the ones running the show...for now.\n现在我们还是老大.. 暂时啦\n\nChunking has been applied to computer interfaces for things\n界面设计用了分块 \\N 比如下拉菜单 和带按钮的菜单栏\n\nlike drop-down menu items and menu bars with buttons.\n界面设计用了分块 \\N 比如下拉菜单 和带按钮的菜单栏\n\nIt’d be more efficient for computers to just pack all those together, edge to edge\n对电脑来说，全部挤在一起更有效率\n\n– it’s wasted memory and screen real estate.\n分块浪费内存 浪费屏幕\n\nBut designing interfaces in this way makes them much easier\n但这样设计更容易扫视，记住和访问\n\nto visually scan, remember and access.\n但这样设计更容易扫视，记住和访问\n\nAnother central concept used in interface design is affordances.\n界面设计中另一个重点概念是\"直观功能\"\n\nAccording to Don Norman, who popularized the term in computing,\nDon Norman 让这个词在计算机界流行起来，根据他的说法\n\n\"affordances provide strong clues to the operations of things.\n\"直观功能 为如何操作物体提供线索\n\nPlates are for pushing.\n平板用来推\n\nKnobs are for turning.\n旋钮用来转\n\nSlots are for inserting things into.\n插槽用来插东西\n\n[...] When affordances are taken advantage of, the user knows what to do just by looking:\n[...]直观功能做的好，用户只需要看一眼就知道怎么做：\n\nno picture, label, or instruction needed.\"\n不需要图片，标签或指南来说明\"\n\nIf you’ve ever tried to pull a door handle, only to realize that you have to push it open,\n如果你拉过门把手打不开，然后意识到要推开才对\n\nyou’ve discovered a broken affordance.\n那么你发现了一个坏掉的\"直观功能\"\n\nOn the other hand, a door plate is a better design\n平板是更好的设计\n\nbecause it only gives you the option to push.\n因为只能推开\n\nDoors are pretty straightforward – if you need to put written instructions on them,\n门是简单的东西，如果你要贴指示让人们明白怎么用.\n\nyou should probably go back to the drawing board.\n那么也许你应该重新设计\n\nAffordances are used extensively in graphical user interfaces,\n\"直观功能\"广泛用于图形界面\n\nwhich we discussed in episode 26.\n我们在第26集讨论过\n\nIt’s one of the reasons why computers became so much easier to use than with command lines.\n这是图形界面比命令行更容易用的原因之一\n\nYou don’t have to guess what things on-screen are clickable, because they look like buttons.\n你不用猜测屏幕上什么东西是可点的，\\N 可点的会看起来像按钮\n\nThey pop out, just waiting for you to press them!\n他们弹出来，只是等着你压他们！\n\nOne of my favorite affordances, which suggests to users that an on-screen element is draggable,\n我最喜欢的\"直观功能\"之一，是向用户表明元素是可拖动的\n\nis knurling – that texture added to objects\n\"滚花\" - 一种视觉纹理\n\nto improve grip and show you where to best grab them.\n告诉用户哪里可以拖动\n\nThis idea and pattern was borrowed from real world physical tools.\n这个点子来自现实世界中的工具\n\nRelated to the concept of affordances is the psychology of recognition vs recall.\n和\"直观功能\"相关的一个心理学概念是 \"认出与回想\"\n\nYou know this effect well from tests –\n如果你考过试，肯定感受过这个\n\nit's why multiple choice questions are easier than fill-in-the-blank ones.\n这就是为什么选择题比填空题容易\n\nIn general, human memory is much better when it’s triggered by a sensory cue,\n一般来说，用感觉来触发记忆会容易得多\n\nlike a word, picture or sound.\n比如文字，图片或声音\n\nThat’s why interfaces use icons – pictorial representations of functions\n所以我们用图标代表功能\n\n– like a trash can for where files go to be deleted.\n- 比如\"垃圾桶\"图标 代表里面放着被删除的文件\n\nWe don’t have to recall what that icon does, we just have to recognise the icon.\n我们不用去回想图标的功能是什么，只要能认出来就行了\n\nThis was also a huge improvement over command line interfaces,\n比命令行好得多\n\nwhere you had to rely on your memory for what commands to use.\n命令行得依靠记忆来输命令\n\nDo I have to type \"delete\", or \"remove\", or... \"trash\", or… shoot, it could be anything!\n到底是输入\"删除\"\"移除\"\"垃圾\"还是\"射出\"？\\N 可能是任何命令！\n\nIt’s actually \"rm\" in linux,\n顺带一说，在 Linux 里删除文件的命令是 \"rm\"\n\nbut anyway, making everything easy to discover and learn sometimes means slow to access,\n回到正题，\\N 让所有菜单选项好找好记，有时候意味着用的时候会慢一些\n\nwhich conflicts with another psychology concept: expertise.\n这与另一个心理学概念冲突：\"专业知识\"\n\nAs you gain experience with interfaces, you get faster,\n当你用界面熟悉之后，速度会更快一些\n\nbuilding mental models of how to do things efficiently.\n建立如何高效完成事情的\"心理模型\"\n\nSo, good interfaces should offer multiple paths to accomplish goals.\n所以 好的界面应该提供多种方法来实现目标\n\nA great example of this is copy and paste, which can be found in the edit dropdown menu\n一个好例子是复制粘贴，可以在\"编辑\"的下拉菜单中找到\n\nof word processors, and is also triggered with keyboard shortcuts.\n也可以用快捷键\n\nOne approach caters to novices, while the other caters to experts, slowing down neither.\n一种适合新手，一种适合专家，两者都不耽误\n\nSo, you can have your cake and eat it too!\n鱼和熊掌兼得！\n\nIn addition to making humans more efficient,\n除了让人类做事更高效，\n\nwe'd also like computers to be emotionally intelligent –\n我们也希望电脑能有一点情商\n\nadapting their behavior to respond appropriately\n能根据用户的状态做出合适地反应\n\nto their users' emotional state – also called affect.\n能根据用户的状态做出合适地反应\n\nThat could make experiences more empathetic, enjoyable, or even delightful.\n让使用电脑更加愉快\n\nThis vision was articulated by Rosalind Picard in her 1995 paper on Affective Computing,\nRosalind Picard 在 1995 年关于\"情感计算\"的论文中，阐述了这一愿景\n\nwhich kickstarted an interdisciplinary field combining aspects\n这篇论文开创了心理学，社会科学和计算机科学的跨学科结合\n\nof psychology, social and computer sciences.\n这篇论文开创了心理学，社会科学和计算机科学的跨学科结合\n\nIt spurred work on computing systems that could recognize,\n促进了让计算机理解人类情感的研究\n\ninterpret, simulate and alter human affect.\n促进了让计算机理解人类情感的研究\n\nThis was a huge deal, because we know emotion influences cognition and perception\n这很重要，因为情绪会影响日常活动\n\nin everyday tasks like learning, communication, and decision making.\n比如学习，沟通和决策\n\nAffect-aware systems use sensors, sometimes worn, that capture things like speech and\n情感系统会用传感器，录声音，\n\nvideo of the face, as well as biometrics, like sweatiness and heart rate.\n录像（你的脸）以及生物指标，比如出汗和心率\n\nThis multimodal sensor data is used in conjunction with computational models that represent how\n得到的数据和计算模型结合使用\n\npeople develop and express affective states, like happiness and frustration,\n模型会写明人类如何表达情感，怎么是快乐 怎么是沮丧\n\nand social states, like friendship and trust.\n以及社交状态，比如友谊和信任\n\nThese models estimate the likelihood of a user being in a particular state,\n模型会估算用户的情绪\n\nand figure out how to best respond to that state,\n以及怎样以最好的回应用户\n\nin order to achieve the goals of the system.\n以达到目标\n\nThis might be to calm the user down, build trust, or help them get their homework done.\n比如让用户冷静下来，建立信任，或帮忙完成作业\n\nA study, looking at user affect, was conducted by Facebook in 2012.\nFacebook 在 2012 年进行了一项\"影响用户\"的研究\n\nFor one week, data scientists altered the content\n数据科学家在一个星期内\n\non hundreds of thousands of users' feeds.\n修改了很多用户 时间线上显示的内容\n\nSome people were shown more items with positive content,\n有些人会看到更多积极向上的内容\n\nwhile others were presented with more negative content.\n有些人会看到更多负面消极的内容\n\nThe researchers analyzed people's posts during that week,\n研究人员分析了那一周内人们的发帖\n\nand found that users who were shown more positive content,\n发现看到积极向上内容的用户，\n\ntended to also post more positive content.\n发的帖子往往更正面\n\nOn the other hand, users who saw more negative content, tended to have more negative posts.\n另一方面，看到负面内容的用户，发的内容也更负面\n\nClearly, what Facebook and other services show you\n显然，Facebook和其他网站向你展示的内容\n\ncan absolutely have an affect on you.\n绝对会对你有影响\n\nAs gatekeepers of content, that’s a huge opportunity and responsibility.\n作为信息的守门人，这是巨大的机会 同时也是责任\n\nWhich is why this study ended up being pretty controversial.\n研究结果相当有争议性.\n\nAlso, it raises some interesting questions about\n而且它还产生了一个有趣的问题：\n\nhow computer programs should respond to human communication.\n计算机程序如何回应人类\n\nIf the user is being negative, maybe the computer shouldn’t be\n如果用户的情绪比较负面，也许电脑不应该\n\nannoying by responding in a cheery, upbeat manner.\n以一种烦人的 \"你要振作起来呀\" 的态度回答问题.\n\nOr, maybe the computer should attempt to evoke a positive response,\n或者，也许电脑应该试着积极正面的回应用户\n\neven if it's a bit awkward.\n即使这有点尴尬.\n\nThe \"correct\" behavior is very much an open research question.\n什么行为是\"正确的\"，是个开放性的研究问题\n\nSpeaking of Facebook, it’s a great example of computer-mediated communication, or CMC,\n既然说到Facebook，\\N 这是一个\"以计算机为媒介沟通\"的好例子，简称 \"CMC\"\n\nanother large field of research.\n也是一个很大的研究领域\n\nThis includes synchronous communication – like video calls, where all participants are online\n这包括同步通信 - 所有参与者同时在线进行视频通话\n\nsimultaneously – as well as asynchronous communication – like tweets, emails, and\n以及异步通信 - 比如推特，邮件，\n\ntext messages, where people respond whenever they can or want.\n短信，人们可以随时随地回复信息\n\nResearchers study things like the use of emoticons, rules such as turn-taking,\n研究人员还研究用户怎么用表情包，怎么轮换发言，\n\nand language used in different communication channels.\n以及用不同沟通渠道时，用词有什么区别.\n\nOne interesting finding is that people exhibit higher levels of self-disclosure\n一个有趣的发现是，比起面对面沟通，\n\n– that is, reveal personal information –in computer-mediated conversations,\n人们更愿意在网上透露自己的信息\n\nas opposed to face-to-face interactions.\n人们更愿意在网上透露自己的信息\n\nSo if you want to build a system that knows how many hours a user truly spent\n所以如果想知道用户 \\N 真正花了多少小时看\"大英烘培大赛\"(电视节目)\n\nwatching The Great British Bakeoff, it might be better to build a chatbot\n比起做个带脸的虚拟助理 \\N 做 聊天机器人 是个更好的选择\n\nthan a virtual agent with a face.\n比起做个带脸的虚拟助理 \\N 做 聊天机器人 是个更好的选择\n\nPsychology research has also demonstrated that eye gaze is\n心理学研究也表明，如果想说服，讲课，或引起注意 \\N 眼神注视非常重要\n\nextremely important in persuading, teaching and getting people's attention.\n心理学研究也表明，如果想说服，讲课，或引起注意 \\N 眼神注视非常重要\n\nLooking at others while talking is called mutual gaze.\n在谈话时看着别人叫 相互凝视\n\nThis has been shown to boost engagement and help achieve the goals of a conversation,\n这被证明可以促进参与感 帮助实现谈话目标，\n\nwhether that’s learning, making a friend, or closing a business deal.\n不管是学习，交朋友，还是谈生意\n\nIn settings like a videotaped lecture, the instructor rarely, if ever, looks into the\n在录像讲座中，老师很少直视相机 \\N 一般是看在场学生\n\ncamera, and instead generally looks at the students who are physically present.\n在录像讲座中，老师很少直视相机 \\N 一般是看在场学生\n\nThat’s ok for them, but it means people who\n对他们没问题，但这会让在线看视频的人  没什么参与感\n\nwatch the lectures online have reduced engagement.\n对他们没问题，但这会让在线看视频的人  没什么参与感\n\nIn response, researchers have developed computer vision\n为此，研究人员开发了计算机视觉和图形软件 \\N 来纠正头部和眼睛\n\nand graphics software that can warp the head and eyes,\n为此，研究人员开发了计算机视觉和图形软件 \\N 来纠正头部和眼睛\n\nmaking it appear as though the instructor is looking into the camera\n视频时会觉得对方在直视摄像头，看着他们\n\n– right at the remote viewer.\n视频时会觉得对方在直视摄像头，看着他们\n\nThis technique is called augmented gaze.\n这叫\"增强凝视\"\n\nSimilar techniques have also been applied to video conference calls, to correct for\n类似技术也用于视频会议\n\nthe placement of webcams, which are almost always located above screens.\n纠正摄像头位置，因为摄像头几乎总在屏幕上方\n\nSince you’re typically looking at the video of your conversation partner,\n因为你一般会盯着屏幕上的另一方 \\N 而不是盯着摄像头\n\nrather than directly into the webcam,\n因为你一般会盯着屏幕上的另一方 \\N 而不是盯着摄像头\n\nyou'll always appear to them as though you're looking downwards –\n所以视频里看起来像在向下看\n\nbreaking mutual gaze – which can create all kinds of\n没有相互凝视 - 这会导致各种不幸的副作用，比如权力不平衡\n\nunfortunate social side effects, like a power imbalance.\n没有相互凝视 - 这会导致各种不幸的副作用，比如权力不平衡\n\nFortunately, this can be corrected digitally, and appear to participants\n幸运的是  可以用软件修正\n\nas though you're lovingly gazing into their eyes.\n看起来像在凝视着对方的眼睛\n\nHumans also love anthropomorphizing objects, and computers are no exception,\n人类也喜欢\"拟人化\"的物体，对计算机也不例外\n\nespecially if they move, like our Robots from last episode.\n特别是会动的计算机，比如上集说的机器人\n\nBeyond industrial uses that prevailed over the last century,\n在过去一个世纪，除了工业用途机器人\n\nrobots are used increasingly in medical, education, and entertainment settings,\n有越来越多机器人用于医疗，教育和娱乐 \\N 它们经常和人类互动\n\nwhere they frequently interact with humans.\n有越来越多机器人用于医疗，教育和娱乐 \\N 它们经常和人类互动\n\nHuman-Robot Interaction – or HRI\n人机交互，简称 HRI\n\n– is a field dedicated to studying these interactions,\n- 是一个研究人类和机器人交互的领域，\n\nlike how people perceive different robots behaviors and forms,\n比如人类如何感受 机器人的不同形式和不同行为\n\nor how robots can interpret human social cues to blend in and not be super awkward.\n或是机器人如何明白人类暗示来社交，而不是尴尬的互动\n\nAs we discussed last episode, there’s an ongoing quest to make\n正如上集说的，我们有追求\n\nrobots as human-like in their appearance and interactions as possible.\n把机器人的外表和行为，做得尽可能像人一样\n\nWhen engineers first made robots in the 1940s and 50s, they didn’t look very human at all.\n工程师在1940 1950年代刚开始做机器人时，\\N 看起来完全不像人\n\nThey were almost exclusively industrial machines with no human-likeness.\n是完完全全的工业机器\n\nOver time, engineers got better and better at making human-like robots\n随着时间的推移，工程师越来越擅长做类人机器人\n\n– they gained heads and walked around on two legs,\n它们有头，而且用两条腿走路\n\nbut… they couldn't exactly go to restaurants and masquerade as humans.\n但它们做不到伪装成人类去餐馆点餐\n\nAs people pushed closer and closer to human likeness,\n随着机器人可以做得越来越像人类\n\nreplacing cameras with artificial eyeballs, and covering metal chassis with synthetic flesh,\n用人造眼球代替摄像头，用人工肌肉盖住金属骨架\n\nthings started to get a bit... uncanny...\n事情会开始变得有些.. 奇怪.. \\N 引起一种怪异不安的感觉\n\neliciting an eerie and unsettling feeling.\n事情会开始变得有些.. 奇怪.. \\N 引起一种怪异不安的感觉\n\nThis dip in realism between almost-human and actually-human became known as the uncanny valley.\n这个\"几乎像人类\"和\"真的人类\"之间的小曲线，叫 \"恐怖谷\"\n\nThere’s debate over whether robots should act like humans too.\n对于机器人是否应该有人类一样的行为，也存在争议\n\nLots of evidence already suggests that even if robots don’t act like us,\n很多证据表明，即使机器人的行为不像人类\n\npeople will treat them as though they know our social conventions.\n人类也会用社交习俗对待它们\n\nAnd when they violate these rules – such as not apologizing if they cut in front of\n而当机器人违反习俗时 - 比如插队或踩了脚不道歉 \\N 人们会很生气！\n\nyou or roll over your foot – people get really mad!\n而当机器人违反习俗时 - 比如插队或踩了脚不道歉 \\N 人们会很生气！\n\nWithout a doubt, psychology and computer science are a potent combination,\n毫无疑问，心理学+计算机科学是强大的组合\n\nand have tremendous potential to affect our everyday lives.\n可以影响日常生活的巨大潜力\n\nWhich leaves us with a lot of question, like you might lie to your laptop,\n这也带来了很多开放式问题，比如你可能会对计算机撒谎\n\nbut should your laptop lie to you?\n但计算机应不应该对你撒谎？\n\nWhat if it makes you more efficient or happy?\n如果撒谎能让你更高效更快乐呢？\n\nOr should social media companies curate the content they show you to\n或社交媒体公司 \\N 是否应该精心挑选展示给你的内容\n\nmake you stay on their site longer to make you buy more products?\n让你在网站上多待一会儿，买更多东西？\n\nThey do by the way.\n顺带一说，他们的确有这样做\n\nThese types of ethical considerations aren’t easy to answer, but psychology can at least\n这类道德问题不容易回答，但心理学至少可以\n\nhelp us understand the effects and implications of design choices in our computing systems.\n帮助我们理解不同选择 带来的影响和意义\n\nBut, on the positive side, understanding the psychology behind design\n但从积极的方面来说，了解设计背后的心理学\n\nmight lead to increased accessibility.\n能增加易用性\n\nA greater number of people can understand and use computers\n让更多人可以明白和使用电脑，如今计算机比以往更加直观\n\nnow that they're more intuitive than ever.\n让更多人可以明白和使用电脑，如今计算机比以往更加直观\n\nConference calls and virtual classrooms are becoming more agreeable experiences.\n线上会议和虚拟教室的体验越来越好\n\nAs robot technology continues to improve, the population\n随着机器人技术不断提高，互动也会越来越舒适\n\nwill grow more comfortable in those interactions.\n随着机器人技术不断提高，互动也会越来越舒适\n\nPlus, thanks to psychology, we can all bond over our love of knurling.\n另外，感谢心理学，让我们能分享对\"滚花\"的热爱\n\nI’ll see you next week.\n我们下周见\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\\N\n\nOne of the most dramatic changes enabled by computing technology\n计算机带来的最大改变之一  \\N 是信息的创造和传播能力\n\nhas been the creation and widespread availability of information.\n计算机带来的最大改变之一  \\N 是信息的创造和传播能力\n\nThere are currently 1.3 billion websites on the internet.\n目前有13亿个网站在互联网上\n\nWikipedia alone has five million English language articles,\n仅维基百科就有500万篇英文文章\n\nspanning everything from the Dancing Plague of 1518\n涵盖从\"1518年的舞蹈瘟疫\"\n\nto proper toilet paper roll orientation.\n到\"正确的纸卷方向\"\n\nEvery day, Google serves up four billion searches to access this information.\n每天，Google提供40亿次搜索来访问这些信息\n\nAnd every minute, 3.5 million videos are viewed on Youtube,\nYoutube上每分钟有350万个视频被观看.\n\nand 400 hours of NEW video get uploaded by users.\n每分钟用户上传400小时的新视频\n\nLots of these views are people watching Gangnam Style and Despacito.\n很多观看量都是 Gangnam Style 和 Despacito\n\nBut another large percentage could be considered educational,\n但剩下的 大部分是教育型内容\n\nlike what you’re doing right now.\n就像你现在看的这个.\n\nThis amazing treasure trove of information can be accessed\n如今只要手机上点几下 就能访问到这些宝藏\n\nwith just a few taps on your smartphone.\n如今只要手机上点几下 就能访问到这些宝藏\n\nAnywhere, anytime.\n任何时间，任何地点\n\nBut, having information available isn’t the same as learning from it.\n但能获取到信息和学习不是一回事\n\nTo be clear, we here at Crash Course we are big fans of interactive in-class learning,\n先说清楚，我们 Crash Course 喜欢互动式课堂学习\n\ndirected conversations, and hands-on experiences as powerful tools for learning.\n课上提问，以及上手实践，它们是很棒的学习途径\n\nBut we also believe in the additive power of educational technology\n但我们也相信教育型技术在课内课外带来的帮助\n\nboth inside and outside the classroom.\n但我们也相信教育型技术在课内课外带来的帮助\n\nSo today we’re going to go a little meta,\n今天我们要在这个教育型视频里 \\N 聊教育型科技\n\nand talk specifically about how computer science\n具体讲解计算机怎么帮助我们学习\n\ncan support learning with educational technology.\n具体讲解计算机怎么帮助我们学习\n\nTechnology, from paper and pencil to recent machine-learning-based intelligent systems,\n从纸和笔 到用机器学习的智能系统，\n\nhas been supporting education for millennia -\n科技几千年来一直在辅助教育\n\neven as early as humans drawing cave paintings\n甚至早期人类 在洞穴里画狩猎场景也是为了后代\n\nto record hunting scenes for posterity.\n甚至早期人类 在洞穴里画狩猎场景也是为了后代\n\nTeaching people at a distance has long been a driver of educational technology.\n远距离教育一直推动着教育科技的发展\n\nFor example, around 50 CE, St. Paul was sending epistles\n例如公元50年左右，圣保罗就发书信 \\N 给亚洲设立的新教堂提供宗教课程\n\nthat offered lessons on religious teachings\n例如公元50年左右，圣保罗就发书信 \\N 给亚洲设立的新教堂提供宗教课程\n\nfor new churches being set up in Asia.\n例如公元50年左右，圣保罗就发书信 \\N 给亚洲设立的新教堂提供宗教课程\n\nSince then, several major waves of technological advances\n从那以后，有几大技术浪潮，自称要改变教育\n\nhave each promised to revolutionize education,\n从那以后，有几大技术浪潮，自称要改变教育\n\nfrom radio and television, to DVDs and laserdiscs.\n从广播和电视，到DVD和光碟\n\nIn fact, as far back as 1913, Thomas Edison predicted,\n事实上，在1913年 托马斯·爱迪生 预测说\n\n\"Books will soon be obsolete in the schools…\n\"书籍很快会过时.. 用影片来教授所有知识是可能的\n\nIt is possible to teach every branch of human knowledge with the motion picture.\n\"书籍很快会过时.. 用影片来教授所有知识是可能的\n\nOur school system will be completely changed in the next ten years.\"\n学校体系将在未来十年彻底改变\"\n\nOf course, you know that didn’t happen.\n当然，他的预测没有成真\n\nBut distributing educational materials in formats like video has become more and more popular.\n但发布教育视频变得越来越流行\n\nBefore we discuss what educational technology research can do for you,\n在讨论教育技术可以帮你做什么之前\n\nthere are some simple things research has shown you can do,\n有研究表明 有些简单事情 \\N 可以显著提高学习效率\n\nwhile watching an educational video like this one,\n有研究表明 有些简单事情 \\N 可以显著提高学习效率\n\nsignificantly increase what you learn and retain.\n有研究表明 有些简单事情 \\N 可以显著提高学习效率\n\nFirst, video is naturally adjustable, so make sure the pacing is right for you,\n1. 把速度调整到适合你，YouTube 的速度设置在右下角\n\nby using the video speed controls.\n1. 把速度调整到适合你，YouTube 的速度设置在右下角\n\nOn YouTube, you can do that in the right hand corner of the screen.\n1. 把速度调整到适合你，YouTube 的速度设置在右下角\n\nYou should be able to understand the video and have enough time to reflect on the content.\n让你能理解视频  有足够的时间思考\n\nSecond, pause!\n2. 暂停！在困难的部分暂停\n\nYou learn more if you stop the video at the difficult parts.\n2. 暂停！在困难的部分暂停\n\nWhen you do, ask yourself questions about what you’ve watched, and see if you can answer.\n问自己一些问题，看能不能回答\n\nOr ask yourself questions about what might be coming up next,\n或想想视频接下来可能讲什么 \\N 然后继续播放，看猜对没有\n\nand then play the video to see if you’re right.\n或想想视频接下来可能讲什么 \\N 然后继续播放，看猜对没有\n\nThird, try any examples or exercises that are presented in the video on your own.\n3. 做视频中的提供的练习\n\nEven if you aren’t a programmer, write pseudocode on paper,\n即使不是程序员，你也可以在纸上写伪代码，或试试学编程\n\nand maybe even give coding a try.\n即使不是程序员，你也可以在纸上写伪代码，或试试学编程\n\nActive learning techniques like these\n这些主动学习的技巧已被证明 \\N 可以把学习效率提升10倍或以上\n\nhave been shown to increase learning by a factor of ten.\n这些主动学习的技巧已被证明 \\N 可以把学习效率提升10倍或以上\n\nAnd if you want more information like this - we’ve got a whole course on it here.\n如果想学学习技巧，有整个系列专门讲这个\n\nThe idea of video as a way to spread quality education\n把高质量教育内容做成视频传播 \\N 在过去一个世纪吸引了很多人\n\nhas appealed to a lot of people over the last century.\n把高质量教育内容做成视频传播 \\N 在过去一个世纪吸引了很多人\n\nWhat’s just the latest incarnation of this idea\n这个老想法的新化身\n\ncame in the form of Massive Open Online Courses, or MOOCs.\n以\"大型开放式在线课程\"（MOOC）的形式出现\n\nIn fact, the New York Times declared 2012 the Year of the MOOC!\n纽约时报宣称 2012 年是 MOOC 年！\n\nA lot of the early forms were just videos of lectures from famous professors.\n很多早期视频 直接录制著名教授上课\n\nBut for a while, some people thought this might mean the end of universities as we know them.\n有段时间，有些人以为大学要终结了\n\nWhether you were worried about this idea or excited by it,\n不管你是担心还是开心，这暂时还没成为现实\n\nthat future also hasn’t really come to pass\n不管你是担心还是开心，这暂时还没成为现实\n\nand most of the hype has dissipated.\n现在热度也淡去了\n\nThis is probably mostly because when you try to scale up learning\n这可能是因为加大规模时 同时教百万名学生\n\nusing technology to include millions of students simultaneously\n这可能是因为加大规模时 同时教百万名学生\n\nwith small numbers of instructional staff - or even none\n但老师数量很少，甚至完全没有老师\n\n- you run into a lot of problems.\n- 会遇到很多问题\n\nFortunately, these problems have intrigued computer scientists and more specifically,\n幸运的是，这引起了计算机科学家，\\N 或具体一点 \"教育科技家\"的兴趣\n\neducational technologists, who are finding ways to solve them.\n他们在想办法解决这些问题\n\nFor example, effective learning involves getting timely and relevant feedback\n比如，为了有效学习，学生要及时获得反馈\n\nbut how do you give good feedback\n但如果有几百万学生，只有一名老师，\n\nwhen you have millions of learners and only one teacher?\n怎么提供好的反馈？\n\nFor that matter, how does a teacher grade a million assignments?\n一个老师怎么给一百万份作业打成绩？\n\nSolving many of these problems means creating hybrid, human-technology systems.\n为了解决问题，很多时候需要把科技和人类都用上\n\nA useful, but controversial insight,\n一种有用 但有些争议的做法是\n\nwas that students could be a great resource to give each other feedback.\n学生互相之间提供反馈\n\nUnfortunately, they’re often pretty bad at doing so –\n不幸的是，学生一般做不好\n\nthey’re neither experts in the subject matter, nor teachers.\n他们既不是专家也不是老师\n\nHowever, we can support their efforts with technology.\n但我们可以用技术来帮助他们\n\nLike, by using algorithms, we can match perfect learning partners together,\n比如通过算法，从数百万个选择里 \\N 匹配出最完美的学习伙伴\n\nout of potentially millions of groupings.\n比如通过算法，从数百万个选择里 \\N 匹配出最完美的学习伙伴\n\nAlso, parts of the grading can be done with automated systems while humans do the rest.\n另外，有些部分可以机器打分，剩下的让人类打分\n\nFor instance, computer algorithms that grade the\n例如，给 SAT 写作部分打分的电脑算法\n\nwriting portions of the SATs have been found to be\n已被证实和人工打分一样准确\n\njust as accurate  as humans hired to grade them by hand.\n已被证实和人工打分一样准确\n\nOther algorithms are being developed that provide personalized learning experiences,\n还有些算法提供个性化学习体验\n\nmuch like Netflix’s personalized movie recommendations or Google’s personalized search results.\n类似于 Netflix 的电影推荐 \\N 或 Google 的个性化搜索结果\n\nTo achieve this, the software needs to understand what a learner knows and doesn’t know.\n为了个性化推荐，\\N 软件需要了解用户知道什么，不知道什么\n\nWith that understanding, the software can present the right material, at the right time,\n在正确的时间提供正确的资料，\n\nto give each particular learner practice on the things that are hardest for them,\n让用户练习没理解的难的部分\n\nrather than what they’re already good at.\n而不是给出用户已经学会的内容\n\nSuch systems – most often powered by Artificial Intelligence –\n这种系统一般用 AI 实现\n\nare broadly called Intelligent Tutoring Systems.\n泛称叫法是\"智能辅导系统\"\n\nLet’s break down a hypothetical system that follows common conventions.\n我们现在讲一个假想的辅导系统\n\nSo, imagine a student is working on this algebra problem in our hypothetical tutoring software.\n假设学生在这个假想的辅导系统中，研究一个代数问题\n\nThe correct next step to solve it, is to subtract both sides by 7.\n正确的下一步是两边-7\n\nThe knowledge required to do this step can be represented by something called a production rule.\n我们可以用 \"判断规则\" 来表示这一步\n\nThese describe procedures as IF-THEN statements.\n用 IF-THEN 语句来描述\n\nThe pseudo code of a production rule for this step would say\n伪代码是\n\nIF there is a constant on the same side as the variable,\n*如果* 变量和常数在同一边\n\nTHEN subtract that constant from both sides.\n*那么* 两侧都减去这个常数\n\nThe cool thing about production rules is that they can also be used\n\"判断规则\" 酷的地方是也可以用来\n\nto represent common mistakes a student might make.\n代表学生的常犯错误\n\nThese production rules are called \"buggy rules\".\n这些\"判断规则\"叫\"错误规则\"\n\nFor example, instead of subtracting the constant,\n例如，学生可能不去减常数\n\nthe student might mistakenly try to subtract the coefficient.\n而是去减系数\n\nNo can do!\n这不行！\n\nIt’s totally possible that multiple competing production rules\n学生做完一个步骤后可能触发多个\"判断规则\"\n\nare triggered after a student completes a step –\n学生做完一个步骤后可能触发多个\"判断规则\"\n\nit may not be entirely clear what misconception has led to a student’s answer.\n系统不能完全弄清 是什么原因让学生选了那个答案\n\nSo, production rules are combined with an algorithm that selects the most likely one.\n所以\"判断规则\"会和算法结合使用，判断可能原因\n\nThat way, the student can be given a helpful piece of feedback.\n让学生得到有用反馈\n\nThese production rules, and the selection algorithm,\n\"判断规则\"+选择算法，组合在一起成为 \"域模型\"\n\ncombine to form what’s called a Domain Model,\n\"判断规则\"+选择算法，组合在一起成为 \"域模型\"\n\nwhich is a formal representation of the knowledge,\n它给知识，解决步骤和一门学科 比如代数，\\N 用一种\"正式写法\"来表示\n\nprocedures and skills of a particular discipline - like algebra.\n它给知识，解决步骤和一门学科 比如代数，\\N 用一种\"正式写法\"来表示\n\nDomain models can be used to assist learners on any individual problem,\n域模型可以用来 帮助学习者解决特定问题\n\nbut they’re insufficient for helping learners move through a whole curriculum\n但它无法带着学习者 \\N 以正确顺序搞定整个学科该上的所有课程\n\nbecause they don’t track any progress over time.\n因为域模型不记录进度\n\nFor that, intelligent tutoring systems build and maintain a student model\n因此智能辅导系统 负责创建和维护学生模型\n\n– one that tracks, among other things, what production rules a student has mastered,\n- 记录学生已经掌握的判断规则\n\nand where they still need practice.\n以及还需练习的生疏部分\n\nThis is exactly what we need to properly personalize the tutor.\n这正是个性化辅导系统需要的。\n\nThat doesn’t sound so hard,\n听起来好像不难，\n\nbut it’s actually a big challenge to figure out what a student knows and doesn’t know\n但只靠学生对一些问题的回答，\\N 来弄清学生知道什么，不知道什么，是很大的挑战\n\nbased only on their answers to problems.\n但只靠学生对一些问题的回答，\\N 来弄清学生知道什么，不知道什么，是很大的挑战\n\nA common technique for figuring this out is Bayesian knowledge tracing.\n\"贝叶斯知识追踪\" 常用来解决这个问题\n\nThe algorithm treats student knowledge as a set of latent variables,\n这个算法把学生的知识 当成一组隐藏变量\n\nwhich are variables whose true value is hidden from\n这些变量的值，对外部是不可见的\n\nan outside observer, like our software.\n比如我们的软件\n\nThis is also true in the physical world,\n这在现实中也是一样的\n\nwhere a teacher would not know for certain whether\n老师无法知道 学生是否完全掌握了某个知识点\n\na student knows something completely.\n老师无法知道 学生是否完全掌握了某个知识点\n\nInstead, they might probe that knowledge using a test\n老师会出考题，测试学生能否答对\n\nto see if the student gets the right answer.\n老师会出考题，测试学生能否答对\n\nSimilarly, Bayesian knowledge tracing updates its estimate of the students’ knowledge\n同样，\"贝叶斯知识追踪\" \\N 会看学生答题的正确度，更新学生掌握程度的估算值\n\nby observing the correctness of each interaction using that skill.\n同样，\"贝叶斯知识追踪\" \\N 会看学生答题的正确度，更新学生掌握程度的估算值\n\nTo do this, the software maintains four probabilities..\n它会记录四个概率\n\nFirst is the probability that a student has learned how to do a particular skill.\n首先是 \"学生已经学会的概率\"\n\nFor example, the skill of subtracting constants from both sides of an algebraic equation.\n比如从代数方程的两边减去常数\n\nLet’s say our student correctly subtracts both sides by 7.\n假设学生正确将两边-7\n\nBecause she got the problem correct,\n做对了\n\nwe might assume she knows how to do this step.\n我们可以假设她知道怎么做\n\nBut there’s also the possibility that the student got it correct by accident,\n但也有可能她是瞎蒙的\n\nand doesn’t actually understand how to solve the problem.\n没有真的学会怎么解决问题\n\nThis is the probability of guess.\n这叫 \"瞎猜的概率\"\n\nSimilarly, if the student gets it wrong,\n类似的，如果学生答错了，\n\nyou might assume that she doesn’t know how to do the step.\n你可能会假设她不会做\n\nBut, there’s also the possibility that she knows it,\n但她可能知道答案，只是不小心犯了个错\n\nbut made a careless error or other slip-up.\n但她可能知道答案，只是不小心犯了个错\n\nThis is called the probability of slip.\n这叫 \"失误的概率\"\n\nThe last probability that Bayesian knowledge tracing calculates\n最后一个概率\n\nis the probability that the student started off the problem\n是学生一开始不会做，\\N 但是在解决问题的过程中，学会了怎么做\n\nnot knowing how to do the step, but learned how to do\n是学生一开始不会做，\\N 但是在解决问题的过程中，学会了怎么做\n\nit as a result of working through the problem.\n是学生一开始不会做，\\N 但是在解决问题的过程中，学会了怎么做\n\nThis is called the probability of transit.\n这叫 \"做题过程中学会的概率\"\n\nThese four probabilities are used in a set of equations that update the student model,\n有一组方程，会用这四个概率，更新学生模型\n\nkeeping a running assessment for each skill the student is supposed to know.\n对学生应该学会的每项技能进行持续评估\n\nThe first equation asks:\n第一个等式问：\n\nwhat’s the probability that the student has learned a particular skill\n学生已经知道某技能的概率是多少？\n\nwhich takes into account the probability that it was\n等式里有\n\nalready learned previously and the probability of transit.\n\"之前已经学会的概率\"和\"做题过程中学会的概率\"\n\nLike a teacher, our estimate of this probability that it was already learned previously\n就像老师一样，\"之前已经学会的概率\"\n\ndepends on whether we observe a student getting a question correct or incorrect,\n取决于学生回答问题正确与否，\n\nand so we have these two equations to pick from.\n回答正确和错误分别有2个公式\n\nAfter we compute the right value, we plug it into our first equation,\n算出结果之后，我们把结果放到第一个方程\n\nupdating the probability that a student has learned a particular skill,\n更新\"之前已经学会的概率\"\n\nwhich then gets stored in their student model.\n然后存到学生模型里.\n\nAlthough there are other approaches,\n虽然存在其他方法，\n\nintelligent tutoring systems often use Bayesian knowledge tracing\n但\"智能辅导系统\"通常用 贝叶斯知识追踪\n\nto support what’s called mastery learning, where students practice skills,\n让学生练习技能，直到掌握\n\nuntil they’re deeply understood.\n让学生练习技能，直到掌握\n\nTo do this most efficiently, the software selects the\n为了高效做到这点，软件要选择合适的问题\n\nbest problems to present to the student to achieve mastery,\n呈现给学生，让学生学\n\nwhat’s called adaptive sequencing,\n这叫：自适应式程序\n\nwhich is one form of personalization.\n个性化算法的形式之一\n\nBut, our example is still just dealing with data from one student.\n但我们的例子只是一个学生的数据\n\nInternet-connected educational apps or sites\n现在有 App 或网站\n\nnow allow teachers and researchers the ability\n让教师和研究人员 收集上百万学习者的数据\n\nto collect data from millions of learners.\n让教师和研究人员 收集上百万学习者的数据\n\nFrom that data, we can discover things like common pitfalls and where students get frustrated.\n从数据中可以发现常见错误\\N 一般哪里难倒学生\n\nBeyond student responses to questions,\n除了学生的回答，还可以看回答前暂停了多久\n\nthis can be done by looking at how long they pause\n除了学生的回答，还可以看回答前暂停了多久\n\nbefore entering an answer, where they speed up a video,\n哪个部分加速视频，\n\nand how they interact with other students on discussion forums.\n以及学生如何在论坛和其他人互动\n\nThis field is called Educational Data Mining,\n这个领域叫 \"教育数据挖掘\"\n\nand it has the ability to use all those face palms and \"ah ha\" moments\n它能用上学生所有的\"捂脸\"和\"啊哈\"时刻\n\nto help improve personalized learning in the future.\n帮助改善未来的个性化学习\n\nSpeaking of the future, educational technologists have often\n谈到未来，教育技术人员经常从科幻小说中获得灵感\n\ndrawn inspiration for their innovations from science fiction.\n谈到未来，教育技术人员经常从科幻小说中获得灵感\n\nIn particular, many researchers were inspired by the future envisioned in the book\n具体来说，Neal Stephenson 的\"钻石时代\"这本书\\N 激励了很多研究人员\n\n\"The Diamond Age\" by Neal Stephenson.\n具体来说，Neal Stephenson 的\"钻石时代\"这本书\\N 激励了很多研究人员\n\nIt describes a young girl who learns from a book\n里面说一个年轻女孩从书中学习\n\nthat has a set of virtual agents who interact with her\n书中有一些虚拟助手会和她互动，教她知识\n\nin natural language acting as coaches, teachers,\n书中有一些虚拟助手会和她互动，教她知识\n\nand mentors who grow and change with her as she grows up.\n这些助手和她一起成长\n\nThey can detect what she knows and how’s she’s feeling,\n直到她学会了什么，以及感觉如何，\n\nand give just the right feedback and support to help her learn.\n给她正确的反馈和支持，帮助她学习\n\nToday, there are non-science-fiction researchers, such as Justine Cassell,\n如今 有非科幻小说研究者，比如 贾斯汀卡塞尔，\n\ncrafting pedagogical virtual agents\n在制作虚拟教学助手\n\nthat can \"exhibit the verbal and bodily behaviors found in\n助手可以\"像人类一样沟通 有人类一样的行为\n\nconversation among humans, and in doing so, build trust,\n在陪伴过程中和学习者建立信任，\n\nrapport and even friendship with their human students.\"\n相处融洽，甚至和人类学生成为朋友\"\n\nMaybe Crash Course in 2040 will have a little John Green A.I. that lives on your iPhone 30.\n2040年的\"速成课\" \\N 可能会有一个 John Green AI，活在你的 iPhone 30 上\n\nEducational technology and devices are now moving off of laptop and desktop computers,\n教育科技和设备 \\N如今在逐渐扩展到笔记本和台式电脑之外\n\nonto huge tabletop surfaces, where students can collaborate in groups,\n比如巨大桌面设备，让学生可以团队合作\n\nand also tiny mobile devices, where students can learn on the go.\n以及小型移动设备，让学生路上也能学习\n\nVirtual reality and augmented reality are also getting people excited\n\"虚拟现实\"和\"增强现实\"也让人们兴奋不已\n\nand enabling new educational experiences for learners –\n它们可以为学习者提供全新的体验 -\n\ndiving deep under the oceans, exploring outer space,\n深潜海洋，探索太空，\n\ntraveling through the human body, or interacting with cultures\n漫游人体，或是和现实中难以遇见的生物互动\n\nthey might never encounter in their real lives.\n漫游人体，或是和现实中难以遇见的生物互动\n\nIf we look far into the future, educational interfaces might disappear entirely,\n如果猜想遥远的未来，教育可能会完全消失，\n\nand instead happen through direct brain learning,\n直接在大脑层面进行\n\nwhere people can be uploaded with new skills, directly into their brains.\n把新技能直接下载到大脑\n\nThis might seem really far fetched,\n这看起来可能很遥远，\n\nbut scientists are making inroads already - such as detecting\n但科学家们已经在摸索 - 比如\n\nwhether someone knows something just from their brain signals.\n仅仅通过检测大脑信号，得知某人是否知道什么\n\nThat leads to an interesting question:\n这带来了一个有趣的问题：\n\nif we can download things INTO our brains,\n如果我们可以把东西下载到大脑里\n\ncould we also upload the contents of our brains?\n我们能不能上传大脑里的东西？\n\nWe’ll explore that in our series finale next week about the far future of computing.\n下周的最后一集，我们会讨论计算的未来\n\nI'll see you then.\n到时见\n\nHi, I’m Carrie Anne, and welcome to Crash Course Computer Science!\n(｡･∀･)ﾉﾞ嗨，我是 Carrie Anne \\N 欢迎收看计算机科学速成课！\n\nWe’re here: the final episode!\n我们到了 最后一集！\n\nIf you’ve watched the whole series,\n如果你看了整个系列，\n\nhopefully you’ve developed a newfound appreciation\n希望你对计算机影响的深度和广度 \\N 有全新的认知和欣赏\n\nfor the incredible breadth of computing applications and topics.\n希望你对计算机影响的深度和广度 \\N 有全新的认知和欣赏\n\nIt’s hard to believe we’ve worked up from mere transistors and logic gates,\n难以相信 我们从简单的晶体管和逻辑门开始\n\nall the way to computer vision, machine learning, robotics and beyond.\n一直到计算机视觉，机器学习，机器人以及更多\n\nWe’ve stood on the shoulders of giants\n我们站在巨人的肩膀上\n\nlike Babbage and Lovelace, Hollerith and Turing,\nCharles Babbage \\N Ada Lovelac \\N Herman Hollerith \\N Alan Turing\n\nEckert and Hopper, Sutherland and Engelbart,\nJ. Presper Eckert \\N Grace Hopper \\N  Ivan Sutherland \\N Douglas Engelbart\n\nBush and Berners Lee, Gates and the Woz,\nVannevar Bush (Memex) \\N  Berners-Lee  (万维网) \\N Bill Gates (微软)\\N Steve Wozniak (苹果)\n\nand many other computing pioneers.\n和许多其他先驱\n\nMy biggest hope is that these episodes have inspired you to\n我最大的希望是 这些视频能激励你 \\N 去了解这些东西如何影响你的人生\n\nlearn more about how these subjects affect your life.\n我最大的希望是 这些视频能激励你 \\N 去了解这些东西如何影响你的人生\n\nMaybe you’ll even pick up programming or choose a career in computing.\n甚至开始学编程，或找一份计算机职业\n\nIt’s awesome!\n这很棒！\n\nIt’s also a skill of the future.\n这是未来的技能\n\nI said in the very first episode that computer science isn’t magic, but it sort of is!\n我在第一集说过，计算机科学不是魔法\\N 但它有点像魔法\n\nKnowing how to use and program computers is sorcery of the 21st century.\n学习使用电脑和编程，是21世纪的巫术\n\nInstead of incantations and spells, it’s scripts and code.\n只不过用的不是咒语 而是代码\n\nThose who know how to wield that tremendous power will be able to craft great things,\n懂得运用的人，能创造出伟大的东西\n\nnot just to improve their own lives, but also their communities and humanity at large.\n不仅改善自己的生活，还有当地社区乃至整体人类\n\nComputing is also going to be literally everywhere –\n计算机会随处可见 -\n\nnot just the computers we see today, sitting on desks and countertops,\n不仅是放在桌上 带在包里\n\nand carried in pockets and bags – but inside every object imaginable.\n而是在所有可想象的东西里\n\nInside all your kitchen appliances, embedded in your walls, nanotagged in your food,\n厨房用具里，墙里，食物里\n\nwoven into your clothes, and floating around inside your body.\n编织进衣服里，在你的血液里\n\nThis is the vision of the field of Ubiquitous Computing.\n这是\"普适计算\"的愿景\n\nIn some ways, it’s already here, and in other ways, we’ve got many decades to go.\n从某种角度来讲 它已经来临了\\N 而换一个角度  还要几十年\n\nSome might view this eventuality as dystopian,\n有些人把这种未来看成 反乌托邦\n\nwith computers everywhere surveilling us and competing for our attention.\n到处都有监视器，有无数东西想吸引我们的注意力\n\nBut the late Mark Weiser, who articulated this idea in the 1990s,\n但 1990 年代提出这个想法的 马克·维泽尔\n\nsaw the potential very differently:\n看到了非常不同的潜力：\n\n\"For [fifty] years, most interface design, and most computer design,\n\"[五十]年来，大多数界面和计算机设计，\n\nhas been headed down the path of the \"dramatic\" machine.\n都是朝\"戏剧性\"方向前进\n\nIts highest idea is to make a computer so exciting, so wonderful,\n想把计算机做得超好，让人一刻也不想离开\n\nso interesting, that we never want to be without it.\n想把计算机做得超好，让人一刻也不想离开\n\nA less-traveled path I call the \"invisible\";\n另一条少有人走的路 是\"无形\"的\n\nits highest idea is to make a computer so imbedded, so fitting,\n把计算机整合到所有东西里 \\N 用的时候很自然 完全注意不到\n\nso natural, that we use it without even thinking about it …\n把计算机整合到所有东西里 \\N 用的时候很自然 完全注意不到\n\nThe most profound technologies are those that disappear.\n最厉害的科技是看不见的科技\n\nThey weave themselves into the fabric of everyday life\n它们融入到日常生活的每一部分 直到无法区分\"\n\nuntil they are indistinguishable from it.\"\n它们融入到日常生活的每一部分 直到无法区分\"\n\nThat doesn’t describe computing of today\n如今我们还没达到这样\n\n– where people sit for hours upon end in front of computer monitors,\n- 人们在电脑前连续坐好几小时\n\nand social media notifications interrupt us at dinner.\n吃晚餐被手机推送通知打扰\n\nBut, it could describe computing of the future, our final topic.\n但它可以描述计算的未来 \\N  本系列最后一个主题\n\nWhen people think of computing in the future,\n人们思考计算机的未来时 经常会直接想到人工智能\n\nthey often jump right to Artificial Intelligence.\n人们思考计算机的未来时 经常会直接想到人工智能\n\nNo doubt there will be tremendous strides made in AI in the coming years,\n毫无疑问，接下来几十年人工智能会有巨大进步\n\nbut not everything will be, or need to be, AI-powered.\n但不是所有东西都要做成 AI ，或需要 AI\n\nYour car might have an AI to self-drive, but the door locks\n车有自动驾驶AI，但门锁依然会很简单\n\nmight continue to be powered by what are essentially if-statements.\n车有自动驾驶AI，但门锁依然会很简单\n\nAI technology is just as likely to enhance existing devices,\n人工智能可能只是增强现有设备\n\nlike cars, as it is to open up entirely new product categories.\n比如汽车，AI 带来了一个全新的产品种类\n\nThe exact same thing happened with the advent of electrical power – lightbulbs replaced candles.\n刚出现电力时也是这样，灯泡取代了蜡烛.\n\nBut electrification also led to the creation of hundreds of new electrically-powered gadgets.\n但电气化也导致上百种新的电动小工具诞生\n\nAnd of course, we still have candles today.\n当然 我们如今仍然有蜡烛\n\nIt’s most likely that AI will be yet another tool\n最可能的情况是 AI 变成 \\N 计算机科学家手中的另一门新工具\n\nthat computer scientists can draw upon to tackle problems.\n最可能的情况是 AI 变成 \\N 计算机科学家手中的另一门新工具\n\nWhat really gets people thinking, and sometimes sweating,\n但真正让人深思和担忧的是\n\nis whether Artificial Intelligence will surpass human intelligence.\n人工智能是否会超越人类智能？\n\nThis is a really tricky question for a multitude of reasons,\n这个问题很难 有多方面原因\n\nincluding most immediately: \"what is intelligence?\"\n比如 \"智能的准确定义是什么？\"\n\nOn one hand, we have computers that can drive cars,\n一方面，有会开车的计算机\n\nrecognize songs with only a few seconds of audio,\n几秒就能识别歌的 App\n\ntranslate dozens of languages, and totally dominate at games like chess, Jeopardy, and Go.\n翻译几十种语言，\\N 还称霸了一些游戏，比如象棋，知识竞答和围棋\n\nThat sounds pretty smart!\n听起来很聪明！\n\nBut on the other hand, computers fail at some basic tasks,\n但另一方面，计算机连一些简单事情都做不了\n\nlike walking up steps, folding laundry,\n比如走楼梯，叠衣服，\n\nunderstanding speech at a cocktail party, and feeding themselves.\n在鸡尾酒派对和人聊天，喂饱自己\n\nWe’re a long way from Artificial Intelligence that’s as general purpose and capable as a human.\n人工智能成长到和人类一样通用，还有很长的路\n\nWith intelligence being somewhat hard to quantify,\n因为\"智能\"是难以量化的指标\n\npeople prefer to characterize computers and creatures\n人们更喜欢用处理能力来区分\n\nby their processing power instead,\n人们更喜欢用处理能力来区分\n\nbut that’s a pretty computing-centric view of intelligence.\n但这种衡量智能的方法比较\"以计算为中心\"\n\nNonetheless, if we do this exercise,\n但如果把视频中出现过的电脑和处理器 画张图\n\nplotting computers and processors we’ve talked about in this series,\n但如果把视频中出现过的电脑和处理器 画张图\n\nwe find that computing today has very roughly equivalence in calculating\n可以看到 如今的计算能力粗略等同于一只老鼠\n\npower to that of a mouse...\n可以看到 如今的计算能力粗略等同于一只老鼠\n\nwhich, to be fair, also can’t fold laundry, although that would be super cute!\n公平点说，老鼠也不会叠衣服\\N 但如果真的会叠 就太可爱了\n\nHuman calculating power is up here, another 10 to the 5,\n人类的计算能力在这儿，多10的5次方\n\nor 100,000 times more powerful than computers today.\n也就是比如今电脑强10万倍\n\nThat sounds like a big gap, but with the rate of change in computing technologies,\n听起来差距很大，但按如今的发展速度，\n\nwe might meet that point in as early as a decade,\n也许十几年就可以赶上了\n\neven though processor speeds are no longer following Moore’s Law,\n虽然现在处理器的速度 不再按摩尔定律增长了\n\nlike we discussed in Episode 17.\n我们在第17集讨论过\n\nIf this trend continues, computers would have more processing power/intelligence,\n假设趋势继续保持下去，在本世纪结束前\n\nthan the sum total of all human brains combined before the end of this century.\n计算机的处理能力/智能 会比全人类加起来还多\n\nAnd this could snowball as such systems need less human input,\n然后人的参与会越来越少，人工超级智能会开始改造自己\n\nwith an artificial superintelligence designing and training new versions of itself.\n然后人的参与会越来越少，人工超级智能会开始改造自己\n\nThis runaway technological growth, especially with respect to an intelligence explosion,\n智能科技的失控性发展叫 \"奇点\"\n\nis called the singularity.\n智能科技的失控性发展叫 \"奇点\"\n\nThe term was first used by our old friend from Episode 10,\n第10集 约翰·冯·诺伊曼 最早用这个词\n\nJohn von Neumann, who said:\n他说：\n\n\"The accelerating progress of technology and changes in the mode of human life,\n\"越来越快的技术发展速度和人类生活方式的改变，\n\ngive the appearance of approaching some essential singularity\n看起来会接近人类历史中某些重要的奇点\n\nin the history of the race beyond which human affairs,\n看起来会接近人类历史中某些重要的奇点\n\nas we know them, could not continue.\"\n这个势头不会永远继续下去\"\n\nAnd Von Neumann suggested this back in the 1950s,\n冯诺依曼在 1950 年代说的这话.\n\nwhen computers were trillions of times slower than they are today.\n那时计算机比现在慢得多\n\nSixty years later, though, the singularity is\n六十年后的今天，奇点仍然在遥远的地平线上\n\nstill just a possibility on the horizon.\n六十年后的今天，奇点仍然在遥远的地平线上\n\nSome experts believe this progress is going to level off,\n一些专家认为 发展趋势会更平缓一些\n\nand be more of an S curve than an exponential one,\n更像是S型，而不是指数型\n\nwhere as complexity increases, it becomes more difficult to make additional progress.\n而随着复杂度增加，进步会越来越难\n\nMicrosoft co-founder Paul Allen calls it a \"complexity brake\".\n微软联合创始人 保罗·艾伦 叫这个\"复杂度刹车\"\n\nBut, as a thought experiment,\n但当作思维练习\n\nlet’s just say that superintelligent computers will emerge.\n我们假设 超智能计算机会出现。\n\nWhat that would mean for humanity is a hotly debated topic.\n这对人类意味着什么，是个讨论激烈的话题\n\nThere are people who eagerly await it,\n有些人迫不及待\n\nand those who are already working to stop it from happening.\n有些人则努力阻止它\n\nProbably the most immediate effect would be technological unemployment,\n最直接的影响可能是\"技术性失业\"\n\nwhere workers in many job sectors are rendered obsolete\n很多工作被计算机，比如AI和机器人，给代替掉了\n\nby computers – like AIs and Robots –\n很多工作被计算机，比如AI和机器人，给代替掉了\n\nthat can do their work better and for less pay.\n它们的效率更高，成本更低\n\nAlthough computers are new, this effect is not.\n虽然计算机出现没多久，但\"技术性失业\"不是新事\n\nRemember Jacquard's Loom from Episode 10?\n还记得第10集里 雅卡尔的织布机 吗？\n\nThat automated the task of skilled textile workers back in the 1800s, which led to riots.\n它让1800年代的纺织工人失业，导致了骚乱\n\nAlso, back then, most of the population of the US and Europe were farmers.\n当时美国和欧洲 大部分人都是农民\n\nThat’s dropped to under 5% today,\n如今农民占人口比例<5％\n\ndue to advances like synthetic fertilizers and tractors.\n因为有合成肥料和拖拉机等等技术\n\nMore modern examples include telephone switchboard operators\n时间更近一些的例子是\"电话接线员\"\n\nbeing replaced with automatic switchboards in 1960,\n在1960年被自动接线板代替了\n\nand robotic arms replacing human painters in car factories in the 1980s.\n还有1980年代的\"机器喷漆臂\"替代了人工喷漆\n\nAnd the list goes on and on.\n这样的例子还有很多.\n\nOn one hand, these were jobs lost to automation.\n一方面，因为自动化失去了工作\n\nAnd on the other hand, clothes, food, bicycles, toys,\n另一方面，我们有大量产品，\\N 衣服，食物，自行车，玩具等\n\nand a myriad of other products are all plentiful today\n另一方面，我们有大量产品，\\N 衣服，食物，自行车，玩具等\n\nbecause they can be cheaply produced thanks to computing.\n因为可以廉价生产\n\nBut, experts argue that AI, robots and computing technologies in general,\n但专家认为人工智能，机器人 以及更广义的计算\n\nare going to be even more disruptive than these historical examples.\n比之前更有破坏性\n\nJobs, at a very high level, can be summarized along two dimensions.\n工作可以用两个维度概括\n\nFirst, jobs can be either more manual – like assembling toys\n首先，手工型工作，比如组装玩具\n\n– or more cognitive – like picking stocks.\n- 或思维型工作 - 比如选股票\n\nThese jobs can also be routine – the same tasks over and over again\n还有重复性工作，一遍遍做相同的事\n\nor non-routine, where tasks vary and workers need to problem solve and be creative.\n或非重复性，需要创造性的解决问题\n\nWe already know that routine-manual jobs can be automated by machines.\n我们知道 重复性手工工作，可以让机器自动化\n\nIt has already happened for some jobs and is happening right now for others.\n现在有些已经替代了，剩下的在逐渐替代\n\nWhat’s getting people worried is that non-routine manual jobs,\n让人担心的是\"非重复性手工型工作\"\n\nlike cooks, waiters and security guards, may get automated too.\n比如厨师，服务员，保安。\n\nAnd the same goes for routine cognitive work,\n思维型工作也一样\n\nlike customer service agents, cashiers, bank tellers, and office assistants.\n比如客服，收银员，银行柜员和办公室助理\n\nThat leaves us with just one quadrant that might be safe,\n剩下一个暂时比较安全的象限\n\nat least for a little while:\n剩下一个暂时比较安全的象限\n\nnon-routine cognitive work,\n非重复性思维型工作\n\nwhich includes professions like teachers and artists,\n包括教师和艺术家，\n\nnovelists and lawyers, and doctors and scientists.\n小说家和律师，医生和科学家\n\nThese types of jobs encompass roughly 40% of the US workforce.\n这类工作占美国劳动力大概40％\n\nThat leaves 60% of jobs vulnerable to automation.\n意味着剩下60％工作容易受自动化影响\n\nPeople argue that technological unemployment at this scale\n有人认为这种规模的技术失业\n\nwould be unprecedented and catastrophic,\n是前所未有的，会导致灾难性的后果，\n\nwith most people losing their jobs.\n大部分人会失业\n\nOthers argue that this will be great,\n其他人则认为很好，\n\nfreeing people from less interesting jobs to pursue better ones,\n让人们从无聊工作解脱，去做更好的工作，\n\nall while enjoying a higher standard of living with the bounty of food and products\n同时享受更高生活水平，有更多食物和物品\n\nthat will result from computers and robots doing most of the hard work.\n都是计算机和机器人生产的.\n\nNo one really knows how this is going to shake out,\n没人知道未来到底会怎样\n\nbut if history is any guide, it’ll probably be ok in the long run.\n但如果历史有指导意义，长远看 一切会归于平静\n\nAfterall, no one is advocating that 90% of people\n毕竟，现在没人嚷嚷着让90％的人 回归耕田和纺织\n\ngo back to farming and weaving textiles by hand.\n毕竟，现在没人嚷嚷着让90％的人 回归耕田和纺织\n\nThe tough question, which politicians are now discussing,\n政界在讨论的棘手问题是\n\nis how to handle hopefully-short-term economic disruption,\n怎么处理数百万人突然失业 \\N 造成的短期经济混乱\n\nfor millions of people that might be suddenly out of a job.\n怎么处理数百万人突然失业 \\N 造成的短期经济混乱\n\nBeyond the workplace, computers are also very likely to change our bodies.\n除了工作，计算机很可能会改变我们的身体\n\nFor example, futurist Ray Kurzweil believes that\n举个例子, 未来学家 Ray Kurzweil 认为\n\n\"The Singularity will allow us to transcend\n\"奇点会让我们超越 肉体和大脑的局限性\n\n[the] limitations of our biological bodies and brains.\n\"奇点会让我们超越 肉体和大脑的局限性\n\nWe will gain power over our fates.\n我们能掌控自己的命运\n\n... We will be able to live as long as we want.\n可以想活多久活多久  我们能完全理解并扩展大脑思维\n\nWe will fully understand human thinking and will vastly extend and expand its reach.\"\n可以想活多久活多久  我们能完全理解并扩展大脑思维\n\nTranshumanists see this happening in the form of cyborgs,\n超人类主义者认为会出现\"改造人\"\n\nwhere humans and technology merge, enhancing our intellect and physiology.\n人类和科技融合在一起，增强智力和身体\n\nThere are already brain computer interfaces in use today.\n如今已经有脑电接口了\n\nAnd wearable computers, like Google Glass and Microsoft Hololens,\n而 Google Glass 和 微软 Hololens \\N 这样的穿戴式计算机 也在模糊这条界线\n\nare starting to blur the line too.\n而 Google Glass 和 微软 Hololens \\N 这样的穿戴式计算机 也在模糊这条界线\n\nThere are also people who foresee \"Digital Ascension\",\n也有人预见到\"数字永生\"\n\nwhich, in the words of Jaron Lanier,\nJaron Lanier 的说法是\n\n\"would involve people dying in the flesh and being uploaded into a computer and remaining conscious\".\n\"人类的肉体死去，意识上传到计算机\"\n\nThis transition from biological to digital beings\n从生物体变成数字体 可能是下一次进化跨越\n\nmight end up being our next evolutionary step...\n从生物体变成数字体 可能是下一次进化跨越\n\nand a new level of abstraction.\n一层新的抽象\n\nOthers predict humans staying largely human,\n其他人则预测  人类大体会保持原样\n\nbut with superintelligent computers as a benevolent force,\n但超智能电脑会照顾我们，帮我们管农场\n\nemerging as a caretaker for humanity – running all the farms,\n但超智能电脑会照顾我们，帮我们管农场\n\ncuring diseases, directing robots to pick-up trash,\n治病，指挥机器人收垃圾，\n\nbuilding new homes and many other functions.\n建房子 以及很多其他事情\n\nThis would allow us to simply enjoy our time on this lovely pale blue dot.\n让我们在这个可爱蓝点上(地球) 好好享受\n\nStill others view AI with more suspicion –\n另一些人对 AI 持怀疑态度 -\n\nwhy would a superintelligent AI waste its time taking care of us?\n为什么超级人工智能 会费时间照顾我们？\n\nIt’s not like we’ve taken on the role of being the benevolent caretaker of ants.\n人类不也没照顾蚂蚁吗？\n\nSo maybe this play out like so many Sci-Fi movies\n也许会像许多科幻电影一样，和计算机开战\n\nwhere we’re at war with computers, our own creation having turned on us.\n也许会像许多科幻电影一样，和计算机开战\n\nIt’s impossible to know what the future holds,\n我们无法知道未来到底会怎样\n\nbut it’s great that this discussion and debate is already happening,\n但现在已经有相关讨论了，这非常好\n\nso as these technologies emerge, we can plan and react intelligently.\n所以等这些技术出现后，我们可以更好地计划\n\nWhat’s much more likely, regardless of whether you see computers as future friend or foe,\n不论你把计算机视为未来的朋友或敌人\n\nis that they will outlive humanity.\n更有可能的是，它们的存在时间会超过人类\n\nMany futurists and science fiction writers have speculated\n许多未来学家和科幻作家猜测\n\nthat computers will head out into space and colonize the galaxy,\n机器人会去太空殖民\n\nambivalent to time scales, radiation,\n无视时间，辐射 \\N 以及一些其他让人类难以长时间太空旅行的因素.\n\nand all that other stuff that makes\n无视时间，辐射 \\N 以及一些其他让人类难以长时间太空旅行的因素.\n\nlong-distance space travel difficult for us humans.\n无视时间，辐射 \\N 以及一些其他让人类难以长时间太空旅行的因素.\n\nAnd when the sun is burned up and the Earth is space dust,\n亿万年后太阳燃尽 地球成为星尘 \\N 也许我们的机器人孩子 会继续努力探索宇宙每一个角落\n\nmaybe our technological children will be hard at work\n亿万年后太阳燃尽 地球成为星尘 \\N 也许我们的机器人孩子 会继续努力探索宇宙每一个角落\n\nexploring every nook and cranny of the universe,\n亿万年后太阳燃尽 地球成为星尘 \\N 也许我们的机器人孩子 会继续努力探索宇宙每一个角落\n\nhopefully in honor of their parents’ tradition to build knowledge,\n以纪念它们的父母，同时让宇宙变得更好，\n\nimprove the state of the universe,\n以纪念它们的父母，同时让宇宙变得更好，\n\nand to boldly go where no one has gone before!\n大胆探索无人深空\n\nIn the meantime, computers have a long way to go,\n与此同时，计算机还有很长的路要走\n\nand computer scientists are hard at work advancing\n计算机科学家们在努力推进  过去40集谈到的话题\n\nall of the topics we talked about over the past forty episodes.\n计算机科学家们在努力推进  过去40集谈到的话题\n\nIn the next decade or so,\n在接下来的十几年\n\nwe’ll likely see technologies like virtual and augmented reality,\nVR 和 AR，无人驾驶车，无人机，可穿戴计算机，\n\nself-driving vehicles, drones, wearable computers,\nVR 和 AR，无人驾驶车，无人机，可穿戴计算机，\n\nand service robots go mainstream.\n和服务型机器人 会变得主流\n\nThe internet will continue to evolve new services,\n互联网会继续诞生新服务\n\nstream new media, and connect people in different ways.\n在线看新媒体. 用新方式连接人们\n\nNew programming languages and paradigms will be developed\n会出现新的编程语言和范例，帮助创造令人惊叹的新软件\n\nto facilitate the creation of new and amazing software.\n会出现新的编程语言和范例，帮助创造令人惊叹的新软件\n\nAnd new hardware will make complex operations blazingly fast,\n而新硬件能让复杂运算快如闪电 \\N 比如神经网络和3D图形\n\nlike neural networks and 3D graphics.\n而新硬件能让复杂运算快如闪电 \\N 比如神经网络和3D图形\n\nPersonal computers are also ripe for innovation,\n个人电脑也会创新\n\nperhaps shedding their forty-year old desktop metaphor\n不像过去40年着重宣传 \"桌面\" 电脑\n\nand being reborn as omnipresent and lifelong virtual assistants.\n而是变成无处不在的虚拟助手\n\nAnd there’s so much we didn’t get to talk about in this series,\n这个系列 我们还有很多话题没谈\n\nlike cryptocurrencies, wireless communication,\n比如加密货币，无线通讯，3D打印，生物信息学和量子计算\n\n3D printing, bioinformatics, and quantum computing.\n比如加密货币，无线通讯，3D打印，生物信息学和量子计算\n\nWe’re in a golden age of computing\n我们正处于计算机的黄金时代\n\nand there’s so much going on, it’s impossible to summarize.\n有很多事情在发生，全部总结是不可能的\n\nBut most importantly, you can be a part of this amazing transformation and challenge,\n但最重要的是 你可以学习计算机 \\N 成为这个惊人转型的一部分\n\nby learning about computing, and taking what’s arguably humanity’s greatest invention,\n但最重要的是 你可以学习计算机 \\N 成为这个惊人转型的一部分\n\nto make the world a better place.\n把世界变得更好\n\nThanks for watching.\n感谢收看\n\n"
  },
  {
    "path": ".gitignore",
    "content": "extract_from_ass_subtitle/node_modules\nextract_from_ass_subtitle/package-lock.json\n*.DS_Store\n"
  },
  {
    "path": "1. screenshot.py",
    "content": "# Crash Course Computer Science\n# 这里的程序只是为了截图视频开头 00:00:00 的时间表\n# 最后的输出结果：40张 jpg 图片\n\nimport os\n\nfiles = [f for f in os.listdir('.') if os.path.isfile(f)]\nfor f in files:\n    # 文件名举例： \n    # 1. 计算机早期历史-Early Computing_BiliBili.mp4\n    # 23. 屏幕&2D 图形显示-Screens&2D Graphics_BiliBili.mp4\n    filename = f\n    filename_array = filename.split('.')\n    number = filename_array[0] # 拿 1\n    suffix = filename_array[-1] # 拿 mp4\n    if suffix == 'mp4':\n        cmd = \"ffmpeg -ss 00:00:00 -i '{0}' -vframes 1 -q:v 2 {1}.jpg\".format(filename, number)\n        # 截图第一帧图片#\n        # {0} 是 input 文件名\n        # {1} 是输出的 jpg 名\n        os.system(cmd) # 执行"
  },
  {
    "path": "README-about-subtitle.md",
    "content": "## 1. 关于公开字幕的一些说明\n公开字幕是为了方便大家学习   \n因为字幕是可以搜索的，而视频是没法搜索的   \n这里只公开了 txt 格式    \n\n* `(字幕)全40集中英字幕文本.txt`  这个 txt 文件\n* `(字幕)全40集中英字幕文本` 这个文件夹     \n\n都是用 Node.js 脚本从 .ass 字幕文件中提取出来的    \n\n## 2. 我们不会公开中英双语 .ass 字幕文件   \n\n因为大部分人都没做过字幕，我解释一下，翻译视频时，字幕是一个 .ass 文件   \n里面有字幕的样式，大小，颜色，时间轴（字幕的出现时间和消失时间）等等，我们用来做字幕的软件是 Aegisub    \n如果对字幕翻译有兴趣，可以看我做的教程：   \n\n[教程] 0基础入门字幕翻译（下载->翻译->压制, 教整个流程） @糖醋陈皮 制作   \nhttps://www.bilibili.com/video/av23046009     \n\n\n而视频的压制则是把 .mp4 视频视频和 .ass 字幕文件通过软件压制一下（我们是用小丸工具箱）   \n得到最后的成品（就是你在 B 站上看的那个）         \n\n因为国内目前环境不太好，我们之前遭遇过被中国电信的天翼把视频盗过去收费的事情        \n（请看如下的微博链接）     \nhttps://weibo.com/5237129097/Fy61opQ2B?from=page_1005055237129097_profile&wvr=6&mod=weibotime\nhttps://weibo.com/5237129097/Fy5UT1qaf?from=page_1005055237129097_profile&wvr=6&mod=weibotime&type=comment#_rnd1528465493854\nhttps://weibo.com/5237129097/FyfXvdVp8?from=page_1005055237129097_profile&wvr=6&mod=weibotime&type=comment#_rnd1528465495773\n\n而且，别忘了国内有很多垃圾自媒体（你在 B 站 App 的首页随便扫两下估计能看到3-4个）     \n所以如果把 .ass 文件放出来，对抄袭者来说成本就很低了，只需要把源视频下载一下，把 ass 字幕批量压制一下，   \n然后改个名字就可以说是自己的了，扯皮都扯不清楚。    \n\n所以 ass 字幕文件是不会放出来的。     \n\n## 3. 总结\n为了方便大家学习 + 防止抄袭者拿走然后低成本就变成自己的视频，所以放 txt 格式的文件     \n这里写这一堆只是为了给没做过字幕的同学一些小科普 + 解释为什么这么做      \n\n## 4. 最后\n参与字幕翻译的所有翻译君都是出于热爱 Crash Course，花费了大量个人时间免费翻译           \n希望大家好好学习~~    \n让自己变得更厉害，让这个世界变得更美好 ;)       \nDon't forget to be Awesome!    \n"
  },
  {
    "path": "README.md",
    "content": "## 计算机科学速成课 :fire: 2018年5月1号 - 全40集完结撒花\n\n### 精校版：      \nhttps://www.bilibili.com/video/av21376839/     \n\n<br/>\n\n![bilibili](/image/cs40.jpg)    \n\n## 字幕也放出来了(40集中英字幕)         \n两个版本：        \n\n* [所有字幕放一个文件里](./(字幕)全40集中英字幕文本.txt)       \n* [每一集一个文件，共40个文件](./(字幕)全40集中英字幕文本)  \n\n另外，片头总结在 **这篇文章的底部**  \n感谢观看，Don't forget to be Awesome!      \n\n## 感谢所有翻译人员！\n* 不想膨胀的小R - [Github](https://github.com/mrinflated), [微博](https://weibo.com/u/2207493917), [B站](https://space.bilibili.com/5385034#!/video)\n* 糖醋陈皮 - [Github](https://github.com/1c7), [微博](https://weibo.com/2004104451), [博客](http://1c7.me/)\n* ZireHao - [B站](http://space.bilibili.com/27167876/)    \n* gilot - [B站](https://space.bilibili.com/43595622/)\n* 晴空\n* Crazycat\n* Cindy\n* 出门去\n* TMC - RN\n* LCAR979（推特 `_lincr_`）  \n\n## 高赞的课程学习笔记\n* [别人家的孩子小明](https://space.bilibili.com/528566) : [石墨文档(`首发`)](https://shimo.im/docs/vkCKkj3YxGtygrVg/)\n* [汉苍茫茫](https://space.bilibili.com/357394001) : [石墨文档(`很全`)](https://shimo.im/docs/PJAUY30F1uYksv0h/)\n* [GoogTech](https://space.bilibili.com/364361791) : [知识点脑图(`超详细`)](https://www.processon.com/view/link/61ef6e8f0e3e7439ae917672#map)\n\n### 第一版翻译（不推荐观看，看精校版即可）：\n* 1 - [早期的计算 - Early Computing](https://www.bilibili.com/video/av8861057/)\n* 2 - [电子计算 - Electronic Computing](https://www.bilibili.com/video/av9066628/)\n* 3 - [布尔逻辑与逻辑电路 - Boolean Logic & Logic Gates](https://www.bilibili.com/video/av11557339/)\n* 4 - [二进制 - Representing Numbers and Letters with Binary](https://www.bilibili.com/video/av11592079/)\n* 5 - [算术逻辑单元 - How Computers Calculate - the ALU](https://www.bilibili.com/video/av12742941/)\n* 6 - [寄存器 & 内存 - Registers and RAM](https://www.bilibili.com/video/av12881796/)\n* 7 - [中央处理器 - The Central Processing Unit(CPU)](https://www.bilibili.com/video/av12881976/)\n* 8 - [指令和程序 - Instructions & Programs](https://www.bilibili.com/video/av9875360/)\n* 9 -  [高级 CPU 设计 - Advanced CPU Designs](https://www.bilibili.com/video/av11867964/)\n* 10 - [编程史话 - Early Programming](https://www.bilibili.com/video/av13582556/)\n* 11 - [编程语言 - The First Programming Languages](https://www.bilibili.com/video/av14228148/)\n* 12 - [编程原理：语句和函数 - Programming Basics: Statements & Functions](https://www.bilibili.com/video/av14885759/)\n* 13 - [算法初步 - Intro to Algorithms](https://www.bilibili.com/video/av15987761/)\n* 14 - [数据结构 - Data Structures](https://www.bilibili.com/video/av15987774/)\n* 15 - [阿兰·图灵 - Alan Turing](https://www.bilibili.com/video/av16090115/)\n* 16 - [软件工程 - Software Engineering](https://www.bilibili.com/video/av16751202/)\n* 17 - [集成电路、摩尔定律 - Integrated Circuits & Moore’s Law](https://www.bilibili.com/video/av17186768)\n* 18 - [操作系统 - Operating Systems](https://www.bilibili.com/video/av17192468)\n* 19 - [内存 & 储存介质 - Memory & Storage](https://www.bilibili.com/video/av17192483/)\n* 20 - [文件系统 - Files & File Systems](https://www.bilibili.com/video/av17209268/)\n* 21 - [压缩 - Compression](https://www.bilibili.com/video/av17192511/)\n* 22 - [命令行界面 - Keyboards & Command Line Interfaces](https://www.bilibili.com/video/av17451718/)\n* 23 - [屏幕 & 2D 图形显示 - Screens & 2D Graphics](https://www.bilibili.com/video/av17476087/)\n* 24 - [冷战和消费主义 - The Cold War and Consumerism](https://www.bilibili.com/video/av15637307/)\n* 25 - [个人计算机革命 - The Personal Computer Revolution](https://www.bilibili.com/video/av18789303/)\n* 26 - [图形用户界面 - Graphical User Interfaces](https://www.bilibili.com/video/av19035296/)\n* 27 - [3D 图形 - 3D Graphics](https://www.bilibili.com/video/av19164942/)\n* 28 - [计算机网络 - Computer Networks](https://www.bilibili.com/video/av19209394/)\n* 29 - [互联网 - The Internet](https://www.bilibili.com/video/av20716104/)\n* 30 - [万维网 - The World Wide Web](https://www.bilibili.com/video/av20767130/)\n* 31 - [网络安全 - Cybersecurity](https://www.bilibili.com/video/av20785456/)\n* 32 - [黑客与攻击 - Hackers & Cyber Attacks](https://www.bilibili.com/video/av20831479/)\n* 33 - [加密 - Cryptography](https://www.bilibili.com/video/av20882310/)\n* 34 - [机器学习与人工智能 - Machine Learning & Artificial Intelligence](https://www.bilibili.com/video/av20922906)\n* 35 - [计算机视觉 - Computer Vision](https://www.bilibili.com/video/av20974735)\n* 36 - [自然语言处理 - Natural Language Processing](https://www.bilibili.com/video/av21004070)\n* 37 - [机器人 - Robots](https://www.bilibili.com/video/av21043523)\n* 38 - [计算机中的心理学 - Psychology of Computing](https://www.bilibili.com/video/av21066931)\n* 39 - [教育型科技 - Educational Technology](https://www.bilibili.com/video/av21103744)\n* 40 - [(完结) 奇点，天网，计算机的未来 - The Singularity, Skynet, and the Future of Computing](https://www.bilibili.com/video/av21126704)      \n\n精校版质量更好，建议看精校版，之所以第一版目录不删：      \n1. 方便快速扫视，看都聊什么话题     \n2. 方便翻阅之前的版本（如果有需要）        \n\n备注：精校负责人是 @糖醋陈皮\n\n## 翻译时间\n英文版：    \n第 1 集发布： 2017年2月22号    \n第 40 集发布：2017年12月21号     \n\n中文版：     \n第 1 集发布：  2017年2月27号  \n全 40 集翻译完成：2018年3月24号  \n全 40 集精校完成：2018年5月1号  \n\n\n### 原视频\n[Youtube - Crash Course Computer Science Playlist](https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo)     \n![Crash Course CS screenshoht](/image/english.png)       \n\n\n# Thank you Crash Course & Carrie Anne!\n* Patron support Crash Course：https://www.patreon.com/crashcourse  <br/>\n* Crash Course website：https://thecrashcourse.com/\n* Youtube Crash Course: https://www.youtube.com/user/crashcourse\n\n# 感谢速成课！感谢 Carrie Anne！\n* Patron 支持 Crash Course：https://www.patreon.com/crashcourse  <br/>\n* Crash Course 官方网站：https://thecrashcourse.com/\n* Youtube Crash Course: https://www.youtube.com/user/crashcourse\n\n## 片头总结\n\n## 第 1 集：计算机早期历史  \n提到的设备：算盘 → 步进计算器 → 差分机 → 分析机 → 打孔卡片制表机  \n提到的人名：Charles Babbage, Ada Lovelace  \n\n02:27  最早的计算设备是算盘，举例如何使用  \n04:31  Computer 从指代职业变成指代机器  \n04:57  机器里有名的是：步进计算器。第一个可以做加减乘除的机器  \n06:44  炮弹为了精准，要计算弹道，二战是查表来做。但每次改设计了就需要做一张新表  \n07:30  Charles Babbage 提出了 &quot;差分机&quot;, 在构造差分机期间，想出了分析机, 分析机是通用计算机  \n08:50  Lovelace 给分析机写了假想程序，因此成为了第一位程序员  \n09:25  人口普查 10 年一次.  Herman Hollerith 的打孔卡片制表机大大提升了效率  \n\n\n## 第 2 集：电子计算机  \n提到的设备：继电器 → 真空管 → 晶体管  \n\n00:17  20世纪的发展要求更强的计算能力。柜子大小的计算机发展到房间大小  \n01:06  哈佛  Mark 1 号，IBM 1944 年做的  \n02:25  继电器，继电器一秒最多 50 次开关  \n03:24  继电器出 bug  \n03:49  1904 年，热电子管出现，第一个真空管。改进后变成和继电器的功能一样  \n05:34  &quot;巨人1号&quot; 计算机在英国 布莱切利园 首次大规模使用真空管。但编程麻烦，还要配置  \n06:40  1946 年，宾夕法尼亚大学的 ENIAC 是第一个通用可编程计算机  \n07:36  1947 年，贝尔实验室做出了晶体管，晶体管有诸多好处，IBM 很快全面转向晶体管  \n09:27  硅谷的典故：很多晶体管和半导体的开发都是这里做的。而生产半导体最常见的材料是硅  \n09:41  肖克利半导体 → 仙童半导体 → 英特尔  \n\n\n## 第 3 集：布尔逻辑和逻辑门  \n01:00  什么是二进制, 为什么用二进制, 布尔逻辑  \n02:46  3个基本操作：NOT，AND，OR  \n02:51  解释3个基本操作  \n07:11  XOR 异或  \n\n\n## 第 4 集：二进制  \n00:46  用十进制举例二进制的原理，演示二进制加法。存储单位 MB GB TB 等  \n05:30  正数，负数，整数，浮点数的表示  \n07:20  美国信息交换标准代码 - ASCII, 用来表示字符  \n09:00  UNICODE 1992 年诞生，是字符编码标准， 解决 ASCII 不够表达所有语言的问题  \n\n\n## 第 5 集：算数逻辑单元 - ALU  \n00:03  简单介绍 ALU ，英特尔 74181  \n01:24  ALU 有 2 个单元，1 个算术单元和 1 个逻辑单元  \n\n01:32  算术单元  \n半加器 (处理1个 bit，2个输入)  \n全加器 (处理1个 bit，3个输入)  \n8 bit 加法 (1个半加器，7个全加器）  \n溢出的概念，吃豆人的例子  \n乘法除法  \n\n07:32  逻辑单元  \n检测数字是否为 0 的电路（一堆 OR 门最后加个 NOT 门）  \nALU 抽象成一个 V 符号  \nFlag 标志（是否相等，是否小于，是否溢出等等）  \n\n\n## 第 6 集：寄存器和内存  \n本集重点是 Memory （存储 / 内存 两种含义）  \n\n03:30  存 1 位  (Gated Latch - 锁存器）  \n04:48  存 8 位  (Register - 寄存器)  \n\n05:46  16x16 的矩阵存 256 位  \n数据选择器/多路复用器 (Multiplexer) 解码 8 位地址，定位到单个锁存器  \n\n07:38  4 位代表行， 4 位代表列  \n\n08:16  组合 256 位内存 + 多路复用器  \n09:01  可寻址的 256 字节 内存  \n一条1980年代的内存，1M 大小  \n\n10:14  8个模块，每个模块有32个小方块，  \n每个小方块有 4 个小块，每个小块是 128 位 x 64 位  \n\n\n## 第 7 集：中央处理器（CPU)  \n重点  \n1. 拼个 CPU 出来  \n2. CPU 怎么执行命令  \n\n01:00  RAM + 寄存器 + ALU  做个 CPU  \n04:00  解释  &quot;取指令→解释→执行&quot; 这个循环  \n08:00  时钟是什么, 时钟速度和赫兹  \n10:00  超频提升性能, 降频省电  \n\n\n## 第 8 集：指令和程序  \n本集重点：一步步带你运行一遍程序  \n\n00:45  回顾上集的例子程序，一步步讲解。介绍”指令集”的概念  \nLOAD_A，LOAD_B，SUB，JUMP，ADD，HALT 等指令  \n05:16  带条件跳转，JUMP NEGATIVE 是负数才跳转，还有其他类型的 JUMP  \n08:00  真正现代 CPU 用更多指令集。位数更长。  \n09:07  1971年的英特尔 4004 处理器，有 46 个指令  \n09:36  如今英特尔酷睿 i7, 有上千条指令  \n\n\n\n## 第 9 集：高级 CPU 设计  \n00:24  早期是加快晶体管切换速度，来提升 CPU 速度  \n01:20  给 CPU 专门的除法电路 + 其他电路来做复杂操作，比如游戏，视频解码  \n02:28  给 CPU 加缓存，提高数据存取速度，更快喂给 CPU，用计算餐馆销售额举例  \n05:13  脏位 -  Dirty bit  \n05:33  流水线设计，用 1 个洗衣机和 1 个干燥机举例  \n06:01  并行处理 -  parallelize  \n07:33  乱序执行 -  out-of-order execution  \n08:21  推测执行 -  speculative execution  \n08:50  分支预测 -  branch prediction  \n09:34  多个 ALU  \n09:54  多核 (Core)  \n10:11  多个独立 CPU  \n10:52  超级计算机，中国的&quot;神威 太湖之光&quot;  \n\n\n## 第 10 集：早期的编程方式  \n本集重点：早期计算机如何编程  \n打孔纸卡 → 插线板 → 面板拨开关  \n\n00:00  开头说本集重点：程序如何进入计算机  \n00:53  拿纺织业举例，给机器编程的需求远在计算机出现前就有了  \n01:41  打孔纸卡 - Punched card  \n02:36  插线板 - Plugboard  \n04:20  冯诺依曼架构 - Von Neumann Architecture  \n07:00  面板编程 - Panel programming  \n07:29  第一款取得商业成功的家用计算机:  Altair 8800  \n08:15  编程依然很困难，人们需要更友好更简单的方式编程  \n08:44  下周主题：编程语言  \n\n\n## 第 11 集：编程语言发展史  \n编程：二进制 → 助记符（汇编器）→ A-0（编译器）→ FORTRAIN  \n\n01:45  二进制写程序，先纸上写伪代码，手工转二进制，很快就烦了  \n02:28  用 &quot;助记符” 写代码（LOAD_A 14）为了把助记符转二进制，汇编器诞生 (Assembler)  \n04:32  葛丽丝·霍普 (Grace Hopper)  - 哈佛1号计算机首批程序员, 海军军官  \n05:13  Grace 设计了编程语言 A-0  \n05:29  Grace 1952 年做了第一个编译器 (Compiler)，实现 A-0  \n06:29  变量 (Variables)  \n07:01  FORTRAN  \n08:18  COBOL  \n09:25  新语言  \n1960 年代：ALGOL，LISP，BASIC  \n1970 年代：Pascal，C，Smalltalk  \n1980 年代：C++，Objective-C，Perl  \n1990 年代：Python，Ruby，Java  \n\n\n## 第 12 集：编程基础 - 语句和函数  \n00:50  变量, 赋值语句  \n02:08  Grace Hopper 拍虫子游戏  \n02:52  if 判断  \n04:19  while 循环  \n05:48  for 循环  \n07:00  函数  \n11:11  下集介绍算法  \n\n\n## 第 13 集：算法入门  \n03:00  选择排序 - Selection sort  \n03:52  大 O 表示法 - Big O notation  \n04:31  归并排序 - Merge sort  \n08:03  Dijkstra 算法  \n\n\n## 第 14 集：数据结构  \n00:39   数组     - Array  \n02:06   字符串  - String  \n03:12   矩阵     - Matrix  \n04:05   结构体  - Struct  \n04:46   指针     - Pointer  \n04:44   节点     - Node  \n04:53   链表     - Linked List  \n06:21   队列     - Queue  \n06:21   栈        - Stack  \n07:31   树        - Tree  \n08:01   二叉树 - Binary Tree  \n08:26   图        - Graph  \n08:50   没时间讲红黑树和堆, 不同数据结构适用不同场景  \n\n\n## 第 15 集：阿兰·图灵  \n00:33   介绍图灵  \n00:52   可判定性问题  \n01:14   阿隆佐·丘奇，Lambda 算子  \n01:38   图灵机  \n04:54   停机问题  \n08:09   破解德军英格玛加密机  \n10:40   图灵测试  \n11:18   图灵的个人生活  \n12:07   图灵奖  \n\n\n## 第 16 集：软件工程  \n01:31  对象  Object  \n02:39  面向对象编程  Object Oriented Programming.  \n03:55  API  Application Programming Interface  \n04:33  public, private  \n05:36  集成开发环境, IDE - Integrated Development Environments  \n06:09  调试 debugging  \n06:31  文档和注释 - readme, comment  \n07:33  版本控制   Version control  \n08:50  质量控制   Quality Assurance testing，QA  \n09:21  Beta, Alpha  \n\n\n## 第 17 集：集成电路与摩尔定律  \n本集重点：晶圆的制作流程：光刻  (04:21~07:42)  \n\n00:51  分立元件  Discrete components  \n01:09  数字暴政  Tyranny of Numbers - 是 1960 年代工程师碰到的问题  \n意思是如果想加强电脑性能，就要更多部件，这导致更多线路，更复杂。所以很难做  \n04:21  光刻         Photolithography  \n04:26  晶圆         Wafer  \n04:57  光刻胶     Photoresist  \n05:08  光掩膜     Photomask  \n06:00  掺杂         Doping  \n09:09  摩尔定律   Moore’s Law.  \n09:38  英特尔      Intel  \n10:20  晶体管数量大幅度增长, 1980年三万个，1990年一百万个，2000年三千万个，2010年十亿个  \n11:44  进一步小型化会碰到 2 个问题  1. 光的波长不足以制作更精细的设计  2. 量子隧穿效应  \n\n\n## 第 18 集：操作系统  \n00:48  操作系统  Operating systems  \n01:34  批处理     Batch processing  \n01:58  计算机变便宜变多，有不同配置，写程序处理不同硬件细节很痛苦，因此操作系统负责抽象硬件  \n02:12  外部设备         Peripherals  \n02:48  设备驱动程序   Device drivers  \n04:43  多任务处理      Multitasking  \n05:54  虚拟内存         Virtual Memory  \n07:09  动态内存分配  Dynamic memory allocation  \n07:31  内存保护         Memory Protection  \n07:54  1970年代，计算机足够便宜，大学买了让学生用，多个学生用多个 &quot;终端&quot; 连接到主机  \n08:29  多用户分时操作系统，Multics  \n09:32  Unix  \n11:02  MS-DOS  \n12:09  下集是内存&amp;存储介质  \n\n\n## 第 19 集：内存&amp;储存介质  \n本集重点：存储技术的发展  \n\n01:01  纸卡                Paper punch cards  \n02:01  延迟线存储器  Delay Line Memory  \n04:06  磁芯               Magnetic Core Memory  \n06:08  磁带               Magnetic Tape  \n07:08  磁鼓               Magnetic Drum Memory  \n07:43  硬盘               Hard Disk Drives  \n08:53  内存层次结构  Memory Hierarchy  \n09:36  软盘                Floppy Disk  \n10:09  光盘                Compact Disk  \n10:51  固态硬盘         Solid State Drives  \n\n\n## 第 20 集：文件系统  \n00:47  文件格式：可以随便存文件数据，但按格式存会更方便  \n01:00  TXT   文本文件：ASCII  \n01:31  WAV 音频文件：每秒上千次的音频采样数字  \n02:47  BMP  图片文件：像素的红绿蓝 RGB 值  \n04:43  文件系统：很早期时空间小，整个存储器就像一整个文件。后来随容量增长，多文件非常必要  \n05:37  目录文件：用来解决多文件问题，存其他文件的信息，比如开头，结尾，创建时间等  \n\n06:39  平面文件系统 - Flat File System：文件都在同一个层次，早期空间小，只有十几个文件，平面系统够用  \n\n06:57  如果文件紧密的一个个前后排序会造成问题，所以文件系统会： 1. 把空间划分成一块块  2. 文件拆分存在多个块里  \n\n08:30  文件的增删改查会不可避免的造成文件散落在各个块里，  \n如果是磁带这样的存储介质就会造成问题，所以做碎片整理  \n\n09:46  分层文件系统 - Hierarchical File System：有不同文件夹，文件夹可以层层嵌套  \n\n第21集讲压缩  \n\n\n## 第 21 集：压缩  \n00:26  压缩的好处是能存更多文件，传输也更快  \n01:52  游程编码   Run-Length Encoding  \n02:45  无损压缩   Lossless compression  \n03:55  霍夫曼树   Huffman Tree  \n05:56  &quot;消除冗余&quot;和&quot;用更紧凑的表示方法&quot;，这两种方法通常会组合使用  \n06:07  字典编码   Dictionary coders,  游程编码 和 字典编码 都是无损压缩  \n08:03  感知编码   Perceptual coding  \n08:09  有损压缩   jpeg 格式  \n09:39  时间冗余   Temporal redundancy  \n10:30  MPEG-4 视频编码  \n\n\n## 第 22 集：命令行界面  \n本集重点：计算机早期同时输入程序和数据（用纸卡/纸带）  \n运行开始直到结束，中间没有人类进行操作，  \n原因是计算机很贵，不能等人类慢慢输入，执行完结果打印到纸上 (02:34)  \n\n到1950年代，计算机足够便宜+快，人类和计算机交互式操作变得可行  \n为了让人类输入到计算机，改造之前就有的打字机，变成电传打字机 (02:44~05:38)  \n\n到1970年代末，屏幕成本足够低，屏幕代替电传打字机，屏幕成为标配 (07:24)  \n\n00:32  人机交互  Human-Computer Interaction  \n00:50  早期输出数据是打印到纸上，而输入是用纸卡/纸带一次性把程序和数据都给进去  \n03:00  QWERTY  打字机的发展，克里斯托弗·莱瑟姆·肖尔斯 发明于 1868 年  \n05:38  电传打字机  Teletype machine  \n06:32  命令行界面  Command line interface  \n06:38  ls 命令  \n08:22  早期文字游戏  Zork  (1977年)  \n08:47  cd 命令  \n\n\n## 第 23 集：屏幕与 2D 图形显示  \n00:05   PDP-1 计算机。键盘和显示器分开，屏幕显示临时值  \n01:14   阴极射线管  Cathode Ray Tube (CRT)  \n01:38   CRT 有两种绘图方式：  \n矢量扫描  Vector Scanning  \n光栅扫描  Raster Scanning  \n\n02:14   液晶显示器   Liquid Crystal Displays (LCD)，像素 (Pixel)  \n03:32   字符生成器   Character generator  \n03:45   屏幕缓冲区   Screen buffer  \n05:09   矢量命令画图  \n06:34   Sketchpad,  光笔 (Light pen)  \n09:00   函数画线，矩形  \n\n\n## 第 24 集：冷战和消费主义  \n本集重点：冷战导致美国往计算机领域投入大量资源  (00:00~01:43)  \n\n范内瓦·布什 预见了计算机的潜力，提出假想机器 Memex  \n帮助建立 国家科学基金会，给科学研究提供资金  (01:43~03:43)  \n\n1950 年代消费者开始买晶体管设备，收音机大卖  \n日本取得晶体管授权后，索尼做了晶体管收音机，为日本半导体行业崛起埋下种子 (03:43~04:29）  \n\n苏联 1961 年把宇航员加加林送上太空，导致美国提出登月  \nNASA 预算大大增加，用集成电路来制作登月计算机 (04:29~06:27)  \n\n集成电路的发展实际上是由军事应用大大推进的，阿波罗登月毕竟只有 17 次  \n美国造超级计算机进一步推进集成电路 (04:29~07:11)  \n\n美国半导体行业一开始靠政府高利润合同活着，忽略消费者市场，1970年代冷战渐消，行业开始衰败  \n很多公司倒闭，英特尔转型处理器 (07:11~08:23)  \n\n末尾总结：政府和消费者推动了计算机的发展  \n早期靠政府资金，让技术发展到足够商用，然后消费者购买商用产品继续推动产品发展 (08:23~10:41)  \n\n\n## 第 25 集：个人计算机革命  \n本集：全是历史故事  \n00:18   1970年代初成本下降，个人计算机变得可行  \n01:51   Altair 8800  \n02:32   比尔·盖茨 和 保罗·艾伦写 BASIC 解释器  \n03:45   乔布斯提议卖组装好的计算机，Apple-I 诞生  \n04:40   1977年出现3款开箱即用计算机：  \n&quot;Apple-II&quot;，&quot;TRS-80 Model I&quot;，&quot;Commodore PET 2001&quot;  \n\n06:26   IBM 意识到个人计算机市场  \nIBM PC 发布，采用开放架构，兼容的机器都叫 IBM Compatible (IBM 兼容)  \n生态系统产生雪球效应：  \n因为用户多，软硬件开发人员更愿意花精力在这个平台  \n因为软硬件多，用户也更乐意买 &quot;IBM 兼容&quot; 的计算机  \n\n08:44   苹果选封闭架构，一切都自己来，只有苹果在非  &quot;IBM 兼容&quot; 下保持了足够市场份额  \n\n\n## 第 26 集：图形用户界面 (GUI)  \n01:10  图形界面先驱：道格拉斯·恩格尔巴特（Douglas Engelbart）  \n03:20  1970年成立 帕洛阿尔托研究中心（Palo Alto Research Center）  \n03:29  1973年完成 Xerox Alto(施乐奥托) 计算机  \n04:42  举例：写一个简单的 GUI 程序  \n06:38  1981年的 Xerox Star system(施乐之星系统)  \n08:18  史蒂夫·乔布斯去施乐参观  \n07:45  所见即所得 WYSIWYG  \n09:15  1983年推出 Apple Lisa  \n09:31  1984年推出 Macintosh  \n10:12  1985年推出 Windows 1.0，之后出到 3.1  \n10:43  1995年推出 Windows 95 提供图形界面  \n11:08  1995年微软做失败的 Microsoft Bob  \n\n\n## 第 27 集：3D 图形  \n01:15   线框渲染  Wireframe Rendering  \n01:39   正交投影  Orthographic Projection  \n01:50   透视投射  Perspective Projection  \n02:14   网格  Mesh  \n02:37   三角形更常用因为能定义唯一的平面  \n03:09   扫描线渲染  Scanline Rendering  \n05:04   遮挡            Occlusion  \n05:19   画家算法     Painter&apos;s Algorithm  \n06:09   深度缓冲      Z Buffering  \n07:45   Z Fighting 错误  \n07:51   背面剔除      Back Face Culling  \n08:53   表面法线      Surface Normal  \n09:33   平面着色      Flat Shading  \n09:43   高洛德着色   Gouraud shading,  冯氏着色  Phong Shading  \n10:06   纹理映射      Texture Mapping  \n11:24   图形处理单元  GPU, Graphics Processing Unit  \n\n\n## 第 28 集：计算机网络  \n02:05   局域网   Local Area Networks - LAN  \n02:36   媒体访问控制地址   Media Access Control address - MAC  \n02:55   载波侦听多路访问   Carrier Sense Multiple Access - CSMA  \n05:18   指数退避   Exponential Backoff  \n05:36   冲突域       Collision Domain  \n07:08   电路交换   Circuit Switching  \n07:36   报文交换   Message Switching  \n10:20   分组交换   Packet Switching  \n\n\n## 第 29 集：互联网  \n02:23  IP - 互联网协议 - Internet Protocol  \n03:00  UDP - 用户数据报协议 - User Datagram Protocol  \n03:41  校验和 - Checksum  \n05:26  TCP - 传输控制协议 - Transmission Control Protocol  \n08:21  DNS - 域名系统 - Domain Name System  \n10:47  OSI - 开放式系统互联通信参考模型 - Open System Interconnection  \n\n\n## 第 30 集：万维网  \n01:01  超链接  Hyperlinks  \n02:20  URL - 统一资源定位器 - Uniform Resource Locator  \n03:01  HTTP - 超文本传输协议 -  HyperText Transfer Protocol  \n04:13  HTML - 超文本标记语言  - HyperText Markup Language  \n04:24  写一个简单网页，用到了 &lt;h1&gt; &lt;a&gt; &lt;h2&gt; &lt;ol&gt; &lt;li&gt; 标签  \n06:04  第一个浏览器和服务器是 Tim Berners-Lee 花了 2 个月在 CERN 写的  \n06:32  1991年正式发布，万维网就此诞生  \n07:19  开始讲搜索引擎的故事  \n07:40  Jerry 和 David 的万维网指南 后来改名成 Yahoo  \n07:52  搜索引擎  JumpStation  \n09:07  搜索引擎  Google  \n09:20  网络中立性  \n\n\n## 第 31 集：计算机安全  \n01:00   Secrecy, Integrity, Availability  \n保密性, 完整性, 可用性  \n01:49   Threat Model 威胁模型  \n\n03:14   身份验证 (Authentication) 的三种方式：  \nWhat you know, 你知道什么  \nWhat you have, 你有什么  \nWhat you are, 你是什么  \n\n07:34   访问控制   Access Control  \n08:48   Bell LaPadula model  不能向上读取，不能向下写入  \n11:00   隔离 Isolation, 沙盒 Sandbox  \n\n\n## 第 32 集：黑客与攻击  \n01:28  社会工程学   Social Engineering  \n01:38  钓鱼             Phishing  \n02:06  假托             Pretexting  \n02:50  木马             Trojan Horses  \n03:32  NAND镜像  NAND Mirroring  \n04:12  漏洞利用      Exploit  \n04:16  缓冲区溢出   Buffer Overflow  \n05:45  边界检查      Bounds Checking  \n06:16  代码注入      Code Injection  \n09:32  零日漏洞      Zero Day Vulnerability  \n09:53  计算机蠕虫   Worms  \n09:58  僵尸网络      Botnet  \n10:11  拒绝服务攻击   DDoS  \n\n\n## 第 33 集：加密  \n00:16  多层防御  Defence in depth  \n01:00  加密 - Encryption，解密 - Decryption  \n01:11  凯撒加密  Caesar cipher  \n01:27  替换加密  Substitution cipher  \n01:59  移位加密  Permutation cipher  \n02:03  列移位加密  Columnar transposition cipher  \n02:37  德国 Enigma 加密机  \n04:54  1977年&quot;数据加密标准&quot; - Data Encryption Standard (DES)  \n05:24  2001年&quot;高级加密标准&quot; - Advanced Encryption Standard (AES)  \n07:06  密钥交换 - Key exchange  \n07:33  用颜色来举例&quot;单向函数&quot;和&quot;密钥加密&quot;的原理  \n08:24  迪菲-赫尔曼密钥交换 - Diffie-Hellman Key Exchange  \n10:18  非对称加密 - Asymmetric encryption  \n11:22  非对称加密算法  RSA  \n\n\n## 第 34 集：机器学习与人工智能  \n01:23   分类              Classification  \n01:25   分类器           Classifier  \n01:34   特征               Feature  \n02:03   标记数据        Labeled data  \n02:38   决策边界        Decision boundaries  \n03:00   混淆矩阵        Confusion matrix  \n03:39   未标签数据     Unlabeled data  \n03:49   决策树            Decision tree  \n04:25   支持向量机     Support Vector Machines  \n05:52  人工神经网络   Artificial Neural Network  \n08:34  深度学习         Deep learning  \n09:21  弱AI, 窄AI      Weak AI, Narrow AI  \n09:43  强AI               Strong AI  \n10:42  强化学习         Reinforcement Learning  \n\n\n## 第 35 集：计算机视觉  \n02:41  检测垂直边缘的算法  \n03:26  核/过滤器  kernel or filter  \n03:56  卷积 convolution  \n04:23  Prewitt 算子   Prewitt Operators  \n05:34  维奥拉·琼斯 人脸检测   Viola-Jones Face Detection  \n05:35  卷积神经网络   Convolutional Neural Networks  \n07:33  识别出脸之后，可以进一步用其他算法定位面部标志，如眼睛和眉毛具体位置，从而判断心情等信息  \n08:52  跟踪全身的标记点，如肩部，手臂等  \n\n\n## 第 36 集：自然语言处理  \n01:50  词性                   Parts of speech  \n02:15  短语结构规则      Phrase structure rules  \n02:32  分析树                Parse tree  \n05:30  语音识别             Speech recognition  \n07:26  谱图                    Spectrogram  \n07:44  快速傅立叶变换   Fast Fourier Transform  \n08:42  音素                   Phonemes  \n09:29   语音合成           Speech Synthesis  \n\n\n## 第 37 集：机器人  \n02:08  法国吃饭鸭 - Digesting Duck, Canard Digerateur  \n02:23  土耳其行棋傀儡, 下国际象棋  \n02:43  第一台计算机控制的机器出现在1940年代晚期，叫数控机器, Computer Numerical Control(CNC)  \n03:32  1960年 Unimate，第一个商业贩卖的 可编程工业机器人  \n03:47  简单控制回路  simple control loop  \n04:08  负反馈回路  negative feedback loop  \n05:17  比例-积分-微分控制器   Proportional–Integral–Derivative controller   PID 控制器  \n10:48  机器人三定律   Three Laws of Robotics  \n\n\n## 第 38 集：计算机心理学  \n00:45  我们需要了解人类心理学，做出更好的计算机  \n01:12  易用度 - Usability  \n01:31  颜色强度排序 和 颜色排序  \n02:30  分组更好记，电话号码 317-555-3897 比 3175553897 好记  \n03:25  直观功能 - Affordances  \n04:33  认出 vs 回想 Recognition vs Recall  \n05:45  让机器有一定情商以及 Facebook 的研究  \n08:40  用软件修正注视位置。让视频通话时看起来像盯着对方，而不是盯着下方  \n09:58  把机器人做的像人，恐怖谷理论  \n11:35  有很多开放式的问题，心理学帮助我们明白不同选择可能带来的影响  \n\n\n## 第 39 集：教育科技  \n02:15  通过调速，暂停等技巧，加强学习效率  \n03:15  大型开放式在线课程  - Massive Open Online Courses  (MOOC)  \n05:08  智能辅导系统 - Intelligent Tutoring Systems  \n05:22  判断规则 - Production rule  \n06:10  域模型 - Domain Model  \n06:46  贝叶斯知识追踪  Bayesian knowledge tracing  \n1. 学生已经学会的概率  \n2. 瞎猜的概率  \n3. 失误的概率  \n4. 做题过程中学会的概率  \n09:27  教育数据挖掘  Educational Data Mining  \n\n\n## （完结）第 40 集：奇点，天网，计算机的未来  \n01:21  普适计算  Ubiquitous Computing  \n04:55  奇点         Singularity  \n06:51  把工作分为4个象限，讨论自动化带来的影响  \n10:15  机器人的存在时间可能长过人类，可以长时间探索宇宙  \n"
  },
  {
    "path": "extract_from_ass_subtitle/2. extract_head.js",
    "content": "const assParser = require('ass-parser');\nconst fs = require('fs');\nconst common = require('./common.js');\nconst path = require('path')\n\n/*\n2018-6-8 周五 03:42\n\n1. 是什么：\n  从 40 个 .ass 字幕文件中提取片头文字（共2行字幕，字幕样式名统一）\n  仅针对 [计算机科学速成课] Crash Course Computer Science\n\n2. 使用方法：\n  node 2.\\ extract_head.js\n\n3. 备注：\n  所有40集 ass 字幕文件，要和这个脚本放到同一个目录下\n  文件命名必须类似：1. 计算机早期历史-Early Computing.ass\n  1. 开头\n  .ass 结尾\n  因为我们要按顺序读取\n\n  代码是半夜2点写的，目的是快速 hack 出来，\n  所以有些代码不是最“高效”的（比如循环很多次）就不要吐槽啦，管用就好\n*/\n\nvar result = '' // 存临时结果\nvar final_result = ''; // 存最终结果\n\nvar folder = '/Users/remote_edit/Desktop/ass/'\n\n// 循环当前目录下的 ass 文件，按 1，2，3，4...一直到 40 这样的顺序\nfunction loop_current_folder_ass_file_in_order(){\n  fs.readdir(folder, (err, files) => {\n    for (var i = 1; i <= 40; i++) {     // 40*40(files)=1600 loop, I know.. I know.. not the most ‘efficient’ code, but it's good enough\n      files.forEach(file => {           // file == 1. 计算机早期历史-Early Computing.ass\n        var number = file.split('.')[0] // number == 1\n        var ext = path.extname(file);   // ext == ass\n        if (parseInt(number) === i && ext === '.ass'){\n          extract_main_point(file, number);\n        }\n      });\n    }\n  })\n}\n\n// 抽取重点出来，那两行字幕的样式在全部40集中都是统一的，叫'备注 - 主题'和'这一集的名字'\nfunction extract_main_point(file, number){\n  var text = fs.readFileSync(file,'utf8')\n  data = assParser(text);\n  body = data[3]['body'];\n\n  for (var i = 0; i <= body.length-1; i++) {\n    var element = body[i];\n    if (element.key == 'Dialogue') {\n      if (element.value.Style == '这一集的名字'){\n        var text = element.value.Text;\n        text = common.remove_curly_brace_keep_text(text);\n        // console.log(text);\n        result = result + '## ' + text + '\\n';\n      }\n    }\n  }\n\n  for (var i = 0; i <= body.length-1; i++) {\n    var element = body[i];\n    if (element.key == 'Dialogue') {\n      if (element.value.Style == '备注 - 主题'){\n        var text = element.value.Text;\n        text = common.remove_curly_brace_keep_text(text);\n        // console.log(text);\n        result = result + text.replace(/\\\\N/g, '\\n') + '\\n\\n\\n';\n      }\n    }\n  }\n\n\n  // 如果到了最后一集\n  if (number == 40){\n    // 清理两边空格（trim)，然后末尾加俩空格作为 markdown 换行\n    var line_array = result.split('\\n');\n    line_array.forEach(l => {\n      final_result = final_result + l.trim() + '  ' + '\\n';\n    })\n    // 处理 HTML entity\n    final_result = common.convertHTML(final_result);\n    // 写文件\n    fs.writeFile(\"CS_40episode_point.md\", final_result, function(err) {\n        if(err) {\n            return console.log(err);\n        }\n        console.log(\"The file was saved!\");\n    });\n  }\n}\n\n// =============\n\nloop_current_folder_ass_file_in_order();\n"
  },
  {
    "path": "extract_from_ass_subtitle/3. extract_ass_to_txt.js",
    "content": "// ass to txt\n// 不写注释了，参考 2. extract_head.js 即可\n\nconst assParser = require('ass-parser');\nconst fs = require('fs');\nconst common = require('./common.js');\nconst path = require('path')\n\nvar result = ''\nvar folder = '/Users/remote_edit/Desktop/ass/' // 40 集字幕文件的文件夹\n\nfunction loop_current_folder_ass_file_in_order(){\n  fs.readdir(folder, (err, files) => {\n    for (var i = 1; i <= 40; i++) {     // 40*40(files)=1600 loop, I know.. I know.. not the most ‘efficient’ code, but it's good enough\n      files.forEach(file => {           // file == 1. 计算机早期历史-Early Computing.ass\n        var number = file.split('.')[0] // number == 1\n        var ext = path.extname(file);   // ext == ass\n        if (parseInt(number) === i && ext === '.ass'){\n          extract_main_point(folder+file, number);\n        }\n      });\n    }\n  })\n}\n\n\nfunction extract_main_point(file, number){\n  var text = fs.readFileSync(file,'utf8')\n  data = assParser(text);\n  body = data[3]['body'];\n\n  for (var i = 0; i <= body.length-1; i++) {\n    var element = body[i];\n    if (element.key == 'Dialogue') {\n      if (element.value.Style == 'en - 白色'){\n        var text = element.value.Text;\n        text = common.remove_curly_brace_keep_text(text);\n        result = result + text.trim() + '\\n';\n      }\n      if (element.value.Style == 'zh - 黄色'){\n        var text = element.value.Text;\n        text = common.remove_curly_brace_keep_text(text);\n        result = result + text.trim() + '\\n\\n';\n      }\n    }\n  }\n\n  // 写文件\n  // if (number == 40){\n    fs.writeFile(file+'.txt', result, function(err) {\n        if(err) {\n            return console.log(err);\n        }\n        console.log(\"The file was saved!\");\n    });\n  // }\n\n  result = '';\n}\n\n// =============\n\nloop_current_folder_ass_file_in_order();\n"
  },
  {
    "path": "extract_from_ass_subtitle/README.md",
    "content": "## 这里是一些 Node.js 代码\n\n## 用途\n抽取 ass 字幕文件的信息       \n\n## 说明\n针对计算机速成课的 ass 字幕                \n不通用（不能随便把什么 .ass 都拿来当输入），就是快速 hack 了一下写了点 node.js 代码把事情搞定     \n\nInput: 40个 .ass 后缀的字幕文件     \nOutput: 看下面的说明    \n\n`2. extract_head.js` 负责抽取40集的片头文字总结，放到一个文件中（结果：1个 .md 文件）        \n`3. extract_ass_to_txt.js` 把 ass 转成 txt （结果：40个 .txt 文件）       \n"
  },
  {
    "path": "extract_from_ass_subtitle/common.js",
    "content": "// Remove all {}\n// Input: \"{\\c&HCC9933&}Subtitles by {\\c\\c&HFFFFFF &}MemoryOnSmells{\\c} {\\c&HCC9933&}Exclusive for http://UKsubtitles.ru{\\c}\"\n// Output: \"Subtitles by MemoryOnSmells  Exclusive for http://UKsubtitles.ru\"\nfunction remove_curly_brace_keep_text(str) {\n  return str.replace(/\\s*\\{.*?\\}\\s*/g, ' ').trim();\n}\n\nfunction convertHTML(str) {\n    var entityPairs = [\n        {character: '&', html: '&amp;'},\n        {character: '<', html: '&lt;'},\n        {character: '>', html: '&gt;'},\n        {character: \"'\", html: '&apos;'},\n        {character: '\"', html: '&quot;'},\n    ];\n\n    entityPairs.forEach(function(pair){\n        var reg = new RegExp(pair.character, 'g');\n        str = str.replace(reg, pair.html);\n    });\n    return str;\n}\n\nexports.remove_curly_brace_keep_text = remove_curly_brace_keep_text\nexports.convertHTML = convertHTML\n"
  },
  {
    "path": "extract_from_ass_subtitle/package.json",
    "content": "{\n  \"name\": \"cc_nodejs\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"ass-parser\": \"^0.2.0\"\n  }\n}\n"
  }
]