字幕列表 影片播放
Hi, I'm chris peach.
嗨,我是chris peach。
I'm a professor of computer science at stanford University.
我是斯坦福大學的一名計算機科學教授。
Today, I'll be answering your questions from twitter.
今天,我將在微博上回答你的問題。
This is coding support.
這就是編碼支持。
First up from M.
首先是來自M.
T.
T.
X.
X.
T.
T.
How many coding languages are there?
有多少種編碼語言?
Well there's a lot of coding languages.
嗯,有很多的編碼語言。
Some of the most popular ones include python.
一些最受歡迎的包括蟒蛇。
That's great.
這很好。
If you're doing data science or if you're writing scripts for your computer, there's java script.
如果你在做數據科學,或者如果你在為你的電腦寫腳本,有java腳本。
That's great if you're writing a website and there's a whole bunch of other ones like C.
如果你在寫一個網站,那就很好,還有一大堆像C的其他。
C.
C.
Plus plus java and that's just five of the top most common ones.
再加上java,這只是最常見的五種頂級的。
My friend from university even made a coding language of their own just for fun.
我的大學朋友甚至自己做了一個編碼語言,只是為了好玩。
Eugene Daniel asked encoding being self taught.
尤金-丹尼爾問編碼是自學的。
Absolutely.
絕對的。
Coding is such a special what matters is that you have the skills.
編碼是如此特別,重要的是你有技能。
It doesn't matter so much if you have a credential saying you can do it, what matters is that you can pick up a computer and you can code it and make it do wonderful things.
如果你有一個證書說你能做到這一點並不重要,重要的是你能拿起一臺電腦,你能給它編碼,讓它做一些奇妙的事情。
There's a lot of incredible resources out there stanford myself, we offer free programming class if you're interested.
斯坦福大學有很多令人難以置信的資源,如果你有興趣,我們提供免費的編程課。
I know a lot of self taught success for you When I worked at Pixar.
我知道很多自學成才的你 當我在皮克斯工作時。
I knew a lot of programmers there who had never even studied computer science in university or anything like that.
我認識那裡的很多程序員,他們甚至從來沒有在大學裡學習過計算機科學或類似的東西。
They just taught themselves and now we're working at one of the coolest programming companies?
他們只是自學,現在我們在最酷的編程公司之一工作?
Okay.
好的。
Next glacial icon.
下一個冰川型圖標。
I always wondered apocalyptic and action movies.
我總是想知道世界末日和動作電影。
How do coders managed to save the day without ever using stack overflow and glacial icon.
編碼員如何在不使用堆棧溢出和冰川圖標的情況下設法拯救世界。
I'm gonna say that's a fantastic question realistically when we're coding, we're using stack overflow stack overflow is a website where you can go ask questions and see answers and you can see code snippets that other people use to solve problems.
我要說的是,這是一個奇妙的問題,現實中,當我們在編碼時,我們使用堆棧溢出堆棧溢出是一個網站,你可以去問問題,看到答案,你可以看到其他人用來解決問題的代碼片段。
Every serious coder I know use a stack overflow to build better answers.
我認識的每個嚴肅的程序員都使用堆棧溢出來建立更好的答案。
And so it's pretty unrealistic that in an action movie they're not using stack overflow.
是以,在一部動作電影中,他們不使用堆棧溢出,是非常不現實的。
So I guess if you only have a few minutes to save the world, maybe you have to code without getting any help.
所以我想如果你只有幾分鐘的時間來拯救世界,也許你必須在沒有得到任何幫助的情況下編碼。
The origin of the term stack overflow is actually an interesting story.
堆棧溢出一詞的起源實際上是一個有趣的故事。
It comes from one of the problems that you could have while programming, your program has a certain amount of memory.
它來自於你在編程時可能遇到的一個問題,你的程序有一定的內存量。
Part of it's called the stack.
它的一部分被稱為堆棧。
And that stack uses too much memory.
而且這個堆棧使用了太多的內存。
It throws a stack overflow air and this often happens when there's something going really wrong with your program is just consuming memory wildly.
它拋出了一個堆棧溢出空氣,這往往發生在你的程序真的出了問題,只是瘋狂地消耗內存。
But the stack overflow website isn't just about that problem.
但堆棧溢出網站不僅僅是為了解決這個問題。
It's a whole cow community where people come together and help each other and I love that community of all of us coming together and making each other better are 40.
這是一個完整的奶牛社區,人們走到一起並互相幫助,我喜歡這種大家走到一起並使對方變得更好的社區是40。
40 asks what does front and and back and mean?
40問:前面和和後面和是什麼意思?
I love this question and you know what to show you.
我喜歡這個問題,你知道要給你看什麼。
I'd like to explain a little bit about how the internet works when you use a mobile application.
我想解釋一下,當你使用一個移動應用程序時,互聯網是如何工作的。
Let's say you're using google maps and google maps is telling you how to get from point A to point B.
假設你在使用谷歌地圖,谷歌地圖告訴你如何從A點到B點。
There's a computer program that's running on your phone and that's called the front end, but not all the work is done on your phone.
有一個電腦程序在你的手機上運行,這被稱為前端,但不是所有的工作都在你的手機上完成。
In fact a lot of the work might be done on a different computer.
事實上,很多工作可能是在不同的電腦上完成的。
So what your phone does is it connects over the internet to another computer that we call a server and that computer can do calculations and send the answer back to your phone.
是以,你的手機所做的是通過互聯網連接到另一臺計算機,我們稱之為服務器,該計算機可以進行計算並將答案發回給你的手機。
And you know, this is basically the idea of the internet.
而且你知道,這基本上是互聯網的想法。
We have all these devices and they're talking to other computers on different parts of the world and programs that run on this computer, we call those the back end.
我們有所有這些設備,它們與世界上不同地方的其他計算機和在這臺計算機上運行的程序進行對話,我們把這些稱為後端。
So you have the front end running on things that you interface with and back and running on things that are doing some work behind the scenes that you never see.
是以,你有前端運行的東西,你與之對接,後端運行的東西,在幕後做一些工作,你永遠看不到。
You know, maybe it's a little bit like a car.
你知道,也許它有點像汽車。
The front end might be the steering wheel, that's what humans interact with.
前端可能是方向盤,那是人類互動的東西。
There's a whole bunch of technology there, the back end is the technology you don't see maybe it's like the engine, it's doing really important stuff.
那裡有一大堆技術,後端是你看不到的技術,也許它就像引擎,它在做真正重要的事情。
But when everything is working smoothly, you just interact with that steering wheel.
但當一切工作順利時,你只是與那個方向盤互動。
Some people only specialized in writing programs for the front end.
有些人只擅長為前端編寫程序。
Some people only specialize in writing programs for the back end or you might hear this term full stack engineer and those are programmers who can do both.
有些人只專注於為後端編寫程序,或者你可能會聽到全棧工程師這個詞,那些是可以做這兩件事的程序員。
The front end and the back end.
前端和後端。
And that's a good thing to be next question from Vegas Gasper.
而這是拉斯維加斯加斯帕的下一個問題,是一件好事。
What is the shortest piece of code that changed the world?
改變世界的最短的一段代碼是什麼?
That's a good question.
這是個好問題。
And over a drink we could have a great conversation and debate this.
而在喝酒的時候,我們可以有一個很好的對話,辯論這個問題。
I'm going to say back propagation for artificial intelligence.
我要說的是人工智能的反向傳播。
Back propagation is the few lines of code that tells an artificial intelligence algorithm.
反向傳播是告訴一個人工智能算法的幾行代碼。
If I see data, how can I become smarter based off of that data?
如果我看到了數據,我怎樣才能在這些數據的基礎上變得更聰明?
It's a very simple piece of code based off some cool calculus and that's where most ai gets its intelligence from say your ai algorithms trying to learn what a cat is and it sees a picture of a cat.
這是一個非常簡單的代碼,基於一些很酷的微積分,這就是大多數人工智能獲得其智能的地方,比如說你的人工智能算法試圖學習什麼是貓,它看到了一張貓的圖片。
It can put it through its own little ai brain.
它可以把它通過自己的小ai大腦。
Back propagation will tell it how to change its ai brain so that it is better able to understand cats in the future.
背面傳播將告訴它如何改變它的ai腦,以便它在未來能夠更好地理解貓。
To our but doesn't really have a question but a cute little rhyme.
對我們來說,但並沒有真正的問題,而是一個可愛的小韻律。
How much could a C.
一個C.能有多少錢?
Plus plus if a C.
如果是C的話,加加。
Plus could plus plus C.
加可以加加C。
Plus plus is one of the most popular programming languages.
加加是最流行的編程語言之一。
In fact, it's the one that I first learned on.
事實上,這是我第一次在上面學習。
That's how old I am.
這就是我的年齡。
And C.
和C.
Plus plus is it's what you want to use if you're writing a really intense program like a three D computer game or if you're writing the program to animate a Pixar movie C Plus plus is what you'd use C.
如果你要寫一個非常緊張的程序,比如一個三D電腦遊戲,或者你要寫一個皮克斯電影的動畫程序,C Plus plus就是你要用的C。
Plus plus is actually a descendant of another programming language called C.
加加實際上是另一種叫做C的編程語言的後裔。
And C.
和C.
Is like the grandfather of all languages like the latin equivalent from which may any different language to extend C.
就像所有語言的祖父一樣,相當於拉丁語,任何不同的語言都可以從中擴展出C。
Plus plus is one of those and you can see where it got its name from its C.
加加是其中之一,你可以看到它的名字來自於它的C。
And then Plus plus this program speech for one better.
然後再加上這個方案的演講,就更完美了。
So it's like I'm like see but I'm a little bit better.
所以我就像看到了,但我的情況好了一點。
And there's other descendants you might have heard of like java and python.
還有一些你可能聽說過的後代,如java和python。
And the fact that all these three languages descend from C.
而事實上,這三種語言都是C語言的後代。
Tells you how similar that they are to one another.
告訴你他們之間的相似程度。
Why is C.
為什麼C.
Or C.
或C.
Plus plus?
加加?
So good for video game programming because it's so computational e intense you have to render an entire three D.
對視頻遊戲編程來說是很好的,因為它的計算能力很強,你必須渲染整個三D。
World with trees in the distance and things animating in the front and that.
遠處有樹的世界,前面有東西的動畫,還有那個。
Just ask so much of your computer, C.
只是對你的電腦要求太多,C。
And C.
和C.
Plus plus.
加加加。
They're like your bare bones programming languages.
它們就像你的原始編程語言。
They're the most efficient so they can run the fastest and they can do the most computations per second python and java they're easier to read so it's easier to write the program but the computer can't run them as quickly.
它們是最有效的,所以它們可以運行得最快,每秒鐘可以做最多的計算,python和java它們更容易閱讀,所以寫程序更容易,但計算機不能快速運行它們。
Loss mary angus 14 asks my computer science teacher asked what is python and I replied a very dangerous snake.
Loss mary angus 14 asked my computer science teacher asked what is python and I replied a very dangerous snake.
Uh And he beat me up.
呃,他還打了我。
I feel like we have to have a different conversation about corporal punishment.
我覺得我們必須就體罰問題進行不同的對話。
Here, did you know the name python?
在這裡,你知道蟒蛇這個名字嗎?
The name for this programming language actually comes from monty.
這種編程語言的名字實際上來自蒙蒂。
Python's flying circus.
Python的飛行馬戲團。
The person who invented the programming language called python.
發明了名為python的編程語言的人。
I'm a big fan of the Tv show.
我是這個電視節目的大粉絲。
So I gave it that name.
所以我給它起了這個名字。
It's a general purpose programming language.
它是一種通用的編程語言。
So you could write a google maps back end on it.
所以你可以在上面寫一個谷歌地圖的後端。
You could write data science, you could just write a script that does something fun.
你可以寫數據科學,你可以只寫一個腳本,做一些有趣的事情。
Or you could write a chatbot even.
或者你甚至可以寫一個哈拉機器人。
Do you want to see what python looks like?
你想看看python是什麼樣子的嗎?
I can tell you a really basic intro to python program Hello World.
我可以告訴你一個非常基本的python程序介紹Hello World。
And print 10 numbers.
並打印10個數字。
Here's an example of a very simple python program.
下面是一個非常簡單的python程序的例子。
This says when you run this program, so somebody goes to the computer and they click on, click on your program.
這說的是當你運行這個程序時,所以有人去電腦上,他們點擊,點擊你的程序。
It's going to open up a console and it's going to say hello world.
它將會打開一個控制檯,並會說hello world。
That's the greeting we use when we're trying to show that we can write our first program.
這就是我們在試圖表明我們可以編寫第一個程序時使用的問候語。
It's like your program saying hi, I'm new to this world.
這就像你的程序在說嗨,我是這個世界的新人。
Tell me all about it.
告訴我所有的情況。
And then your program in very cool faction says I'm going to print the numbers.
然後你的程序在非常酷的派別中說我要打印這些數字。
The 1st 10 numbers.
前10個數字。
So it'll print zero, then one, then two, then three, then four, then five and six and seven and eight and nine main is what happens when somebody starts your program.
所以它會打印0,然後是1,然後是2,然後是3,然後是4,然後是5,然後是6,然後是7,然後是8,然後是9,主要是當有人啟動你的程序時會發生什麼。
So death main says when someone starts your program, I'm going to execute all of these commands and then I write the commands one by one.
所以死亡主說,當有人啟動你的程序時,我要執行所有這些命令,然後我一個一個地寫命令。
The first command I wrote is print.
我寫的第一個命令是print。
Hello world Print doesn't mean like print through your printer it means show up on the screen.
Hello world 打印並不是指通過打印機打印,而是指顯示在螢幕上。
The next line says for I in range.
下一行說,對於範圍內的I。
One of the great things about computers is that they can do lots of repetitive tasks without being coming frustrated humans not so much.
計算機的一個好處是,它們可以做很多重複性的工作,而不至於讓人感到沮喪,而人類就不一樣了。
This is one of those basic commands you need to know to make a computer repeated task.
這是那些你需要知道的基本命令之一,以使計算機重複任務。
It says I want to repeat something 10 times and 10 times.
它說我要重複某事10次,10次。
I would like to print out a value.
我想打印出一個數值。
This is a value that's going to change numbers from zero up til nine.
這是一個將改變從零到九的數字的值。
So when you run this program it'll print zero and one and two and three and four and five and six and seven and eight and nine.
是以,當你運行這個程序時,它會打印出0、1、2、3、4、5、6、7、8、9。
Next question from esquire what is the meaning of error?
esquire的下一個問題,錯誤的含義是什麼?
Four oh four oh four oh four is what you see when you go to a website and that website doesn't exist.
4哦4哦4哦4是你去一個網站時看到的東西,而這個網站並不存在。
And the web pages saying I don't know what website you're looking for more broadly when programs don't know what to do or when they break they often throw a thing called an error.
還有網頁說我不知道你在找什麼網站,更廣泛地說,當程序不知道該怎麼做,或者當它們發生故障時,它們經常會拋出一個叫做錯誤的東西。
And as a human you're given these errors errors always have codes they tell the human and they tell somebody who's trying to diagnose what went wrong exactly what the problem was.
作為一個人,你會得到這些錯誤,錯誤總是有代碼,它們告訴人,它們告訴試圖診斷出錯的人,到底是什麼問題。
So when you 044 that's a specific message saying exactly what went wrong was that I wasn't able to find the particular U.
是以,當你的044是一個具體的資訊,說到底是什麼出了問題,我無法找到特定的U。
R.
R.
L.
L.
You were looking for.
你正在尋找。
Web error codes were actually defined by the guy who invented the web tim Berner lee as I understand it.
據我所知,網絡錯誤代碼實際上是由發明網絡的人Tim Berner lee定義的。
He was just coming up with sequential codes.
他只是想出了連續的代碼。
I think the first four means that there was a problem with your web page for a 1424344.
我認為前四條意味著你的網頁出現了問題,為1424344。
Or just different problems that could come up when you're trying to load a webpage.
或者只是在你試圖加載一個網頁時可能出現的不同問題。
Okay next question.
好的下一個問題。
Formula.
公式。
Our programming coding the same thing.
我們的編程編碼也是如此。
Yes coding is the process of opening up an application on your computer and writing a sequence of commands that look a lot like english but are in a specific language that your computer can understand.
是的,編碼是在你的電腦上打開一個應用程序,寫下一連串的命令,這些命令看起來很像英語,但卻是你的電腦可以理解的特定語言。
You can code in something like python or javascript.
你可以用python或javascript之類的東西編碼。
These are the languages of coding and that's how you tell a computer.
這些是編碼的語言,這就是你告訴計算機的方式。
I want you to perform all these actions when somebody hits a button or when somebody opens this application, programming is exact same thing.
我想讓你在有人點擊一個按鈕或有人打開這個應用程序時執行所有這些動作,編程是完全相同的事情。
You're making a program when you're coding future, Lear what is raspberry pi and what can be used for future.
你在做程序的時候,你在編碼未來,李爾什麼是樹莓派,什麼可以用於未來。
Earlier.
早些時候。
This is a raspberry pi and this is one of the world's cheapest computers.
這是樹莓派,這是世界上最便宜的計算機之一。
What are we looking at here?
我們在這裡看的是什麼?
We're looking at a small version of a motherboard and on it it has things that you can plug in like a USB has a place for audio and a place for internet connection and on the chip, it has a thing called a CPU so it's central processing unit, so it can process programs and it has some space for memory, so it can store some