Subtitles section Play video
DAVID MALAN: Welcome back, everyone.
DAVID MALAN:歡迎回來,大家好。
So yesterday, you'll recall that we focused on these topics here.
所以昨天,你會記得, 我們針對這些主題在這裡。
So we had four overarching topics-- privacy, security, and society;
因此,我們有四個首要topics-- 隱私,安全和社會;
internet technologies; cloud computing; and ultimately, web development.
互聯網技術;雲計算; 最終,Web開發。
>> Did anyone have the bandwidth or the time
>> 沒有人有 帶寬或時間
to watch a little John Oliver last night?
觀看小約翰 奧利弗昨晚?
It's actually pretty amusing, if not a little frightening.
這其實很有趣, 如果不是有點恐怖。
Any questions on anything we did yesterday?
對任何事情有任何疑問 我們昨天做?
Any clarifications?
任何澄清?
Any questions that you want to make sure we touch on today in some form?
要做出任何疑問 相信我們觸及到今天以某種形式?
So clean slate.
所以洗涮。
>> So what's on the agenda for today?
>> 那麼什麼是上了議事日程今天?
So I thought we'd begin today with a look at what's generally
因此,我認為我們今天會開始 一起來看一下什麼是一般
known as computational thinking-- at the risk of oversimplifying, thinking
被稱為在計算thinking-- 簡單化的風險,思考
like a computer, perhaps thinking like an engineer,
像一台計算機,也許 想著像一個工程師,
and trying to start to organize your thoughts
並試圖開始 組織你的想法
or to give you a better sense of what's involved in actually commanding
或者給你一個更好的感 涉及什麼實際指揮
a computer to do something by way of programming.
一台電腦做一些事情 通過編程方式。
And we'll keep it at a pretty high level, pretty much English,
我們會保持它在一個相當 高的水平,相當多的英語,
but try to use of familiar examples to formalize how
但嘗試使用熟悉的 舉例正式如何
you would go about solving problems.
你會去解決問題。
>> And we will revisit some CS topics, like abstraction,
>> 我們將重溫一些CS 主題,像抽象,
which came up a couple of times yesterday,
裡面傳來了一對夫婦 次昨日,
algorithms, and then representation.
算法,然後表示。
And that's where we'll begin today in just a moment.
而這也正是我們將開始 今天在短短的時刻。
Then we'll take a look at programming.
然後我們將看看節目。
We'll take a look at some fundamental constructs
我們就來看看一些 基礎構造
with which you might be familiar and might even find quite intuitive.
與您可能熟悉 甚至可能會發現很直觀。
>> We'll look, in fact, at a sample programming
>> 我們來看看,其實, 在樣品編程
environment that's very accessible, very playful, and indeed targeted
環境是非常便利, 很愛玩,也確實有針對性
for ages 12 and up.
對於年齡在12歲以上。
We will spend a few minutes there and then take things to a lower level
我們將花幾分鐘時間有 然後拿東西到較低的水平
and actually talk about some of the algorithms and data structures,
實際上談一些 的算法和數據結構,
so to speak, that programmers typically use
可以這麼說,那 程序員通常使用
to solve problems far more efficiently than you might
解決更為問題 效率可能比你
be able to do without them altogether.
能夠不通通做。
Then after lunch, we'll take a look at technology stacks, which is just
午餐後,我們就一起來看看 在技術堆棧,這僅僅是
a fancy way of saying collections of technologies
說的一種假想方式 技術集合
that you might use to solve some problem.
你可能使用 解決一些問題。
And we'll talk about the alphabet soup of languages that exist today--
我們將談論字母表 中存在的語言湯today--
Java and Python and C++ and PHP and Ruby and all sorts of other things.
Java和Python和C ++ PHP和 Ruby和各種其他的東西。
>> We'll take a look briefly at design patterns.
>> 我們將看一看簡要 在設計模式。
Programmers, over time, have adopted methodologies
程序員,隨著時間的推移, 有採用的方法
that tend to help them solve problems more readily.
傾向於幫助他們 解決問題更容易。
When you start to see yourself writing the same kind of code again and again,
當你開始看到自己寫的 同樣的代碼連連,
people formalize those repetitions and ascribe names to them
人的正式重複 而歸於名字給他們
and then use them and promote them, ultimately.
然後用它們和 推進當中,最終。
And we'll talk a little bit about mobile strategies,
我們將討論一點點 關於移動戰略,
like what does it mean to actually make a mobile app or a mobile website.
像什麼意思實際上 使移動應用或移動網站。
Do you do it for Android?
你為Android做呢?
Do you do it for iOS?
你於iOS呢?
Do you do it for both of those?
你為那些呢?
And what are the trade-offs?
什麼是取捨?
And then finally, we'll take a look web programming, which
然後最後,我們將採取 看看網絡編程,這
is a collective term really describing any time
是的總稱 真正描述的任何時間
you write software that's meant to run on the web,
你寫軟件的 為了在網絡上運行,
whether on phones or desktops or laptops.
無論是在手機還是 桌面或筆記本電腦。
We'll take a brief look at databases and the design
下面我們通過一個簡單的介紹一下 數據庫和設計
therein, if only because almost any interesting web-based application
其中,如果僅僅是因為幾乎所有的 有趣基於網絡的應用
these days has some kind of database.
這幾天有某種數據庫。
Otherwise, it would just be static content.
否則,它會 只是靜態內容。
And a database allows you to make changes over time, whether yourself
和數據庫使您可以 隨時間的變化,無論是你自己
or from users.
或者從用戶。
And we'll consider how you would go about designing
我們會考慮如何 會去設計
that database and the kind of jargon that might come up in an engineer's
該數據庫的那種行話 可能出現的以工程師
discussion at a white board when actually implementing
在白板討論 當實際執行
an app for the first time.
首次的應用程式。
>> We'll talk briefly about APIs, useful services
>> 我們將討論簡單說一下 API的,有用的服務
that you can use to stand on the shoulders of others, whether companies
您可以使用站上 別人的肩膀上,無論公司
or individuals, and solve your own problems more quickly.
或個人,以及解決您的 自己的問題更迅速。
And then we'll dabble perhaps a bit with JavaScript,
然後,我們也許會涉足 有點用JavaScript,
a programming language that's used both in browsers these days, but also
該公司使用的編程語言 無論是在瀏覽器這些天,但也
in servers.
在服務器上。
And perhaps, we'll revisit, time permitting,
也許,我們將 重溫,時間允許的話,
some of the hands-on web stuff we did yesterday and integrate the two
一些動手網絡的東西,我們的 昨天做和整合兩個
together before we adjourn.
我們一起休會之前。
>> So with that-- what's ahead-- is there anything missing that you
>> 因此,與that--什麼ahead--是 有什麼遺漏,你
would like to make sure we insert and touch on at some point.
想確保我們插入 並在某些點觸摸。
If it's springs to mind, bring it up before long.
如果是彈簧介意, 要拿出來不久。
But why don't we begin with a look at computational thinking.
但是,我們為什麼不開始與 看看計算思維。
>> And let me propose that computational thinking is, again,
>> 讓我提議, 計算思維是,同樣,
sort of the high level description of what a computer scientist might do.
排序的高層描述的 什麼是計算機科學家可能會做。
And indeed, let's start with three ingredients that
事實上,讓我們開始 有三個成分,
might go into computational thinking.
可能會進入計算機思維。
This is just one way of describing it.
這僅僅是一個描述它的方式。
We could certainly define this in any number of ways.
我們當然可以定義 這在任何數量的方式。
>> But let me propose, for the sake of today,
>> 但是,讓我提議, 今天的緣故,
that the world's problems, all of the world's problems,
這世界上的問題, 所有的世界難題,
when approached by a computer scientist could
當由接近 計算機科學家可以
be viewed as what we'll call inputs, which
如被看作是我們將 電話輸入,
need to get fed into what we'll call algorithms, which then yield outputs.
需要得到送入我們就這麼叫 算法,則得到的輸出。
In other words, the entire world of problem-solving I claim
換言之,整個 解決問題的我主張世界
can be distilled into these three ingredients.
可以蒸餾成 這三種成分。
So what do I mean by inputs?
所以,我是什麼意思的投入?
Inputs is just what you're handed in order to solve.
輸入正是你在做什麼 遞給為了解決。
>> For instance, here's an old school problem.
>> 舉例來說,這裡的 一個老同學的問題。
If I have a phone book here and I want to look something into it,
如果我這裡有電話本和 我想看看東西進去,
this is my input.
這是我的意見。
I have 1,000 or so pages in a phone book.
我有1000個左右 在電話簿頁面。
This is the input to my problem.
這是輸入到我的問題。
And I want to find something like Mike Smith, so a friend
我想找到的東西 像邁克·史密斯,這樣的朋友
whose name and number is hopefully in this address book.
其名稱和編號是 希望能在這個地址簿。
>> This is before the days of cell phones, so I can't just search for it.
>> 這是細胞的天前 手機,所以我不能只是搜索。
So I have to do it old school and actually search
所以,我必須這樣做舊 學校實際上搜索
these inputs for some answer.
這些投入對於一些答案。
And that answer is just going to be called the output.
這答案是正要 被稱為輸出。
So the input is the phone book.
所以輸入是電話簿。
The algorithm is whatever set of steps I use to find Mike Smith.
該算法是任何集 步驟我用找到邁克·史密斯。
And the output is, hopefully, Mike Smith's phone number.
和輸出,希望 邁克·史密斯的電話號碼。
And this then would be just representative of most any problem
而這則是剛 最具代表性的任何問題
to with you are handed inputs and want to produce outputs.
與你手輸入 並希望產生的輸出。
>> So before we consider the process by which we can solve that problem,
>> 因此,我們認為這個過程之前, 通過它我們可以解決這個問題,
finding Mike Smith and something like that,
尋找邁克·史密斯和 類似的東西,
let's consider the first and the last-- inputs and outputs.
讓我們考慮的第一和 的last--輸入和輸出。
Physically, of course, the input here is a whole bunch of paper glued together
物理上,當然,輸入在這裡 由紙一大堆粘在一起
in the form of a phone book.
在電話簿的形式。
But computers, of course-- laptops and desktops and even phones
但是電腦,筆記本電腦course-- 和台式機甚至是手機
these days-- those are electronic devices.
這些days--那些 電子設備。
>> And at the end of the day, what's the only input to a computer?
>> 和在一天結束時,什麼 唯一的輸入到電腦?
Well, it's something like this power cord here.
嗯,這是像 在這份電源線。
I plug it into the wall, and I get a flow of electrons,
我將其插入牆上, 我得到的電子流,
which allows me to run the machine.
這讓我運行的機器。
Or maybe those electrons are created by way of my battery.
或者,也許這些都是電子 我的電池的方式產生。
But at the end of the day, that's the only thing going into my laptop.
但在一天結束時,這是 唯一進入我的筆記本電腦。
And so much interesting stuff is ultimately
和這麼多有趣 東西最終是
coming out, whether by way of the printer
中走出來,無論是 由打印機的方式
or the screen or audially or the like.
或屏幕或audially或類似物。
>> So if all we have as our fundamental input to a computer
>> 所以,如果我們所有的作為我們的 基本輸入到計算機
is electricity, so just electrons going in and or out,
電,所以才 電子進入和或縮小,
and so how can we use that input to actually represent information?
所以我們如何使用該輸入 實際上代表的信息?
In other words, how do we get from a simple flow of electricity
換句話說,我們如何獲得 從電力的簡單流程
to representing actual numbers or actual letters
到代表實際 數字或字母實際
or actual images on the screen or actual movies or e-mails
在屏幕上或實際圖像 或實際的電影或電子郵件
or any number of these higher level concepts,
或任何數量的這些 更高層次的概念,
if you will, that at the end of the day somehow
如果你願意,在 到頭來不知何故
have to be stored in this electronic mechanical device
已被存儲在這 電子機械裝置
using only those simple ingredients-- electrons coming in and out?
只使用簡單的ingredients-- 電子出入?
>> So it would seem that, in the simplest form,
>> 因此,它似乎是, 在最簡單的形式,
the only kind of states I have in my world, so
唯一的一種狀態 我在我的世界,所以
to speak-- conditions in my world-- is either
到speak--條件 在我的天下 - 要么是
I have electrons flowing, electricity flowing, or I do not-- so on, off.
我有電子流,電 流動的,或者我不是 - 等等,關閉。
And let's formalize on and off, as a computer scientist might,
讓我們正式開啟和關閉, 作為一名計算機科學家可能,
with just 1 and 0.
只用1和0。
Let's just describe some arbitrary but consistent number to it.
讓我們只介紹一些武斷 但一致的編號。
1 means on, 0 means off.
1意味著,0表示關閉。
Or you might also view this as true means on and false means.
或者你也可以認為這是 對真正的手段和虛假的手段。
You could also do black and white or red and blue.
你也可以做黑色 和白色或紅色和藍色。
You just need two descriptors.
你只需要兩個描述符。
And a computer scientists would generally just use 0 and 1.
和計算機科學家們 一般只要用0和1。
>> So if that's the case, my only alphabet is consisting of 0's and 1's, how
>> 所以,如果是這樣的話,我唯一的字母 是由0和1的,如何
could I possibly get to even the number 2 in a computer, let alone the number 3
我可不可以去連號 2在一台電腦,更別說3號
or a letter of the alphabet or an image or a movie?
或一個字母 或圖像或電影?
How do we sort of bootstrap ourselves from this basic principle
我們怎麼樣的引導 從自己這一基本原則
of 0's and 1's and actually represent something more interesting?
的0和1的和實際 代表更有趣的東西?
>> Well, let's put that question on hold for just a moment
>> 好了,讓我們把這個問題 擱置一會兒就好了
and consider something hopefully familiar,
並考慮什麼 希望熟悉,
even if you haven't really thought about it in any detail for 10, 20, 30, 40, 50
即使你有沒有想過 它在任何細節為10,20,30,40,50
more years.
更多年。
This is what?
這是什麼?
How would you pronounce that?
你將如何發音呢?
Not a trick question.
不是一個很難回答的問題。
A number, but what is it?
一個數字,但它是什麼?
1, 2, 3, or 123.
1,2,3,或123。
And I liked how you said 1, 2, 3, because that's one way of viewing it.
我喜歡你是怎麼說的1,2,3, 因為這是觀看它的一種方式。
1, 2, 3, it's a sequence of three symbols.
1,2,3,它的一個序列 三個符號。
It's pictures that we now have words for.
這是圖片,我們 現在有話。
And if you sort of read them all together, a typical human in English
如果你之類的閱讀全部 同時,在英國一個典型的人類
would say 123.
會說123。
And that's sort of a higher level concept,
這就是形式的 更高層次的概念,
feels like a reasonably big number.
感覺就像一個相當大的數字。
>> But how did we get there?
>> 但是,我們是怎麼到達那裡?
Well, it might be a while since you've thought about it like this,
嗯,這可能是因為一段時間 你想過這個問題是這樣,
but back in my day, I kind of learned this
但早在我的一天,我 那種得知這個
as the 1's column, the 10's column, and the 100's column.
作為1的專欄中,10級的 列和100的列。
So as Lakisa says, it is 1, 2, 3, but it's also 123.
從而Lakisa說,這是 1,2,3,但它也是123。
But how do we get from the former to the latter?
但是,我們如何從中獲取 前者向後者?
>> Well, you would typically do in the 100's column, I have a 1.
>> 那麼,你通常會做 100的專欄中,我有一個1。
So that's like saying 100 times 1.
所以,這等於是說100次1。
And then in 10's column, I have 2.
然後在10的專欄中,我有2個。
So that's like saying 10 times 2.
所以,這等於是說10次2。
In the 1's column, I have 3.
在1的專欄中,我有3個。
So that's like saying 1 times 3.
所以,這等於是說1次3。
>> And if I add these things together, this, of course,
>> 如果我添加這些東西 在一起,這當然
is 100 plus the 10 plus 3.
是100加10加3。
And oh, that's why I get this higher level notion of 123.
呵呵,這就是為什麼我得到這個 123更高級別的概念。
It's just basic math, whereby these symbols have weights to them, if you
這只是基本的數學運算,由此這些 符號具有權重給他們,如果
will, placeholder or column values.
將佔位符或列的值。
And once I multiply everything out, I get this number.
有一次我乘的一切 出來,我得到這個號碼。
>> So how many of you know how to speak binary-- 0's and 1's-- like a computer?
>> 所以,你知道怎麼很多怎麼說話 binary-- 0和1's--像電腦一樣?
OK, perfect, no one, or none of you think you do.
OK,完美的,沒有一個人,或 你們沒有覺得你做的。
But I would claim you actually know this already.
不過,我會聲稱你 其實已經知道了。
We just need to sort of tweak our mental model a little bit.
我們只需要幾分調整 我們的心智模式一點點。
But the process is exactly the same.
但是這個過程是完全相同的。
>> Let me leave this one up there and instead pull this down for a moment.
>> 讓我離開這一個那裡, 而不是拉下來了一會兒。
In the world of computers, we only have 0's and 1's.
在計算機世界, 我們只有0和1的。
And so the thing that's going to change is what?
這樣一來,事情那 要改變的是什麼?
Well, in my human world, the decimal system, dec meaning 10,
那麼,在我的人類世界中, 十進位制,DEC意義10,
I have how many digits at my disposal?
我已經在我手上了多少位?
10, right?
10,對不對?
0 through 9, of course.
0到9,當然。
>> And that's why we have the 10's place and the 100's place.
>> 這就是為什麼我們有 10的地點和100的位置。
Where is that coming from?
那是哪裡來的?
Well, this is 10 to the power of 0.
那麼,這是10到0的力量。
This is 10 to the power of 1, 10 to the power of 2, and so forth.
這是10到1的功率,10 到2的冪,等等。
You just keep multiplying your columns by 10, starting off with just 1
你只是保持你的乘以列 10,出發只需1
in the rightmost one here.
在這裡最右邊的之一。
>> So in the world of computers, if you only
>> 因此在世界上 電腦,如果你只
have binary-- bi meaning 2-- or 0's and 1's, we just
有binary--雙向含義 2--或0和1的,我們只是
really need to change the base of that math.
真的需要改變 那數學的基礎。
So in other words, now we'll just have the 1's column and the--
因此,換句話說,現在我們只是 有1的專欄和曲風
where is this going-- the 2's column, the 4's column, and maybe beyond.
這是哪裡going-- 2的專欄中, 4個專欄,也許超越。
Why is that?
這是為什麼?
Well, this is 2 the 0-th power.
那麼,這是2 0次方。
This is 2 the 1.
這是2 1。
This is 2 to the 2, and so on.
這是2到2,依此類推。
>> So whereas here, we have 1, 10's, 100's, 1,000's, 10,000's, 100,000's, 1
>> 因此而在這裡,我們有1,10年代, 100的,1000的,萬的,10萬級的,1
millions, and so forth, here we have 1, 2, 4, 8, 16, 32, 64.
數以百萬計,等等,這裡 我們有1個,2個,4個,8個,16個,32,64。
You just keep multiplying by 2, instead of keep multiplying by 10.
你只要保持乘以2, 而不是繼續乘以10。
So now, if the goal at hand is to represent
所以,現在,如果目標在 一方面是代表
numbers using only 0's and 1's, let's consider how we get there.
僅使用0和1的數字, 讓我們考慮我們如何到達那裡。
>> This, of course, is the pattern 0 0 0, but what number conceptually
>> 此,當然,是模式0 0 0,但什麼號碼概念
does it represent?
它代表什麼?
Well, 4 times 0 plus 2 times 0 plus 1 times 0, let's add those together.
那麼,4次加0 2次加0 1次0,讓我們添加這些在一起。
4 times 0 is, of course, 0, plus 2 times 0 is, of course, 0 plus 1 times 0
4次0,當然,0,加2 次0是,當然,0加1次0
is, of course, 0.
是,當然,0。
So ah, this represents the number we humans know as 0.
所以啊,這代表了 一些我們人類所知道的0。
>> Well, now, let's very quickly fast forward.
>> 好了,現在,讓我們很 迅速快進。
If I'm instead not representing 0 0 0, but let's do 1 0 1,
如果我不是沒有代表 0 0 0,但讓我們做1 0 1,
that might be how Lakisa, earlier, would just pronounce it 1 0 1.
這可能是如何Lakisa,此前, 只會念它1 0 1。
But now, how do we take it to the higher level the number we humans might know?
但是現在,我們怎麼把它帶到更高 水平,我們人類可能知道多少?
So what is this number?
那麼,什麼是這個數字?
It's 5, the number we know as 5.
這是5,我們知道5的數量。
>> Well, why is that?
>> 那麼,這是為什麼?
Well, we can really sort of walk through it methodically
好了,我們才能真正的排序 穿行有條不紊
4 times 1, 2 times 0, 1 times 1.
4次1,2 0次,1次1。
Add those together, so this is 4 plus 0 plus 1.
添加這些在一起,所以 這是4加0加1。
And that's, indeed, 5.
而這,的確,5。
So it's getting a little tedious now doing the arithmetic again and again.
所以它現在變得有些乏味 一次又一次地做算術。
But the process is exactly the same.
但是這個過程是完全相同的。
>> The only thing that has changed in our world
>> 有唯一 在我們的世界變了
is that our columns are 1, 2, 4, 8, 16, and so forth, instead of 1, 10, 100,
是,我們的列是1,2,4,8,16, 等,代替1,10,100,
1,000.
1000。
And that's just because our alphabet has shrunk from 0 through 9 to just 0 to 1.
而這僅僅是因為我們的字母表 從0到9減少到只有0到1。
>> So as a little quiz here, how would you represent the number 7 in binary?
>> 因此,作為一個小測驗這裡,怎麼會 你代表二進制數字7?
0?
0?
Well, 0, you mean 0 0 0?
好吧,0,你的意思是0 0 0?
Say it again , Karina.
再說一遍,卡琳娜。
Perfect.
完善。
Why is that?
這是為什麼?
It's effectively 4 plus 2 plus 1.
這是有效的4加2加1。
So good.
很好。
>> How do we represent a little another-- how about number 2?
>> 我們如何代表一點點 another--怎麼樣2號?
Close, but backwards.
關閉,而是倒退。
So what is this?
所以,這是什麼?
Is 4 plus 1, so that's 5 again.
為4加1,以便再次是5。
>> So what's-- I'm sorry, Karina?
>> 所以what's--對不起,卡琳娜?
0 1 0.
0 1 0。
0 1 0 would be 2, because again, even if it sort of doesn't jump out at you,
0 1 0將是2,因為再次,甚至 如果是那種不跳出你,
just do the math.
只是做數學題。
4 times 0, 0, 2 times 1 is 2, 1 times 0 is 0.
4次0,0,2倍 1是2,1次0為0。
So this is the number we know as 2.
因此,這是我們所知道的2的數量。
>> How about the number 8?
>> 如何對數8?
Hm?
嗯?
Good.
好。
So we kind of need another placeholder.
所以,我們種需要另一個佔位符。
We need 1 0 0 0.
我們需要1 0 0 0。
And that's true of our sort of old school decimal system.
這就是我們的那種真正的 老同學十進制。
How do you represent the number 1,000?
你如何代表人數1000?
>> Well, you would seem to be kind of in a tough spot,
>> 嗯,你似乎是 那種在一個艱難的位置,
if ask you to represent the number 1,000,
如果問你代表 數字1000,
because even if you give yourself like 9 of these, 9 of these, 0 of these,
因為即使你給自己喜歡 這些9,這些9,這些0,
which is the biggest number you have, you didn't quite get to 1,000.
這是最大的數字,你 有,你沒有完全得到為1000。
So if you 1,000, you just need another position, so that you can do 1 0 0 0,
所以,如果你1000,你只需要另 的位置,這樣就可以做1 0 0 0,
ergo the number 1,000.
ERGO人數1000人。
>> So now, let's map this sort of conceptual discussion back to hardware,
>> 所以,現在,讓我們來映射這種 概念性的討論給硬件,
where again, the input was just this little power cable, electricity
再次在這裡,輸入只是 這個小電力電纜,電
coming in and flowing out.
進來和流出。
And so for that to be mapped from here to there, well, what do we really need?
所以對於從這裡被映射 在那裡,那麼,我們真的需要?
Well, you can think of being inside of a computer, a whole bunch of light bulbs,
那麼,你能想到的是一個內部 電腦,一大堆的燈泡,
if you will.
如果你願意。
They're really called transistors.
他們真的叫晶體管。
And transistors are just switches that can either be on or off.
和晶體管只是切換 這可以是打開或關閉。
So you can think of a transistor that's on
所以,你能想到的 晶體管那是上
is allowing electricity to flow and a transistor that's off as stopping
是允許電力流動, 晶體管那是冒充停止
electricity from flowing.
電力流入。
And rather than take over the lights here,
而非採取 在這裡的燈光,
why don't I do this sort of new school style.
為什麼不讓我做這種 新的派風格。
So this might be a 1, a flashlight being on, only barely though.
因此,這可能是一個圖1中,手電筒 正對,僅勉強雖然。
And this might be a 0, and now it's off.
而這可能是0,現在是關閉。
>> So using this physical device, I can now represent the binary system.
>> 因此,使用這種物理設備,我 現在可以表示二進制的系統。
I just need two states.
我只需要兩個狀態。
It doesn't matter what color it is or what it is.
不要緊什麼 顏色是或它是什麼。
All that matters is that I have one state on and another state off.
所有重要的是,我有 在一個國家和另一個國家了。
So using my phone here, how do I represent the number we know as 0?
因此,使用我的手機在這裡,我該怎麼辦 代表我們所知道的0的數量?
Or put equivalently, what number am I representing now?
或者把等價,是什麼 數字我現在能代表?
0, because the device is off.
0,因為該設備處於關閉狀態。
>> And if I do this?
>> 如果我這樣做呢?
And now, how do I represent the number 2?
而現在,我該怎麼辦 表示數字2?
Can I borrow your phone here, as we did yesterday?
我能借你的手機 在這裡,正如我們昨天做?
So let's see, so if I want to represent the number 2, is this the number 2?
因此,讓我們來看看,所以如果我要代表 數字2,這是2號?
No.
沒有。
What number am I accidentally representing here?
什麼號碼是我不小心 代表在這裡?
This is actually the number 3.
這實際上是數字3。
>> So which one do I want to turn off?
>> 那麼,哪一個做我想要關掉?
The black phone or-- well, if they're-- black phone or the white phone?
黑手機or--好,如果they're-- 黑手機或白色手機?
The white phone.
白色手機。
So if I turn this off and we line it up over here, we have a 1
所以,如果我把這個關閉,我們 線它在這裡,我們有一個1
in the 2's place and a 0 in the 1's place.
在2的地方,並 0在1的位置。
And so I'm now representing the number 2.
所以我現在 表示數字2。
And this, Of course, would be the number 3, because now both of these lights
而這,當然,會是多少 3,因為現在這兩個燈
are on.
在...上。
>> And I'll stop here, but it stands to reason
>> 我會停在這裡, 但按理說
if I want to represent the number 4 or 8 or higher,
如果我想代表 號4或8或更高,
I'm going to need more phones.
我將需要更多的手機。
But that's all that's going on.
但是,這一切是怎麼回事。
So if you've ever heard that inside of a-- thank you-- computer
所以,如果你曾經聽說過 中A--裡面感謝你 - 計算機
is millions of transistors, that's just millions of tiny little switches.
是數百萬個晶體管,這是 只是數百萬小小的開關。
And they're not light bulbs that turn on and off,
他們不是光 燈泡是打開和關閉,
but they do either allow electricity to flow somewhere or stop it.
但他們要么允許電 某處流動或停止。
And so there's your two states-- on or off, on or off.
所以,有你的兩個 states--開或關,開或關。
>> So we would seem now to have this ability
>> 所以我們現在似乎 有這種能力
to represent this concept that we'd like in actual hardware.
代表這個概念, 我們希望在實際硬件。
But all we have now is the ability to represent numbers it would seem.
但是,所有我們現在擁有的是能力 來表示數字又好像。
So how do we go about representing letters of the alphabet, which
那麼,我們如何去代表 英文字母,這
feels like the next sort of feature you would want to add to a modern computer
感覺像一個排序功能的你 將要添加到現代計算機
once you have numbers?
一旦你有數字嗎?
>> And indeed, if you think about it, historically, computers
>> 事實上,如果你仔細想想 它在歷史上,計算機
were introduced really to serve as calculators numerically.
真的被引入到 作為數字計算器。
But of course, these days, they do much more.
但當然,這些 天,他們做更多的事情。
Even when they boot up, you typically see one or more words.
即使當他們啟動,你 通常會看到一個或多個單詞。
So how do you represent words, if all you have is, again,
那麼,你如何表現的話, 如果你已經是再次
electricity at the end of the day, or equivalently 0's and 1's?
在電的結束 天,或等效地0和1的?
>> Yeah.
>> 是啊。
Yeah, I mean, we kind of did this yesterday in some form,
是的,我的意思是,我們種做 這個昨天以某種形式,
where at some point, I think I arbitrarily
其中,在某些時候, 我想我隨意
said that, if we want to represent the letter A, we could just call that a 1.
說,如果我們想要代表 字母A,我們可以只把那個叫1。
It was in the context of cryptography, where we just needed some kind of code,
它是在加密的情況下, 在這裡我們只是需要某種形式的代碼,
some kind of mapping.
某種映射。
>> So maybe A will be represented as a 1, and B will be represented as a 2,
>> 因此,也許A將被表示為 1,和B將被表示為2,
and Z will be represented as a 26, for instance.
和Z將被表示 作為26,例如。
And then the only caveat is that if I'm going to encode letters in my emails
然後是唯一需要注意的是,如果我 要在我的電子郵件編碼的信
or in my text messages as numbers, you all
還是在我的短信 數字,大家
have to agree to use the same set of conventions.
必須同意使用 同組約定。
And indeed, the world has done exactly that.
事實上,世界 做了這一點。
>> There is a system in the world called ASCII, American Standard
>> 有在世界上的系統 所謂的ASCII,美國標準
Code for Information Interchange, which is simply a decision some years
信息交換碼, 這是一個簡單的決定,有些年份
ago that the humans made that decided that A is going to equal, not
以前,人類製造的 決定,是要平等的,不
1, 2, and 26, and so forth-- it's a little different-- but 65, 66, 67.
1,2,和26,以及因此forth--它是一個 小different--但65,66,67。
And I'll pull up a chart in just a moment.
我拉了 圖中只是一瞬間。
But it's arbitrary.
但它的隨意性。
But it doesn't matter that it's arbitrary.
但沒關係 它的隨意性。
The world has to just be consistent.
世界上有只保持一致。
>> Now, more recently, there's something fancier
>> 現在,最近, 有一些票友
called Unicode, because the world's kind of realized, after inventing computers,
所謂的Unicode,因為世界上的那種 來實現,發明電腦後,
that there's more than well 256 symbols in the world
有比多好 在世界上256個符號
that we might want to represent, especially when you introduce
我們可能要代表, 尤其是當你介紹
Asian languages and other symbologies that need more expressiveness than you
亞洲語言和其他符號 需要比你更表現
can fit in the earliest version of this code, which was called ASCII.
可以容納的最早版本 這個代碼,這被稱為ASCII。
So Unicode actually allows you to use more 0's and 2.
所以Unicode的實際上允許 您使用起來更加的0和2。
In particular, you keep hearing the word bytes in society and even just
特別是,你不斷聽到 字的字節社會中甚至只
yesterday.
昨天。
And a byte is what again?
而一個字節又是什麼?
>> What's a byte?
>> 什麼是字節?
It's just 8 bits.
這只是8位。
So what does that really mean?
那麼是什麼究竟意味著什麼?
Well, that means, earlier, when we were talking about binary and I was using
嗯,這意味著,更早的時候,我們 談到二進制和我所用
arbitrarily three bits when we were talking about binary-- the 1's place,
任意三位當我們 談到binary-- 1的地方,
the 2's place, and the 4's place-- well, a byte just means that you're talking
2的地方,和4的place--好, 一個字節只是意味著你在說
not in units of three but four, five, six, seven eight,
未在三個單位,但 四,五,六,七八,
which gives us 8's place, 16's, 32's, 64's, and 128's.
這給了我們8的地方, 16年代,32年代,64年代,和128的。
>> In other words, a bit isn't all that useful a unit of measure,
>> 換句話說,比特是不是所有的 該措施的有用單位,
because it's just like one tiny little piece of information, on or off.
因為它就像一個很小的小 片的信息,開啟或關閉。
So some years ago, the world just decided
因此,一些年前, 世界剛剛決定
it's slightly more convenient to talk in terms of bytes, eight things at a time.
它稍微更方便地在說話 字節為單位,在時間八件事。
And so thus was born the notion of a byte.
於是從而誕生 一個字節的概念。
And so we have eight bits here.
所以,我們在這裡有八位。
>> And it turns out, too, for similar reasons, the world decided years
>> 而事實證明,也為類似 原因,世界上決定年
ago that to represent an ASCII letter, you're going to use units of 8 bits.
以前,來表示一個ASCII字母, 你要使用8位的單位。
So even if you don't need that many, you're
所以,即使你不 需要那麼多,你
always going to use 8 bits to represent a letter of the alphabet.
始終將使用8位 代表一個字母。
And this is convenient, because then if you
這是方便的, 因為那樣的話,如果你
receive a message that has a 0 0 0 1 1 1 1 0 followed by another 1 1 1 0 1 0
收到具有0 0 0 1 1信息 1 1 0後跟另一個1 1 1 0 1 0
0 1, so if you receive 16 bits, the world can just
0 1,因此,如果您收到16 位,世界正好可以
assume that the first 8 are one letter and the second 8 are another letter.
假定第一8是一個字母 第二是8的另一封信。
>> Doesn't matter how many there are.
>> 不要緊,有多少。
It just matters that we're all consistent
它只是事項 我們都一致
when we're interpreting these bits.
當我們解釋這些位。
And this was just random.
而這只是隨機的。
That means something, but I didn't really think about what it means.
這意味著什麼,但我沒有 仔細想想這意味著什麼。
>> So it's a small white lie.
>> 所以這是一個白色的小謊言。
Originally, ASCII actually used only 7 bits.
原來,ASCII 實際使用的僅7位。
And the eighth bit is called extended ASCII.
而第八位 所謂擴展ASCII。
But the point is, ultimately, the same.
但問題是,最終是一樣的。
The world generally standardized on 8 bits.
世界一般 標準化的8位。
>> So this would seem to be a little limiting, because I can only
>> 因此,這似乎是一個小 限制,因為我只能
represent capital A, capital B through capital Z.
代表資本A, 通過資本Z.資本2
But indeed not, if I go to-- there's a bunch of resources
但是確實不,如果我去中場休息 有一堆資源
online, for instance, asciitable.com, this
線上,例如, asciitable.com,這
is going to be a little overwhelming at first.
將是一個小 壓倒在第一。
But I'll point out what's important here.
但我會指出, 這裡是什麼是非常重要的。
>> This just happens to be-- and I'll walk-- let's see, if I go over here.
>> 這恰好be--,我會 walk--讓我們來看看,如果我去在這裡。
Here is, in the decimal column, the number 65.
這裡,在該小數 列,數65。
And on the right hand column letter character, Chr, is the letter A.
而在右手列字母 性格,人權委員會,是字母A.
And you can ignore, for now, everything in the middle.
而且你可以忽略,現在, 一切都在中間。
This is hexadecimal, octal, and an HTML code.
這是十六進制, 八進制,和一個HTML代碼。
To this site is just trying to throw a lot of information at you at once.
這個網站只是試圖拋出 你有很多一次的信息。
But all we care about is the decimal column and the character column.
但是,我們關心的是十進制 列和字符列。
>> So by this logic, what is the number that the world
>> 因此,通過這樣的邏輯,是什麼 數,世界
has decided represents a lowercase a?
已經決定代表小寫?
Yeah, 97.
是啊,97。
And just to confuse potentially slightly,
而僅僅是用來迷惑 可能略有下降,
what number has the world decided would represent the number 1?
什麼號碼已經是世界決定 將代表數字1?
Right, because we-- 49, it seems here, down in the bottom left.
沒錯,因為we-- 49,似乎 在這裡,在底部向下走了。
>> Now, what do I mean by that?
>> 現在,我是什麼意思呢?
So it turns out that in computer systems,
所以,事實證明, 在計算機系統中,
there is generally a fundamental difference
一般是有 根本的區別
between a number and a character.
之間的數字和字符。
A number is the thing we learned growing up when
一個數字是我們的事 學會長大的時候
we were super young in grade school.
我們在小學的超級年輕。
It's things you count with.
這事你算。
But a character is just a shape, a glyph, so to speak, on the screen.
但一個字符僅僅是一個形狀, 字形,可以這麼說,在屏幕上。
>> Now, we humans sort of see something that looks like this.
>> 現在,我們人類那種見 一些看起來是這樣的。
And we say, oh, that is the number 2.
而我們說,哦,那是2號。
But no, that's just a symbol that looks like what we know as the number 2.
但是,沒有,這只是看起來的象徵 就像我們所知道的數字2。
And so there's this fundamental distinction
所以有這 根本的區別
between actual numbers and characters.
實際數字和字符之間。
This is a number.
這是一個數字。
But generally, in the context of a computer,
但是總體來說,在 一台電腦的情況下,
if you instead see something like this quoted--
如果你不是看到 像這樣quoted--
and you don't always have to see it quoted,
而你總是不 必須看到它引用,
but for the sake of discussion-- if you see quotes around the number,
但對於discussion--的緣故,如果 你看到周圍的一些報價,
this is now a character.
現在這是一個字符。
So this number 2 underneath the hood inside of a computer
因此,這2號下方 一個計算機的內部機罩
would be represented with a pattern of bits that represent the number
將與一個圖案來表示 代表的比特數
50 according to the chart online.
50,根據圖表聯機。
>> However, if a computer just sees this, this
>> 然而,如果計算機 剛看到這一點,這
would be represented with the pattern of bit 0 0 0 0 0 0 1 0.
將與表示 位0 0 0 0 0 0 1 0模式。
Whereas, this character would actually be represented as-- and now,
然而,這種性格會 實際as--現在代表,
I got to think a little harder-- so this character would be represented with 0
我覺得有點harder--所以這 人物將與0來表示
0 1-- what do I need here?
0 1--需要什麼嗎?
0 0 1 1 0 0 1 0.
0 0 1 1 0 0 1 0。
How did I do this?
我是如何做到這一點?
Well this is the number 50, if you multiply it out using these columns,
嗯,這是50號,如果你 使用這些列繁衍出來,
this is the number 2, and so that's why there is this dichotomy.
這是2號,等等 這就是為什麼有這種二分法。
>> And this is just a teaser now for features
>> 而這僅僅是一個 現在傳情的特點
that exist in programming languages that we'll touch on briefly later today.
中存在的編程語言 我們將簡要地對今天晚些時候觸及。
In programming languages, you have generally,
在編程語言, 你一般有,
but not always, things call different data types.
但並非總是如此,事 調用不同的數據類型。
In other words, a programmer-- when he or she is writing,
換言之,一個programmer-- 當他或她正在寫,
a programmer gets to decide in what format to store his or her data.
程序員獲取決定什麼 格式存儲自己的數據。
You can either store data as raw numbers, like the number 2.
您可以將數據存儲為 原始數據,如數字2。
Or you can store them as strings, or sequences of characters
或者你可以將它們存儲為字符串, 或字符序列
that you would generally express with quotes in your programming language.
你會通常與表達 報價在您的編程語言。
>> You can have things called-- I'll oversimplify and call them
>> 你可以擁有的東西called-- 我會簡單化,並呼籲他們
real numbers-- so numbers that aren't integers like the number 2,
實numbers--使數字, 就像數字2不是整數,
but numbers like 4.56.
但喜歡的數字4.56。
So real numbers can also have decimal points,
所以實數還可以 有小數點,
so that's a different fundamental piece of data in a computer.
所以這是一個根本的不同 在計算機中的數據塊。
And then you can even have other data types still.
然後,你甚至可以有 其他數據類型仍。
So that's just a teaser really of the simplest of design decisions
所以這真的只是一個傳情 最簡單的設計決策
that a programmer might make underneath the hood.
一個程序員可能 使引擎蓋下方。
>> So any questions just yet?
>> 所以,只是還沒有什麼問題嗎?
So let's try to make this a little more real.
因此,讓我們試著讓 這一點更真實。
This hardware is not so much in use anymore.
此硬件不 這麼多的使用了。
But most everyone in this room probably grew up with and still uses hard drives
但大多數人在這個房間可能 從小一起長大的,並仍然使用硬盤驅動器
in some way.
某種程度上來說。
>> Even though most of our laptops no longer
>> 儘管大多數的 我們的筆記本電腦不再
have devices that operate like this, instead laptops today generally
有一個這樣的操作設備, 今天,而不是一般筆記本電腦
have solid state drives with no moving parts.
有固態硬盤 沒有移動部件。
And that tends to be more expensive, unfortunately, but a little bit faster
並且更趨於昂貴, 不幸的是,但有點快
and a-- well, often, a lot faster, which is one of the reasons.
和A--很好,經常,速度快了很多, 這是原因之一。
And also it doesn't generate as much heat.
而且它不 產生很多熱量。
It can be smaller, so it's generally a net positive.
它可以更小,因此它的 通常一個淨正。
>> But this allows us to map a little more concretely what
>> 但是,這使我們能夠映射 多一點具體什麼
we're talking about at the 0's and 1's level now to a physical device.
我們在0的談論和 現在1的水平提升到一個物理設備。
It's one thing for me to talk about 0's and 1's in terms
這是一件事對我說話 大約0和1中術語
of my phone or abstractly in terms of switches being on and off.
我的手機或抽象的術語 的開關被打開和關閉。
But what about hard drives?
但對於硬盤驅動器?
In your laptops, if you have an older one, or in your desktop computer,
在你的筆記本電腦,如果你有一個舊 之一,或在您的台式電腦,
or certainly in servers today, where you have
或肯定服務器 今天,在這裡你有
hard drives that have a terabyte of space,
有硬盤驅動器 的空間兆兆位
4 terabytes of space, well what does that mean?
4 TB的空間, 還有什麼意思呢?
>> A hard drive with 1 terabyte of space means
>> 一個硬盤驅動器1 空間的手段太字節
there's 1 trillion bytes inside of it somehow,
有1萬億字節 它以某種方式裡面,
or equivalently 8 trillion bits inside.
或等價內8萬億比特。
1 terabyte would be 8 terabits or 1 trillion bits, which
1 TB的將是8兆兆位 或1萬億位,
means if you have a hard drive, you have somehow
意味著如果你有一個硬 驅動器,你有不知何故
or other a trillion 0's and 1's inside of it.
或其他一萬億0 和1的內部的它。
And if we just take a look at an arbitrary picture of a hard drive
如果我們只是來看看的 硬盤驅動器的任意圖像
representative, this is what a hard drive might typically look like inside.
的代表,這是一個多麼難 驅動器可能通常看起來像裡面。
>> It, too, is kind of like an old phonograph player
>> 它也有點像 一個老唱機
but generally with multiple records inside, so
但一般用 多個記錄裡面,所以
to speak-- multiple platters, as they're called,
到speak--多 盤片,因為他們是所謂的,
metal circular disks, and then a little reading head,
金屬圓盤,和 這時,一個小的讀頭,
much like an old record player.
很像一個老唱機。
And that reading head moves back and forth and somehow reads the bits.
和讀頭前後移動 提出並以某種方式讀取位。
And what's on these platters, even though we humans can't see them,
什麼是對這些盤片,甚至 雖然我們人類無法看到它們,
either in reality or in this picture, there's tiny little magnetic particles.
無論是在現實還是在這張照片, 有微小的磁性顆粒。
And even if you've long forgotten how electricity works,
而且,即使你早就 忘了電的使用原理,
a magnetic particle that's charged generally
磁性粒子 即通常的充電
has a north end and a south end-- so north and south.
有北邊和南邊 end--所以南北。
And so the world just decided some time ago
這樣一來,世界剛 決定前一段時間
that, if a magnetic protocol essentially is aligned like this, north-south,
即,如果基本上是一個磁性協議 在這樣的排列,南北,
let's call that a 1.
讓我們把那個叫1。
If it's instead south-north, let's just call that a 0.
如果它是代替南北, 我們只需要調用一個0。
And so if you have at your disposal a trillion
所以,如果你有 您的處置一萬億
tiny little magnetic particles-- and hopefully,
小小的磁 particles--和希望,
the hardware ingenuity in order to flip those around
硬件中匠心 為了翻轉周圍的人
as you see fit-- if you want to represent a whole bunch of 0's, you
當你看到fit--,如果你想 代表一大堆0,你
just need 8 magnetic particles all aligned like this.
只需要8磁性顆粒 所有的排列是這樣的。
And if you want to represent eight 1's, you just
如果你要代表 8個1的,你只要
need 8 magnetic particles aligned back to back to back like this.
需要對齊的8磁性顆粒 回背靠背這樣。
>> What do I mean by the magnetic particles?
>> 這是什麼意思了 磁性粒子?
Frankly, all these years later, the thing that still comes to my mind
坦率地說,這些年過去了, 仍然在我腦海中的東西
is this guy, if you grew up with this thing.
就是這個傢伙,如果你 從小一起長大的這件事情。
This is a little-- for those unfamiliar-- a
這為little-- 這些unfamiliar--一個
little childhood toy that has this hairless man here
小童年的玩具 這裡有這個人無毛
that has all these tiny little black magnetic particles that come with it.
擁有所有這些小小的黑色 磁性粒子隨之而來。
And using that red stick, which is just a magnet,
而使用紅棒, 這僅僅是一個磁鐵,
you can sort of give him a mustache or eyebrows or hair or anything on him.
你可以排序的給他鬍子或 眉毛或頭髮他或任何東西。
So in fact, if we zoom in, for instance, this
所以,事實上,如果我們放大 在,例如,這
is the kind of game you can play with Wooly Willy.
是一種遊戲,你 可以用長毛威利玩。
>> And this is only to say, these are much larger magnetic particles
>> 而這只是說,這些 大得多的磁性粒子
than are actually on a hard drive, and far fewer magnetic particles.
比實際是一個硬盤驅動器上, 和少得多的磁性粒子。
But let's actually see then if you do have
但是讓我們真正看到 那麼,如果你確實有
tiny magnetic particles in a hard drive, how you can actually
微小磁性顆粒在 硬盤驅動器,你怎麼能真正
use those to represent data.
使用這些表示數據。
>> [VIDEO PLAYBACK]
>> [視頻回放]
>> -The hard drive is where your PC stores most of its permanent data.
>> -The硬盤是你的電腦 大多數商店的永久數據。
To do that, the data travels from RAM along
要做到這一點,數據 沿RAM旅行
with software signals that tell the hard drive how to store that data.
軟件的信號,告訴 硬盤如何存儲這些數據。
The hard drive circuits translate those signals into voltage fluctuations.
硬盤驅動器電路的轉換 信號轉換成電壓波動。
These, in turn, control the hard drive's moving parts-- some of the few moving
這些,反過來,控制硬盤的 曲子分為移動一些為數不多的搬家
parts left in the modern computer.
零件留在現代計算機。
>> Some of the signals control a motor, which spins metal-coated platters.
>> 一些信號控制電機, 其中旋轉的金屬塗層的拼盤。
Your data is actually stored on these platters.
您的數據實際上是 存儲在這些盤片。
Other signals move the read/write heads to read or write data on the platters.
其他信號移動讀/寫磁頭 讀或寫在盤片的數據。
This machinery is so precise that a human hair couldn't even
該機械是如此精確 一個人的頭髮甚至無法
pass between the heads and spinning platters.
首腦之間傳遞 和旋轉盤片。
Yet, it all works at terrific speeds.
然而,這一切工作以驚人的速度。
[END PLAYBACK]
[結束播放]
And you can see at the tail end of the video,
你可以在看 視頻的尾部,
there are generally multiple platters.
一般有多個盤片。
And so that reading head isn't just reading the top.
因此,閱讀頭 不只是讀頂部。
It's kind of like three or four or more reading heads
這有點像三 四個或更多的讀出頭
that move like this, reading data simultaneously.
這一舉動像這樣, 同時讀取數據。
>> So there's a lot of complexity and sort of timing
>> 所以有很多的 複雜性和排序時機
that's involved in a hard drive.
該公司參與了硬盤驅動器。
And the thing is spinning really darn fast, so there's a lot of complexity.
而事情是真的紡織補 速度快,所以有很多的複雜性。
But let's zoom in a little deeper and see where are these magnetic particles
但是,讓我們在一個小更深的放大和 看到這些磁性顆粒
and how are we're getting at them.
以及如何我們在他們得到。
>> [VIDEO PLAYBACK]
>> [視頻回放]
>> -Let's look at what we just saw in slow motion.
>> - 讓我們看看我們 只是慢動作看到的。
When a brief pulse of electricity is sent to the read/write head,
當電力的短暫脈衝 被發送到讀/寫頭,
it flips on a tiny electromagnetic for a fraction of a second.
它翻轉上一個微小的電磁 用於第二的一小部分。
The magnet creates a field, which changes
磁鐵創建 場,它改變
the polarity of a tiny, tiny portion of the metal particles
一個很小,很小的極性 金屬顆粒的一部分
which coat each platter's surface.
其中每個大衣盤片表面。
A pattern series of these tiny charged up areas on the disk
圖案系列這些微小的 磁盤上的充電區域
represents a single bit of data in the binary number system used by computers.
表示在數據的單個位 由計算機使用的二進制數字系統。
>> Now, if the current is sent one way through the read/write head,
>> 現在,如果當前正在發送的一個 通過讀/寫頭的方法,
the area is polarized in one direction.
該區域在一個方向上偏振。
If the current is sent in the opposite direction,
如果當前在發送 相反的方向,
the polarization is reversed.
極化反轉。
How do you get data off the hard disk?
你如何讓數據從硬盤?
Just reverse the process.
剛剛反轉的過程。
So it's the particles on the disk that get the current
因此,它是在粒子 磁盤獲取當前
in the read/write head moving.
在讀/寫頭移動。
Put together millions of these magnetized segments,
放在一起的數百萬 這些磁化段,
and you've got a file.
和你有一個文件。
>> Now, the pieces of a single file may be scattered all over a drive's platters,
>> 現在,一個單一的文件的塊可以是 散佈在驅動器的盤片,
kind of like the mess of papers on your desk.
有點像亂 在你的辦公桌上的文件。
So a special extra file keeps track of where everything is.
因此,一個特殊的額外的文件保留 跟踪的東西在哪裡。
Don't you wish you had something like that?
難道你不希望你有 類似的東西?
>> [END PLAYBACK]
>> [結束播放]
>> So being alluded to there, perhaps, is that topic from yesterday of deletion.
>> 所以被提到的有,或許是 在刪除昨天的話題。
When you delete a file, yesterday we said
當你刪除一個 文件,昨天我們說
that a computer actually does what, when you drag something
一台電腦實際上做 什麼,當你拖動的東西
to the Recycle bin or trash bin?
到回收站或垃圾桶?
It just forgets it.
它只是忘記它。
But the 0's and 1's, the magnetic particles
但是0和1的, 磁性粒子
that look like red and blue things here, or my arm here,
看起來像紅色和藍色 這裡的東西,或在這裡我的手臂,
are still there on the hard drive.
仍然存在硬盤上。
>> And so there exists software-- Norton Utilities and Yesteryear
>> 所以存在軟件 - Norton實用程序和昔日
and other more modern software-- that just
和其他更現代 軟件 - 剛
will scan a whole hard drive looking at all those 0's and 1's, because it
將掃描整個硬盤驅動器尋找 在所有這些0和1的,因為它
turns out that most file formats-- Word documents, Excel files, images,
事實證明,大多數文件formats-- Word文檔,Excel文件,圖像,
video files-- all have certain patterns that are common among them.
視頻files--都有一定的 圖案,其中常見的。
Every video file might be of a different video,
每個視頻文件可能 是一個不同的視頻,
but the first several bits are usually the same.
但前幾 位通常是相同的。
Or the last several bits are usually the same.
或最後幾個位 通常是相同的。
>> And so with high probability, you can look for those patterns.
>> 因此具有較高的概率, 你可以看一下這些模式。
And even if the file has been forgotten, you can say with high probability,
而且,即使該文件已被遺忘, 你可以以很高的概率說,
but this looks like a Word document, lets recover it and un-forget it,
但是這看起來像一個Word文檔, 讓恢復它和取消算了吧,
if you will.
如果你願意。
And so that's how you can recover data that's either been accidentally
所以這就是你如何恢復 數據要么被意外
deleted or deleted or deliberately deleted for whatever purposes.
刪除或刪除或故意 刪除的任何目的。
>> By contrast, secure deletion does what in the context of a picture like this?
>> 相比之下,安全刪除做什麼 在這樣的圖像的上下文中?
Exactly, makes them all random.
沒錯,讓他們全部隨機。
So it sort of moves some of them down, some of them up,
所以它像是移動的一些 他們失望,他們中的一些起來,
leaves some of them unchanged, and generally makes random noise out of it,
留下他們中的一些不變, 通常會使隨機噪聲出來,
or just maybe makes all of them 0's or all of them 1's.
或只是也許使所有的 他們0或全部的1的。
And that too can generally scrub your data away.
而這也可以一般 擦洗你的數據了。
>> So let's return now to the issue of computational thinking, whereby
>> 現在讓我們回到問題 的計算思維,即
we have the formula inputs.
我們有公式輸入。
And algorithms gives you outputs ultimately.
和算法給出 你最終輸出。
We focus now on inputs and outputs, because now, I
我們現在專注於投入和 輸出,因為現在,我
claim we have a way of representing inputs and outputs.
要求我們有辦法 表示輸入和輸出。
We're just going to use binary.
我們只是要使用二進制。
>> And no matter what we want to represent today,
>> 而且不管我們 今天想代表,
whether it's a number or a letter or thousands thereof in a phone book
不管它是一個數字或字母 或其數千電話簿
or images or movies, at the end of the day, it's all 0's and 1's.
或圖像或電影,在結束 這一天,它的所有0和1。
And I claim that, even though this is a super simple world with just 0's
而我堅持認為,儘管這 是一個超級簡單的世界,只是0
and 1's, we can build ourselves up.
和1,我們可以建立自己的。
And we've seen one example of that with letters thus far.
而我們看到的一個例子 與字母迄今。
>> So let's focus now on this middle ingredient, an algorithm.
>> 現在讓我們專注於此 中間成分的算法。
And let's return to this example of Mike Smith.
讓我們回到本 例如邁克·史密斯。
So in this phone book, which admittedly, we don't use so much anymore,
所以在這個電話簿,這不可否認, 我們不使用那麼多了,
there's a problem to be solved.
有待解決的問題。
We want to find someone like Mike Smith.
我們希望找到一個像邁克·史密斯。
>> And what might I do to find Mike?
>> 而且我可以做什麼找邁克?
Well, I could just open up this book, start at the first page,
好吧,我可以打開這個 書,開始在第一頁,
and realize, oh, I'm in the A section.
實現,哦,我在一節。
Mike's not there.
邁克不在那裡。
I need the S section for Smith.
我需要史密斯在S部分。
So just keep turning one page at a time.
所以,只要保持在同一時間開啟一頁。
Let me pretend that this is all white pages and not yellow pages,
讓我假裝這是所有 白頁,而不是黃頁,
because we're not going to find Mike in the yellow pages anyway.
因為我們不會找到 邁克黃頁反正。
But I'm in the white pages.
但是,我在白頁。
And now, I'm in the B section.
而現在,我在B部分。
I still haven't found him.
我還沒有找到他。
So I keep turning one page at a time.
所以我一直在同一時間開啟一頁。
>> This is an algorithm.
>> 這是一種算法。
It's a set of instructions for solving some problem.
它是一組指令 為解決一些問題。
In other words, look at page, if Mike's not on it,
換句話說,看 頁面上,如果麥克的不就行了,
turn page, and repeats again and again and again,
翻頁,並重複 再,再而三,
ideally looking down as you're doing it.
理想情況下低頭,你正在做的。
So is this algorithm, this process, correct?
所以該算法中, 這個過程中,是否正確?
>> Sorry.
>> 抱歉。
No, I hear some nos.
不,我聽到一些號。
OK, but it is-- yeah, it's certainly tedious.
OK,但它is--是啊, 它肯定乏味。
Like, we'll be here all day if I keep looking for Mike at this speed.
就像,我們將在這裡一整天,如果我 保持在這個速度尋找邁克。
But let me claim it's correct.
但讓我聲稱它是正確的。
It's stupid, but it's correct.
這是愚蠢的,但它是正確的。
>> At the end of the day, long as it might take, I will find Mike if he's in there
>> 在一天結束時,只要它可能 走,我會找到邁克,如果他在那裡
and I'm paying attention.
而我關注。
And I eventually reach his page.
我最終到達他的頁面。
And if I get too far, if I get to the T section,
如果我太遠,如果 我得到的T形截面,
then I can slightly optimize and just say, hm, all done.
然後,我可以稍微優化 而只是說,HM,全部完成。
I don't even need to waste time going to the Z's.
我甚至都不需要浪費 時間要到Z的。
But this is a very linear approach, if you
但是,這是一個非常 線性方法,如果你
will, a very sort of left-to-right approach, a straight line.
將一個很有幾分左到右 方法中,一條直線。
And its correct but slow.
而它的正確的,但速度慢。
>> So I remember from grade school, sort of an optimization from a first grader,
>> 所以我從小學記得,排序 從小學一年級學生的優化,
where I learned how to count not by ones but by twos-- so 2, 4, 6.
在那裡我學會了如何不算數 由那些而是由twos--所以2,4,6。
It's A, lot harder to do, but in theory, it's
這是一個,要困難得多 這樣做,但在理論上,這是
faster-- 8, 10, 12, 14, and so forth.
faster-- 8,10,12,14,等等。
How about that algorithm?
怎麼樣的算法?
Is it more efficient?
是不是更有效?
Is it faster?
是不是更快嗎?
>> AUDIENCE: It's efficient.
>> 聽眾:這是有效的。
>> DAVID MALAN: Yeah, so it's def-- it's literally twice as fast, assuming I
>> DAVID MALAN:是的,所以它的def--它的 從字面上快一倍,假設我
don't get tripped up with my fingers.
不要讓她絆倒了我的手指。
It's twice as fast, because I'm turning through two
這是快一倍,因為 我轉向通過兩個
pages at once instead of one, but it's potentially in correct, because why?
一次,而不是一個網頁,但它是 潛在地正確的,因為為什麼呢?
>> AUDIENCE: You're skipping some.
>> 聽眾:你跳過一些。
DAVID MALAN: Right, what if Mike happens to be sandwiched-- maybe when I'm later
DAVID MALAN:對,如果邁克會發生什麼 被也許sandwiched--當我後來
in the phone book, Mike happens to be sandwiched between these two pages,
在電話簿,麥克恰好是 夾在這兩個頁面之間,
and I just blindly skip over it.
我只是一味地略過。
So we need a little fix there.
因此,我們需要一點點修復那裡。
Once I hit the T section, I can't just confidently say,
有一次,我打了T形截面,我 不能只是自信地說,
we didn't find Mike Smith.
我們沒有找到邁克·史密斯。
I probably have to double back.
我大概有原路折回。
Or in fact, once I reach someone named S-N, instead of S-M for Smith,
或事實上,當我到達的人 命名為S-N,而不是S-M代表史密斯,
immediately, I could double back, because maybe he
馬上,我可能會增加一倍 回來了,因為也許他
was on the previous page.
是以前的頁面上。
>> But I don't have to double back far.
>> 但我沒有遠加倍奉還。
In theory, if I do it at the right time, I just go back one page.
從理論上講,如果我這樣做,在合適的 那時,我剛回去一頁。
So it's adding only one extra step.
因此它僅添加一個額外的步驟。
So I've gone twice as fast, but it cost me one extra page.
所以,我已經走了快一倍, 但它花了我一個額外的頁面。
But that feels like a net win.
但是,這感覺就像一個淨贏。
>> But this is not how most people in this room would solve this problem.
>> 但是,這並不怎麼大多數人 這個房間將解決這個問題。
What would a typical person, maybe a few years ago do, to find Mike Smith?
什麼將一個典型的人,也許是 幾年前做的,找邁克·史密斯?
Yeah, didn't find Mike.
是啊,沒發現邁克。
What do I do?
我該怎麼辦?
So get a little closer, but I do know-- what is true about a phone book?
因此,獲得更近了一點,但我做的 知道 - 什麼是真正的關於電話簿?
AUDIENCE: It's sequential.
聽眾:這是連續的。
DAVID MALAN: It's sequential.
DAVID MALAN:這是連續的。
It's alphabetical.
這是按字母順序排列。
And so if I'm in the M section, Mike is clearly to the right,
所以,如果我在M部分, 邁克顯然是正確的,
I can literally tear the problem in half--
我可以從字面上撕裂 在half--問題
it's usually easier than that-- tear the problem in half and throw it away,
它通常比that--容易撕裂 一半的問題,並把它扔掉,
so that now, I have a problem that's no longer 1,000 pages-- that was hard,
所以現在,我有一個問題,這就是 不再是1000 pages--這是辛苦,
because I think I actually tore the phone book this time-- not
因為我覺得我居然撕毀 電話簿這個時間 - 不
1,000 pages, but 500.
1000頁,而500元。
>> So the problem is literally half as big.
>> 所以,問題是字面上一半大。
And that's pretty compelling, because with my previous algorithms, version
這是相當有吸引力的,因為 與我以前的算法,版本
1 and 2, I was only making the problem one page smaller, two pages smaller
圖1和2,我只是使問題 一個頁面較小,兩頁小
at a time.
在一個時間。
Whereas now, I made it 500 pages smaller all at once.
而現在,我做到了500 頁面的小的一次。
>> OK, so now, Karim proposes that I go to the right half.
>> 好了,現在,卡里姆建議 我去的右半部分。
So I'm going to go roughly to the middle, give or take.
所以我要去大致 到中間,給予或採取。
And if I did this mathematically, I could go right to the middle.
如果我這樣做數學, 我可以去正確的中間。
And now, I realize, oh, I'm in the T section.
而現在,我意識到,哦, 我在T節。
I actually did go too far.
其實我走得太遠。
>> But I can, again, tear the problem in half, throw it away.
>> 但我可以再次撕裂 一半的問題,把它扔掉。
And my bytes not as big.
而我的字節不一樣大。
It's only, what, 256 pages or 250 pages, give or take right now.
這只是什麼的,256頁或250 頁面,給予或現在服用。
But it's still way more than one page or two pages.
但它仍然方式更 超過一頁兩頁。
>> And so now, I go roughly to the middle.
>> 所以現在,我去大致中間。
Oh, I didn't go quite far enough now.
哦,我沒去很遠夠了。
So I repeat, repeat, repeat, repeat, until I'm hopefully
所以我重複,重複,重複, 重複,直到我希望
left with just one page.
只剩下一個頁面。
>> So that invites the question, if I started with roughly 1,000 pages,
>> 這樣邀請問題,如果我 開始的約1,000名頁面,
how many steps did it take me with version 1 of my algorithm?
做到了多少步帶我 我的算法1版本?
Well, if Mike is in the S section, in the worst case,
好吧,如果邁克是在S 部,在最壞的情況下,
that's pretty close to the end of the alphabet.
這是相當接近 字母表的末尾。
So if the phone book has 1,000 pages, I'll find Mike within 1,000 pages,
因此,如果電話本有1000頁, 我會在1000頁找到邁克,
give or take.
給予或採取。
Maybe it's like 800 or so, but it's pretty close to 1,000.
也許它就像800左右,但 這是相當接近1000。
>> Whereas, in the second algorithm, how many
>> 然而,在第二 算法,多少
page turns maximally might I require to find Mike Smith?
翻頁最大可能我 需要找邁克·史密斯?
There's 1,000 pages, but I'm doing them two at a time.
有1000多頁,但我 在時間做他們二。
Right, so max like 500ish, because if I go through the whole phone book,
對,所以最大似500ish,因為 如果我去通過整個電話簿,
at which point, I can stop.
在這一點,我可以停止。
But I can shave off a few by just stopping at the T section.
但我可以刮掉一小部分被 只是停在T形截面。
But it's at worst case 500 pages.
但它在最壞的情況下,500頁。
>> So how many times can I divide a 1,00o-page phone book in half again
>> 所以,我有多少次可以分割 1,00o頁電話簿中再次半
and again and again-- from 1,000 to 500 to 250 to 125?
並一次again--從 1000至500至250至125?
How long before I hit one page?
多久之前,我打一個頁面?
Yeah, it's about 10.
是啊,這是10個左右。
Depending on rounding and such, it's about 10 pages total need to be turned
根據舍入和這樣,它的 約10頁共需要開啟
or phone books need to be torn.
或電話簿需要被撕裂。
>> So that's pretty powerful.
>> 所以這是非常強大的。
We started with a 1,000-page problem in all three of these stories.
我們開始了1000頁的問題 在所有這三個故事。
But in the first algorithm, it took me, worst case, 1,000 page
但是在第一種算法,它 拉著我,最壞的情況下,1000頁
turns to find Mike.
周折找到邁克。
Second algorithm, 500 pages to find Mike.
第二種算法,500 網頁找到邁克。
Third algorithm, 10 pages to find Mike.
第三個算法,10頁找到邁克。
And it's even more powerful when you think
而且它更 強大的,當你認為
about sort of an opposite scenario.
有關排序相反的情景。
Suppose that the phone company next year maybe merges two towns together,
假設電話公司下一個 今年也許合併兩個鄉鎮一起,
and the phone book is suddenly this thick, instead of this that,
和電話簿突然 這厚厚的,而不是說這個,
so 2,000 pages instead of 1,000.
所以2000頁,而不是1000。
Well, my first algorithm looking for Mike Smith in a 2,000-page phone book,
好吧,我的第一個算法尋找 邁克·史密斯在2000頁的電話本,
worse case, it's going to take how many page turns next year?
更糟糕的情況下,要採取 明年有多少頁打開?
>> Phone book is 2,000 pages, so-- well, not one more.
>> 電話簿為2,000頁, so--好,不是一個。
If the phone book is twice as thick in the first algorithm, first algorithm,
如果電話簿兩倍厚 第一算法,第一算法,
2,000, right?
2000,對不對?
In the worst case, Mike is really close to the end of the book,
在最壞的情況下,邁克真的 關閉到書的結尾,
so it's 2,000 page turns.
所以它的2000翻頁。
Second algorithm going by twos, like 1,000 pages.
第二種算法通過去 三三兩兩,像1000頁。
>> But how about in my third and most recent algorithm?
>> 但是怎麼樣在我的第三個 和最近算法?
If the phone company doubles the number of pages from 1,000 to 2,000,
如果電話公司的一倍 從1000至2000的頁數,
how many more times need I tear that book in half to find Mike?
多少次需要我撕 那本書一半找到邁克?
>> AUDIENCE: Just one.
>> 聽眾:剛才之一。
>> DAVID MALAN: Just one more, because with one page tear,
>> DAVID MALAN:只要多一個, 因為一個頁面撕裂,
I can literally divide and conquer, if you will,
我可以從字面上分 和征服,如果你願意,
that problem in half taking a massive bite out of it.
在半則服用了這個問題 一個巨大的咬出來。
And so this is an example of efficiency and arguably an algorithm
所以這是一個例子 效率,可以說是一種算法
with which all of us are sort of intuitively familiar.
與我們所有人都 排序直觀地熟悉。
But it's just as correct as my other algorithms
但它只是為正確 我的其他算法
with that tweak for the second algorithm,
與對TWEAK 第二算法,
but it's so much more efficient.
但它是如此有效得多。
>> And in fact, what a computer scientist, or in turn a programmer,
>> 而事實上,什麼是計算機 科學家,或者反過來程序員,
would typically do when writing code is try to figure out,
書寫時通常會做 代碼是揣摩,
all right, I don't want my program just to be correct,
沒事,我不希望我的 節目剛是正確的,
I also want it to be efficient and solve problems well.
我也希望它是有效的 問題和解決問題很好。
Imagine in the real world today, like Google indexes, searches
今天在現實世界中想像, 像谷歌索引,搜索
like billions of pages, imagine if they used the first algorithm to find cats
像數十億個網頁,試想如果他們 使用第一算法來查找的貓
among a billion pages-- looking at the first page in their database,
一個十億pages--看著之中 第一頁在他們的數據庫,
the second, the third, just looking for a cat, looking for a cat.
第二個,第三個,只是尋找 一隻貓,尋找一隻貓。
That's pretty darn slow it would seem.
這是相當不錯的減緩它似乎。
They could instead use something called binary search, which
他們可以改用東西 稱為二進制搜索,這
is no coincidence-- bi meaning two, we keep dividing something in 2, in half--
沒有coincidence--雙向含義二,我們 不斷分裂東西2,在half--
they could use binary search and maybe find cats even faster,
他們可以使用二進制搜索 也許找貓甚至更快,
or whatever it is you're searching for.
或不管它是你正在尋找。
>> And frankly, there's even fancier algorithms
>> 坦率地說,有 更炫的算法
that do much more than just dividing things in half
該做的不僅僅是更多 分東西兩半
in order to find information quickly.
為了快速查找信息。
And we'll talk a little bit about those after lunch today.
我們將討論一點點 今天的午飯後。
So let me just try to represent this.
因此,讓我只能盡力代表這一點。
We don't need to go into any math or actual numbers.
我們並不需要進入 任何數學或實際數字。
We can talk about this in the abstract.
我們可以抽象地談論這個。
>> But let me just propose, if you were having a discussion now
>> 但讓我求婚,如果你 現在是具有討論
with the engineers proposing this algorithm
與工程師 提出這種算法
and you're trying to make a calculated decision,
而你試圖讓 計算的決定,
because maybe the engineer says to you, you
因為也許 工程師對你說,你
know what, I can implement a linear search in like two minutes.
知道嗎,我可以實現 像2分鐘線性搜索。
It's that easy.
就是這麼簡單。
Binary search is not that fancy, but it's going to take me like 10 minutes,
二進制搜索是不是花哨,但 它會帶我像10分鐘,
so 5 times as long.
所以5倍長。
>> There's a trade here, even in terms of deciding what software to write.
>> 有一個行業在這裡,即使是在條件 在決定寫什麼軟件。
Do you write the simpler algorithm, which will just take you two minutes?
你寫的簡單算法, 這將只是把你們倆分鐘呢?
Or do you spend more time, 10 minutes, writing the fancier algorithm?
或者你花更多的時間,10分鐘, 寫愛好者算法?
How do you decide that kind of question?
你如何決定樣的問題?
Or you could make it a little more real.
或者你可以讓它多了幾分真實。
I tell my boss it's going to take me either one week or 10 weeks
我告訴我的老闆是要採取 我任何一個星期10週
to implement the software in this way, how
實施 在這種方式的軟件,如何
do you decide which algorithm to green-light?
你決定哪些 算法綠燈?
Karim?
卡里姆?
>> AUDIENCE: The audience, I guess.
>> 聽眾:觀眾,我猜。
>> DAVID MALAN: The audience.
>> DAVID MALAN:觀眾。
What do you mean by the audience?
你說的觀眾呢?
>> AUDIENCE: If it's going to be used by users
>> 聽眾:如果它是怎麼回事 由用戶使用
who [INAUDIBLE] by users [INAUDIBLE].
誰[聽不清]使用者[聽不清]。
But if it's something you're just doing for yourself
但是,如果它的東西你 只是在做自己
to facilitate a problem, [INAUDIBLE] quicker.
便利的問題, [聽不清]更快。
DAVID MALAN: Yeah, it's quick and dirty is a good way to describe it.
DAVID MALAN:是的,它的快速和 臟來形容它的好方法。
In fact, if you're describing much of my time
事實上,如果你是 描述了很多我的時間
in grad school, whereby often times, I wrote bad code consciously so--
在研究生院,其中很多時候, 我寫了糟糕的代碼自覺so--
at least, that's how I rationalized it-- consciously so,
至少,這就是我如何 合理化它 - 那麼自覺,
because even though I was writing code that was relatively slow to execute,
因為即使我在寫代碼 這是執行相對緩慢,
I was able to write the code itself pretty fast, spending just minutes
我能寫代碼本身 相當快,支出僅幾分鐘
or hours not days.
或小時而不是幾天。
And it turned out, I occasionally needed to sleep.
而事實證明,我 偶爾需要睡覺。
So even if my code required 8 hours to run, well that's fine,
所以,即使我的代碼需要8 小時運行,很好,很好,
I'll just go to sleep while it runs.
我只是走在它運行時睡覺。
>> So at the time, I thought this was very clever, even though I apparently
>> 所以在當時,我認為這是 很巧,即使我顯然
worked through my PhD very slowly.
通過我的博士工作非常慢。
But the converse of that is that, if I were writing software
但是,反過來是 即,如果我寫的軟件
for other people who mattered more than me, well,
其他人誰 更要緊比我好,
having them wait 8 hours to get back their search results
讓他們等候8小時 拿回自己的搜索結果
is not all that compelling.
是不是所有的引人注目。
And so spending more time up front to write software
所以,花更多的時間 前面編寫軟件
that is more efficient, more like our third algorithm,
即更高效,更 像我們的第三個算法,
probably benefits the users over time.
可能有利於用戶在一段時間。
So it really depends over time how those costs add up.
因此,它實際上取決於在 時間如何將這些費用加起來。
If you're going to be writing software to use it once,
如果你將要寫作 軟件使用一次,
probably might as well do quick and dirty, as they say.
可能還不如做 快速和骯髒的,因為他們說。
Just throw it together.
只是把它在一起。
It's code that embarrasses you, it's so bad,
它的代碼尷尬 你,這是如此糟糕,
but it gets the job done correctly, even though it's not efficient.
但它得到正確地完成任務, 即使它是沒有效率。
Conversely, you spend more time on something, get it just right.
相反,你花更多的時間 的東西,得到它恰到好處。
And then amortized over time, that upfront cost of time
然後攤銷隨著時間的推移, 時間的前期費用
is probably worthwhile, if you keep optimizing for the common case.
也許是值得的,如果你繼續 優化為常見的情況。
>> And indeed, that's a theme in programming, or computer science more
>> 事實上,這是在一個主題 編程,或計算機科學更多
generally, trying to optimize not for the uncommon case
通常,試圖優化 不是為罕見的情況下
but the common case-- what operation is going to happen again and again?
但共同的case--什麼操作 是要一次又一次地發生?
If you're going to have billions of users searching on your website,
如果你想擁有數十億美元 用戶搜索您的網站上,
you should probably spend the extra weeks up front writing better software,
你應該花額外的 週前面編寫更好的軟件,
so that all of your users benefit.
讓所有的用戶受益。
Now, let's try to capture this a little pictorially, but not so much
現在,讓我們嘗試捕捉這個 形象地少,但沒有這麼多
numerically.
數字。
>> So here's just an old school chart.
>> 因此,這裡只是一個老同學的圖表。
And let me say that this is time.
讓我說,這就是時間。
And it doesn't matter what-- actually, no, not time.
並不要緊what-- 其實,不,不是的時間。
Let's put that on the other axis.
讓我們把那另一個軸。
Let's say that this is the time, and this is size of problem.
讓我們說,這是時間, 這就是問題的大小。
>> And a computer scientist might generally call
>> 和一個計算機科學家 通常可能調用
this just n. n is like our go-to variable, where
這僅僅局限於N。 n是像 我們去到變量中,其中
n is a number, n number, and it's the number of whatever inputs you have.
n是一個數,n個,以及它的 你有任何的投入數量。
So in this case, n is the number of pages.
因此,在這種情況下,n是 的頁數。
So it might be 1,000 in the case we just told.
所以它可能是1000中 的情況下,我們只是告訴。
>> So time can be any unit of measure.
>> 所以,時間可以是任何計量單位。
Maybe, it's second.
也許,這是第二次。
Maybe, it's days.
也許,這是天。
Maybe, it's like page turns.
也許,這就像翻頁。
Doesn't matter.
沒關係。
Whatever you want to count in, that will be time or cost equivalently.
無論你希望計算,即 將時間或等效的成本。
>> So with that very first algorithm, if I, for instance,
>> 因此,與第一個 算法,如果我,例如,
had a 1,000-page phone book, I'm going to draw a dot there,
有一個1000頁的電話本, 我要畫一個點那裡,
because if it's 1,000 pages, it took roughly 1,000 page turns, give or take.
因為如果它是1000頁,花了 大約1000翻頁,給予或採取。
And then if I had a 2,000-page phone book,
然後,如果我有一個 2000頁的電話本,
and I'm going to draw a second dot here, because for 2,000 pages,
我要去畫第二 在此點,因為2000頁,
it's like 2,000 seconds or page turns or whatever.
它就像2000秒 或翻頁或什麼的。
And so when I said earlier, it's kind of a linear relationship,
因此,當我前面說的,這是 樣的線性關係,
that was deliberate, because I wanted later on-- right now-- to draw a line.
這是故意的,因為我想 後來on--權now--劃清界限。
It's kind of a straight line relationship.
這是怎樣的一個直 行的關係。
The slope is 1/1, if you will.
斜率是1/1,如果你願意。
>> Meanwhile, the second algorithm said, if you've got 1,000 pages
>> 同時,第二算法 說,如果你有1000頁
and you were using the second algorithm, where I counted by 2's, turning
而你使用第二算法, 在那裡我數2的,把
two pages at a time, should I draw a dot below or above my original dot?
同時兩頁,我要畫一個 點低於或者高於我的原始點?
>> AUDIENCE: Below.
>> 聽眾:下面。
>> DAVID MALAN: Below, because as we saw, it takes less time, half as much time.
>> DAVID MALAN:下面,因為正如我們所看到的, 它需要較少的時間,一半多的時間。
So the dot should be half as high as the other.
所以點應該是一半 高達另一個。
And same deal over here, this dot should probably be roughly there.
而同樣的協議在這裡,此點 也許應該是大致那裡。
And so my second algorithm, similarly, has a linear relationship with time.
所以我的第二個算法,同樣地, 具有隨時間的線性關係。
And we can draw it as such.
而且我們可以得出它是這樣。
>> So now, the third and final algorithm is a little harder to draw.
>> 所以,現在,第三個和最後 算法是有點難以得出。
But intuitively, if I've got 1,000 pages with my third algorithm,
但是直覺,如果我有1000 我的第三個算法的網頁,
it should only take me like 10 steps.
它應該只把我像10步。
And if I've got 2,000 pages with my third algorithm,
如果我有2000頁 我的第三個算法,
it should take me not 10 steps, but 11, just one more.
應採取我不要10 步驟,但11,只是多一個。
So we're only barely going to see this.
因此,我們只能勉強維持會看到這一點。
>> And it turns out, if I zoom in on this, I'm
>> 而事實證明,如果 我放大此,我
going to exaggerate for effect, the shape of that line, ultimately,
要誇大的效果, 該線的形狀,最終
is not a straight line-- because, indeed if it were,
不是直line-- 因為,事實上,如果它是,
it would look more like the others-- it's actually a curved line
它看起來更像 others--它實際上是一個曲線
that, if we zoom in, is going to look much more like this.
,如果我們放大,是怎麼回事 看起來更像這一點。
It-- well, OK, ignore this part.
它 - 嗯,好吧,忽略這一部分。
That was my pen going of angle.
這是我的鋼筆一樣的角度。
It's a curved line that is always increasing, always, always, always
這是一個曲線,就是始終 越來越多,永遠,永遠,永遠
increasing, but only just barely.
增加,但只是勉強。
>> And so over time, you have a relationship that's more like this.
>> 所以,隨著時間的推移,你有一個 關係,即更喜歡這個。
It almost looks straight.
它看起來幾乎筆直。
But it's ever so slowly increasing.
但它是非常緩慢地上升。
But for almost all points along your x-axis, horizontal axis,
但沿著幾乎所有的點 您的x軸,水平軸,
it's lower than those other lines.
它比其他行低。
>> So this might be a relationship n, whereby if you have n pages,
>> 所以這可能是一個關係 N,因此,如果您有n頁,
takes you n seconds.
你需要n秒。
This might be a relationship n/2.
這可能是有關係的n / 2。
You have n pages, it takes you n/2 seconds, half as many.
您有n個網頁,它需要 你N / 2秒,一半多。
And this is a logarithmic relationship, which
而這是一個對數 關係,這
if you recall, log base 2 of n captures this kind of growth, so to speak.
如果你還記得,日誌N捕獲基地2 這種增長,可以這麼說。
So this is the sort of holy grail among the three of these
因此,這是何許神聖 在這三個中的聖杯
here, because it's just so much more efficient, but arguably more complex
在這裡,因為它只是這麼多 高效,但可以說更複雜
to implement.
實現。
Any questions?
任何問題?
>> Well let me do this, let me open up a text window
>> 那麼,讓我做到這一點,讓 我打開一個文本窗口
just so we can try to formalize something here.
只是讓我們可以嘗試 在這裡正式的東西。
So let me go ahead now and implement this algorithm
所以,現在讓我繼續前進, 實現這個算法
for finding Mike Smith in code, if you will, pseudocode code.
在代碼中發現邁克·史密斯, 如果你願意,偽碼。
I'm not going to use Java or C++.
我不打算使用Java或C ++。
I'm just going to use sort of English-like syntax, which we
我只是要使用排序 英語的語法,這是我們
would generally call pseudocode code.
一般會叫偽代碼。
Here, I have a blank window.
在這裡,我有一個空白窗口。
And I'm saying step 1 of the very first algorithm is pick up phone book.
而且我說的很第一步 第一種算法是拿起電話簿。
Step 2 is open book to first page.
第二步是開卷第一頁。
Step 3 will be look at page for Mike Smith.
步驟3將看 麥克·史密斯頁面。
If on page, call Mike.
如果頁面上,叫麥克。
else turn page and go to step 3.
其他依次頁,轉到第3步。
Done, let's say.
完成後,讓我們說。
>> And so it's not quite perfect, which we'll see in a moment.
>> 所以它不是相當完美, 我們將看到一個時刻。
But let's consider what concepts I've introduced here.
但是,讓我們考慮一下 概念我在這裡介紹。
So steps 1 and 2 and 3 are pretty much verbs.
所以步驟1和2和3 有相當多的動詞。
They're statements, actions-- do this.
他們聲明,actions--做到這一點。
And so in a programming language, we would generally
因此在編程 語言,我們一般會
call them statements or functions or procedures,
叫他們陳述或 函數或過程,
call them any number of things.
打電話給他們許多東西。
But they're just actions-- do this.
但他們只是actions--做到這一點。
>> Step 4 is fundamentally different, because it's kind of asking a question.
>> 第4步是根本不同的, 因為它是一種問一個問題。
It's saying we're kind of at a fork in the road.
它說我們是一種 的在一個岔路口。
If Mike is on the page, call him, so turn left, if you will.
如果麥克在頁面上,請致電 他,所以左轉,如果你願意。
And if not, go back to some other page-- or rather, sorry,
如果沒有,回去一定 其他page--或者說,對不起,
go back to some other step, which induces some kind of looping construct.
回去一些其他步驟,其中 導致某種循環結構。
And we do it again and again and again.
而我們一次又一次地做一遍。
>> And actually, you know what?
>> 而實際上,你知道嗎?
Yeah.
是啊。
else if at end of book stop.
否則,如果在書站結束。
So we need kind of a third condition, because you
因此,我們需要怎樣的一個第三 狀態,因為你
can't keep turning the page ad nauseum, because eventually, I'll
不能讓翻頁廣告 nauseum,因為最終,我會
hit the end of the book.
撞書的結尾。
And a bug in a program might be not anticipating that scenario.
並且在一個程序中的錯誤可能是 沒有預見到的情況。
And then I just realized, oh, wait a minute, I need a third scenario.
然後我才意識到,哦,等等 一分鐘,我需要第三個場景。
If I'm out of pages, I should really just stop.
如果我出的網頁,我 真的應該只停留。
Otherwise, it's undefined.
否則,它是不確定的。
What's going to happen if I keep saying turn the page and go back,
這是怎麼回事,如果我繼續發生 說翻過這一頁,回去,
this is when computers freeze or crash, when you hit
這是當電腦 死機或崩潰,當你打
some unanticipated situation like that.
一些未預料到的情況那樣。
>> Now, what about Mike Smith's third algorithm--
>> 現在,邁克 史密斯的第三算法 -
pick up the phone book, open book to first-- to
拿起電話本, 翻書序曲一到
no, not first page this time, to middle-- oh, well, that'd
不,不是第一頁這個時候, 到middle--哦,嗯,那倒是
be the second algorithm.
是第二算法。
Let's just skip to the third.
讓我們只是跳到第三。
>> AUDIENCE: Oh, I'm sorry.
>> 聽眾:哦,對不起。
>> DAVID MALAN: That's fine.
>> DAVID MALAN:那很好。
Let's just skip to the third-- open to middle and now look for Mike Smith.
讓我們只是跳到third--開放 以中,現在找邁克·史密斯。
if on page, call Mike.
如果頁面上,叫麥克。
And then what do we want to say here?
然後,我們究竟要在這裡說什麼?
else what?
還有什麼?
We can express this in any number of ways.
我們可以表達這種 在任何數量的方式。
There's no right answer.
有沒有正確的答案。
OK, if not again, but we need to be-- OK, we do want to divide in two,
好吧,如果不再,但我們需要 be-- OK,我們確實需要兩分,
but do we want to go left or go right?
但做我們想要去向左或向右走?
How do we express that notion?
我們如何表達這一概念?
Well, in Mike's case, yes, that's fair.
那麼,在小李的情況下,是的,這是公平的。
But OK, so that's actually a good point.
但是好了,這實際上是一個很好的點。
That's fine.
沒關係。
We'll keep going with this logic.
我們將繼續與這個邏輯下去。
So--
所以 -
>> AUDIENCE: Less than half.
>> 聽眾:不到一半。
DAVID MALAN: Yeah.
DAVID MALAN:是的。
So else if page is, we'll say, less than Smith, to the left of Smith,
所以,如果別的頁面,我們會說,少 比·史密斯,史密斯的左側,
then-- let's see, is this going to complicate?
then--讓我們來看看,是 這要複雜?
else if page comes before Smith, tear in half, throw away which half?
否則,如果屏幕出現之前,史密斯, 撕了一半,扔掉哪一半?
>> AUDIENCE: I thought that was [INAUDIBLE].
>> 聽眾:我想 這是[聽不清]。
>> DAVID MALAN: I'm hearing both answers.
>> DAVID MALAN:我聽說兩個答案。
>> AUDIENCE: Left.
>> 聽眾:左。
DAVID MALAN: OK, throw away left half, as Lakisa
DAVID MALAN:OK,扔 遠的左半邊,如Lakisa
said earlier, the left half, then I kind of
前面說了,左 一半的話,我有種
want to just go to-- I go to the right.
想只是去中場休息,我去的權利。
Or equivalently, and I made a little bit of a mess of the beginning here,
或等價的,我做了一個小 一開始的有點亂在這裡,
I effectively want to go to step 2 again,
我切實想 再去步驟2,
where open to the middle-- or open-- yeah, let's just say, pages to middle.
其中,開到middle--或open-- 是的,我們只能說,頁面中間。
And this fixes it.
而這種修復它。
It's no longer a book.
它不再是一本書。
It's just half of a book, so open pages to middle.
這只是一本書的一半, 如此開放頁面中間。
>> else-- were almost there.
>> else--是幾乎沒有。
Step 6, else if page comes after Smith, tear in half, throw away right half,
第6步,否則,如果屏幕出現後,史密斯, 撕成兩半,扔掉右前衛,
then go to step 2.
然後轉到步驟2。
else quit, a fourth scenario if we have no pages left to turn.
別的不干了,第四個情況下,如果 我們沒有離開頁面打開。
So we could clean this up.
這樣我們就可以打掃一下。
And we should clean this up.
我們應該打掃一下。
This is very pseudocode code, if you will, very high level description.
這是很偽代碼,如果你 會的,非常高的水平的描述。
But it does generally capture the idea.
但它確實一般拍攝的想法。
>> And, again, in this scenario, we have the notion of a condition,
>> 並再次,在這種情況下,我們 有一個條件的概念,
a branch, a fork in the road, making a decision-- if this, go this way,
一個分支,在一個岔路口,使得 一個decision--如果,走這條路,
else if, go this way, else if, go that way.
否則如果走這條路, 否則如果走那條路。
And this is a very common programming technique
而這是一個非常普遍的 編程技術
to decide which direction to go, so to speak.
決定哪個方向 去,可以這麼說。
And we also have some kind of looping structure, where
我們也有一些 的循環結構,其中
we're doing something again and again.
我們一次又一次地做一些事情。
>> Now, it turns out, much as in this example,
>> 現在,事實證明,很多 如在本實施例中,
being super precise is important.
作為超級精確是非常重要的。
But we've also seen something that we keep calling abstraction.
但是,我們也看到了一些 我們保持通話抽象。
What does it mean to pick up phone book?
這是什麼意思拿起電話簿?
We're just kind of taking for granted in this room
我們只是那種服用 理所當然的在這個房間
that that has some semantic meaning.
這是有一定的語義。
All of us just kind of know, oh, well, pick up the phone book.
我們都只是一種知道,哦, 好了,拿起電話本。
What does that really mean?
這是什麼究竟意味著什麼?
Well, that really means extend hand, lean over, extend fingers,
嗯,這實際上意味著延長 手,俯身,延長手指,
pinch book between fingers, stand up, pull hand towards you.
手指之間捏書, 站起來,用手拉向你。
And we could be really pedantic about this,
我們可以真正做到 迂腐這一點,
really being super precise as to what I'm doing.
真的是超級精確 至於我在做什麼。
But all of those steps collectively are what it means to pick up a phone book.
但是,所有這些步驟都統稱 這意味著什麼,拿起了電話本。
>> And so earlier, when I said, each of these first two statements
>> 因此更早的時候,我說,每 前兩個語句
can be thought of as a proceed or a function,
可以被認為是一個 繼續或函數,
really it represents what we keep calling an abstraction.
實際上它代表了我們 保持通話的抽象。
It's like a high level conceptual description of a problem that
這就像一個高層次的概念 的問題的說明那
actually involves quite a few steps.
實際上涉及相當多的步驟。
And so this, too, is a recurring topic in programming,
所以這一點,也是一個 在編程中經常性的話題,
whereby I might write a program using syntax like this--
因此我可能會寫一個程序 使用語法像this--
pick_up_phone_book().
pick_up_phone_book()。
And then syntactically, I'm going to steal something
然後,語法,我 要偷東西
from most programming languages.
從大多數編程語言。
>> Now, step 1 looks even more like a function,
>> 現在,第1步看起來更加 更像是一個函數,
as a programmer would call it.
作為一個程序員調用它。
It looks like code that someone has given a name to and given
它看起來像代碼有人 給一個名稱,並給予
to me to use somehow-- in other words, what the line I've highlighted
我在其他使用somehow-- 也就是說,什麼線我突出
represents functionality that maybe I didn't even implement myself.
代表的功能,也許 我甚至沒有實現自己。
Someone older, wiser than me already figured out
有人年長,比聰明 我已經想通了
how you express the notion of picking up a phone book.
如何表達你的觀點 的拿起電話簿。
And it's like the five steps I just rattled off, off the top of my head.
它就像五個步驟我只是 列舉了,把我的頭頂部。
>> But he or she already implemented this, gave those several steps
>> 但他或她已經實現 這一點,給了那些幾個步驟
a name, pick_up_phone_book.
一個名字,pick_up_phone_book。
And the parentheses is just what most programmers
而括號是 正是大多數程序員
do at the end of statements like this.
在做這樣的語句的結束。
I now can stand on his or her shoulders and never again,
我現在能站在他或她的 肩膀再也沒有,
think about what it means to pick up a phone book.
想想這意味著什麼 拿起電話簿。
I can just say, pick up the phone book.
我只能說,拿起電話簿。
And that's exactly what all of us humans did here.
而這正是 我們所有的人在這裡做。
>> When we were probably 1 year old, 2 years old,
>> 當我們大概1 歲,2歲時,
someone had to teach us what it meant to pick up a phone book.
有人曾教給我們什麼 為了拿起電話簿。
And ever since then, we've abstracted away
從那之後, 我們已經抽象化了
from those very uninteresting mechanical steps.
從這些很無趣 機械步驟。
And we just have an intuitive understanding
我們只是有一個 直觀的了解
of what it means to pick up a phone book.
中意味著什麼 拿起電話簿。
>> And you can extrapolate now to more complicated things--
>> 你現在可以推斷 更複雜的things--
construct a building.
建築大樓。
Like, to some people, that actually has meaning.
像對某些人來說, 實際上具有意義。
To contractors, to architects, that has some meaning.
承包商,建築師, 有一定的意義。
And they would know what to do, if I said, go construct a building.
他們會知道該怎麼做,如果 我說,去構建一個建築。
>> But most of us in the room couldn't deal with that level of abstraction.
>> 但在房間裡我們大多數人不能 處理抽象的那個級別。
You need to tell us like go get the shovel and go get the concrete
你需要告訴我們喜歡去拿 鏟去得到具體
and nail the pieces of wood together and whatever else
並釘上木塊 一起和其他任何
is involved in building a building.
參與建設的建築。
And that's because we have not yet been programmed to understand
那是因為我們還沒有 尚未被編程理解
what it means to construct a building.
這意味著什麼建築大樓。
We don't have that abstraction.
我們沒有這樣的抽象。
We don't have that functionality.
我們沒有這個功能。
>> And so what you'll see in programming languages, in general,
>> 所以你會看到 編程語言,在一般情況下,
especially more modern languages, like Java, PHP, Ruby, and Python,
尤其是更現代的語言, 像Java,PHP和Ruby和Python,
they're much more mature than older languages,
他們更成熟 比舊的語言,
like C and C++ and yet others.
像C和C ++,但其他人。
And so they come with more functionality built in.
因此他們提出更多 功能內置的。
More code has been written by people in the past
更多的代碼已被寫入 人們過去
that we can now call or summon or use, as I'm hinting
我們現在可以通過電話或 召喚或使用,因為我暗示
at with this highlighted line here.
在這個位置突出顯示的行。
And so even though we're not talking about programming languages per se,
所以,即使我們不說話 大約本身的編程語言,
just pseudocode code, all of the ideas are still in that discussion.
只是偽代碼,所有的 想法仍然在討論中。
And it turns out precision is super important, as is abstraction.
而事實證明精度 超級重要的,是抽象。
And let's try to communicate that as follows.
讓我們試著 傳達如下。
>> I accidentally might have spoiled this by flashing a slide on the screen
>> 我不小心可能會被寵壞 這個在屏幕上閃爍的幻燈片
prematurely.
過早。
But let me ask for a brave volunteer, if you don't mind coming up.
但讓我問一個勇敢的志願者, 如果你不介意的話來了。
You'd be in front of the camera, if you're OK with that.
你會在前面 相機,如果你與確定。
Would anyone like to come up and give instructions to your colleagues here?
有沒有人願意來,並給 說明在這裡你的同事?
Just have to come over here and stand over here and say some words.
只要有到這裡來和 站在這裡了,說一些話。
>> Victoria is smiling the most and avoiding my eyes the most.
>> 維多利亞是微笑最 並避免我的眼睛最。
Would you be willing to come on up?
你願意來上了?
OK.
好。
And if everyone else at your seats could take out a piece of scrap paper,
如果每個人都在你的座位 可以拿出一張廢紙,
if you will.
如果你願意。
Lined paper is fine.
橫格紙是罰款。
Come around this way.
過來這樣。
Or some of the paper that you were given yesterday,
或某些紙張的那 你昨天給予,
just any blank sheet of paper, if you could.
隨便一個空白頁 紙,如果你能。
And if you don't have any, just ask your neighbor if you could.
如果你沒有任何,只 如果你可以問你的鄰居。
>> So for the moment, for this example, Victoria
>> 所以,就目前而言,對於 本例中,維
is going to play the role of a programmer, an engineer, who
將要發揮的作用 一個程序員,工程師,誰
needs to program you all, as the computers, to do something.
需要你的程序是,作為 電腦,做一些事情。
And we'll see what assumptions you decide to make.
我們會看到什麼假設 你決定做。
We'll see how precise she chooses to be.
我們將看到她選擇的精確度是。
And if this demonstration goes pedagogically well, lots of mistakes
如果這個演示雲 教學上很好,很多錯誤
will be made, that we'll then use that as an opportunity for discussion.
將作出,我們會再使用 隨著討論的機會。
But the challenge for you should be to avoid those mistakes,
但你應該挑戰 要避免這些錯誤,
be a good programmer.
成為一個優秀的程序員。
And so the challenge at hand, if you'd liked to walk over here,
因此在手的挑戰,如果 你喜歡在這裡走了過來,
is in front of Victoria on the screen here-- and hopefully, none of you
在屏幕上的維多利亞前 這裡 - 並希望,沒有你
remember this when I flashed on the screen.
當我記得這個 閃現在屏幕上。
And do not turn around at all, because there is another screen in this room
不要轉身可言,因為 還有另外一個屏幕在這個房間
that I can turn off.
我可以關掉。
So don't turn around.
所以,不要回頭。
>> In front of Victoria is that same scream.
>> 在維多利亞面前 是一樣的尖叫。
And her job now is to tell you all on your piece of paper what to draw.
而她現在的工作是告訴你 你一張紙上畫什麼。
And we will see, based on verbal instructions alone,
我們將看到,基於 單單口頭指示,
computer code, if you will, how accurate your drawings
計算機代碼,如果你願意, 如何準確的圖紙
are-- your implementations are.
are--你的實現是。
Make sense?
合理?
>> AUDIENCE: Yeah.
>> 聽眾:是的。
DAVID MALAN: OK, execute.
DAVID MALAN:OK,執行。
>> AUDIENCE: Draw a square.
>> 聽眾:畫一個正方形。
>> [LAUGHTER]
>> [笑聲]
>> DAVID MALAN: And no questions may be asked.
>> DAVID MALAN:而且沒有 問題可能會問。
Can only do what you're told.
只能做有人告訴你什麼。
Oh, and if you have today's slides open in a tab, don't look at your tab.
哦,如果你有今天的幻燈片 在標籤頁中打開,不看你的標籤。
OK?
好?
>> AUDIENCE: OK, draw a circle.
>> 聽眾:OK,畫一個圓。
A slope-- can I say slope?
一個slope--我能說的斜率?
DAVID MALAN: Up to you.
DAVID MALAN:給你。
AUDIENCE: A slope.
聽眾:一個斜坡。
And a triangle.
和一個三角形。
>> DAVID MALAN: All right.
>> DAVID MALAN:好的。
And stay here for just a moment.
而在這裡呆一會兒就好了。
And I'm going to come around in just a moment.
而且我要來 在短短的時刻左右。
And no need to put your names on it.
沒必要把你們的名字。
Let me come around and collect your drawings,
讓我來到我身邊 收集您的圖紙,
if you don't mind tearing them out.
如果你不介意撕裂出來。
>> Here is what we got back.
>> 下面是我們回來。
I'll project it on the screen.
我會投影在屏幕上。
I see a square, a circle, a slope, and a triangle.
我看到一個正方形,圓形, 一個斜率和一個三角形。
So that was one answer there.
所以這是一個答案在那裡。
And let's-- whoops.
和let's--哎呦。
Thank you.
謝謝。
Here's another assortment, and one behind it.
這裡的另一個品種, 和一個它的後面。
>> So they all seem to capture the spirit.
>> 因此,他們似乎都捕捉到的精神。
Thank you.
謝謝。
There's another, and here's another one.
還有一個,這裡是另外一個。
The slope interpretation is a little different, little curvy.
斜坡的解釋是 有點不同,有點彎曲。
And the closest, either because of the wonderful specificity with which you've
與最接近的,或者是因為 與你已經特異性精彩
described, or maybe you kind of saw it before, this is indeed
描述的,或者你有種 看到它之前,這確實是
what Victoria was actually describing.
維多利亞什麼實際描述。
>> But now, those of you who didn't get it quite right,
>> 但現在,那些你們誰 沒有得到它完全正確,
let's offer some objections here.
讓我們在這裡提供了一些異議。
So Victoria first said draw a square.
所以維多利亞先說畫一個正方形。
And now, we can assume for the sake of today
而現在,我們可以假設 今天的緣故
that everyone knows how to draw a square.
大家都知道 如何繪製一個正方形。
But that's not wholly clear, right?
但是,這並不完全清楚,對不對?
How else could you have drawn a square, or where
你怎麼還能有 畫出的方形,或在
might be some of the ambiguities here for the computer?
可能是一些模棱兩可的 這裡的電腦嗎?
AUDIENCE: Location and size.
聽眾:位置和大小。
DAVID MALAN: Location, right?
DAVID MALAN:位置,對不對?
All of you had a paper of some shape, generally rectangles, but slightly
在座的各位有一些形狀的紙, 一般矩形,但稍微
different sizes.
不同的尺寸。
But you certainly could have drawn, if you wanted, a huge square, maybe
但你肯定會已制定, 如果你想,一個巨大的廣場,也許
a tiny square.
一個小廣場。
Maybe, it was rotated.
也許,有人旋轉。
I don't think we saw that.
我不認為我們看到了。
But it could have been more diamond like but still, nonetheless,
但是,它可能是更多的鑽石 喜歡但還是儘管如此,
mathematically a square.
數學上的正方形。
So that was arguably ambiguous.
所以這是可以說是模棱兩可。
>> Then she said, draw a circle.
>> 然後她說,畫一個圓。
Some of you did draw it next to it, which isn't unreasonable,
你們有些人根本旁邊繪製 它,這是沒有道理的,
because humans tend to think or read right to left in most languages, so not
因為人類傾向於認為或閱讀 從右到左的大多數語言,所以不是
a bad guess.
一個壞的猜測。
But that circle could have been inside the square,
但那個圈子可能 一直在正方形內,
could have been around the square, could have been elsewhere
本來是圍繞著 廣場上,本來是在別處
on the sheet, so arguably ambiguous.
在紙張上的,所以可以說是模棱兩可。
>> Slope might have been maybe taking the most liberties verbally
>> 斜率可能已經也許 採取最自由口頭
with what that means.
有什麼意思。
And some of you interpreted it as a squiggly line
和你們中的一些解釋 它作為一個波浪線
or a straight line or the like.
或直線等。
And then triangle, too, could have been oriented in any number of ways.
然後三角形,也可以有 被定向在任何數量的方式。
So in short, even with something that you glance and you're like, wow, so
因此,在短期,即使有一些 你一眼,你就像,哇,好
simple, a child could draw this, well not
簡單,小孩子可以 得出這樣的,好了沒有
really, unless you're super, super persuasive
真的,除非你 超級,超級說服力
and tell the computer exactly what to do.
並告訴計算機 究竟該怎麼做。
So if we could, if you have another sheet of paper, let's
因此,如果我們可以,如果你有 另一張紙上,讓我們
try this once more.
試試這一次。
And I'm going to give Victoria one other example on the screen here.
我想給維多利亞1 這裡,屏幕上的其他的例子。
And again, don't turn around and don't look at your slides.
再次,不掉頭 不看你的幻燈片。
And I'll give her a moment to think about how to describe this.
我給她一點時間 想想如何描述這一點。
Don't let them see the fear in your eyes.
不要讓他們看到 恐懼在你的眼前。
>> [LAUGHTER]
>> [笑聲]
>> And again, this time leverage some of those takeaways
>> 再次,這一次槓桿 其中一些外賣
and try to get almost everyone at least the right answer.
並試圖讓幾乎所有人 至少正確的答案。
>> AUDIENCE: OK, take a piece of paper, look
>> 聽眾:OK,取 一張紙,看看
in the middle of that piece of paper.
在一張紙的中間。
In the middle of that piece of paper, draw a cube.
在那片中間 紙,畫一個立方體。
>> [LAUGHTER]
>> [笑聲]
DAVID MALAN: What have we learned?
DAVID MALAN:有我們學到了什麼?
We were so close.
我們是如此接近。
OK, repeat if you could, for everyone.
OK,重複,如果你能為大家。
>> AUDIENCE: In the middle of the piece of paper, draw an object,
>> 聽眾:在的中間 一張紙,畫一個對象,
which looks like a cube.
它看起來像一個立方體。
>> DAVID MALAN: OK, that's all you get to work with.
>> DAVID MALAN:OK,這是 你所得到的工作。
Allow me to be analytical and not so much critical,
請允許我以分析 並沒有那麼多的關鍵,
but to make the claim that Victoria definitely
但要索賠 維多利亞肯定
seems to be thinking in very high level abstractions, which
似乎非常想在 高層次的抽象,它
is not unreasonable.
不是沒有道理的。
Because otherwise, we'd all be pretty dysfunctional,
因為否則的話,我們都會 是非常不正常的,
if we had to be ever so precise with everything we do in the world.
如果我們是有史以來如此精確 與我們所做的一切的世界。
>> But saying go to the middle-- I thought we were on such a good track
>> 但話說到了我middle-- 以為我們是在這樣一個良好的跟踪
there, like go to the very middle of the page, and then draw a cube.
那裡,就像去正中央 頁面,然後繪製一個立方體。
So she's thinking in abstractions, because she's still viewing
於是,她的思維抽象, 因為她還是觀看
what's on the screen as indeed a cube.
什麼是確實是屏幕上的立方體。
But there's so many opportunities for interpretation there.
但是,有這麼多的機會 口譯那裡。
And in fact, there's so many other ways you could express
而事實上,有這麼多 你可以表達其它方式
that, which I'll propose in a moment.
是,我將在稍後提出。
So here we have one incarnation of the picture-- whoops-- one
所以在這裡我們有一個化身 在picture-- whoops--之一
incarnation of the picture, so a little three dimensionality to it,
圖片的化身,所以 小三維它,
which is nice.
這是很好的。
>> Here's another one, where you have the same, though it's kind of an open cube.
>> 這裡是另外一個,在這裡你有 同樣的,雖然它是一種開放的立方體。
Some folks took it a little more flat, two dimensional.
有些人把它一點點 更加扁平化,二維的。
And that's fine.
這很好。
So there, indeed in the center of the paper.
所以,確實是在 紙張的中心。
This one I think you'll like, because if we go here,
這一次我想你會 喜歡,因為如果我們何去何從,
this is what she was describing.
這就是她被描述的。
So now, let me propose how else we might describe this situation.
所以,現在,讓我提出怎麼回事 我們可以描述這種情況。
>> Back in the day, one of the most more common ways to learn programming
>> 早在一天,一個最 比較常見的方式來學習編程
was to write code, writes lines of instructions,
是寫代碼,寫 指令線,
that controlled a little turtle on the screen.
該控制的小 龜在屏幕上。
Logo and other variants of this was the name of the language.
標誌和本其他的變種 是語言的名稱。
And the turtle lived in a world.
而龜生活的世界。
>> So suppose this rectangular space is his world.
>> 因此,假設該矩形 空間是他的世界。
And you would start by assuming-- I don't really know how to draw turtle,
你會被assuming--我做起 真的不知道怎麼畫烏龜,
so let's do it like this.
讓我們像這樣做。
And then he's got a shell and then maybe some feet.
然後,他有一個殼 然後也許有些腳。
So you might have this little character on the screen.
所以,你可能有這個小 字符在屏幕上。
>> And the object of this programming language
>> 並在此對象 程序設計語言
was to compel the turtle to go up, down, left, right
是迫使龜 往上走,下,左,右
and to put his pen down or pick his pen up,
並把他下筆 或拿起他的筆了,
so he could actually draw on the screen in this very flat rectangular world.
因此他居然可以在屏幕上繪製 在這個平面呈長方形的世界。
So where I thought you might be going, and where you should consider diving
那麼,我想你可能會去, 並且,你應該考慮跳水
down to mentally when describing instructions more generally,
到精神上描述時, 說明更一般地,
I would claim, is put your pen down in the middle--
我會聲稱,就是把你 筆在middle--下降
and we'll get rid of the turtle, because I can't really
我們會擺脫 烏龜,因為我真的不能
keep drawing him very well.
不斷吸引他很好。
>> And now, how else could I say draw a cube?
>> 而現在,還能怎樣 我說畫一個立方體?
Well, we could say something like draw a diagonal line northeast, for instance,
好了,我們可以這樣說平局 一個對角線東北,例如
or at a 45-degree angle upward.
或以45度角向上。
And that might have gotten me here.
而這可能會在這裡得到了我。
And I'm pretty far from a cube.
而我從一個立方體很遠。
But now, I could say something like turn 90 degrees to the left
但現在,我可以說的東西 像旋轉90度到左側
and draw a line of equal length northwest.
畫線的 等長西北部。
And I could continue with similar directions.
而且我可以繼續 具有類似的方向。
And it's not going to be easy.
而且這不是一件容易的事。
And frankly, we probably would have been here for five minutes.
坦率地說,我們可能會 在這裡已經五分鐘。
But maybe we would have gotten to something that, at the end of the day,
但也許我們會得到以 東西,在一天結束時,
ends up being a cube, but we dived inside of that abstraction
最終被一個立方體,但我們 跳水是抽象的內
to do it at such a low level that you can't really
做到這一點在如此低的 級別你不能真正
see what you're doing until the whole thing is actually there on the page.
看到你在做什麼,直到整個 事情是居然還有在頁面上。
And so this is a general principle, again, of programming-- this idea
所以這是一個總的原則, 再次,programming--這個想法
of abstraction.
抽象。
It's so wonderfully powerful, because again,
它是如此奇妙 強大,因為再次,
she just said, draw a cube, which all of us pretty much would grok very quickly.
她只是說,畫一個立方體,所有的 我們幾乎將神交非常快。
We would just understand, OK, draw a cube.
我們只是知道, OK,繪製一個立方體。
We might not know the orientation, so we could be a little more precise,
我們可能不知道的方向, 所以我們可以是一個小更精確,
but we can generally picture or know what a cube is.
但我們可以大致想像 或者知道一個立方體是什麼。
And that's useful, because if every time you
這是非常有用的, 因為如果你每次
sat down as a programmer at your keyboard to write code,
坐了下來,作為一個程序員在 鍵盤來寫代碼,
if you had to think at such a low level, none of us
如果你不得不想在這樣 較低的水平,我們誰也沒
would ever get anything done.
會永遠做成任何事情。
And certainly, none of us would enjoy the process of writing code.
當然,沒有人會 享受編寫代碼的過程。
It would be like writing in 0's and 1's, which frankly wasn't all that long ago
它會像在0和1的寫作, 坦率地說是不是所有的很久以前
humans were writing code in 0's and 1's.
人類是在0和1的編寫代碼。
And we very quickly came up with these higher level languages--
我們很快就想出了 這些較高級別languages--
C++ and Java and others.
C ++和Java等。
>> So let's try this once more just to flip the tables, so that all of us
>> 因此,讓我們試試這個一次剛 翻轉表,讓我們所有的人
have the chance to think in rather the same way.
不得不思考的機會 在相當的方式相同。
Could we get one more volunteer this time to come up to the board and draw,
我們可以得到一個更多志願者這 來時間最長的板和借鑒,
not recite?
不背誦?
Yeah, OK.
是啊,OK。
Ben, come on up.
本,上來吧。
And, Ben, in this case, once you face the board, don't look left,
而且,本,在這種情況下,一旦你 面對董事會,不看左邊,
don't look right.
不看的權利。
Only do what your colleagues here tell you.
只能做你的 同事在這裡告訴你。
And for everyone else in the room, you now are the programmer.
而對於其他人的 房間裡,你現在的程序員。
He's the computer.
他的計算機。
And the picture I've chosen here in advance is this one here.
和畫面我在這裡選擇 提前這是一個在這裡。
They're just-- they're thinking of a funny joke is all.
他們just--他們在想 一個有趣的笑話就是一切。
>> So would does someone like to volunteer the first instruction
>> 所以會有人不喜歡 志願的第一條指令
or statement that should command Ben's pen?
或聲明應 命令Ben的筆嗎?
And we'll do this collectively, maybe one instruction from each person.
我們會集體這樣做,也許 從每人一個指令。
I'm sorry?
對不起?
>> AUDIENCE: Draw a circle.
>> 聽眾:畫一個圓。
DAVID MALAN: Draw a circle is the first thing I heard.
DAVID MALAN:畫一個圓 是我聽到的第一件事。
>> AUDIENCE: Up top.
>> 聽眾:向上頂。
>> DAVID MALAN: Up top.
>> DAVID MALAN:往上頂。
OK, we can let you delete, undo.
OK,我們可以讓你刪除,撤消。
And now, someone else.
而現在,別人。
Dan, would you be comfy offering the next instruction?
丹,你會舒服 提供的下一個指令?
>> AUDIENCE: Sure, draw the center of the bottom of the circle,
>> 聽眾:當然,繪製中心 圓的底部的,
with a small-- a little small space from that,
與small--一點 從狹小的空間,
draw a straight line down to three quarters of the way down the board
畫一條直線下降到三 的方式季度在案板上
a slight angle to your left.
一個微小的角度,以你的左邊。
>> DAVID MALAN: Good.
>> DAVID MALAN:好。
>> AUDIENCE: Slight angle.
>> 聽眾:很小的角度。
>> DAVID MALAN: Undo, Control-Z. OK.
>> DAVID MALAN:撤銷,Ctrl-Z鍵。好。
Andrew, you want to offer up the next instruction?
安德魯,你想提供 向上的下一個指令?
>> AUDIENCE: Sure.
>> 聽眾:當然。
From the bottom of that line, a further slight angle--
從該行的底部, 進一步輕微angle--
whoops-- maybe about a third of the length [INAUDIBLE],
whoops--也許大約三分之一 長度[聽不清]
slight angle downward and like a third of the length of [INAUDIBLE].
很小的角度向下像 第三[聽不清]的長度。
So yeah, from that point, draw a line a third
所以是的,從這一點來說, 畫一條線第三
of the length of the previous line further to the left.
先前的長度的 線進一步向左側。
>> DAVID MALAN: That OK?
>> DAVID MALAN:那行嗎?
Straight line, that's OK?
直線,這是確定?
OK, Olivier, you want to offer up the next?
OK,奧利弗,你要 提供了下?
>> AUDIENCE: [INAUDIBLE] from the bottom of the circle, [INAUDIBLE].
>> 聽眾:[聽不清]從 圓的底部,[聽不清]。
Draw on the right hand side of [INAUDIBLE] centimeters.
借鑒右側 的[聽不清]厘米。
>> [LAUGHTER]
>> [笑聲]
>> DAVID MALAN: I think you're going to have to convert that's inches here.
>> DAVID MALAN:我想你會 要轉換這裡是英寸。
>> AUDIENCE: Stop.
>> 聽眾:停止。
>> [LAUGHTER]
>> [笑聲]
>> DAVID MALAN: OK.
>> DAVID MALAN:OK。
[? Ara, ?] you want to offer up the next?
[? ARA,?]你想 提供了下?
>> AUDIENCE: Draw a [INAUDIBLE] the upper [INAUDIBLE] the same.
>> 聽眾:繪製[聽不清] 上部[聽不清]相同。
[INAUDIBLE] circle, draw to the [INAUDIBLE] and draw [INAUDIBLE].
[聽不清]畫圓,畫到 [聽不清],並繪製[聽不清]。
>> DAVID MALAN: OK, no more undo.
>> DAVID MALAN:OK,沒有更多的撤消。
Let's do one or two more instructions.
讓我們做一個或兩個指令。
Chris, you want to offer one?
克里斯,你想提供一個?
>> AUDIENCE: At the bottom of the circle, [INAUDIBLE]
>> 聽眾:在底部 圓的,[聽不清]
draw an equal line slopping downward to the left [INAUDIBLE].
繪製平等線噴濺 向下向左[聽不清]。
>> DAVID MALAN: OK.
>> DAVID MALAN:OK。
Andrew?
安德魯?
We did-- Karim?
我們did--卡里姆?
>> AUDIENCE: Starting from the right line, the end of the left line, the bottom,
>> 聽眾:從右邊線開始, 左行的末尾,底部
you're going to go right about the same length as that line
你要去說得對 的長度相同線
you're on, drawing to the right [INAUDIBLE].
你在,繪圖 正確的[聽不清]。
[INAUDIBLE] degrees, so [INAUDIBLE] degrees on the right side.
[聽不清]度,所以[聽不清] 度在右側。
>> DAVID MALAN: All right.
>> DAVID MALAN:好的。
Let's pause.
讓我們暫停一下。
Don't turn around yet.
不要轉身呢。
Let's pause, and let's try one other attempt
讓我們暫停,讓我們 嘗試另一個嘗試
before we reveal to Ben what he's been drawing.
我們之前透露給本 他一直畫。
Can you shuffle Ben to the right-- or actually,
您可以隨機播放奔 在right--或實際,
no, let's just give you another board, even better.
沒有,我們只是給你 另一塊板,甚至更好。
So would someone now like to take more of the approach
所以會有人現在想 採取更多的辦法
that Victoria took earlier on, where we speak in a higher level abstraction
維多利亞在早期花了,在那裡 我們在一個更高層次的抽象說話
and in just a sentence or two describe to Ben
在短短一個句子 兩個描述奔
what to draw without getting into the weeds,
沒有什麼畫 漸入雜草,
so to speak, at this a lower level?
可以這麼說,在這一個較低的水平?
Victoria.
維多利亞。
[LAUGHTER]
[笑聲]
AUDIENCE: Draw a figure of the walking man.
聽眾:畫一個圖 的行走的人。
And his legs and arms have to be the right side.
而他的腿和胳膊 必須是右側。
>> DAVID MALAN: OK, that's all you get.
>> DAVID MALAN:OK,這就是你得到的。
All right.
好吧。
Why don't we reveal to Ben what he did.
我們為什麼不透露給奔他做了什麼。
So a round of applause.
所以,掌聲雷動。
That was the hardest perhaps.
這是最難的也許。
>> So even though we're talking in fairly silly terms
>> 因此,即使我們談論 在相當愚蠢的條款
about just drawing pictures, hopefully you
關於剛剛繪製 圖片,希望你
can really appreciate the degree of expressiveness that might be necessary
才能真正體會的程度 表現,可能是必要
in order to tell a computer what to do.
為了告訴計算機做什麼。
And in fact, the fact that Ben was able to draw this so quickly
而事實上,這一事實本 之所以能夠如此迅速地得出這樣的
is sort of testament to using a language, maybe a higher level
是有點遺囑於使用 語言,也許是更高層次
version of English, that allows him to just use words, or hear words
英文版本,允許他 只是使用的話,或者聽到的話
from Victoria, that allow him these abstractions-- just draw
從維多利亞,這讓他 這些abstractions--只畫
a figure walking to the right-- that sort of has
一個人影步行到 right--那種有
some semantic meaning to it that isn't nearly as obvious when you're just
一些語義它不是 幾乎一樣明顯,當你只是
saying, put your pen down, draw to the right, draw to the left.
他說,把你的下筆,畫 到右側,繪製到左邊。
>> And so this, too, is very common in programming.
>> 所以這也很 常見的編程。
This would be said to be like a very low level language, programming
這可以說是像 非常低級語言,編程
in 0's and 1's if you will.
在0和1的,如果你願意。
And this would be a higher level language programming in Java,
並且這將是一個更高的水平 編程語言在Java中,
or something like that.
或類似的東西。
A bit of an oversimplification, but that's
的A位 過於簡單化,但是這
the sort of like emotional feeling that you feel when
該有點像情緒 感覺,你覺得當
using one kind of thing or another.
用一種東西或其他。
A bit of frustration here by the need for such precision, but the opportunity
無奈有點這裡所需要 對於這樣的精度,但機會
to be a little looser with the interpretation here.
是有點寬鬆與 這裡的解釋。
But of course, bugs can arise as a result.
不過,當然,錯誤 可以作為結果產生。
>> If you'd like at home-- we won't do this one in class--
>> 如果您想在home--我們 不會做這一塊的分類 -
but if you'd like to bring this one home,
但如果你想 這帶來一個歸屬,
I thought we would dive into this.
我以為我們會潛入這一點。
So if you'd like to play this game with your significant other
所以,如果你想打這個 遊戲與其他顯著
or kids or the like, you might enjoy that as well.
或孩子或類似物,則 可能會喜歡這一點。
>> So let's go ahead and look at one last thing here for computational thinking.
>> 因此,讓我們繼續前進,並期待在最後 這裡計算思維的東西。
And that brings us to John Oliver, not for the clip
這給我們帶來了約翰 奧利弗,不為剪輯
you might have seen last night, but to a somewhat recent issue.
你可能已經看到昨晚, 但是有點最近的問題。
A few months back, Volkswagen took quite a bit of flak
幾個月前,大眾汽車 花了很有點高射砲
for what reason, if you know?
是什麼原因,如果你知道嗎?
What did they get in trouble for?
他們怎麼惹上麻煩呢?
>> Yeah, so emissions-- they were trying to beat emissions
>> 是啊,所以他們emissions-- 試圖擊敗排放
tests by essentially having their cars pollute the environment less
通過實質上有測試他們的 汽車污染環境少
when their cars were being tested and pollute the environment more
當他們的汽車被正在測試 ,污染環境的更
when the cars were not being tested.
當汽車沒有被測試。
And what's increasingly interesting in the world, as you may have inferred
什麼是越來越有趣 在世界上,你可能已經推斷出
from discussions of like-- what is it-- CarPlay, Apple's software for cars
從like--討論是什麼 它 - CarPlay,蘋果軟件汽車
and the fact that many of us increasingly
而事實上,許多 我們越來越多地
have touch screens in our cars, there's a frightening amount
有觸摸屏在我們的汽車, 有一個可怕的量
of software in people's cars today, which
在人們的軟件 今天的汽車,這
frankly opens a whole can of worms when it comes to security and physical risk.
坦率地打開蠕蟲的時候一個整體 它涉及到安全和人身風險。
But for today, let's focus on just what's
但在今天,讓我們 只關注什麼
involved in writing software that might have gamed the system.
參與編寫軟件 可能已耍花招系統。
>> For the definition of the problem, for those unfamiliar,
>> 對於的定義 問題,對於那些不熟悉,
let's take a look at John Oliver.
讓我們來看看約翰·奧利弗。
And for those familiar with the problem, let's look at it
而對於那些熟悉 這個問題,讓我們來看看它
in a fun lens via John Oliver as well.
在通過約翰·奧利弗一個有趣的鏡頭,以及。
So let me hit play on this, I think, three-minute introduction.
因此,讓我打這個遊戲,我 認為,三分鐘的介紹。
Damn it.
該死的。
[VIDEO PLAYBACK]
[視頻回放]
-Cars--
-汽車 -
DAVID MALAN: Obviously, on YouTube, it's--
DAVID MALAN:很明顯, 在YouTube上,it's--
- --the smartest characters in the Fast and Furious movies.
- --the最聰明的字符 在速度與激情的電影。
This week, German automaker Volkswagen found itself
本週,德國汽車製造商 大眾發現自己
in the middle of a scandal of potentially criminal proportions.
在醜聞的中間 潛在的犯罪比例。
>> -Volkswagen is bracing for billions in fines, possible criminal charges
>> -Volkswagen是支撐數十億 罰款,可能的刑事指控
for its executives, as the company apologizes
其高管,如 公司道歉
for rigging 11 million cars to help it beat emissions tests.
索具1100多萬輛汽車,以 幫助其擊敗的排放測試。
>> -Certain diesel models were designed with sophisticated software that
>> - 某些柴油車型設計 與先進的軟件,
used information, including the position of the steering wheel and vehicle
使用的信息,包括位置 方向盤和車輛的
speed, to determine the car was undergoing emissions testing.
速度,以確定汽車是 進行排放檢測。
Under that circumstance, the engine would reduce toxic emissions.
該種情況下,發動機 將減少有毒物質的排放。
But the car was rigged to bypass that when it was being driven.
但是汽車操縱旁路 當它被驅動。
Emissions increased 10 to 40 times above acceptable EPA levels.
排放量增加10至40 次超過可接受水平的EPA。
>> -Wow, 10 to 40 times greater than the EPA allows.
>> -Wow,10〜40倍 大於EPA允許。
That is the worst thing Volkswagen has ever done,
這是最糟糕的事情 大眾已經做過,
is something you might say if you'd never heard of World War II.
是你可能會說,如果 你從來沒有聽說過二戰。
But maybe the surest sign of how much trouble Volkswagen is in,
但也許是如何最確實的標誌 比較麻煩大眾是,
is that people at the very top have stepped down.
是人們在很 上面已經下台。
The CEO resigned on Wednesday after scrambling to do damage control,
該公司首席執行官辭職後,週三 爭著做損害控制,
saying he was endlessly sorry, which sounded great until it turned out
說他對不起不休,這 響起了巨大直到它橫空出世
he was only 10% sorry but had rigged his mouth
他只有10%的遺憾 但操縱了他的嘴
to artificially inflate his sorriness.
人為誇大他的sorriness。
And meanwhile, Volkswagen's US chief had an apology of his own.
而與此同時,大眾汽車在美國 首席有他自己的道歉。
>> -Let's be clear about this, our company was dishonest.
>> - 讓我們清楚這一點, 我們公司是不誠實的。
And in my German words, we have totally screwed up.
而在我的德語單詞,我們 已經完全搞砸了。
>> -Yeah, but totally screwed up are not German works.
>> 是啊,但完全擰 最多是不是德國人的作品。
And the German language has many beautiful phrases
和德語 有許多美麗的短語
to describe situations just like this, such as [GERMAN], which means roughly,
來形容,就像這樣的情況下, 如[德國],這意味著大致,
the sadness that comes from business related lies,
自帶的悲傷 從業務相關的謊言,
or [GERMAN], which translates as shaming ones father involving
或[德國],換算 作為羞辱那些涉及父親
clouds of gasoline.
汽油雲。
It's a beautiful language.
這是一個美麗的語言。
It just sails off the tongue.
它只是帆了舌頭。
And by the way, while that man's apology may have sounded sincere,
順便說一句,而男人的 道歉也許聽起來誠懇,
it's worth noting he was speaking at an official launch party for the 2016
值得注意的是,他在講話 2016年官方發布派對
Volkswagen Passat, meaning that shortly after saying sorry, he said this.
大眾帕薩特,這意味著短期內 說對不起後,他這樣表示。
>> -Thank you very much for coming.
>> - 謝謝的光臨。
Enjoy the evening.
享受夜晚。
Up next is Lenny Kravitz.
旁邊是藍尼·克羅維茲。
>> [MUSIC PLAYING]
>> [音樂]
>> -OK, OK, ending your apology with up next
>> -OK,OK,你的結局 道歉與旁邊
Lenny Kravitz does not scream sober contrition.
藍尼·克羅維茲不 尖叫清醒悔悟。
It screams, we asked Bon Jovi, and he said no.
它的尖叫聲,我們問苯教 喬維,他說沒有。
Volkswagen's brand has been badly damaged.
大眾汽車的品牌有 遭到嚴重破壞。
And frankly, their new ad campaign is not exactly helping.
坦率地說,他們的新廣告 運動是不完全幫助。
>> --[GERMAN], we at Volkswagen would like to apologize for deceiving you with
>> - [德國],我們在大眾汽車希望 為欺騙你道歉
our vehicles.
我們的車輛。
>> [END PLAYBACK]
>> [結束播放]
DAVID MALAN: So this was a roundabout way of-- sorry--
DAVID MALAN:所以這是一個 環島路of-- sorry--
this was a roundabout way of introducing a fundamental problem
這是一種迂迴的方式 引入一個基本問題
in software, which is that you need to detect certain conditions.
在軟件,這是你 需要檢測一定的條件。
And so the question at hand here is, how does a car potentially,
這樣一來,在眼前的問題在這裡 是,請問有車有可能,
as implemented in software by these programmers,
作為在軟件中實現 這些程序員,
detect that it's actually being tested?
檢測到它實際上被測試?
So to be super clear, what they were doing
所以要超清晰, 他們在做什麼
was, in environments where the programmers figured
是,在環境中 程序員想通
the car was being tested, they somehow made
該車當時正在 經過測試,他們不知何故
the car emit less emissions, fewer emissions, so less toxic fumes
汽車排放少排放,少 排放量,所以毒性較低的煙霧
and such.
和這樣的。
But when it's normally driving on the road,
但是,當它通常 駕駛的道路上,
it would just emit as much pollution as it wanted.
它只是發出盡可能多 污染,因為它想要的。
>> So how could we write the pseudocode for this algorithm?
>> 所以,我們怎麼可能寫 偽這個算法?
How could we write the pseudocode for the software running in the car?
我們怎麼能寫的偽代碼 在汽車運行的軟件?
I mean, in a nutshell, it boils down to something like this.
我的意思是,簡而言之,沸騰 到這樣的事情。
if being tested, emit less.
在被測試,減少排放。
else emits more.
其他排放更多。
But that's a little too high level, right?
但是,這是一個小 過高的水平,對不對?
>> Let's try to dive in as to what this abstraction of being tested means.
>> 讓我們嘗試潛水至於這是什麼 被測試手段抽象。
In other words, even if you know nothing about cars, what sort of questions
換句話說,即使你什麼都不知道 問題關於汽車,什麼樣的
might you ask in order to determine if you're being tested, if you're the car?
也許你為了確定是否問 你正在測試中,如果你的車?
What characteristics might be present if a car is being tested?
什麼樣的特點可能是 目前如果汽車正在測試?
>> AUDIENCE: Testing equipment.
>> 聽眾:檢測設備。
>> DAVID MALAN: Testing equipment.
>> DAVID MALAN:檢測設備。
So if testing equipment nearby, then emit less.
因此,如果檢測設備 在附近,然後減少排放。
So I could imagine implementing that with some kind of cameras
所以,我可以想像實施 與某種相機
or detecting what's around you.
或者檢測什麼是你的周圍。
And let me propose, that just feels too complicated
讓我,讓我們 只是感覺太複雜
to actually have additional hardware just for that purpose.
實際上還有其他 硬件只是用於這一目的。
>> AUDIENCE: If you're in park, if your hood is open.
>> 聽眾:如果你在 公園,如果你的引擎蓋打開。
>> DAVID MALAN: In park or hood open, so that's good.
>> DAVID MALAN:在公園或 引擎蓋打開,所以這是很好的。
>> AUDIENCE: And car running.
>> 聽眾:與汽車的運行。
>> DAVID MALAN: So that's a little more concrete-- and car running.
>> DAVID MALAN:所以這是一個有點 更concrete--和汽車的運行。
So this would be the conjunction of a few different conditions, if you will.
因此,這將是一個會合 幾個不同的情況下,如果你願意。
So if the car is in park, and even though this is a very mechanical thing
因此,如果汽車在公園裡,甚至 雖然這是一個非常機械的東西
typically, I could imagine writing software,
通常情況下,我可以 想像編寫軟件,
especially because there's often a light there these days,
特別是因為有 常光有這些天,
I could imagine there being software that can query the shifter
我可以想像那裡是 軟件可以查詢器
or what not, are you in park, are you in drive, are you in reverse.
或什麼不是,你在公園裡,有 你的驅動器,你在相反。
And I can get back an answer that's either yes
我可以回去了 回答是肯定的任
or no to those kinds of questions.
或無來者的題型。
>> And so I could also probably answer a question like, is the hood open.
>> 所以,我也大概可以回答 一個問題一樣,是引擎蓋打開。
Maybe, there's some kind of sensor that either gives me back a 1 or 0,
也許,有一些類型的傳感器 要么給我回1或0,
true or false, the hood is open.
真的還是假的,發動機罩打開。
And then car running, I could detect that somehow via what mechanism?
然後車跑,我可以檢測 通過什麼樣的機制,不知何故?
Like, the car is running, I could detect that it's on,
一樣,汽車運行過程中,我 可以檢測到它的上,
could I detect somehow that the car is moving?
我能以某種方式檢測 該汽車在行駛?
>> AUDIENCE: RPMs.
>> 聽眾:RPM包。
>> DAVID MALAN: Yeah, so there's always that needle that
>> DAVID MALAN:是啊,所以有 總是那針
tells you how many rotations per minute the wheels are experiencing.
告訴你每多少轉 分鐘的車輪正在經歷。
And so I could look at that.
因此,我可以看看那個。
And if it's not 0, that probably means the car is moving.
如果它不是0,這可能 是指汽車在行駛。
But we have to be a little careful there,
但是,我們必須是一個 稍微細心那裡,
because-- let's simplify this-- if we just said, if car running,
因為 - 讓我們簡化this-- 如果我們只是說,如果車跑,
we don't want to just emit less, we want if the car is running
我們不希望只是減少排放, 我們想,如果汽車運行
and it's being tested.
和它的被測試。
>> So there are a few other ingredients that folks
>> 所以有一些其他 成分,鄉親
have hypothesized the software is doing, because absent the actual source code,
已經假設該軟件是幹什麼的, 由於缺少實際的源代碼,
you can only sort of infer from the physical effects of the car as to what
您可以從只有幾分推斷 汽車的物理效應,以什麼
might be going on underneath the hood in software.
可能是下面怎麼回事 罩中的軟件。
So if car running and maybe, say, rear wheels not moving,
所以,如果車跑,也許, 比如說,後輪不動,
might this be indicative of some kind of test?
這可能預示 的一種考驗?
What am I hinting at here?
我究竟在暗示這裡?
Yeah, maybe, it's on one of those roller things,
是的,也許,這是在一個 這些輥的事情,
where like the wheels are turning in the front or in the back,
其中類似的車輪轉向 在前面或在後面,
depending on whether it's front wheel or rear wheel drive, so half of the wheels
取決於它是否是前輪或 後輪驅動,所以一半的輪子
are moving, but the other two aren't, which
是移動的,但該 另外兩個都沒有,這
is a weird situation in the real world.
是在現實世界中一個奇怪的局面。
If you're driving on the road, that shouldn't happen.
如果你開車在 道路,這是不應該的。
But if you're in a warehouse on some kind of roller system,
但如果你是在一個倉庫 對某種輥系統,
that might indeed happen.
確實可能發生。
>> I think folks also proposed that maybe, if the car is running and steering
>> 我認為,人們還提出,也許, 如果汽車是運行和轉向
wheel not moving, that too might be a signal,
沒有秒針輪動,即 太可能是一個信號,
because that's reasonable for like a straightaway on a road.
因為這是合理的 就像道路上的通俗易懂。
But even then, the human is probably moving it a little bit or certainly
但即便如此,人類可能是 移動一點點或肯定
over a few seconds.
超過幾秒鐘。
Or the course of a minute, odds are it's not
或一過程 分鐘,賠率是它不
going to be fixated in exactly the same position.
要在對被固定 完全相同的位置。
>> So in other words, we can take substraction,
>> 因此,換句話說,我們 可以採取減法,
are you being tested, and break down that functionality
你正在測試, 打破這個功能
into these component ingredients.
到這些部件的成分。
And that's truly what Volkswagen's engineers somehow did.
這就是真正的大眾汽車什麼的 工程師在某種程度上做到了。
They wrote software consciously to detect if the car is being tested,
他們編寫軟件自覺地 檢測汽車是否正在測試中,
therefore emit less, else emit in the usual way.
因此,減少排放,否則 發射在通常的方式。
>> And the problem here, too, is that software is not
>> 這裡的問題也是如此, 是,軟件不是
something you can really see unless you have the so-called source code.
是你真的可以看到,除非 有所謂的源代碼。
So there's two different types of code-- at least two different types
因此,有兩種不同類型的 代碼 - 至少兩種不同類型的
of code in the world.
在世界上的代碼。
There's something called source code, which is not unlike what
有一種叫做源 碼,這是不不像
we've been writing, source code.
我們一直在寫,源代碼。
>> This is source code written in a language called pseudocode,
>> 這是源代碼寫在 一個叫偽語言,
which is just something English-like.
這只是一些英語等。
There's no formal definition of it.
還有就是它沒有正式的定義。
But C, and Java, C++, those are all formal languages that,
但是,C,以及Java,C ++,這些 都是正規的語言說,
when you write in them, what you have is a text file containing source code.
當你在寫他們,你有什麼 是包含源代碼的文本文件。
>> But there is also something in the world called machine code.
>> 但也有一些在 世界稱為機器代碼。
And machine code, unfortunately, is just 0's and 1's.
和機器代碼,不幸的是, 僅有0和1的。
So machine code is what machines understand, of course.
所以機代碼是什麼 機器理解,當然。
Source code is what humans understand.
源代碼是什麼人懂。
>> And generally, but not always, there is a program
>> 一般,但不 總是有一個節目
that a programmer uses that takes source code and turns it into machine code.
一個程序員使用了採用源 代碼並把它變成機器代碼。
And that program is generally called a compiler.
而這程序 一般被稱為編譯器。
So your input is source code, your output is machine code,
所以,你的輸入源代碼, 你的輸出是機器代碼,
and the compiler is a piece of software that does that process.
而編譯器是一塊 軟件,做這一進程。
So this actually maps nicely to our inputs, algorithms, outputs.
所以實際上很好地映射到 我們的投入,算法的輸出。
>> But this is a very specific incarnation of that, which is to say that,
>> 但是,這是一個非常具體的化身 的這一點,這是說,
even if you own one of Volkswagen's cars that is guilty of this,
即使你擁有大眾汽車的一個 汽車就是犯了這一點,
it's not like you can just open the hood or open the user's manual or look
它不喜歡你可以打開 罩或打開的用戶手冊或者查看
at the source code, because by the time it reaches your car in your driveway,
在源代碼,因為由時間 到達您的車停在你的車道,
it's already been converted into 0's and 1's.
它已經被 轉換成0和1的。
And it's very hard, not impossible, but very hard to glean much of anything
而且它是很辛苦的,不是不可能的, 但很難收集很多的事情
from just looking at the underlying 0's and 1's.
從剛剛在看 底層0和1的。
So you can figure it out, ultimately, if you understand how a machine operates--
所以,你自己看著辦吧,最終,如果 您了解機器operates--
Intel inside-- if you understand the Intel architecture,
英特爾inside--如果你了解 英特爾架構,
but it's very time consuming.
但它是非常耗時。
And even there, you might not be able to see everything
而即使在那裡,你可能 無法看到的一切
that the code can actually do.
該代碼可以做。
>> Any questions about this or this kind of process more generally?
>> 這個或任何疑問 樣的過程更普遍?
And actually, we can tie this discussion to yesterday's discussion of Apple.
而實際上,我們可以配合這個討論 蘋果昨天的討論。
This, too, is why the FBI can't just go and look in the suspect's phone
這也就是為什麼聯邦調查局不能只 去看看在犯罪嫌疑人的手機
and find the lines of code, for instance, that enable the passcode
找到的代碼行,為 例如,使密碼
or enable that 80-millisecond delay.
或啟用,80毫秒的延遲。
Because by the time it's on the fellow's iPhone,
因為到那時它的 在老鄉的iPhone,
it's already been converted to 0's and 1's.
它已經被 轉換為0和1的。
>> Well, let's pause here for our look at computational thinking.
>> 好吧,讓我們暫停這裡為我們 看看計算思維。
Why don't we take a 15 minute break.
我們為什麼不採取有15分鐘的休息時間。
And when we return, we'll take a look at programming
而當我們回來,我們將 看看編程
itself and start to map some of these high level concepts
本身並開始繪製一些 這些高層次的概念
to an actual, if playful, programming language.
一個實際的,如果俏皮, 編程語言。