>> They only use that when the program that you're running-- the program that you're referring to is going to your computer?
>它只有在你运行程序的时候才用到-,那你刚刚提到的程序,会到你的电脑上运行吗?
I've decided that I need to be able, in my program, to swap the value of two variables. All right.
我觉定在我的程序中,我可以,交换两个变量值,好的。
I made a ton of random things when I was at Harvard and most of them no one ever saw.
我在哈佛写了许多程序,很多都没人见过。
By putting it in a function bug if I find a bug and I change my program I can just run the function again.
把我输入的值放到一个函数里,如果以后我在程序中发现了一个,并对程序进行更改的话,我可以直接。
What is it about the thought that the computer is just following a program?
电脑仅仅只是在执行程序,这个观点到底是什么样的
The strategy then often is to figure out how, what sort of program can solve these problems and then we go on to ask, "How could this program be instantiated in the physical brain?"
心理学家们通常要先弄清,什么样的程序可以解决这些问题,然后我们会接着问到,"这个程序在我们的生理大脑中,是如何进行编译的"
You double click an icon, the program gets loaded into memory, well, conceptually where does your program end up?
双击一个图标,程序就被加载到内存中,那么,程序在哪里结束?
And here, too, it's just a little baby program in that I'm hardcoding the expression 17 divided by 13.
然后这里,这只是一个子程序,在那里面我硬编码了表达式“17除以13“
And so now, you have two threads so to speak, two miniature programs, two sprites all interacting with one another.
现在我们有两个线程,两个轻量型程序,两个精灵在沟通。
Said a different way, in the case of the straight-line programs, how long would it take to run a program?
换种说法,在直线式程序里面,运行一个程序要多长时间?
So today is about writing some programs and empowering you to write your own starting this coming week when Pset One goes out via the website tonight by 7:00 p.m.
今天我们将要写一些程序,并且让你们,在接下来的一周写你们自己的程序,今天晚上七点,习题集1会发布在网站上。
And that's basically trying to make sure our program has not regressed, as to say, gone backwards in how well it works. And so we always test it on everything.
这只是从根本上确保,我们的程序并没往后退,也就是说在可用性方面倒退了,因此我们在任何东西上,都要进行这样的测试。
But let's suppose that I realize that I'm doing a lot of addition in my programs, and I actually want to factor out what seems to becoming a lot of copy, paste.
但是假如我在程序中做了很多加法,我实际上想要提出那些,复制粘贴的东西。
All right so it has to live in RAM as opposed to the hard drive because otherwise things would be terribly slow as you know so it's much better if your programs live while they're running in RAM and they end up in what's called the tech segment.
好的,它存在内存中,而不是硬盘中,因为,否则程序会非常的缓慢,程序在内存中运行会好得多,它们在技术段,的地方结束。
But it's a valuable thing. It says, in each case, I return some useful value from this procedure.
但是这就是变量,是在每个例子中,我从这个程序中返回了一些有用的值。
So I wrote a little program called "chart" that, based on some data I happened to hardcode into the program, shows us their numbers for the past several years.
我写了一个叫做“图表“的小程序,基于我在程序中硬编码的一些数据,向我们显示在过去几年中我们课程的人数。
OK, here we go, here we go, you see, I'm doing it down here, I can't see it, does that-- ah, I hear his sighs of relief, OK, good. There we go. Better. All right.
好,我们开始,大家可以看到,我在这里写这个程序,我看不见,这是不是-啊,我听到大家放松的叹气了,好,让我们开始吧,好多了,好。
OK, you say, come on, I've seen these all the time. Every time I type something into my program, it does one of these things, right?
好了,或者你要说,我总是能看见这些,每一次我在程序里输入一些内容的时候?
With simple branching, how long is it going to take to run a piece of code?
但是在简单分支程序中,执行一个程序,要多长时间呢?
It's a bad habit to get into, because when you come back to it, it may haunt you later on down the road. So really get into that notion of trying to be defensive as you program.
来运行程序的时候,错误就会出现缠住你了,因此现在我们真的要培养,在程序中有防卫性设计的概念。
Alright, so maybe a little underwhelming and we saw already what this program is going to do but let's just go through this process once before we start doing more interesting things and then we'll come back and at least give you a hint of what some of these syntactic details are doing.
好吧,这个程序也许太平庸了,让人印象不够深刻,我们也知道这个程序是干嘛的,在我们开始更有意思的事情之前,让我们再来讨论一下整个过程后再回来,这些语法细节到底是在做什么呢?,先给你们一点小小的提示。
We'd expect you to write now or perhaps ever since this program was written as part of an obfuscated C contest.
我希望你们现在就开始写程序,否则你们将会在C语言比赛中,写得非常糟糕。
That says it's in here. It's in this tri-block. It raised an exception, but it wasn't and I O error.
这在这里它是一个try程序块,它报出异常,但他不是io错误。
Yes, it stops at the first step, right? Let's look at it.
对的,程序会,在第一步就停止了。
So, an alternative to that that is incredibly common in just the programming world and in industry is to actually not write programs on your own personal computer but to actually write and run them on a server, someplace where the software is all standardized.
那么,在编程界和工业界普遍,使用的一个解决方案是,不在你自己的电脑上写程序,而是在服务器上编程运行,服务器上的软件都是标准化的。
Figure out what I'm going to do at the end of it.
弄清楚在程序的最后该做些什么。
Right. We're not going to have 140,000 variables in my program.
对的,在我的程序中没有140,000个变量。
So, in this program when we call this version of swap 1 and 2 do not end up here, right?
所以,在这个程序中,当我们调用这个swap版本1,和版本2,不是在这里结束,对不?
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.
但是它确实是一种很方便的思考方式,不仅仅限于编程序,在将程序分解为小部分时也很有用。
If I wanted every stock to have the same volatility, I could just do that, if you will, at the time I wrote my program.
如果我希望每只股票的浮动值都相同,在我编写程序的时候,如果你愿意的话,我会这么做。
应用推荐