If you want to control a program file, open, copy, paste not get me ready for my trip to Stanford.
如果想要掌控一项程序文件,打开,复制粘贴,并不会铺平通向斯坦福的路。
And here, too, it's just a little baby program in that I'm hardcoding the expression 17 divided by 13.
然后这里,这只是一个子程序,在那里面我硬编码了表达式“17除以13“
The distinction I made in the paper that we talked about in the class is between procedural justice and substance of justice in the university.
我曾经在一篇论文中做了一个区分,在课堂上讲到过,那就是大学程序性公正,和实质性公正的区别。
But it is a very handy way of thinking about, not just how to program, but how to break problems down into nice sized chunks.
但是它确实是一种很方便的思考方式,不仅仅限于编程序,在将程序分解为小部分时也很有用。
But if there were a lottery and they'd all agreed to the procedure, you think that would be okay?
但如果他们抽签了,他们也都同意这一程序,那你认为就没问题,是吧?
It looks as though the natural thing to say about the chess-playing computer is, it does have beliefs. It does have desires.
这看起来好像是一件自然的事情,说象棋程序,有自己的信念 有欲望
It turned out that one of--there were three vaccine manufacturers, one of them was using the procedure not quite correctly, they weren't completely killing the virus when they produced their vaccine.
结果显示,疫苗的生产厂家一共有三个,其中一家的生产程序不是非常正确,他们在生产疫苗的时候,并没有完全杀死病毒
You should acquire overtime this instinctive aversion to just code or programs that just look ugly because things that look ugly generally are not easy to maintain.
对于代码和程序你会有一种本能的讨厌,这是因为这些代码和程序看起来很丑陋,并且不容易维护。
And a large part of being a good programmer, or learning to be a good programmer, is learning how to debug. And it's one of these things where it's harder.
没人能凭本能做好它,如果你相当一名优秀的程序员,或者想通过学习成为一名优秀的程序员,很重要的一部分就是学习怎么去调试。
I could have just done this, and the only reason I didn't here is just because now I look - at this, and now it's just getting confusing for me -- even for someone who's been programming for a while.
我本可以这样做,我之所以没有这样做是因为,现在我看着这个,它是我有点迷惑了-,甚至是对于某些已经写了一段时间程序的人来说。
There's unit testing, where we validate each piece of the program independently.
一种是单元测试,也就是,分别验证程序中的每一个独立部分。
We decrement so to speak the variable and then where will we go next in terms of the flow control, the flow of this program.
可以这么说,我们递减这个变量,然后按照控制流,即程序流进入到下一语句。
This is me writing one hour of that episode of Pirandello and telling the other authors, here's what I'm assuming as you use it. So it's up to me to do it right, but if I do it, I'm going to specify, what does this function do?
作为一个程序员,我得为用户提供一些信息,这正是我写写的皮兰德娄戏剧的一小时片段,并且要告诉其它的作家,这是我希望你使用的地方,所以由我决定怎样去做好它?
And robots, the objection goes, are programmed; they necessarily follow their program.
而且这一反驳指出,机器人是被编程的,机器人必须遵照程序做事
So we want to write programs to do that.
为了实现这一目标我们要去写一个执行程序。
And so now we're going to try and see if we can write a simulation that will give us some insight as to which of these might be better or worse.
现在我们回来看看我们能否,写一个程序来看看,哪一种选择会更好。
I know this is a simple example, but when you mature as a programmer, one of the first things you should do when you sit down to tackle some problem is write something like this pseudo code.
我知道这是个很简单的例子,但是当你们成长为一名程序员后,当你们碰到问题后第一件事情就是,该写一些类似于,伪代码的东西。
You can even implement your own versions of some of the most popular console games today for which I need another volunteer.
现在你就可以编写程序,把当下最流行的控制台小游戏,改造成自己的版本,现在我需要再上来一名志愿者。
And because there's nothing else in the code at that point, the program should just quit naturally in a good way. Yeah?
因为在那个阶段的没有其它的代码了,这个程序将以一种比较好的方式自然地退出,请说?
- So sleep -- as the name implies -- simply puts the program to sleep for a second.
所以睡眠--顾名思义-,简单地将程序睡眠一秒钟。
You had a whole team of people trying to figure out how to do arctans.
一整个团队的人都为这个程序工作者,他们试着运行这个程序。
So one of the things I want you to notice here is that testing and debugging are not the same thing. When we test, we compare an input output pair to a specification.
这里我想大家注意的一件事,就是测试和调试是不同的两件事情,我们测试的时候,我们把输入输出,跟程序的规格说明书对比下。
So now let me recreate this program from memory.
现在我们在脑子里再过一遍这个程序。
So here is a computer program.
这里有一段计算机程序。
Because we obviously can't, in any course, or even any set of courses, tell you everything you'll ever want to know in life we've seeded some things in this program that will be unfamiliar, so during the time you're studying the program, get online, look it up, figure out what they do.
因为在任何一门课上或者几门课上,我们都不可能告诉你,所有你想知道的事情,我们在这个程序中,加上了一些你们不熟悉的东西,所以在你们研究这个程序的时候,你们可以上网找资料,弄懂它是干什么的。
This is a very important mission and so there is a computer program named Hal that helps run the ship and takes a lot of the burdens off of the part of the human astronauts who are on the ship.
这是一项非常重要的任务,因此,一个被命名为哈尔的计算机程序,被安排协助飞船的运行,减轻飞船上,人类宇航员的负担
For the latter, this is a place where running test cases would do a good job of helping with that. Nonetheless, having done that, let's look at a better way to write this. Which is right here it is also, I think, on your sheet, I'm going to uncomment that, and comment this one out, yeah. All right?
对于后者来说,运行测试用例,对它会有很大的帮助,尽管如此,讲完了这些,让我们再来看看更好的,来写这个程序的一种方法吧,也就是这里,我想这程序也在,你们的课堂手册上面,我得先把这里取消注释,然后注释掉这里,是的,对不对?
In Scratch you may have realized that, "I could implement my program this way with these puzzle pieces, but it kind of feels -- like I could use these puzzle pieces instead" -- that's absolutely the case in programming.
在Scratch中你可能已经意识到,“我可以用这一段代码来,执行我的程序,不过这有点感觉到,我可以用这些代码段来代替“,那绝对是编程中的一个情况。
So the goal is to figure out a way to stamp them all out.
一种把bugs都,驱逐出程序的方法。
应用推荐