字幕列表 影片播放 列印所有字幕 列印翻譯字幕 列印英文字幕 >> [VIDEO PLAYBACK] >> [視頻回放] >> [CAR DOOR SHUTTING] >> [汽車車門關閉] >> [CAR ENGINE STARTING] >> [汽車發動機起動] >> [MUSIC PLAYING] >> [音樂播放] >> -Moving right along in search of good times and good news. >> 右沿搜索-Moving 美好的時光和一個好消息。 With good friends you can't lose. 有了良好的朋友,你不能輸。 >> -This could become a habit. >> - 這可能會成為一種習慣。 >> -Opportunity knocks Let's just reach out and grab it. >> -Opportunity敲門讓我們 只要伸出手抓住它。 -Yeah! 是啊! -Together we'll nab it. -Together我們逮到它。 -We'll hitch hike, bus, or yellow cab it. -We'll順利調漲, 公交車,或黃色出租車吧。 -Dammit. -Dammit。 -We're moving right along. -We're正確的順動。 -Footloose and fancy free. -Footloose和花式免費。 -Getting there is half the fun. -Getting有一半的樂趣。 Come share it with me. 跟我來分享。 >> -We're moving right along. >> -We're正確的順動。 >> -We're going to share the load. >> -We're要分擔負載。 >> -We don't need a map to get this show on the road. >> - 我們並不需要一個地圖 獲得本次車展的道路上。 -Hey Fozzy, I want you to turn left if you come to a fork in the road. - 嘿Fozzy,我希望你能左轉 如果你來到了一個岔路口。 -Yes, sir. - 是的,先生。 Turn left at the fork in the road. 左轉,在三岔路口。 Turn left. 左轉。 >> -I don't believe that. >> - 我不相信。 >> -Cruising right along we found the lights on the highway. >> -Cruising沿著正確的發現 在高速公路上的燈光。 >> -And your way or my way. >> - 和你的方式或我的方式。 >> -So trust my navigation. >> - 所以相信我的導航。 >> -Movie stars with flashy cars and life with the top down. >> - 電影恆星浮華汽車 和壽命與自上而下。 >> -We're storming the big hills. >> -We're強攻大陵。 >> -Yeah, storm is right. >> 是啊,暴風雨是正確的。 Should it be snowing? 是否應該下雪? >> -No, I don't think so. >> 不,我不這麼認為。 >> -Moving right along. >> 沿著正確-Moving。 >> -Footloose and fancy free. >> -Footloose和花式免費。 >> -You're ready for the big time. >> -You're準備好大的時間。 >> -Is it ready for me? >> -is它為我準備好? >> -Moving right along. >> 沿著正確-Moving。 Moving right along. 運動沿著正確的。 Moving right along. 運動沿著正確的。 Moving right along. 運動沿著正確的。 -I think you better pull over. - 我想你最好靠邊停車。 -Yes, sir. - 是的,先生。 >> [END PLAYBACK] >> [結束播放] >> [APPLAUSE] >> [掌聲] >> DAVID J. MALAN: This is CS50. >> DAVID J.馬蘭:這是CS50。 And this is the end of Week 0, but the start of a beautiful friendship. 這是第0週的端部,但 一段美好友誼的開始。 We are so excited to be here at Yale University 我們很高興能成為 這裡在耶魯大學 for the very first time with our friend Scaz, and Jason, and Andy. 對於第一次與我們 朋友Scaz,和Jason,和安迪。 All 40 of CS50's TF's and CA's here at Yale. 的CS50的TF的所有40 和CA在這裡在耶魯大學。 And all of you. 而這一切都是你的。 And in fact, it's probably time to-- 而事實上,它可能是時間用於: >> [APPLAUSE] >> [掌聲] >> So, even though most of the lectures will indeed be in Cambridge this year, >> 所以,儘管大部分的演講 的確將在劍橋今年, the reality is that by design, and very much deliberately in CS50, 現實情況是,由設計, 很刻意的CS50, I do think we're nearing the point technologically, and pedagogically, 我認為,我們正在接近的地步 技術和教學上, where it can be a superior educational experience to engage with some 它可以是一個優越的教育 經驗,與一些 of the course's material online. 課程的材料在網上的。 Indeed, the reality-- and if I believe this philosophically-- is that lectures 事實上,reality--如果我相信 這philosophically--是講座 are not a particularly effective means for delivering 是不是一個特別 為提供有效的手段 fairly complex information. 相當複雜的信息。 Certainly over hour plus long spans of time. 當然,在小時 再加上大跨度的時間。 And indeed every few minutes-- I remember myself in college-- 事實上每隔幾個minutes-- 我記得自己在college-- you zone out for a moment, you miss some complex topic, 你掃開了一會兒, 你錯過了一些複雜的問題, and you're gone pretty much for the next 45 minutes. 和你走了差不多 在接下來的45分鐘。 And the reality is that whether you're here in New Haven or Cambridge 而現實情況是,無論是 你在這裡在紐黑文和劍橋 or beyond, the simplicity of having the ability to pause and fast forward, 或超越,具有簡單 暫停的能力和快進, rewind, hyperlink to related resources, search full text transcripts 快退,超鏈接到相關的 資源搜索全文成績單 and the like is an opportunity that I dare say for our online students 等是一個機會 我敢說我們的在線學生 well beyond New Haven, offers them an opportunity 遠遠超出了紐黑文, 為他們提供了一個機會, to really grasp the conceptual material that we 要真正掌握 概念性的材料,我們 introduce in lectures all the better. 講座介紹就更好了。 >> But ultimately in CS50, is the students' experience >> 但最終在CS50,是 學生的經驗 is characterized so, so much more by the course's problem sets, 的特徵是,這麼多 在課程的習題集, or weekly programming projects, the course's sections led by the teaching 或每週編程項目, 當然各科為首教學 fellows, the nightly office hours led by the course assistants and the teaching 研究員,夜間辦公時間為首的 過程助理和教學 fellows, and indeed such events as CS50 Puzzle 研究員,實際上這樣的 事件CS50謎 Day, CS50's Hack-a-thon, the CS50 Fair, weekly lunches, and so much more. 當天,CS50的黑客馬拉松,在CS50 公平,每週午餐,和這麼多。 And so whether you're here in New Haven, or tuning in from afar, 所以,無論你在這裡新 紐黑文,或調整從遠方來, today in Cambridge, and we'll see you again soon, 今天在劍橋,和 我們將再次看到您的到來, the reality is this is one and the same class. 現實的情況是,這是 一個和相同的類。 And we are so excited to be here all together today. 而我們是如此興奮 在這裡一起今天。 And so at the end of the semester, whether here or afar, well 所以在學期結束時, 無論是在這裡還是遠遠望去,以及 hopefully you wear proudly, happily, and perhaps with a bit of relief, 希望你穿自豪,令人高興的是, 或許有一點緩解, the shirt that bears witness to you having taken CS50. 這見證襯衫 你已經採取CS50。 >> So where did we leave off on Wednesday? >> 那麼,我們什麼週三離開了嗎? We took a look at computational thinking. 我們看了看 計算思維。 And that's toward what we distilled computer science unto, at least 而這對我們蒸餾 計算機科學對,至少 for now. 現在。 But we distilled it little further into at least three components elements. 但是,我們蒸餾水它遠一點為 至少三種組分的元素。 >> Inputs, so what is the problem we're trying to solve? >> 輸入,所以什麼 問題,我們正在努力解決? Outputs, what is the answer we're hoping to get? 產出,什麼是 回答我們希望能得到? And the representation there of. 並表示那裡。 And we won't dwell here on after on binary, or even ASCII, 我們不會住在這裡 後二,甚至是ASCII碼, and the like so much, but rather take for granted 之類的那麼多,但 而想當然地 that we can represent this information, because the far more interesting parts 我們可以代表這個信息, 因為更為有趣的部分 of those problems are not just the inputs and outputs, but the algorithms 這些問題不只是在 輸入和輸出,但這些算法 that go into solving those problems. 該進入解決這些問題。 >> And you might recall from the other day that we >> 你可能還記得 有一天,我們 took a fairly traditional concept of looking someone up 花了相當傳統 尋找個人上來概念 in a fairly large phone book, or more generally digitally these days, 在一個相當大的電話簿,或 更普遍的數字,這些天, just a very large data set. 只是一個非常大的數據集。 A really big contacts list, with lots of names alphabetically sorted. 一個非常大的聯繫人列表,用 很多名稱的字母順序排序。 And we realized that while I could approach this problem simply 我們認識到,儘管我 可以簡單地解決這個問題 by using a linear approach-- page by page, 通過使用線性 approach--逐頁, or even two's at a time-- we realized that the more intuitive algorithm-- 甚至兩公司在我們實現了時間 - 該更直觀算法 - just kind of dividing and conquering the problem again, and again, 只是種分治 再次問題,並再次, and again-- halving it with each time, gave us this green result. 和again--它與每個減半 時間,給了我們這個綠色的結果。 And it's so much flatter because it suggests 而且它是如此更平坦 因為它表明 that even as this problem gets bigger and bigger, 即使因為這個問題 變得越來越大, as is the case these days with data sets and reality-- Facebook and Google 既然是這樣,這些天的數據 集和reality-- Facebook和谷歌 search results and the like-- does our algorithm 搜索結果和 like--做我們的算法 perform just as effectively with those bigger bites 執行一樣有效 與那些更大的叮咬 as it did even with the smaller bites. 因為它沒有甚至更小的叮咬。 >> Now it begs the question, what can we actually solve similarly >> 現在,它引出了一個問題,是什麼 我們可以真正解決類似 with this kind of intuition? 用這種直覺? This sort of division and conquering? 這種分裂和征服的? Well, we could do something like this today here. 那麼,我們可以做些什麼 今天這個樣子這裡。 We could take attendance. 我們可以好好聽講。 So maybe like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11-- 因此,也許像1,2,3,4, 5,6,7,8,9,10,11-- not going to be all that efficient. 不會是所有的高效率。 So wait, grade school. 所以等待,小學。 2, 4, 6, 8, 10, 12, 14, 16, 18 and so forth. 2,4,6,8,10,12,14, 16,18等。 But could we do a little better? 但是,我們可以做的更好一點? >> I'm pretty sure I can't do this by myself. >> 我敢肯定,我不能 我自己做到這一點。 So if you'll humor us for just a moment, we brought with us 所以,如果你要的幽默我們只是 一個時刻,我們帶來了我們 an algorithm that's just got three steps, 一種算法是 剛拿到三個步驟, but it does require-- if you don't mind-- all of us stand up, 但它確實如果require-- 不mind--我們所有的人站起來, if you would. 如果你會的。 So, with all of us now standing, step one of this algorithm is the following. 因此,所有我們現在站,步 該算法中的一個是如下。 Stand up and assign yourself the number 1. 站起來並分配 自己的號碼1。 So at this point in time, literally everyone in this room 因此,在這個時間點, 從字面上每個人都在這個房間 hopefully is thinking to themselves, however awkwardly, the number 1. 希望在想自己, 但是笨拙,數字1。 >> Now step two of this algorithm is going to involve the following. >> 現在,第二步,該算法是 將涉及以下內容。 Step two, pair off with someone standing, 步驟二,雙關 與人站立, add your numbers together, and adopt the sum as your new number. 添加數字加在一起,和 採用的總和作為新的號碼。 Quick sanity check. 快速完整性檢查。 What number is everyone thinking of now? 什麼號碼是每個人想的呢? >> So 2, except maybe for one, awkward, lonesome person. >> 所以2,也許除了為一體, 尷尬的,寂寞的人。 If we have an odd number of people in the room. 如果我們有一個奇數 人在房間裡。 So one person might still be the number 1, that's fine. 所以,一個人可能仍然 數字1,這很好。 But step three here, one of you should sit down. 但是,一步三到這一步, 你應該坐下。 The other should go back to step two, and repeat, if you would. 另外應該回到步驟 二,如果你會重複。 >> So if still standing, you should be among those going back to step two. >> 所以,如果仍然屹立不倒,你應該 在那些回到第二步。 Keep going. 繼續前進。 A few people still standing. 有幾個人還站著。 >> So, if still standing, pair up with someone. >> 所以,如果仍然屹立不倒, 配對與某人。 All right, dwindling down. 好了,越來越少了。 A few people still standing. 有幾個人還站著。 I'll help if need be. 我會幫助,如果需要的話。 Remember the key takeaway here, is how much faster this is than me counting. 記住關鍵外賣這裡,是怎麼 要快得多,這是比我計數。 >> So let's see. >> 所以,讓我們來看看。 I can help out. 我可以幫忙。 So what number are you still thinking of? 那麼,什麼數量 你還在想什麼? >> AUDIENCE: I'm at 44. >> 聽眾:我在44。 >> DAVID J. MALAN: 44, so you go ahead and sit down. >> DAVID J.馬蘭:44,所以 你先走一步,坐下。 What number are you thinking of? 什麼號碼,你在想什麼? AUDIENCE: 74. 聽眾:74。 >> DAVID J. MALAN: 74. >> DAVID J.馬蘭:74。 All right, go ahead and sit down. 好吧,繼續坐下。 Who else is still standing? 還有誰仍然屹立不倒? 86. 86。 And is anyone else still standing? 而且是其他人還站著? >> What number? >> 什麼號碼? I heard 67. 聽說67。 And then in top? 然後在上面? 32. 32。 Anyone else still standing and thinking of a number? 任何人都還站著 和思考的一個數字? >> Oh, hi. >> 哦,你好。 Sorry. 抱歉。 Be right back. 就回來。 42. 42。 Anyone else? 還有其他人? >> AUDIENCE: 47. >> 聽眾:47。 >> DAVID J. MALAN: 47. >> DAVID J.馬蘭:47。 Is anyone else still standing who hasn't been counted? 是任何人都還站著 誰沒有被計算在內? So the final number of people in a room that has 497 seats is-- all of which 所以,人在一個房間裡最後的數 擁有497個座位is--所有這些 are filled-- is 390. 是filled--是390。 So this is great. 因此,這是偉大的。 >> We will soon discuss the notion of a bug in a computer program. >> 我們下面將要探討的概念 在一個計算機程序中的錯誤。 But we'll come back to that before long. 但是,我們會回來的,不久。 But in theory, what might have happened just now? 但在理論上,可能是什麼 已經發生了剛才? So even though there were three big steps to this algorithm, each of those 因此,即使有三大 步驟以這種算法中,每個那些 was just kind of one big operation. 只是其中的一種大的操作。 And there was this cyclicity to it in that if you were still standing, 而有這種週期性吧 原因是,如果你還站著, you kept going from step three to two, step three to two, step three to two. 你不停地從第三步去二, 一步三到二,一步三到二。 >> But what kept happening on each iteration? >> 但是,保持發生 在每次迭代? Each cycle of this loop? 這個循環的每個循環? What was happening elsewhere in the room? 發生了什麼 其他地方的房? Not only the same thing, but what was happening to half of you? 不僅同樣的事情,但什麼 正在發生的事情的一半,你呢? Sitting down. 坐了下來。 And so there in lies this insight, much like the phone book example, 所以有謊言這種認識, 很像電話簿例如 in that if half of you are sitting down each time, 中,如果有一半的你 每次坐了下來, the problem is starting with maybe 400 people, 該問題已經開始 也許有400人, then to 200 people, than 100 people, then 50 people, and so forth. 然後,200人,100餘人, 然後50人,等等。 >> And so we whittle down in theory to just one person, >> 因此,我們在惠特爾下來 理論只是一個人, thinking of the total value of everyone. 想每個人的總價值。 Now reality, some social dynamics, and some arithmetic errors 現在現實中,一些社會動態, 還有一些算術錯誤 might contribute to that ultimate bug. 可能有助於這一最終的bug。 But in theory, while I was still counting away, 但在理論上,而我 還在指望了, taking several dozen steps, or hundreds of steps 服用幾十 步驟,或幾百步驟 to count yourselves, to count a roomful of 500 or so people 算呀,算 500左右的人一個屋子 should have taken far fewer steps, because you can only divide 500 and 1/2 應該採取更少的步驟, 因為你只能劃分500和1/2 so many times. 這麼多次。 And so just like with the phone book example the other day, 所以,就像用手機 本書實例有一天, did we have something logarithmic so to speak, 我們什麼有什麼 對數可以這麼說, whereby if we were all operating in unison, 因此,如果我們都 統一經營, and ignoring the addition errors, would we 而忽略了 另外的錯誤,我們會 have achieved exactly that kind of running time? 已經完全實現 那樣的運行時間? >> Now to be fair, kind of cheated, in that I leveraged another resource. >> 現在,為了公平起見,一種被騙了,在 我利用其他資源。 Whereas it's just one of me, I leveraged hundreds of you. 雖然這只是我的一個, 我利用數百你。 But that might be said to be an example of parallel processing, 但是,這可以說是一種 例如並行處理, or a state of art very much in vogue where computers these days have 或藝術的狀態非常流行 其中,電腦這幾天有 multiple CPUs, or more technically, more multiple cores, 多個CPU,或者更 在技術上,更多個內核, and can truly do multiple things at once, much like you 可以真正做到多 件事情,就像你 all we're doing there, in parallel. 我們所做的存在,在並行。 But recall that what we also did on Wednesday 但記得,我們 也做週三 was try to capture this intuition and formalize it in code. 在試圖捕捉這種直覺 並規範它的代碼。 Something like pseudo-code. 像偽代碼。 And in fact, and I hope you'll forgive, it's like 80 degrees in here. 而事實上,我希望你會 原諒,這就像在這裡80度。 So I'm going to take this off for just a little bit. 所以,我要藉此 關閉只是一點點。 What I thought we'd do is transition now to an application whereby 我以為我們會做的是轉變 現在的應用程序,從而 we again engage the audience, but write a program in English 我們再次吸引觀眾的, 但用英語寫一個程序 like syntax, with which to solve this problem here. 像語法,與其中 這裡解決這個問題。 [VIDEO PLAYBACK] [視頻回放] -It's peanut butter jelly time. - 它的花生醬果凍時間。 Peanut butter jelly time. 花生醬果凍時間。 Peanut butter jelly time. 花生醬果凍時間。 >> Way ya! >> 路亞! Way ya! 路亞! Way ya! 路亞! Way ya! 路亞! Now there you go! 現在,你去那裡! There you go! 你去那裡! There you go! 你去那裡! There you go! 你去那裡! Peanut butter jelly! 花生醬果凍! Peanut butter jelly! 花生醬果凍! >> Peanut butter jelly! >> 花生醬果凍! Peanut butter jelly! 花生醬果凍! Peanut, peanut butter jelly! 花生,花生醬果凍! Peanut butter jelly! 花生醬果凍! Peanut butter jelly with a baseball bat. 花生醬果凍用棒球棒。 >> [END PLAYBACK] >> [結束播放] DAVID J. MALAN: --that video, but it is a little addictive, DAVID J.馬蘭:--that視頻, 但它是一個有點上癮, if not a bit annoying. 如果不是有點討厭。 But to do this, I thought what we'd do is try to write a program together, 但要做到這一點,我還以為會有什麼新 要做的就是盡量一起編寫一個程序, for which we need three volunteers. 為此我們需要三個志願者。 Have to be comfortable on camera and internet. 一定要舒服 相機和互聯網。 Sam, come on up. 山姆,拜託了。 Purple shirt, right here, come on up. 紫色上衣,就在這裡,上來吧。 >> And from over here, let me go a little farther back. >> 而從在這裡,讓我 再走一回。 Crimson and blue shirts, come on up. 緋紅色和藍色襯衫,上來吧。 Perfect. 完善。 Come on now. 現在來吧。 Come on up, come on up. 上來吧,來吧起來。 >> And what's your name? >> 而你叫什麼名字? Erica. 埃里卡。 David, nice to meet you. 大衛,很高興見到你。 If you'd like to take this seat here. 如果你想坐這個座位在這裡。 This is Sam. 這是薩姆。 >> What's your name? >> 你叫什麼名字? Antonio. 安東尼奧。 Antonio, nice to meet you. 安東尼奧,很高興見到你。 Erica and Sam, if you'd like to have a seat here. 埃里卡和Sam,如果你願意 想在這裡有一個座位。 What we've come prepared with, as these guys are discovering, 我們已經有備而來, 因為這些傢伙們發現, is the ingredients with which to make a peanut butter and jelly sandwich. 是,用以使各成分 花生醬和果凍三明治。 >> Now this might be something that you take very much for granted. >> 現在,這可能是東西, 你採取非常理所當然的。 But we've given each of our three volunteers 但是,我們已經給每個 我們的三個志願者 here-- two volunteers and Sam here, a loaf of bread each, a plate, a knife, 這裡 - 兩名志願者和Sam在這裡,一 的每個麵包,板,一把刀, a jar of jelly or jam, and a jar of peanut butter. 一罐果凍或果醬,以及 花生醬的罐子。 And the goal at hand now is going to be for these three 而這一目標在手,現在是 將要為這三個 to make a peanut butter and jelly sandwich. 使花生醬 和果凍三明治。 But what we're going to do is expect the audience-- since all of you 但是,我們要做的是期待 因為大家的audience-- surely know how to do this so well in reality-- 肯定知道該怎麼辦 這個這麼好reality-- are going to provide us with the step by step instructions. 要我們提供 在一步一步的指示。 The pseudo-code, if you will. 偽代碼,如果你願意。 >> So I'll play the role of scribe here. >> 所以,我在這裡玩劃線的作用。 And I've got a little to-do list, and so as each of you, one at a time, 我也有一個小的工作清單, 等作為各你,一次一個, calls out a potential instructional, I'll 召喚出一個潛在的 教學,我會 write it down, repeat it as needed. 把它寫下來,並根據需要重複。 And then you guys are going to make a peanut butter and jelly sandwich 然後你們要作 花生醬和果凍三明治 only by doing what you are told. 只有做你被告知。 So think of yourselves as computers. 因此,認為自己作為電腦。 >> You can only do what you're told. >> 你只能做你告訴我。 No assumptions, no questions. 沒有假設,沒有什麼問題。 You just need to do it. 你只需要做到這一點。 So who would like to hazard the first instruction for making a PBJ sandwich? 那麼,誰願意冒險第一 指令製作PBJ三明治? On the balcony there. 在陽台那裡。 >> AUDIENCE: Open the bag of bread. >> 聽眾:打開麵包袋。 >> DAVID J. MALAN: Open the bag of bread, if you will. >> DAVID J.馬蘭:打開 一袋麵包,如果你願意。 So let's see. 所以,讓我們來看看。 Let's iterate, and get a little more precise. 讓我們迭代,並獲得 更確切的一點。 >> Good way to begin though. >> 良好的方式開始,但。 Step two, someone else. 第二步,別人。 Now no one wants to volunteer. 現在,沒有人願意當志願者。 Step two, in front. 步驟二,在前面。 AUDIENCE: Open the inner bag of bread as well. 聽眾:打開內 一袋麵包也是如此。 DAVID J. MALAN: Open the inner bag of bread as well. DAVID J.馬蘭:打開 麵包內袋為好。 Great, we learning. 太好了,我們學習。 A little more precise. 更確切的一點。 Let's get this working. 讓我們得到這個工作。 Yes, in green shirt. 是的,在綠色襯衫。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] DAVID J. MALAN: Slices of bread. DAVID J.馬蘭:麵包片。 Gently remove two slices of bread. 輕輕地取出兩片麵包。 That's good. 這是很好的。 Step four, someone else? 第四步,別人? Over here, yes? 在這裡,是嗎? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: Place bread on plate. >> DAVID J.馬蘭:上板放置麵包。 Step five? 第五步? Step five, yeah? 第五步,是嗎? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] DAVID J. MALAN: On top of-- oh, hand. DAVID J.馬蘭:在上面of--哦,手。 Place hand on top of peanut butter. 將手放在花生醬的頂部。 Is that what I head? 難道這就是我的頭上? >> AUDIENCE: Yeah, and unscrew. >> 聽眾:是啊,擰開。 >> DAVID J. MALAN: And-- say it again. >> DAVID J.馬蘭:和 - 說了一遍。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: And put the lid next to the peanut butter. >> DAVID J.馬蘭:與放 蓋旁邊的花生醬。 Lightly place hand on top of peanut butter, 輕輕地放在手放在 花生醬的頂部, and unscrew, and put the lid next to the peanut butter. 擰開,並把蓋子 旁邊的花生醬。 OK, step six. OK,第六步。 Step six, someone else. 第六步,別人。 Yeah? 是嗎? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] DAVID J. MALAN: Say it again. DAVID J.馬蘭:再說一遍。 AUDIENCE: Repeat step five again. 聽眾:再次重複第五步。 DAVID J. MALAN: And repeat step five again, DAVID J.馬蘭:和 再次重複步驟五, which is going to create a bit of a problem 這是要創建 有點問題 now if we're doing this step by step. 現在,如果我們這樣做,一步一步來。 So now we go back to step five. 所以,現在我們回到第五步。 Lightly place hand on top of peanut butter and unscrew 輕輕用手放在上面 花生醬和鬆開的 and put lid next to the peanut butter. 並把旁邊的花生醬蓋。 Then grasp the peanut butter and repeat step five again. 然後抓住花生醬 並再次重複第五步。 >> So we'll override that infinite loop, if you will. >> 因此,我們將覆蓋 無限循環,如果你願意。 Step seven, someone else. 第七步,別人。 Yeah, in back. 是啊,在後面。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: --on top of other. >> DAVID J.馬蘭:其他的 - 論之上。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: On the other hand on the other top. >> DAVID J.馬蘭:在 在其他頂級另一方面。 Do you want to just come up here? 你想只是來這兒? How do I finish the instruction? 我如何完成的指令? What's the rest of the instruction? 什麼是指令的休息嗎? >> AUDIENCE: Ignoring that part. >> 聽眾:忽略的那部分。 >> DAVID J. MALAN: Ignoring that part. >> DAVID J.馬蘭:忽略的那部分。 Let's start over. 讓我們重新開始。 Step seven. 第七步。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: Grasp with opposing hand-- this is good. >> DAVID J.馬蘭:兩手抓, 反對hand--這是件好事。 This is actually good. 其實,這是很好的。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: And plastic jar-- >> DAVID J.馬蘭:塑料jar-- >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: And twist-- >> DAVID J.馬蘭:與twist-- >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: For two seconds. >> DAVID J.馬蘭:兩秒鐘。 Just open the peanut butter jar. 只要打開花生醬罐子。 I hope you'll forgive. 我希望你能原諒。 So let's assume we got there. 因此,讓我們假設我們到了那裡。 Open the peanut butter jar. 打開花生醬罐子。 >> [APPLAUSE] >> [掌聲] >> DAVID J. MALAN: Step eight, let's go. >> DAVID J.馬蘭:第八步,我們走吧。 Step eight, yes, in back. 第八步,是的,回來了。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: Good. >> DAVID J.馬蘭:好。 Step nine, yes? 第九步,是嗎? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: --out of the peanut butter jar. >> DAVID J.馬蘭:--out的 花生醬罐子。 And-- and what? 還有 - 什麼? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: And put knife back into peanut butter. >> DAVID J.馬蘭:並把刀 回花生醬。 Step ten. 第十步。 Step ten. 第十步。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: Put the knife out, and then remove the seal. >> DAVID J.馬蘭:將刀 出來,然後取出密封。 Nice. 美觀大方。 Off the peanut butter. 關閉花生醬。 All right, step 11. 好吧,第11步。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: OK, grey computer follow blue or red computer. >> DAVID J.馬蘭:OK,灰色電腦 按照藍色或紅色的計算機。 Good. 好。 >> [APPLAUSE] >> [掌聲] DAVID J. MALAN: Bring us home. DAVID J.馬蘭:帶我們回家。 Couple more steps. 夫婦更多的步驟。 What's next? 下一步是什麼? Steps 12. 步驟12。 Step 12. 步驟12。 Yeah? 是嗎? >> AUDIENCE: Put one of the slices of bread gently on one of your hands. >> 聽眾:放的片段之一 麵包輕輕地對你的一隻手。 >> DAVID J. MALAN: One of your hands. >> DAVID J.馬蘭:一是你的手。 And then, step 13. 然後,步驟13。 Yeah? 是嗎? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: --on slice of bread. >> DAVID J.馬蘭:麵包 - 談片。 Good. 好。 Pretty good. 不錯。 Step 14, yeah. 步驟14,是的。 >> AUDIENCE: Undo step 13. >> 聽眾:撤消步驟13。 >> DAVID J. MALAN: Undo step 13. >> DAVID J.馬蘭:撤消步驟13。 Let's move on to jelly. 讓我們繼續果凍。 It's a 100- step program, but we're were on step 15. 這是一個100-步程序, 但我們是在第15步。 Yeah. 是啊。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: 7 through 13 using the jelly, because those went so well. >> DAVID J.馬蘭:7至13使用 果凍,因為這些去這麼好。 Repeat steps 7 through 13, using the jelly. 重複步驟7至 13,使用果凍。 So grasp the lower half of the jelly jar with one hand on top. 因此掌握的下半部分 果凍罐子用一隻手在上面。 On the other hand of the other top, ignoring that part, 論另一方面 其他上面,忽略了一部分, grasp with opposing hands, the lid and the plastic jar 把握與反對的手, 蓋和塑料罐 at the bottom, and twist for two seconds. 在底部,並 擰兩秒鐘。 Then open the jelly jar. 然後打開果凍罐子。 And lastly, let's try to give us something edible. 最後,讓我們試著 給我們一些可食用。 Step 16. 步驟16。 So why don't we leave it there. 那麼,我們為什麼不把它那裡。 Thank you so much to our three volunteers. 謝謝你這麼多 我們的三名志願者。 [APPLAUSE] [掌聲] >> We have a little CS50 stress ball for you. >> 我們有一個小CS50 壓力球給你。 It was going to be a sandwich but-- so what 這將是一個 夾心但 - 還等什麼 was the point, beyond having a bit of fun with the algorithm? 是點,超越具有 有趣的算法位? But the reality is that even when you're programming a computer, 但現實情況是,即使 你是計算機編程, you need to be super precise. 你需要超精密。 As complex or intimidating as your own computer 由於複雜或恐嚇 為自己的電腦 might very well be to you, at least when something goes wrong, 很可能是你的,在 出問題的時候至少, the reality is it's a pretty dumb device that was invented by us humans, 實際情況是這是一個非常愚蠢的 設備發明了我們人類, and can only do a subset of what we do-- sometimes certainly faster-- 並且只能做的一個子集我們 do--有時肯定faster-- but it doesn't know how to make assumptions. 但它不知道如何 作出假設。 It doesn't know how to be on the same wavelength as you. 它不知道怎麼上 相同波長你。 >> It will only do precisely what you tell it. >> 它只會做精確 你告訴它。 And you'll be struck, perhaps, as we start 你會被擊中, 也許,在我們開始 writing actual code with the first problem sets and beyond, 寫入與實際的代碼 第一個問題集和超越, just how easy it is to make an assumption as a human, 它是多麼容易使 假設作為一個人, and not anticipate I need to handle that case, or that corner case, 而不是預測我需要處理 這種情況下,或該角的情況下, so to speak, that might very well arise if for instance Sam had the only 可以這麼說,這很可能 如果出現例如山姆擁有的唯一 squeezable jar of jelly, whereas everyone else had some glass jars as 果凍擠壓瓶子,而 其他人有一些玻璃瓶作為 well. 良好。 So before we turn our attention to some actual code, 所以在我們把 注意一些實際的代碼, allow me to introduce the course's heads here at Yale. 請允許我介紹一下 在耶魯課程的負責人。 Our friends Scaz, Andy, and Jason to come up and say hello. 我們的朋友Scaz,安迪,和 傑森上來打招呼。 >> [APPLAUSE] >> [掌聲] >> SCAZ: We've lost Jason temporarily. >> SCAZ:我們已經暫時失去傑森。 Hi again, everyone. 您好再次,每個人。 My name is Scaz. 我的名字是Scaz。 I've been teaching at Yale since 2001. 我一直任教於耶魯大學從2001年開始。 And when I am not teaching, my research is in robotics 而當我不教, 我的研究是機器人 and artificial intelligence. 和人工智能。 >> And the announcement that I have today is that starting in a couple of weeks, >> 而我今天的公告 開始在幾個星期了, we're going to be bringing some supplementary material to CS50 to talk 我們將要帶來一些 補充材料CS50交談 about intelligence software. 關於智能軟件。 We're going to talk about how places like Netflix and Hulu 我們要談談如何 像Netflix和Hulu的地方 can recommend movies which you might want to watch. 可以推薦電影這 你可能想觀看。 Where we'll talk about how driver-less cars actually work. 當我們將談論如何 司機少車的實際工作。 And we'll be able to ground these things in the concepts 我們將能夠對地 這些東西在概念 that you're learning in this class today. 你正在學習 在這個類的今天。 >> Because all of these things are built upon the same foundation. >> 因為所有這些事情都是 在相同的基礎之上。 And that's what this series will explore. 這就是這 系列將探索。 So I'm really looking forward to seeing more of you 所以我真的很期待 期待看到你更多的 all, and you're going to get to see more from all of us very soon. 一切,你會去 多看我們大家很快。 Let me then introduce Jason. 那麼,讓我來介紹賈森。 >> JASON: Hi everyone. >> 傑森:大家好。 My name is Jason. 我的名字是賈森。 I unfortunately went to Harvard as an undergrad. 我不幸去了 哈佛大學為本科生。 That's going to get cut out of the actual stream. 那將得到削減 出實際流。 >> And now I'm here as a lecturer in the computer science department. >> 而現在我在這裡作為一個講師 計算機科學系。 And I'm helping run the course with Scaz, David and Andy. 而且我幫助運行過程 與Scaz,大衛和安迪。 >> ANDY: Hey guys. >> 安迪:嘿,伙計們。 My name's Andy. 我的名字叫安迪。 I am actually the only Yale student on the stage right now. 我其實只有耶魯大學 學生在舞台上現在。 >> [APPLAUSE] >> [掌聲] >> I'm in Berkeley College, originally from Solon, Ohio. >> 我在伯克利大學, 最初是從梭倫,俄亥俄州。 And I was one of those kids where, when I came to Yale, 而我是那種一個孩子 在那裡,當我來到耶魯大學, I really thought that I would never have to look at a number ever again. 我真的以為我會永遠 來看看一些再次。 And then I realized that you needed both science and QR credits to graduate. 然後我意識到你需要 科學和QR學分才能畢業。 And so my freshman spring, I took a class, a CS, intro CS class here 所以我大一春天,我把 一個類,一個CS,CS介紹這裡的類 at Yale. 在耶魯大學。 I was like, this is like actually pretty cool. 我當時想,這就像 其實很酷。 >> And while I actually ended up declaring as a global affairs major, the skills >> 雖然我實際上結束了聲明 作為一個全球性事務的重大,技能 I learned in CS and programming are so applicable to any field 我在CS和編程教訓 如此適用於任何場 you choose to do. 你選擇這樣做。 And the staff here at Yale, we've been so hard at work 而這裡的工作人員在耶魯大學, 我們一直很努力工作 to prepare for you guys. 以備你們。 And we look forward to seeing all in section and office hours. 我們期待著看到 所有部分和辦公時間。 So yeah. 所以呀。 >> [APPLAUSE] >> [掌聲] DAVID J. MALAN: Thank you. DAVID J.馬蘭:謝謝。 So just before class began, we had an opportunity 因此,只要課前開始, 我們有機會 to walk around campus with a cellphone and take 走在校園裡 與蜂窩電話和取 some selfies in video form of really my first tour of Yale's campus here. 在真正的視頻格式一些selfies 耶魯大學的校園我的第一次巡迴演出在這裡。 And so we thought we'd share a rough cut of exactly this as Scaz and Andy 因此,我們認為我們會共用一個粗略的 切正是以此為Scaz和Andy and Jason took me around campus. 和傑森帶我在校園裡。 [VIDEO PLAYBACK] [視頻回放] [SIRENS] [SIRENS] -David. -David。 -Welcome to Yale. - 歡迎到耶魯大學。 -Good to see you. - 良好的看你。 -Nice to see you. - 尼斯看到你。 -Can we go on a tour? - 能,我們去旅遊? -Let's go on a tour. - 讓我們去參觀。 -Road tour. - 公路之旅。 -This sign has been there for a while. - 這個符號已經有一段時間了。 -Whah, CS50. -Whah,CS50。 >> -Hurry! >> -Hurry! Go, go, go, go. 走,走,走,走。 You should [INAUDIBLE] Harkness Tower. 你應該[聽不清]哈克尼斯塔。 >> -And we saw that a couple times. >> - 和我們看到幾次。 >> [APPLAUSE] >> [掌聲] >> -Look out for the bike! >> -Look出來的自行車! Ahh! 啊! Hi Frank. 嗨弗蘭克。 >> -What's up, guys? >> - 什麼回事,球員? -How are you? - 如何是你? -Good to see you. - 良好的看你。 -Welcome to the video. - 歡迎到視頻。 Don't act too excited. 不要表現得太過興奮。 >> -I love Silliman. >> - 我愛西利曼。 Ahh! 啊! >> -It's been about three hours since Jason had ice cream and Nutella. >> - 它一直約三小時,因為 傑森冰淇淋和花生醬。 So we've got to stop back at Silliman for a little bit. 因此,我們必須停止回 西利曼一點點。 >> -It's not even [INAUDIBLE] yet, just the fact >> - 它甚至沒有[聽不清] 然而,僅僅是事實, that they have it here is so amazing. 他們有在這裡是如此驚人。 Dude, there's Nutella at every meal. 好傢伙,有花生醬每餐。 >> -There was last year too. >> - 存在的最後一年了。 >> -Yeah. >> - 是啊。 >> -tell much about Yale so far. >> -tell很多關於耶魯大學至今。 But I do now that's TD over there. 但我現在的TD那邊。 And that's considered off campus. 而這被認為校外。 >> -Here we have gothic architecture. >> 尤其是圓形,我們有哥特式建築。 World famous. 世界名牌。 We have some more gothic architecture. 我們有一些更多的哥特式建築。 And construction, and more gothic architecture. 和建設, 更多的哥特式建築。 Hi. 你好。 This is where we're having office hours Tuesdays through Thursdays in Hogwarts, 這是我們遇到的辦公時間 至週四在霍格沃茨星期二, as [INAUDIBLE] . 為[聽不清]。 -All right. - 所有權利。 That's it for the tour. 這是它為遊覽。 We are at Yale University's Law School, where 我們正處在耶魯大學 法學院,在那裡 today's lecture is about to take place. 今天的講座即將舉行。 Let's head in. 讓我們頭研究。 >> [END PLAYBACK] >> [結束播放] >> DAVID J. MALAN: And that brings us here now. >> DAVID J.馬蘭:和 這給我們帶來了這裡。 So thus far, we've been focusing on pseudocode, 所以到目前為止,我們已經 專注於偽代碼, which is this English-like syntax. 這是這類似英語的語法。 It has no prescribed specification. 它沒有規定的規範。 It's just you use some intuitive language if you 它只是你使用一些 如果你直觀的語言 want to explain what you want to do. 要解釋你想做的事情。 >> But let's begin now to transition to code, as most people would say. >> 但是,讓我們現在就開始轉型 代碼,因為大多數人會說。 But more precisely, something known as source code. 但更確切地說,一些 稱為源代碼。 This is the language that humans write that computers ultimately-- 這是人類的語言 編寫電腦ultimately-- possibly after some number of steps-- ultimately understands 後可能的一些數 steps--最終理解 so as to know how to do something. 這樣才能知道如何做。 That you saw a glimpse of this perhaps on Wednesday. 你看到的一瞥 這也許是在週三。 >> This is an example that incredibly, underwhelming >> 這是一個例子, 令人難以置信的,給人留下深刻印象 when run simply says "hello world." 在運行時只說“你好世界”。 And it's written in a language called C, which is syntactically very similar 而且它寫在一個叫語言 C,它在語法上是非常相似的 to a lot of other languages that you might not know, 來了很多其他語言 你可能不知道, but might have heard of like Java, and C++, and Python, and Ruby, 但可能也聽說過像Java, 與C ++和Python和Ruby, and the like, and indeed, we'll spend much of the semester using C, 之類的,而事實上,我們將 使用C花太多的學期, and then toward the end of the semester, building upon it, 然後向著結束 學期,在它建立, and introducing any number of other languages. 並引入任何 其它語言的數目。 Among them PHP, and JavaScript, a database language called SQL. 其中PHP和JavaScript, 數據庫語言叫做SQL。 But with C, what we'll have this bottom-up understanding 但隨著C,我們將有 這種自下而上的理解 of exactly how computers work, what you can do with them, 的電腦究竟是如何工作的, 你可以與他們做什麼, and how you can solve problems all the more effectively by this 以及如何解決問題 所有由該地,更 layering that we discussed on Wednesday, and standing 分層,我們討論 週三,和站立 on the shoulders of others. 在別人的肩膀上。 But more on that to come. 但更多的是來。 >> Today we look at a simpler environment, but a fundamentally identical >> 今天我們來看一個簡單的環境, 但基本上是一致 environment known as Scratch by our friends at MIT Media Lab. 環境被稱為划痕 我們的朋友在麻省理工學院媒體實驗室。 This is a graphical programming language, Scratch, 這是一種圖形 編程語言,划痕, whereby you can drag and drop things that 因此,你可以拖動 和丟棄的東西, look like puzzle pieces that only interlock if it makes 看起來像拼圖的 如果它使只有聯鎖 logical or programmatic sense to do so. 邏輯或程序上的意義這樣做。 But it's going to allow us to have a conversation about all 但它會允許我們 有一個關於所有的談話 of the same programming fundamentals that some of you 相同的編程的 基本面你們有些 might know already, that many of you might not 可能已經知道了,那 很多人可能不 know anything of without having to get bogged down frankly, 知道任何事情,而不必 得到坦言越陷越深, in the intellectually uninteresting syntax of semicolons, 在理智 分號無趣的語法, and parentheses, and quotes, and the like. 和括號,並 引用,等等。 All of which, early on, are a distraction 所有這一切,早 對,是一個分心 to what are interesting and genuinely useful ideas. 什麼是有趣的 而真正有用的想法。 So let's take a quick glance at the environment 因此,讓我們快速瀏覽 看一下環境 here, so that you know what awaits. 在這裡,讓你知道什麼是等待。 And in fact, among the games we can play are a few programs written 而事實上,其中的遊戲,我們 可以播放的一些程序編寫 by CS50's own former students. 通過CS50自己以前的學生。 One of them, myself, I'll be this one written in graduate school for me. 他們中的一個,我自己,我會在這一個 寫在研究生院對我來說。 >> If I could take one volunteer who's willing to play >> 如果我能採取一志願 誰是願意玩 a game for the very first time. 一個遊戲的第一次。 Sure. 當然。 Come on up. 上來吧。 What's your name? 你叫什麼名字? >> AUDIENCE: Angela. >> 聽眾:安吉拉。 DAVID J. MALAN: Angela, come on up. DAVID J.馬蘭:張韶涵,上來吧。 So Scratch has been out for a few years. 所以,刮已經流傳了好幾年了。 And when I was in graduate school, I was cross registered at MIT, 而當我在讀研究生, 我在麻省理工學院註冊的十字架, taking professor Mitchel Resnick's course on educational technologies. 以教授米切爾·雷斯尼克的 當然,在教育技術。 And we were among the very first students in the world to actually beta 而我們之間的第一 學生在世界上實際上公測 test Scratch. 測試划痕。 And my project was what Angela has now graciously volunteered 而我的計劃是什麼安吉拉 現在已經慷慨地主動請纓 to play called Oscartime. 以戲稱為Oscartime。 >> So I'm going to go ahead and double click the icon here. >> 所以,我要繼續前進, 雙擊圖標這裡。 It's going to open up a programming environment that we'll soon dive into. 這將打開一個程序 環境,我們很快就會潛入。 I'm going to full-screen it for Angela, here. 我要全屏幕 它的張韶涵,在這裡。 I'm going to hit the green flag in just a moment. 我要打到果嶺 標誌一會兒就好了。 And then a whole lot of trash is going to fall from the sky. 然後一大堆垃圾 會從天上掉下來。 And you're going to use the mouse here to actually drag and drop 而且你要使用鼠標 這裡實際上拖放 the trash into Oscar's trash cans. 垃圾進入奧斯卡的垃圾桶。 So if you want to go ahead and click the green flag, the game will begin. 所以,如果你想繼續前進,點擊 綠旗,比賽就要開始了。 >> [MUSIC PLAYING] >> [音樂播放] >> Oh, I love trash. >> 哦,我愛垃圾。 Anything dirty or dingy or dusty. 任何臟或骯髒或有灰塵。 Anything ragged or rotten, or rusty. 任何衣衫襤褸或腐爛,或生鏽。 Yes, I love trash. 是的,我喜歡垃圾。 If you really want to see something trashy, look at this. 如果你真的想看到 沒用的東西,看看這個。 I have here a sneaker that's tattered and worn. 我這裡有一個運動鞋 這是破爛和磨損。 It's all full of holes holds and the laces are torn. 這一切都千瘡百孔持有 和鞋帶被撕破。 A gift from my mother the day I was born. 從我母親的禮物 一天,我誕生了。 I love it because it's-- 我喜歡它,因為it's-- DAVID J. MALAN: --green these days just be throwing everything in the trash. DAVID J.馬蘭:--green這幾天剛 在垃圾桶裡扔了一切。 And so what one of CS50's own staff did-- 還等什麼之一 CS50自己的工作人員did-- Jordan, who you might meet today-- has actually 喬丹,你可能誰 滿足today--實際上已經 updated this for today's times. 此更新為今天的時代。 And so allow me to open up a remix instead for Angela. 所以讓我開拓 混音,而不是安吉拉。 And we'll play this instead for a few moments where now you're 我們會玩這個,而不是為 片刻的地方現在你 going to have to decide between whether to throw something in the trash, 將不得不之間是否決定 扔東西在垃圾桶裡, or recycle it or compost it. 或回收利用或堆肥它。 So there's a bit of pressure on you to get 因此,有一點 你的壓力得到 this right in front of your 392 to 497 classmates here in the hall, 這一權利在你的392至前 497的同學在這裡的大廳裡, if you would. 如果你會的。 [VIDEO PLAYBACK] [視頻回放] [MUSIC PLAYING] [音樂播放] -Oh I love trash. 哦我愛垃圾。 Anything dirty or dingy or dusty. 任何臟或骯髒或有灰塵。 Anything ragged or rotten or rusty. 任何衣衫襤褸或腐爛或生鏽。 Yes, I love trash. 是的,我喜歡垃圾。 >> If you really want to see something trashy, look at this. >> 如果你真的想看到 沒用的東西,看看這個。 I have here a sneaker that's tattered and worn. 我這裡有一個運動鞋 這是破爛和磨損。 It's all full of holes and the laces are torn. 這一切都千瘡百孔 和鞋帶被撕破。 A gift from my mother the day I was born. 從我母親的禮物 一天,我誕生了。 I love it because it's trash. 我喜歡它,因為它是垃圾。 >> Oh, I love trash. >> 哦,我愛垃圾。 Anything dirty, or dingy, or dusty. 任何臟,或昏暗,或有灰塵。 Anything ragged or rotten or rusty. 任何衣衫襤褸或腐爛或生鏽。 Yes, I love trash. 是的,我喜歡垃圾。 Here's some more rotten stuff. 下面是一些比較爛的東西。 I have here some newspaper-- 我這裡有一些newspaper-- >> [END PLAYBACK] >> [結束播放] DAVID J. MALAN: --are actually compostable. DAVID J.馬蘭:--are 實際上堆肥。 But thank you to our volunteer, Angela. 但是,感謝您對我們的志願者,安吉拉。 We have a stress ball for you here as well. 我們有一個壓力球 你在這裡。 So thank you. 所以,謝謝你。 >> So this one was written by me. >> 因此,這本是我寫的。 But now one by an actual former student who implemented this, which is a game. 但是,現在一個接一個實際的從前的學生 誰實現這一點,這是一個遊戲。 All in this language called Scratch, that we'll soon 所有的這種語言稱為 划痕,那我們很快就會 peel back the layers of. 剝開的層。 But if we'd like-- how about another volunteer? 但是,如果我們想like--如何 關於另一位志願者? Right. 右。 >> Come on up. >> 上來吧。 What's your name? 你叫什麼名字? Glance? 看一眼? Lance. 蘭斯。 Lance, come on up. 蘭斯,上來吧。 Nice to meet you. 認識你很高興。 Come on this way. 來吧這樣。 So this one might have a theme familiar to some of you. 所以這一塊可能有一個 主題熟悉一些你。 But you'll see too that there can be interactivity, 但是你會看到太多的 可以有交互性, whereby you could actually be the role of the character moving around. 因此,你實際上可能是 人物走動的作用。 Nice to meet you. 認識你很高興。 David. 大衛。 >> I give you, Pikachu. >> 我給你,皮卡丘。 Instructions will about to come on the screen. 說明將有關 來在屏幕上。 But in short, you're going to want to catch the tasty stuff, 但在短期,你要 想趕好吃的東西, and avoid the bombs and other things. 避免炸彈和其他的東西。 With the cursors entirely. 隨著光標完全。 So hit the space bar. 所以打空格鍵。 -Pikachu. -Pikachu。 DAVID J. MALAN: Catch the stuff on the left, DAVID J.馬蘭:抓 東西在左邊, don't catch the stuff on the right. 沒有趕上右邊的東西。 >> [MUSIC PLAYING] >> [音樂播放] >> So one last one here. >> 所以,在這裡,人們最後一次。 If we could have one more volunteer here. 如果我們能有一個 更多的志願者在這裡。 We thought we'd recreate something from-- in the yellow shirt-- 我們認為我們會重新東西 from--在黃shirt-- from Wednesday. 從週三。 What is your name? 你叫什麼名字? Mary, come on up Mary. 瑪麗,拜託了瑪麗。 >> And recall on Wednesday we introduced the notion of binary, and binary bulbs. >> 和召回週三我們介紹 二進制的概念,和二進制燈泡。 This is actually now an implementation of that same interface 這實際上是現在的 實現同一界面 that we had on the iPad with the light bulbs, but here digitally rendered. 我們已經在iPad上的光 燈泡,但這裡數字方式再現。 And rather than do a stress ball-- nice to meet you, David. 並且,而不是做一個壓力 ball--很高興認識你,大衛。 We brought a few light bulbs from Cambridge. 我們帶了幾光年 燈泡劍橋。 >> If you can, clicking on those bulbs to turn them on and off, >> 如果可以的話,點擊這些 燈泡將其打開和關閉, come up with the binary representation of say 256. 拿出二進制 的代表說,256。 And you'll see in the middle, the current tally. 你會在看 中間,目前理貨。 So that one's on. 所以,一個人的上。 So the leftmost bit is on. 所以,最左邊的位上。 >> MARY: Yeah, [INAUDIBLE] >> 瑪麗:是啊,[聽不清] >> DAVID J. MALAN: Well, so we have just-- oh. >> DAVID J.馬蘭:好吧, 所以我們just--哦。 So this is the 128 column. 因此,這是128列。 So we're up to 128. 因此,我們128個。 We got to get to 256. 我們得去256。 And you can tinker on and off, no big deal. 你可以鼓搗上 斷斷續續,沒有什麼大不了的。 Or you can hit that 128 more times if you want. 或者你也可以打的128 更多的時候,如果你想要的。 >> All right, good. >> 好了,好了。 24. 24。 Yeah, getting closer. 是的,越來越近。 Closer! 近了! Oh, what's the problem then? 哦,有什麼問題呢? So what's the issue? 那麼,有什麼問題? >> So what do we need to solve this problem? >> 那我們需要 解決這個問題? So we need another bit. 因此,我們需要另一位。 And this is perfectly reasonable in reality, right? 這是完美的 在現實合理的,對不對? If you want to count from the number 1 to 2 to 3 to 4 to 5, 6, 7, 8, 9 如果你想從數來算 1至2〜3 4〜5,6,7,8,9 to actually roll over to 10, you're going to need an additional bit. 實際上翻轉到10,你是 將需要額外的比特。 So let's actually rewind here, and come up 因此,讓我們真正 倒帶這裡,拿出 with-- that was obviously meant to be a set up. with--這是明顯 意思是一組了。 >> You can't do 256 with just a bulb. >> 你不能只用一個燈泡做256。 So how about simply the number 50? 因此,如何簡單地數50? Number 50. 號碼50。 Excellent. 優秀的。 A big round of applause for Mary and hers as well. 又大又圓的掌聲 瑪麗和她的好。 Thank you. 謝謝。 >> So this topic-- intentional as that was-- will actually recur. >> 因此,這topic--故意的 這was--實際上會復發。 The largest value that you can represent with eight bits, or one byte, 最大的價值,你可以 表示將8位,或一個字節, is indeed 256. 確實是256。 But not if you start counting from 0, as we 但如果你開始 從0開始計數,因為我們 seem to keep doing by having all of those bits off. 似乎繼續做由具有 所有這些位斷的。 But now let's dive into the underlying implementation of this environment, 但現在,讓我們深入到底層 實施這種環境, and tease apart some of these ideas. 並梳理出其中的一些想法。 >> So in a moment we're about to see a few different programming fundamentals. >> 因此,在某一時刻,我們即將看到一個 幾個不同的編程基礎。 The first of which we'll call statement. 其中,第一,我們會打電話給說法。 Sort of verbs, if you will. 排序動詞,如果你願意。 Actions. 動作。 Things that should be done. 事情應該做的。 >> And in a moment you'll see blocks that look like this. >> 而就在那一刻,你會看到 塊看起來是這樣。 Say "hello world," for instance. 顯示“Hello World”的實例。 Or wait one second. 或者等待一秒鐘。 Or play sound meow. 或播放聲音喵。 And indeed the environment in which we're going to be doing this 堪與環境 這是我們打算做這個 is called Scratch. 被稱為划痕。 >> And if I pull up Scratch without preloading any actual code, >> 如果我拉刮不 預裝任何實際的代碼, let's take a quick look at this user interface, so to speak. 讓我們快速瀏覽一下這個 用戶界面,可以這麼說。 The controls with which we interact. 這些控件與我們互動。 On the top left here of the screen, below the menus, 在離開這裡的頂部 屏幕下方的菜單, we have the stage, so to speak. 我們有舞台,可以這麼說。 So Scratch is what we'll call Sprite. 因此,划痕就是我們會打電話給雪碧。 It's a character. 這是一個特點。 >> And he can be controlled by writing programs against him. >> 而且,他可以通過控制 寫作對他的方案。 And he'll be able to move up and down and left and right in this environment, 他就可以上下移動 和左,右在這種環境下, not just by moving the mouse, but programmatically. 不只是通過移動 鼠標,但是編程。 I can tell him walk right, walk left, up, down or the like. 我可以告訴他走右邊,走 左,上,下等。 And I can introduce other sprites or characters as well. 我可以介紹其他 精靈或字符為好。 >> Indeed, on the bottom here is where you'll see your list of sprites. >> 事實上,在底這裡是 你會看到你的精靈列表中。 At the moment, I just have one, but I can create more, 此刻,我只是有 一個,但我可以創造更多的, and they'll appear exactly down there. 他們會恰好出現在那裡。 So if you rewind for a moment, like Oscartime-- for instance, Oscar, 所以,如果你後退了一下,像 Oscartime--例如,奧斯卡, on the left, the trash can, was a sprite. 在左邊,垃圾桶 可以的,是一個精靈。 And the thing in the middle, the recycling bin, was another sprite. 而在中間的東西, 回收箱,是另一個精靈。 And the compost bin was another sprite. 而堆肥是另一個精靈。 And every piece of garbage or recyclables 而每一塊 垃圾或可回收 that was falling from the sky is also a sprite, each of which 這是從天上掉下 也是一個子畫面,其中每一個 was programmed individually. 被單獨編程。 >> How do you program? >> 你如何計劃? Well, over here on the right hand side is the scripts area. 好了,在這裡右邊 手側為腳本區域。 And this is where we can drag and drop puzzle pieces. 而這正是我們可以 拖放拼圖。 In a week, it's going to be where we equivalently write code 在一周的時間,這將是 我們等價地編寫代碼 with more of a keyboard, but for today it'll be dragging and dropping 與更多鍵盤,但對於 今天它會被拖放 puzzle pieces, the palettes for which can all 拼圖中, 調色板這都可以 be found here right in the middle. 在這裡找到合適的中間。 Indeed, in the middle here there's a whole bunch 實際上,在中間 這裡有一大堆 of categories of puzzle pieces or blocks. 益智類 片或塊。 One's related to motion, look, sound, a pen going up and down, 一個人的有關運動,你看, 聲音,筆上升和下降, data, events control. 數據,事件控制。 Not quite sure yet what all of these mean, 不太清楚但 什麼所有這些意味著, but you'll see that they've been nicely categorized. 但你會看到,他們已經 被很好的分類。 And to write a program in Scratch, let's do exactly that. 而寫的一個程序 划痕,讓我們這樣做。 >> I'm going to start off under Events, and drag this one here. >> 我打算下啟動關閉 活動,這裡拖動這一個。 When green flag clicked. 當綠旗點擊。 Now why that one? 現在,為什麼呢? Well recall that our volunteers came up, the first thing I 清楚地記得,我們的志願者 上來後,第一件事我 or they did was click that green flag in the top right hand corner. 或者他們所做的只是點擊綠色 標誌在右上角。 And that just means start the program. 而這只是意味著啟動程序。 >> So when that event happens, what do I want to do? >> 因此,當該事件發生時, 我該怎麼想幹什麼? I'm going to go under Looks, and I'm going to do "say hello." 我打算下看起來走, 我要去做“打個招呼。” And I'm going to change this and say something like "hello Yale." 而且我要改變這一點, 這樣說:“你好耶魯大學。” And now I'm going to zoom out, click the green flag, 而現在我要放大 出,點擊綠色旗幟, and voila, I've written a program. 瞧,我寫了一個程序。 It's not all that exciting just yet, but this 這還不是全部令人興奮 只是還沒有,但是這 is exactly where each of those author started, 也正是每個 這些作家開始, both with Pikachu, and the binary bulbs, and Oscartime, 都與皮卡丘,並且 二進制燈泡,和Oscartime, and so many more examples. 和這麼多的更多的例子。 >> You start super simple, and then you start to layer, >> 你開始超級簡單, 然後你開始到層, and add on features and functionality. 和附加的功能和功能性。 So what are these layers going to consist of? 那麼,這些層 要由? Well, beyond statements, we'll also have things that are little more fancily 那麼,超越報表,我們也將 有事情是有點fancily called Boolean Expressions, after someone named Bool. 被稱為布爾表達式, 一個叫布爾之後。 And a Boolean expression is simply an expression that's either true or false, 而布爾表達式是一個簡單的 表達式是真或假, yes or no, 1 or 0. 是或否,1或0。 >> Any polar opposites like that. >> 任何對立的兩極這樣。 It's either true or not. 這是無論是真的還是假的。 But we're also going to see ones that might look like this. 但是,我們也將看到 那些看起來可能是這樣的。 So for instance, is the mouse down? 因此,舉例來說,就是按下鼠標? They're sort of questions, if you will. 這些人都有點問題,如果你願意。 >> The mouse is either down, true or it's not, false. >> 鼠標已關閉, 真或不是,假的。 1 or 0, if you will, tends to be the mapping. 1或0,如果你願意, 往往是測繪的。 True is 1, false is 0. 真為1,假為0。 Well what about less than this? 那麼怎麼樣小於這個? Or so, is this less than this? 或者說,這是不到這一點? That's a question of sorts. 這是各種各樣的問題。 >> And if you put two numbers in there, either x >> 如果你把兩個 在那裡的數字的,X is going to be less than y or equal to y, or greater than y, 將是小於y或 等於y,或比y大, but this block we'll see, is just going to answer the question, 但是這個塊中,我們將看到的,僅僅是 要回答這個問題, is this less than that? 這是不到呢? We might also see something like this. 我們也可以看到這樣的事情。 Touching mouse pointers. 觸摸鼠標指針。 So in Scratch, you can ask the question, is the Sprite 因此,在刮,你可以問 這個問題,是雪碧 touching the mouse pointer? 觸摸鼠標指針? Other words, is the cursor hovering over the cap, or the equivalent? 換句話說,就是將光標懸停 超過了上限,或等同? >> We'll see anding things together. >> 我們會看到安定的東西放在一起。 You can ask two questions, and make sure that both of them 你可以問兩個問題, 確保兩者 give you yes or true answers before making a decision to do something. 給你yes或之前,真正的答案 在決定做一些事情。 But then how do you make decisions? 但是,那你怎麼做決定? Well, we have these conditions. 好了,我們具備這些條件。 >> And we saw this in our example of the phone book. >> 我們看到這個在我們的 例如電話簿。 Looking to the left or right for Mike Smith. 尋找到左側或 正確的邁克·史密斯。 And in the condition, you do something potentially, 並在條件,則 做一些潛在的, if a Boolean expression is true. 如果布爾表達式為true。 >> And indeed, notice the shapes now. >> 事實上,現在看到的形狀。 There's this placeholder right now on the overhead where we can fit-- 有此佔位符,現在 上的開銷,我們可以fit-- if I rewind one slide-- that shape. 如果我倒放slide--的形狀。 It's not quite the same size. 這是不太一樣的大小。 And indeed, you'll see that Scratch resizes things dynamically 事實上,你會看到 刮動態調整大小的東西 to fit puzzle pieces, but the shape is what's important. 適合拼圖,但 形狀是非常重要的。 This thing looks like that, and indeed it's 這東西看起來像 這一點,實際上它是 roughly the same shape that should fit in there. 大致相同的形狀 應該適合在那裡。 And if we want to do something this way or that way, if or else, 如果我們想要做的事 這樣或那樣的方式,如果不然, we have this puzzle piece in Scratch as well. 我們有這個難題 片中划痕也是如此。 >> Now suppose you wanted to do if, else if, or else. >> 現在,假設你想 如果這樣做,否則的話,否則後果不堪設想。 In other words, a three-way fork in the road. 換言之,一 三路的岔路口。 Well what can you do just by glancing at this? 那麼你可以做什麼 只需掃一眼呢? I can take this puzzle piece, and it doesn't seem to fit, 我可以把這個拼圖, 它似乎不適合, but again, Scratch is going to re-size nicely for us. 但同樣,划痕是怎麼回事 重新大小很好地為我們。 I could start to layer these things together. 我可以開始層 這些東西放在一起。 >> So now I have a three-way fork if this is true, do this. >> 所以,現在我有一個三方 叉如果這是真的,做到這一點。 Else if this other thing is true, go this way, else go this other way. 否則,如果這等事是真的, 走這條路,否則走這另一條路。 And in The Muppet Movie, the fork in the road, so to speak, 而在布偶電影中, 岔路口,可以這麼說, between Yale or Stanford, was exactly that, just two conditions. 耶魯大學和斯坦福大學之間,是 正是這樣,只有兩個條件。 Either go this way, else go that way. 無論是走這條路,否則走那條路。 >> Well, loops also exist in programming. >> 好吧,循環也存在於編程。 And we've used these already in class and in pseudocode code, 而且我們已經使用了這些已 類和偽代碼, and surely in those Scratch programs forever. 並肯定這些 刮節目永遠。 Scratch has this puzzle piece that will just let you do something forever. 划痕有這個拼圖的 只是讓你做一些事情,直到永遠。 And sometimes you want to do something forever. 有時你想 做一些事情,直到永遠。 It's not necessarily a bug, it's because you want a clock to keep going, 它不一定是一個錯誤,這是 因為你想有一個時鐘保持下去, or a game to keep playing. 或遊戲繼續玩。 Or you can specify a finite number of steps, as with this repeat block here, 或者,你可以指定一個有限的數量 步驟,在這裡這個重複塊, which will repeat something 10 times. 這將重複的東西10倍。 We can set variables, we'll soon see. 我們可以設置變量,我們很快就會看到。 And with variables, similar in spirit to algebra, like x, or y, or z. 並與變量,神似 代數,如x或y或z。 It's something symbolic that can store some value, some piece of information, 這件事情的象徵,可以存儲 一些價值,一些信息, that you might want to remember for later. 您可能要 要記住以後。 >> Best example of this might be a game where you have a score, >> 這個最好的例子可能是 一個遊戲,你必須得分, like in Pikachu. 像皮卡丘。 How many pieces of cake and whatnot did you catch? 多少蛋糕片 和諸如此類的東西你是否明白? Well, that might be a variable called score that starts at 0. 嗯,這可能是一個變量 所謂的分數從0開始。 And then every time we caught a piece of cake or candy, or the like, 然後我們每次抓到 一塊蛋糕或糖果,或類似的, it gets incremented. 它被遞增。 It gets added to one at a time. 它被添加到一次一個。 And so a variable stores a piece of information like that. 所以,一個變量存儲 一條這樣的消息。 Then there's arrays, and we'll come back to these in a week or two time, 此外,還有陣列,我們會來 回這些在一兩週的時間, but an array is kind of like an inventory or a satchel, inside 但數組是一種像一個 庫存或挎包,裡面 of which you can put virtual things. 其中,你可以把虛擬的東西。 It allows you to store more than one piece of information. 它可以讓你存儲更多 比一個信息。 And that might be useful if in the game, you're 這可能是有用的 如果在遊戲中,你 sort of walking around picking things up. 排序走動 撿東西。 And maybe you want to keep all of those pieces of cake 也許你想保留 所有這些片段蛋糕 around, and not just eat them one after another. 左右,而不能隨便吃 陸續它們。 And then there's a fancier construct we'll 然後還有一個 票友結構,我們將 come to called functions or procedures. 來調用函數或過程。 And though we're going faster here, we'll 雖然我們要去 更快這裡,我們將 see that these are a very natural solution to problems 看到,這些是一個非常 自然的解決問題的方法 that we're going encounter. 我們要去的遭遇。 As our programs start getting bigger we'll 由於我們的項目啟動 越來越大,我們將 start to notice patterns in the code that we're writing, 開始注意到格局 我們正在寫代碼, the puzzle pieces we're dragging and dropping. 拼圖我們 拖放。 And as soon as you notice yourself doing something again and again, or worse yet 而一旦你發現自己做 一遍又一遍的東西,或者更糟糕的是 copying and pasting programming code that you've written, 複製和粘貼編程 你寫的代碼, that's probably an opportunity to factor out 這可能是一個 機會來分解出 whatever you keep copying and pasting, and putting it 你繼續複製任何 和粘貼,並把它 in something called a "function." 在一種叫做“功能”。 But more on those in much more detail before long. 但更多的那些多 不久更多的細節。 >> And then there's even fancier features. >> 然後還有更炫的功能。 For those of you more comfortable, or taking APCS or equivalent, 對於那些你更舒適, 或服用APCS或同等學歷, Scratch actually supports things like threads and events and more. 划痕實際上支持的東西 像線程和活動等。 So realize that it has a fairly high ceiling, 所以認識到,它具有 一個相當高的天花板, even though it's also very broadly accessible to folks 儘管它也很 廣泛地接觸到人 who have never programmed before. 誰以前從未編程。 So indeed, let's take a look at a simple program or two. 因此,我們確實,讓我們一起來看看 在一個簡單的兩方案。 >> We already looked at how we might say hello with Scratch. >> 我們已經看了看我們如何 也許打個招呼與劃傷。 Let me go ahead and open up a little more interesting program 讓我繼續前進,開拓 更有趣的程序 that I wrote in advance. 我寫的提前。 And this one's called Pet the Cat. 而這其中的所謂的寵物貓。 All of these programs will be available on CS50's website. 所有這些方案都將 可在CS50的網站。 Indeed, already there. 事實上,已經存在。 >> So you can download them, and play with them, >> 所以,你可以下載 他們,和他們一起玩, and with Problem Set 0, which is also on the course's website, 並與習題集0, 也是在球場上的網站, you're encouraged to walk through these. 我們鼓勵你走過這些。 And moreover, we have a number of walk-through videos 而且,我們有一個 的步行通過視頻數 online in which I and CS50's team truly walk 在網上,我和 CS50的團隊真正走 through each of these examples at a much slower pace, a very fast forwardable, 通過上述的例子都在非常 較慢的速度,非常快的轉發, or rewindable pace, so that you can walk through these at your leisure as well. 或rewindable的腳步,讓你可以走 通過這些在您的休閒,以及。 So here's Scratch on the left. 因此,這裡的划痕就離開了。 Here's a program at the right that I've already pre-made. 這裡有一個程序在合適的 我已經預先做好。 So let me zoom in on this. 因此,讓我放大這一點。 And could someone in English, knowing what you know, just from now as 並可能有人在英語,知道 你知道,就從現在開始的是什麼 to how Scratch works, sort of say in an English phrase or sentence, 以排序怎麼刮的作品,說 在英語短語或句子, what does this program apparently do? 這是什麼程序顯然是嗎? >> Yeah, in orange shirt. >> 是的,橙色的襯衫。 >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] >> DAVID J. MALAN: Yeah, if your cursor is on Scratch the cat, >> DAVID J.馬蘭:是的,如果你 光標在划痕貓, play a meowing sound. 玩喵喵叫的聲音。 But notice how we express that. 但是請注意,我們如何表達這一點。 There's apparently a loop there, forever. 有顯然是 循環在那裡,直到永遠。 And then there's a condition, the if expression. 然後還有一個 情況下,如果表達式。 And collectively, what do those mean? 和集體,什麼這些是什麼意思? It means this program is just always running, 這意味著該計劃 只是一直在運行, and it's just always waiting and watching and listening 而它只是一直在等待 和觀看和聆聽 for me to move my mouse over the cat. 我將我的鼠標移到貓。 >> Because each time I do that, as you propose, it's going to do this. >> 因為每次我這樣做,因為 你提出,這將做到這一點。 Let me start the program. 讓我啟動程序。 Nothing seems to be happening, but notice how 似乎沒有任何要 發生,但注意如何 it's highlighted now in a yellow line. 它現在是強調了一條黃線。 That just means it's running. 這只是意味著它的運行。 And because there's a forever loop, it's still running. 而且因為有一個永遠 循環,它仍在運行。 >> So let me move my cursor over Scratch. [MEOW] [MEOW] And if I move it off, >> 因此,讓我把我的光標移到划痕。 [MEOW] [MEOW]如果我將它關閉, [MEOW] now it stops, but the program's still running. [MEOW] And so, adorable. [MEOW現在停止,但該方案的 仍在運行。 [MEOW]所以,可愛。 [MEOW] So let's open up slightly more advanced [MEOW]因此,讓我們打開 稍微更先進 example called Don't Pet the Cat. 例如所謂的不要寵物貓。 >> And now let's see what happens here. [MEOW] Meowing. >> 現在,讓我們看看 發生在這裡。 [MEOW]喵喵叫。 So it's a little on auto pilot, if you will. 因此,這一點就 自動駕駛,如果你願意。 --pet the cat. --pet貓。 I wonder why. 我不知道為什麼。 [ROAR] [MEOW] So how did this work? [吼] [MEOW]那麼究竟是怎麼工作的呢? Well, you can kind of reason through it intuitively, perhaps. 好了,可以種原因 通過它直觀,也許吧。 >> But let's look at the actual code. >> 但是,讓我們來看看實際的代碼。 So again, when the green flag is clicked, do this forever. 如此反复,當綠旗 被點擊,永遠做到這一點。 What do you want to do forever? 你要什麼做下去嗎? Well, if touching mouse pointer, then play 好吧,如果觸摸鼠標 指針,然後播放 a sound that's apparently called Lion 5, that's inside of this project, else 一個多數民眾贊成顯然被稱為獅子的聲音 5,這是這個項目裡面,否則 play sound meow, and then wait two seconds, so 播放聲音喵,和 然後等待兩秒鐘,所以 that it's not meowing incessantly. 它沒有喵喵叫個不停。 In fact, you can very quickly start to annoy yourself and your roommates. 事實上,你可以非常快速地啟動 惹惱你和你的室友。 >> Let's remove this block. >> 讓我們刪除此塊。 And notice what's nice about Scratch. 並注意有什麼好的關於划痕。 Things just kind of drag and drop and interlock. 事情就這樣一種拖累 拖放和聯鎖。 So again, it grows to fill what you want. 所以,再一次,它長到 填寫你想要什麼。 But if I remove this, and then hit play, [COMPUTER BLIP SOUND] 但是,如果我刪除此,再 點擊播放,[電腦BLIP音] >> --it's kind of tripping over itself, because it's literally >> --IT是種絆倒 本身,因為它的字面 doing what I'm saying. 做我在說什麼。 It's saying forever play this sound, but I'm not giving it a chance to finish. 它說永遠玩這個聲音,但 我不給它一個機會來完成。 And so that would be a bug. 所以,這將是一個錯誤。 And that's why we had this thing in here now. 這就是為什麼我們有 這個東西在這裡。 So let's actually start from scratch-- sort of pun slightly intended-- 因此,讓我們實際上是從scratch--開始 排序雙關語略intended-- in which we now have the cat move. 在我們現在有貓的舉動。 >> So I'm going to do this on the fly. >> 所以我要做到這一點就飛。 I'm going to zoom in here, just to get me started on Events. 我要放大在這裡,只 讓我開始對事件。 And green flag clicked. 而綠旗點擊。 And there's other ways to start the scripts. 而且還有其他的方法 啟動腳本。 We're going to keep it simple here. 我們要保持簡單在這裡。 >> And now I'm going to go ahead and go under Control. >> 現在我要去 進取,去控制之下。 And again, if you forget where things are, just click around, 再次,如果你忘了在哪裡 事情是,只要按一下周圍, and eventually you find them again. 最終你再次找到他們。 So I want to forever do what? 所以,我要永遠做什麼? I want to use the motion block that I know exists, move 10 steps. 我想用運動塊 我所知道的存在,移動10步。 >> So let's see what happens here if I play this game. >> 因此,讓我們看看會發生什麼 在這裡,如果我玩這個遊戲。 Thankfully it doesn't go too far. 值得慶幸的是它並沒有走太遠。 I can still kind of grab him by the tail and pull him back. 那種我仍然可以抓住他 的尾巴把他拉回來。 But the program's still running, so he's kind of fighting me. 但程序仍在運行, 所以他的那種戰鬥的我。 But it'd be kind of nice if I conditionally fix this in code. 但是,這將會是種很好,如果我 有條件地解決這個問題的代碼。 >> Because this is not-- actually this is really >> 因為這是不是 - 其實這是真的 not a fun game for anyone of any age. 不是一個有趣的遊戲,任何年齡的人。 So let's try to fix this by having some kind of conditions. 所以讓我們嘗試解決這個問題 有一些樣的條件。 So I'm going to go under Control, and then if. 所以,我打算去下 控制,然後如果。 I like this idea. 我喜歡這個主意。 So after moving 10 steps, if-- let me sense where I am. 因此,移動10步後, if--讓我感覺到我在哪裡。 I'm going to go under Sensing, and then it looks I can go here. 我要去檢測下得去, 然後它看起來我可以去這裡。 row to the shape matches. 排的形狀匹配。 >> Size doesn't, but it's going to grow to fill. >> 大小不會,但它的 將增長到填滿。 And now this is a little menu. 而現在,這是一個小菜單。 And now mouse pointer-- I don't want the mouse, I want the edge. 現在鼠標pointer--我不知道 想要鼠標,我想要的邊緣。 So Scratch is smart enough to know when a sprite is touching the edge. 所以划痕是足夠聰明,知道 當精靈接觸到邊緣。 What do I want him to actually do? 我想要什麼他實際上做? >> Let me go ahead and change motion. >> 讓我繼續前進,改變運動。 You know what? 你知道嗎? I'm going to have him turn around. 我打算讓他轉身。 So at 15 degrees isn't really going to help me. 因此,在15度是不 真的要幫我。 I want him to turn around and go the other way. 我希望他轉身 和走另一條路。 >> So let's see what happens here, if I hit Play now. >> 因此,讓我們看看會發生什麼 在這裡,現在如果我打遊戲。 OK, kind of stupid looking, but it's doing exactly what I said. OK,有點傻看,但 它做什麼我說。 And it's rotating the whole sprite. 而且它旋轉了整個精靈。 Now it turns out I can fix this. 現在事實證明,我可以解決這個問題。 And I didn't know how to fix this at first. 我不知道該怎麼 要解決這個問題,在第一。 I kind had to futz around and see the best way to do this. 我有點不得不futz四周, 看到要做到這一點的最好辦法。 But if I go to-- let's see, motion. 但是,如果我去用於:讓我們來看看,議案。 Oh, I found this. 哦,我發現這一點。 Actually, Set Rotation Style. 事實上,設定的旋轉風。 Left, right, or don't rotate, or all around. 左,右,或不 旋轉或四周。 And it turns out that's what I want. 而事實證明,這就是我想要的。 And I'm going to put this is not my loop, because I don't need to set 而且我打算把這個不是我 循環,因為我並不需要設置 the rotation style multiple times. 旋轉樣式多次。 I'm going put it at the very top of this program so that it gets set once, 我打算把它放在最頂端 這個程序,以便它被設置一次, and then remembers. 然後回憶。 And now I'm going to try this again. 而現在我要試試這個了。 Let me stop the program. 讓我停止程序。 >> And now that fixed that bug. >> 而現在,修復了漏洞。 So I'm iteratively improving upon this. 所以,我反复地提高了在此。 The program is getting a little more complex and bigger, 該方案是得到一個 稍微複雜一點大, but I'm taking baby steps so to speak, and small bites out of the problem 但我要帶嬰兒學步可以這麼說, 和小咬出了問題 to get it better and better. 得到它越來越好。 But this too, is kind of lame. 但是,這也同樣是一種跛腳的。 >> You know what? >> 你知道嗎? Would ask someone with a really good, frightful voice like to come up? 會問有人用真正的好, 可怕的聲音喜歡來了? Someone with a voice. 有人用一個聲音。 Uh, yeah. 嗯,是的。 Come on up. 上來吧。 In the green shirt. 在綠色襯衫。 >> So it turns out there's some other fun things, aesthetics and sounds alike. >> 因此,原來有一些其他有趣 事,美學和聲音的一致好評。 Here's the meow. 這裡的喵。 I click on the Sounds tab. 我點擊聲音選項卡上。 [MEOW] There's the meow. [MEOW] [MEOW] [MEOW] --actually record something [MEOW]有喵喵。 [MEOW] [MEOW] [MEOW] --actually記錄的東西 of our own here. 我們自己在這裡的。 >> So let's do exactly that. >> 因此,讓我們這樣做。 Instead of using this cat sound, let's go ahead here, and what's your name? 請不要使用此貓的聲音,讓我們 這裡先走了,你叫什麼名字? Nick, nice to meet you. 尼克,很高興見到你。 It's David. 這是大衛。 So in a moment, I'm going to hit the Record button. 因此,在那一刻,我要去 擊中記錄按鈕。 And if you can just yell into the laptop, 如果你能剛 嚷嚷到筆記本電腦, "ouch," as though you just walked into the wall, “哎喲,”好像你 剛走進牆, that will be much appreciated. 這將非常感激。 1, 2. 1,2。 >> NICK: Ouch! >> 尼克:哎喲! DAVID J. MALAN: Awesome. DAVID J.馬蘭:真棒。 And now can do a little editing here. 現在可以在這裡做一些編輯。 Going to get rid of the quiet parts. 要擺脫安靜的部分。 And I think that's good. 我認為這是很好的。 Thank you very much. 非常感謝你。 >> NICK: Pleasure. >> 尼克:快樂。 DAVID J. MALAN: I've just renamed it "ouch," DAVID J.馬蘭:我已經 剛剛更名為“哎喲” but now I'm going to go back to my scripts. 但現在我要 回到我的腳本。 And notice there is indeed sound here. 並注意確實是有聲音在這裡。 And I'm going to go ahead and play the sound ouch, 而且我要繼續前進 和播放聲音哎喲, and I'm going to do that if it's touching the edges only. 我要去這樣做,如果 它只是接觸的邊緣。 And then I'm going to have it turn around. 然後我要去 有它轉身。 So let's see what happens here. 因此,讓我們看看會發生什麼。 Let's go full screen. 讓我們去全屏。 [VIDEO PLAYBACK] [視頻回放] -Ouch! -Ouch! Ouch! 哎喲! Ouch! 哎喲! Ouch! 哎喲! Ouch! 哎喲! Ouch! 哎喲! Ouch! 哎喲! Ouch! 哎喲! >> [END PLAYBACK] >> [結束播放] >> DAVID J. MALAN: So you realize that we're getting a little lucky. >> DAVID J.馬蘭:所以你實現 我們正在開始有點幸運。 I'm going to have him move like 100 steps at a time. 我打算讓他的舉動 像100步的時間。 The effect of which now is going to be-- [COMPUTER GLITCH SOUND] So 現在的效果會 以be-- [電腦故障聲音]所以, within reason. 在合理範圍內。 So an opportunity to refine that further if we really want to. 所以有機會改進的 進一步,如果我們真的想。 >> So now let's introduce another concept. >> 所以,現在我們來介紹另外一個概念。 To let me go into one called Counting Sheep and use something 讓我去到一個叫 數羊和使用的東西 called a variable. 稱為一個變量。 This is an adorable little sheep, and I changed his costume so to speak. 這是一個可愛的小綿羊,和 我改變了他的服裝可以這麼說。 So even though the default is a cat, you can upload, you can draw, 因此,即使默認是 貓,你可以上傳,就可以得出, you can do any number of characters on your sprite. 你可以做任何數量的 人物在你的精靈。 Here's a program that's going to do what in English? 這裡有一個程序,是 打算做什麼英語? >> Based again on just what you know now. >> 就只是你現在知道再次為主。 What's this program do? 這是什麼節目呢? Yeah, it's going to count. 是的,這是怎麼回事計數。 One number at a time. 一次一個號碼。 We have apparently have this set counter. 我們有很明顯 有這樣一組計數器。 >> I don't know what that is, but maybe it's a variable. >> 我不知道那是什麼, 但也許這是一個變量。 It's just a container, x or y. 這只是一個容器,x或y。 But the word counter is more descriptive than mathematician's x or y. 但這個詞計數器更 描述不是數學家的x或y。 So we can use English words for things. 因此,我們可以用英語單詞的事情。 Forever, just means keep doing this. 永遠的,只是意味著繼續這樣做。 >> Say counter. >> 說計數器。 Now where did this come from? 現在在哪裡這是從哪裡來的? Well, it turns out that counter is a variable. 嗯,事實證明, 計數器是一個變量。 So it's just another puzzle piece I created in advance. 所以它只是一個謎 這塊我提前創建的。 And even though it happens not to be the same shape here, 並且,即使它發生 不是這裡是相同的形狀, normally you would say something like hello here. 通常你會說 像你好這裡。 >> You can also drag a variable so that that's what's get said. >> 您也可以將一個變量 使這就是我們開始說。 Then I wait for a second, I change the counter by one, 然後,我等待一秒鐘,我 一個改變計數器, incrementing it by adding one. 通過添加一個遞增的。 So that the net effect is this adorable counting sheep. 因此淨效果是 這個可愛的數羊。 Though he's counting himself. 雖然他的票自己。 Now it's very quickly going to get boring 現在,它的速度非常快 要得到無聊 because he's going to do this truly forever, 因為他要 做到這一點真正永遠的, but that's exactly what the program's design prescribes. 但是這正是 程序的設計規定。 Lets now try another example that leverages a variable. 現在,讓我們嘗試另一個例子 它利用一個變量。 This one called Hi Hi Hi, that does get annoying quickly. 這個叫喜喜喜,那 並很快得到煩人。 Now this one has two scripts. 現在,這其中有兩個腳本。 And so again, we're taking baby steps. 所以再次,我們正在採取嬰兒的步驟。 >> We started with something super small, added to it, added to it. >> 我們開始與一些超 小,添加到它,加入它。 Now I want to do something even more dynamic, 現在,我想要做的事 更加動感, so I want to be listening for two different things at a time. 所以我想被監聽 同時兩個不同的東西。 So on the left, when green flag is clicked, 所以在左邊,當 綠旗點擊, I set a variable that I wrote in advance called Muted. 我把我寫的一個變量 事先叫靜音。 And I arbitrarily set it to 0. 我隨意將它設置為0。 So Scratch doesn't have true and false, but it does have 0 and 1. 所以划痕不具有真實, 假的,但它確實有0和1。 >> So I can approximate that same idea. >> 因此,我可以近似地認為同樣的想法。 And then forever, if the space bar is pressed, then set the variable to 0. 然後永遠,如果空間酒吧 壓,然後將變量為0。 Or sorry. 還是遺憾。 If the Space is pressed, and if muted, the variable, is 0, 如果空間被按壓,並 如果靜音,變量,是0, then set muted to 1, else set muted to 0. 然後設置靜音為1, 其他設置靜音為0。 This seems sort of like we're just doing and undoing work. 這似乎有點像我們 只是在做和撤銷工作。 >> But what's the effect? >> 但是,有什麼影響? Every time I hit the space bar, what happens to my variable 每次我打空格鍵, 如何處理我的變量是什麼 called muted, logically? 叫靜音,邏輯? Sort of gets flipped. 排序中被翻轉。 It changes from 0 to 1, or 1 to 0. 它改變從0到1,或1至0。 So it took a few blocks to express that, but all 於是花了幾個街區 來表達,但所有 I'm doing is toggling the state of this variable to 0 or 1, or 0 or 1 我做的是切換的狀態 此變量為0或1,或者0或1 each time I hit the space bar. 每次我打空格鍵。 Now over here, what's this doing? 現在在這裡,這是什麼做的? Forever, if muted is 0, so if muted is false. 永遠,如果靜音是0, 因此,如果靜音是假的。 So if it's not muted, is the semantics there, play sound sea lion, 所以,如果它不靜音,是 語義那裡,播放聲音海獅, and think Hi Hi Hi for two seconds, wait two seconds. 並認為喜喜喜兩 秒,等待兩秒鐘。 So notice now these scripts are effectively 所以,現在這些通知 腳本是有效的 going to run in parallel so that one can be listening for one action, the other 要並行運行這樣一方面可以 被偵聽一個動作,另一 to make a decision based on that action. 使基於該行動作出決定。 And it can do this forever. 它可以永遠這樣做。 >> [SEA LION BARKING] >> [海獅BARKING] >> [SEA LION BARKING] >> [海獅BARKING] >> It's going to do this forever and [SEA LION BARKING] as I've just done. >> 這將永遠做到這一點, [海獅BARKING]因為我剛剛做。 And now it's still running but I've "muted" the game. 而現在它仍在運行 但我有“靜音”的遊戲。 [SEA LION BARKING] And that's all this guy does now too. [海獅BARKING]這就是 現在所有的這傢伙也會做。 >> Let's open another example here. >> 讓我們打開另一個例子在這裡。 Let me go into Events, and now this adorable too. 讓我進入事件, 現在這個可愛了。 But notice it has two sprites. 但是請注意,它有兩個精靈。 So not just two scripts with one sprite, but two sprites. 所以,不只是兩個腳本與 一個Sprite,而是兩個精靈。 And if I click on the blue guy as I already have, I see he as one program 如果我點擊藍色的傢伙,我 已經有了,我看到他作為一個程序 up here that literally just says this, when I receive an event, 在這裡,從字面上只是說: 這一點,當我收到一個事件, say "Polo" for two seconds. 說“波羅”兩秒鐘。 >> So if you've ever played in a pool, the game Marco Polo, >> 所以,如果你曾經玩過的 一個游泳池,遊戲馬可波羅, if the orange guy script is any indication, apparently 如果橙色傢伙腳本 任何跡象,顯然 every time I hit the space bar, what's the orange guy going to do? 每次我打空格鍵, 什麼是橙色的人怎麼辦呢? He's going to say "Marco." 他會說:“馬可。” And then this is a new block. 然後這是一個新的塊。 We've not seen this before, but broadcast an event. 我們沒有看到這之前, 但廣播的事件。 And I could call it event anything we want. 我可以叫它 我們希望事件什麼。 >> We'll come back to this perhaps before long. >> 我們再回過頭來此 也許用不了多久。 But broadcasting an event is a way for one sprite 但廣播事件 是一個辦法讓一個精靈 to talk to another by essentially passing it a message. 談話到另一個 本質上它傳遞的消息。 It's not a message you see. 這不是你看到的消息。 It's not something visual. 這不是視覺。 It's sort of a computer message that the other guy is listening for. 這有點計算機信息 那其他人正在監聽。 Because indeed, the blue guy, recall doesn't have when green flag clicked. 因為事實上,藍色的傢伙,召回 沒有,當綠旗點擊。 >> He instead has, when I receive an event. >> 相反,他有,當我收到一個事件。 When he gets handed this note in class, so to speak, he should say "Polo." 當他被移交本說明在課堂上, 可以這麼說,他應該說是“波羅”。 And so the net effect is that when I hit the green flag, nothing happens. 所以淨效果是,當我 打綠色標誌,沒有任何反應。 But when I hit the space bar, he says "Marco," he responds with "Polo." 但是,當我打空格鍵,他說: “馬可”,他響應“波羅”。 But the only sprite I'm interacting with is the orange one. 但唯一的精靈,我 與交互是橙色的。 So this is a way of kind of passing messages between sprites 因此,這是怎樣的一種方式 精靈之間傳遞消息 and having them communicate with one another. 並讓他們交流 彼此。 >> Now let's look at one last one here called Threads. >> 現在,讓我們來看看最後一個 一個在這裡被稱為線程。 And notice this by playing it. 並通過玩它注意到這一點。 So these are two sprites. 所以這是兩個精靈。 The bird is kind of flying around. 這隻鳥是那種飛來飛去。 He's bouncing. 他彈跳。 There's no "ouch," but same idea. 有沒有“哎喲”,但同樣的想法。 >> But the cat seems pretty smart. >> 但貓似乎很聰明。 What is the cat apparently doing? 什麼是貓顯然是在做什麼? And wait for it. 而等待它。 What is the cat apparently doing? 什麼是貓顯然是在做什麼? It's not just bouncing. 這不只是反彈。 >> He's following the bird. >> 他下了小鳥。 And so apparently, there's a way with a combination of blocks here-- 所以很明顯,有辦法 與塊的組合這裡 - and let's look at the cat real fast. 讓我們來看看貓實快。 Forever, if touching bird, then play the sound Lion 4, whatever that is. 永遠,如果觸摸鳥,然後播放 聲音獅4,不管它是什麼。 We heard it once. 我們聽到一次。 Otherwise, point towards bird, and move one step. 否則,指向 鳥類和移動一步。 Now the fact that it's one step is what gives the bird 現在的事實,即它的One 步驟是什麼讓鳥 a bit of an advantage initially, but if we instead 有點優勢 最初,但如果我們不是 make this 10, for instance, so that every iteration of loop he's 使這10,例如,這樣 該循環的每次迭代他 moving 10 steps of time. 移動10步的時間。 So more space. 因此,更多的空間。 Let's see what happens then. 讓我們看看會發生什麼。 [LION ROAR] Not all that much better. [獅子吼]不是所有的好得多。 So now let's try to improve upon these a little iteratively, 所以,現在讓我們嘗試改善 在這些有點反复, and come back to that notion of a function. 回來到 觀念的函數。 >> And indeed one of the fundamental takeaways of the class design. >> 在根本事實上1 的一流的設計外賣。 Not just writing programs that work and that are correct, but are well 不只是編寫工作方案 那是正確的,但也 designed. 設計的。 And design is much more subjective, and you'll get better at it over time. 而且設計更加主觀的, 你會得到它更好的隨著時間的推移。 But let's take some baby steps toward starting with a program that works, 但是,讓我們採取一些嬰兒的步驟走向 開始的程序工作, absolutely, but it's not very good. 絕對,但它不是很好。 It's not very well written. 這不是寫得很好。 >> So here's a program that does this. >> 所以這裡有一個程序,做到這一點。 Cough, cough, cough. 咳,咳,咳。 What does the program look like? 是什麼節目是什麼樣子? Looks correct to me. 看起來是正確的我。 It's saying couch for a second, then it waits. 它是說沙發上 第二個,然後等待。 >> Then it says it again, then it waits. >> 然後它說了一遍,然後等待。 Then it says it again, then it waits. 然後它說了一遍,然後等待。 And then the program implicitly ends, because there's no loop. 然後程序隱式地 最終,因為沒有循環。 But why is this a badly written program? 但是,為什麼這是一個寫的不好的程序? Even if you've never programmed before? 即使你從來沒有編程? Like, what rubs the wrong way, perhaps here? 像什麼磨 走錯了路,也許在這裡? Yeah? 是嗎? >> AUDIENCE: [INAUDIBLE] >> 聽眾:[聽不清] DAVID J. MALAN: Exactly. DAVID J.馬蘭:沒錯。 You're repeating yourself again and again. 你重複 自己一遍又一遍。 And literally, I copied and pasted two of those blocks again and again. 而且從字面上看,我複製並粘貼 兩人再次又一次的塊。 And that's exactly the sort of sanity check that you should be making. 這就是理智的完全排序 檢查你應該做。 Wait a minute. 等一下。 Should I really be doing this? 如果我真的會這麼做? So what's this what's the obvious solution perhaps? 所以,這是什麼什麼 顯而易見的解決方案吧? Have some kind of loop. 有某種循環。 And I don't quite recall what the puzzle piece is, 而且我不太召回 什麼一塊拼圖是, but if I look at the next iteration here, 但如果我看 這裡下一個迭代, indeed, there's not just the forever loop, 事實上,有沒有 只是永遠的循環, there's repeat some number of times. 有重複的次數一定數目。 And so I've specified three. 所以我指定了三個。 And now notice how much tighter, how much more succinct this program is. 現在,請注意如何更緊密,如何 更簡潔的這個計劃是。 And in a sense, how much more maintainable. 在某種意義上,如何 更容易維護。 If I want to change the word from cough to something else, 如果我想改變的話 咳嗽到別的東西, like achoo, like he's sneezing. 像ACHOO,就像他打噴嚏。 Then I change it in one place, and not three. 然後,我在一個更改 的地方,而不是三個。 So this already feels like slightly better design. 因此,這已經感覺 稍微好一點的設計。 Let me instead open cough 2, our third example. 讓我來代替開咳嗽 2,我們的第三個例子。 >> Notice as a computer scientist, I start counting at 0, typically. >> 請注意,作為一名計算機科學家, 我開始計數為0,一般。 Now this looks a little scarier at first, but the effect is the same. 現在,這看起來有點可怕的 首先,但效果是一樣的。 Cough, cough, cough. 咳,咳,咳。 But what seems to be fundamentally new in the top part of the program? 但似乎是根本 新在程序的頂部? I've removed the say. 我已經刪除了發言權。 >> I've removed the wait. >> 我已經刪除了等待。 And what have I plugged in instead? 我在什麼事插入呢? A function. 函數。 A cough block. 咳嗽塊。 I mean, frankly, I seem kind of an idiot if I didn't just 我的意思是,坦率地說,我好像那種 白痴,如果我不只是 start with the block that's apparently called 開始與塊 多數民眾贊成顯然被稱為 "cough," if that's all I want him do. “咳,”如果這就是我想要他做。 But that doesn't exist in Scratch. 但是,這並不在划痕存在。 Rather I went to one in the palette called More Blocks here, 而我在去一 調色板叫更多的塊在這裡, and I drag this big purple thing here that lets me define a function. 我拖動這個大紫色的東西 在這裡,讓我定義一個函數。 It essentially lets me create my own puzzle 它本質上讓我 創建自己的拼圖 piece that can be called anything I want, that can do anything I want, 這可以被稱為什麼我一張 想要的,可以做任何我想要的, but it gives it a name. 但它給它一個名字。 It gives me a new, purple puzzle piece that now does whatever I tell it to do. 它給了我一個新的,紫一塊拼圖 現在做什麼,我告訴它做的事。 So this purple piece here corresponds to this one here. 所以這紫這裡一片 對應於這一個在這裡。 >> And what does it do? >> 而且它有什麼作用? It says cough for a second, and then it waits. 它說,咳了 秒,然後它等待。 And now I've sort of created my own custom puzzle piece, 而現在我已經那種創造 我自己的自定義拼圖, so that it behaves exactly that same way. 使得它的行為 正是方式相同。 So I can keep doing this. 因此,我可以繼續這樣做。 And indeed, there's going to be more and more opportunities for modularization, 事實上,還有的將是更多, 對於模塊化更多的機會, and for layering, complexity on top of one another. 和層次感,複雜性 在彼此的頂部。 But this basic idea, indeed in problem said 0. 但這個基本理念, 確實問題表示0。 What you're going to be challenged to do is 什麼你要 被質疑做的是 to download Scratch, or just use it on the web, and just have fun with it. 下載划痕,或者只是用它 在網絡上,只是有它的樂趣。 We'll give you a set of requirements, having a sound, 我們會給你一套 的要求,具有聲, and some number of puzzle pieces. 和拼圖一些數字。 But you'll do exactly this. 但是,你會做正是這一點。 And you'll realize that you're going to want to take some baby steps initially, 你會意識到,你要 要採取一些嬰兒的步驟開始, until your program gets more and more complex. 直到你的程序得到 越來越複雜。 But considering is this the best way I could do this? 但考慮到這是在 我能做到這一點的最佳方法是什麼? Can I avoid this instinct perhaps, to copy and paste? 我能避免這種本能 也許,複製和粘貼? >> But before Problem Set 0, and before we adjourn, >> 但問題集前 0,我們休會之前, thought we'd take up one more volunteer if we could, 以為我們會佔據一個 更多的志願者,如果我們可以, for a final program that's perhaps the most 對於最後方案 這也許是最 fitting at all, given today's venue. 配件可言,在今天的會場。 Come on down. 下來吧。 Yeah. 是啊。 Yes. 是。 What's your name? 你叫什麼名字? Uh-oh. 嗯,哦。 That's OK. 這是確定的。 Both come down. 這兩個下來。 And I've will deal with this somehow within that next ten seconds. 而且我已經將處理這個不知何故 旁邊十秒內。 So come on down. 因此,下來吧。 Come on down. 下來吧。 >> Let me come on up here. >> 讓我來上了這裡。 Come on. 來吧。 All right. 好的。 Let's see here. 讓我們來看看在這裡。 So notice real fast here, if you'd like to come on up. 因此,發現真正的快速這裡, 如果你想達到來吧。 >> We'll do two rounds of this. >> 我們會做兩輪這一點。 And what's your name? 而你叫什麼名字? >> SABRINA: Sabrina. >> SABRINA:塞布麗娜。 >> DAVID J. MALAN: Sabrina and? >> DAVID J.馬蘭:塞布麗娜和? >> YING GEE: Ying Gee. >> 英GEE:應格萼。 >> DAVID J. MALAN: Ying Gee. >> DAVID J.馬蘭:應格萼。 Nice to meet you both. 很高興見到你們倆。 David. 大衛。 So our final example here is called Ivy's Hardest Game. 因此,我們的最後一個例子這裡是 所謂的常春藤的最難的遊戲。 And why don't we have you do Level 1, and you do Level 2. 為什麼我們不要求你必須去做 1級,而你做的2級。 >> And we'll see how far beyond that we actually go. >> 我們會看到多遠 除此之外,我們居然走了。 Written by a student last year, remixed by me 寫的一個學生 去年,由我混音 so that this would go over well in New Haven. 因此,這將去 在良好的紐黑文。 And I give you a game that's going to involve moving the arrows up and down, 我給你一個遊戲,那將 涉及移動箭頭上下, and getting Yale to the finish line. 並獲得耶魯終點線。 Here we go. 在這裡,我們走了。 >> [VIDEO PLAYBACK] >> [視頻回放] >> [MUSIC -- NFL ON FOX THEME SONG] >> [MUSIC - NFL在狐狸主題曲] [MUSIC -- MC HAMMER, "U CAN'T TOUCH THIS"] [MUSIC - 哈默,“U不能碰 這種“] >> -U can't touch this. >> -U不能碰這個。 U can't touch this. U可以不要碰這個。 Can't touch this. 不能碰這個。 My, my, my, my music hits me so hard, makes me say, oh, my lord. 我的,我的,我的,我的音樂打我,所以 硬,讓我說,哦,我的上帝。 Thank you for blessing me with a mind to rhyme and two hype feet. 感謝您與祝福我 心韻和兩個炒作腳。 >> That's good when you know you're down. >> 這是很好的,當你知道你下來。 A super dope homeboy from the Oaktown. 一個超級塗料巨蟹座從Oaktown。 And I'm known as such and this a beat uh, you can't touch. 而我已知的,而這 一拍呃,你不能碰。 I told you homeboy U can't touch this. 我告訴你巨蟹座U可以不要碰這個。 Yeah, that's how we're living and you know U can't touch this. 是的,這就是我們如何生活 你知道你無法觸摸這個。 >> Look in my eyes, man. >> 看著我的眼睛,男人。 U can't touch this. U可以不要碰這個。 Yo, let me bust the funky lyrics. 喲,讓我胸圍時髦的歌詞。 U can't touch this. U可以不要碰這個。 Fresh new kicks and pants. 全新的踢腿和褲子。 >> You got it like that and you know you wanna dance. >> 你得到了它這樣的, 你知道你想跳舞。 So move out of your seat and get a fly girl and catch this beat. 所以搬出你的座位,並得到 一個飛女,趕上這個節奏。 While it's rolling hold on pump a little bit and let them know what's going on. 雖然它的滾動保持在泵上一點點 一下,讓他們知道發生了什麼事情。 Like that. 喜歡這一點。 Like that. 喜歡這一點。 >> Cold on a mission so pull on back. >> 冷的任務,以便拉回來。 Let them know that you're too much and this is a move uh you can't touch. 讓他們知道你是太多 這是一招呃,你不能碰。 Yo, I told you U can't touch this. 喲,我告訴你,你無法觸摸這個。 Why you standing there man? 為什麼你站在那裡的人嗎? U can't touch this. U可以不要碰這個。 >> Yo, sound the bell school's in, sucker. >> 喲,聲鐘聲學校在,吸盤。 U can't touch this. U可以不要碰這個。 Give me a song, a rhythm making them sweat that's what I'm giving them now. 給我一首歌,節奏使他們 汗水,這就是我現在給他們。 They know when you talk about the Hammer you talk about a show that's hyped. 他們知道,當你談論錘 請您談一下演出,這是炒作。 And tight singers are sweating so pass them a mic. 緊歌手都 出汗使它們傳遞一個麥克風。 >> Or a tape to learn what it's going to take and now >> 或磁帶學什麼 它會採取與現在 he's going to burn the charts. 他要燒的圖表。 Legit either work hard or you might as well quit. 合法要么努力工作或 你還不如退出。 Because you know U can't touch this. 因為你知道你無法觸摸這個。 U can't touch this. U可以不要碰這個。 Break it down. 打破它。 Stop. 停止。 Hammer time. 錘的時間。 Go with the flow in a spin if you can't move to this 走在旋轉的流 如果你不能移動到本 then you probably are dead. 那麼你可能已經死了。 So wave your hands in the air [INAUDIBLE] 所以,把你的手 空氣中[聽不清] >> This is it for a winner dance to this and you're going to get thinner. >> 這是它的一個勝利者舞蹈 這一點,你會變得越來越薄。 Move slide your rump just for a minute let's all do the bump. 移動滑動你的臀部只為 一分鐘,讓我們都做凹凸。 Yeah. 是啊。 U can't touch this. U可以不要碰這個。 >> U can't touch this. >> U可以不要碰這個。 You better get hyped boy U can't touch this. 你最好得到大肆宣傳 男孩U可以不要碰這個。 Ring the bell school's back in. 敲鐘學校。最 Break it down. 打破它。 Stop. 停止。 Hammer time 錘時間 >> DAVID J. MALAN: That's it for CS50! >> DAVID J.馬蘭:這就是它的CS50! Thanks so much for joining us! 非常感謝您加入我們的行列! See you outside. 外面見你。 >> [END PLAYBACK] >> [結束播放] [VIDEO PLAYBACK] [視頻回放] [MUSIC -- "SEINFELD" THEME SONG] [MUSIC - “宋飛傳”的主題曲] -Hey David. - 嘿大衛。 -Hey, David. - 嘿,大衛。 How's it going? 怎麼樣了? >> -Good job, today. >> - 良好的工作,今天。 -So have you thought about what you're going to do for the out jokes? - 所以你有沒有想過是什麼 你會做的出來的笑話? -No, I got nothing. 不,我什麼也沒得到。 -What if-- what if this is the out joke? - 什麼if--如果這是出笑話嗎? -Like, unpacking carts? 樣,拆包車? -Uh-huh. -Uh,呵呵。 You know, it's about nothing. 你知道,這是關於什麼。 >> -So like, no story, no conflict, no resolution. >> - 所以喜歡,沒有故事,沒有 衝突的任何決議。 I don't understand. 我聽不懂。 What's it about then? 它是什麼有關呢? >> -Nothing. >> 什麼也沒有。 >> -So we have out joke is about nothing, and we have no actors. >> - 所以我們出來的笑話是關於 什麼都沒有,我們沒有演員。 Who's going to be in this? 誰將會是在這? >> -No, no, no. >> 不,不,不。 I mean, I'll be in it. 我的意思是,我會在這。 >> -You'll be in it? >> -You'll是嗎? -Yeah! 是啊! People are always telling me I'm a character. 人們總是告訴 我,我是一個性格。 >> -Well, I mean, it's true. >> - 嗯,我的意思是,這是真的。 But who else is going to be in it? 但是,還有誰將會是在裡面? It can't just be you. 它不能僅僅是你。 >> -You will be in it, Gavin, Dan, Dan, Colton, Z'Myla, Alysse, Doug, >> - 你會在裡面,加文,丹, 丹,科爾頓,Z'Myla,Alysse,道格, David, everybody. 大衛大家。 >> -So it's about nothing, and everybody's in it? >> - 因此,它是關於什麼, 每個人都在它? >> -Absolutely nothing. >> -Absolutely什麼。 >> -This is ridiculous. >> - 這是荒謬的。
B1 中級 中文 美國腔 馬蘭 花生醬 聽眾 果凍 程序 耶魯 第0周,繼續 (Week 0, continued) 1186 64 Jason Wang 發佈於 2021 年 01 月 14 日 更多分享 分享 收藏 回報 影片單字